mmserv/tms/tmsserver/src/tmsserver.cpp
branchRCL_3
changeset 19 095bea5f582e
parent 17 60e492b28869
child 20 0ac9a5310753
equal deleted inserted replaced
18:a36789189b53 19:095bea5f582e
    16  */
    16  */
    17 
    17 
    18 #include <e32svr.h>
    18 #include <e32svr.h>
    19 #include <e32uid.h>
    19 #include <e32uid.h>
    20 #include <e32capability.h>
    20 #include <e32capability.h>
       
    21 #include <AudioPreference.h>
    21 #include "tmsutility.h"
    22 #include "tmsutility.h"
    22 #include "tmsclientserver.h"
    23 #include "tmsclientserver.h"
    23 #include "tmstelephonycenrep.h"
    24 #include "tmstelephonycenrep.h"
    24 #include "tmsservershutdown.h"
    25 #include "tmsservershutdown.h"
    25 #include "tmsserversession.h"
    26 #include "tmsserversession.h"
    27 #include "tmscallserver.h"
    28 #include "tmscallserver.h"
    28 #include "tmscallclisrv.h"
    29 #include "tmscallclisrv.h"
    29 #include "tmsglobaleffectssettings.h"
    30 #include "tmsglobaleffectssettings.h"
    30 #include "tmstareventhandler.h"
    31 #include "tmstareventhandler.h"
    31 #include "tmscenrepaudiohandler.h"
    32 #include "tmscenrepaudiohandler.h"
       
    33 #include "tmsdtmftoneplayer.h"
       
    34 #include "tmsdtmfprovider.h"
       
    35 #include "tmspubsublistener.h"
       
    36 #include "tmsrtparam.h"
    32 #include "tmsserver.h"
    37 #include "tmsserver.h"
    33 
    38 
    34 using namespace TMS;
    39 using namespace TMS;
    35 
    40 
    36 // CONSTANTS
    41 // CONSTANTS
    78     iUplCodecs.Reset();
    83     iUplCodecs.Reset();
    79     iUplCodecs.Close();
    84     iUplCodecs.Close();
    80     delete iEffectSettings;
    85     delete iEffectSettings;
    81     delete iTarHandler;
    86     delete iTarHandler;
    82     delete iAudioCenRepHandler;
    87     delete iAudioCenRepHandler;
    83 
    88     DeinitRingTonePlayer();
       
    89     delete iTMSRtPlayer;
       
    90     delete iDTMFUplinkPlayer;
       
    91     delete iDTMFUplinkPlayerEtel;
       
    92     delete iDTMFDnlinkPlayer;
       
    93     delete iSyncVol;
    84     TRACE_PRN_FN_EXT;
    94     TRACE_PRN_FN_EXT;
    85     }
    95     }
    86 
    96 
    87 // -----------------------------------------------------------------------------
    97 // -----------------------------------------------------------------------------
    88 // TMSServer::NewSessionL
    98 // TMSServer::NewSessionL
   127     RThread().SetPriority(EPriorityRealTime);
   137     RThread().SetPriority(EPriorityRealTime);
   128     iEffectSettings = TMSGlobalEffectsSettings::NewL();
   138     iEffectSettings = TMSGlobalEffectsSettings::NewL();
   129     iTarHandler = NULL;
   139     iTarHandler = NULL;
   130     iAudioCenRepHandler = NULL;
   140     iAudioCenRepHandler = NULL;
   131     iCurrentRouting = TMS_AUDIO_OUTPUT_PRIVATE;
   141     iCurrentRouting = TMS_AUDIO_OUTPUT_PRIVATE;
       
   142     iDTMFDnlinkPlayer = NULL;
       
   143     iDTMFUplinkPlayer = NULL;
       
   144     iDTMFUplinkPlayerEtel = NULL;
       
   145     iActiveCallType = -1;
       
   146     iSyncVol = TMSPubSubListener::NewL(KTMSPropertyCategory,ESyncVolume, this);
       
   147 
       
   148     //TODO: EUnit fails to initialize ProfileEngine in RT in eshell mode
       
   149     TRAP_IGNORE(InitRingTonePlayerL());
   132 
   150 
   133     // We need it running for global volume change updates
   151     // We need it running for global volume change updates
   134     StartRoutingNotifierL();
   152     StartRoutingNotifierL();
   135 
   153 
   136     TRACE_PRN_FN_EXT;
   154     TRACE_PRN_FN_EXT;
   178     {
   196     {
   179     return iSession;
   197     return iSession;
   180     }
   198     }
   181 
   199 
   182 // -----------------------------------------------------------------------------
   200 // -----------------------------------------------------------------------------
   183 // TMSServer::SetDnLinkSession
       
   184 //
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 void TMSServer::SetDnLinkSession(const TBool aSession)
       
   188     {
       
   189     iDnlinkSession = aSession;
       
   190     }
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // TMSServer::SetUpLinkSession
       
   194 //
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 void TMSServer::SetUpLinkSession(const TBool aSession)
       
   198     {
       
   199     iUplinkSession = aSession;
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // TMSServer::HasDnLinkSession
       
   204 //
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 TBool TMSServer::HasDnLinkSession() const
       
   208     {
       
   209     return iDnlinkSession;
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // TMSServer::HasUpLinkSession
       
   214 //
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 TBool TMSServer::HasUpLinkSession() const
       
   218     {
       
   219     return iUplinkSession;
       
   220     }
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // TMSServer::GetNewTMSCallSessionHandleL
   201 // TMSServer::GetNewTMSCallSessionHandleL
   224 //
   202 //
   225 // -----------------------------------------------------------------------------
   203 // -----------------------------------------------------------------------------
   226 //
   204 //
   227 void TMSServer::GetNewTMSCallSessionHandleL(RHandleBase& aHandle)
   205 void TMSServer::GetNewTMSCallSessionHandleL(RHandleBase& aHandle)
   260     {
   238     {
   261     TRACE_PRN_FN_ENT;
   239     TRACE_PRN_FN_ENT;
   262 
   240 
   263     TInt status = TMS_RESULT_SUCCESS;
   241     TInt status = TMS_RESULT_SUCCESS;
   264     TMSStartAndMonitorTMSCallThread* callServerThread = NULL;
   242     TMSStartAndMonitorTMSCallThread* callServerThread = NULL;
   265     TRAP(status, callServerThread =TMSStartAndMonitorTMSCallThread::NewL(
   243     TRAP(status, callServerThread = TMSStartAndMonitorTMSCallThread::NewL(
   266             const_cast<TMSServer*>(this)));
   244             const_cast<TMSServer*>(this)));
   267     if (status != TMS_RESULT_SUCCESS)
   245     if (status != TMS_RESULT_SUCCESS)
   268         {
   246         {
   269         delete callServerThread;
   247         delete callServerThread;
   270         }
   248         }
   285                 {
   263                 {
   286                 case TMS_AUDIO_OUTPUT_PUBLIC:
   264                 case TMS_AUDIO_OUTPUT_PUBLIC:
   287                 case TMS_AUDIO_OUTPUT_LOUDSPEAKER:
   265                 case TMS_AUDIO_OUTPUT_LOUDSPEAKER:
   288                     {
   266                     {
   289                     iEffectSettings->GetLoudSpkrVolume(volume);
   267                     iEffectSettings->GetLoudSpkrVolume(volume);
       
   268                     TRACE_PRN_N1(_L("loudspk vol %d"),volume);
   290                     }
   269                     }
   291                     break;
   270                     break;
   292                 default:
   271                 default:
   293                     {
   272                     {
   294                     iEffectSettings->GetEarPieceVolume(volume);
   273                     iEffectSettings->GetEarPieceVolume(volume);
       
   274                     TRACE_PRN_N1(_L("ear vol %d"),volume);
   295                     }
   275                     }
   296                     break;
   276                     break;
   297                 }
   277                 }
   298             aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_VOL_SET, volume);
   278             aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_VOL_SET, volume);
   299             aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_GAIN_SET,
   279             aHandle.SendToCallServer(TMS_EFFECT_GLOBAL_GAIN_SET,
   562     switch (iCurrentRouting)
   542     switch (iCurrentRouting)
   563         {
   543         {
   564         case TMS_AUDIO_OUTPUT_PUBLIC:
   544         case TMS_AUDIO_OUTPUT_PUBLIC:
   565         case TMS_AUDIO_OUTPUT_LOUDSPEAKER:
   545         case TMS_AUDIO_OUTPUT_LOUDSPEAKER:
   566             iEffectSettings->GetLoudSpkrVolume(volume);
   546             iEffectSettings->GetLoudSpkrVolume(volume);
       
   547             TRACE_PRN_N1(_L("TMSServer::GetLevel loudspkr vol %d"),volume);
   567             break;
   548             break;
   568         default:
   549         default:
   569             iEffectSettings->GetEarPieceVolume(volume);
   550             iEffectSettings->GetEarPieceVolume(volume);
       
   551             TRACE_PRN_N1(_L("TMSServer::GetLevel ear vol %d"),volume);
   570             break;
   552             break;
   571         }
   553         }
   572 
   554 
   573     pckg() = volume;
   555     pckg() = volume;
   574     if (status == TMS_RESULT_SUCCESS)
   556     if (status == TMS_RESULT_SUCCESS)
   622             default:
   604             default:
   623                 break;
   605                 break;
   624             }
   606             }
   625 
   607 
   626         iSessionIter.SetToFirst();
   608         iSessionIter.SetToFirst();
   627         TMSServerSession* serverSession =
   609         TMSServerSession* ss = static_cast<TMSServerSession*> (iSessionIter++);
   628                 static_cast<TMSServerSession*> (iSessionIter++);
   610         while (ss != NULL)
   629 
   611             {
   630         while (serverSession != NULL)
   612             ss->HandleGlobalEffectChange(TMS_EVENT_EFFECT_VOL_CHANGED, level,
   631             {
   613                     EFalse, iCurrentRouting);
   632             serverSession->HandleGlobalEffectChange(
   614             ss = static_cast<TMSServerSession*> (iSessionIter++);
   633                     TMS_EVENT_EFFECT_VOL_CHANGED, level, EFalse,
       
   634                     iCurrentRouting);
       
   635 
       
   636             serverSession = static_cast<TMSServerSession*> (iSessionIter++);
       
   637             }
   615             }
   638         }
   616         }
   639 
   617 
   640     TRACE_PRN_FN_EXT;
   618     TRACE_PRN_FN_EXT;
   641     return status;
   619     return status;
   698     if (status == TMS_RESULT_SUCCESS)
   676     if (status == TMS_RESULT_SUCCESS)
   699         {
   677         {
   700         iAudioCenRepHandler->SetMuteState(level);
   678         iAudioCenRepHandler->SetMuteState(level);
   701         iEffectSettings->SetGain(level);
   679         iEffectSettings->SetGain(level);
   702         iSessionIter.SetToFirst();
   680         iSessionIter.SetToFirst();
   703 
   681         TMSServerSession* ss = static_cast<TMSServerSession*> (iSessionIter++);
   704         TMSServerSession* serverSession =
   682         while (ss != NULL)
   705                 static_cast<TMSServerSession*> (iSessionIter++);
   683             {
   706 
   684             ss->HandleGlobalEffectChange(TMS_EVENT_EFFECT_GAIN_CHANGED, level);
   707         while (serverSession != NULL)
   685             ss = static_cast<TMSServerSession*> (iSessionIter++);
   708             {
       
   709             serverSession->HandleGlobalEffectChange(
       
   710                     TMS_EVENT_EFFECT_GAIN_CHANGED, level);
       
   711             serverSession = static_cast<TMSServerSession*> (iSessionIter++);
       
   712             }
   686             }
   713         }
   687         }
   714 
   688 
   715     TRACE_PRN_FN_EXT;
   689     TRACE_PRN_FN_EXT;
   716     return status;
   690     return status;
   825 TInt TMSServer::NotifyTarClients(TRoutingMsgBufPckg routingpckg)
   799 TInt TMSServer::NotifyTarClients(TRoutingMsgBufPckg routingpckg)
   826     {
   800     {
   827     TRACE_PRN_FN_ENT;
   801     TRACE_PRN_FN_ENT;
   828 
   802 
   829     TInt vol;
   803     TInt vol;
   830     iCurrentRouting = routingpckg().iOutput;
   804     TInt status(TMS_RESULT_SUCCESS);
   831     if (iCurrentRouting == TMS_AUDIO_OUTPUT_PUBLIC ||
   805     FindActiveCallType();
   832             iCurrentRouting == TMS_AUDIO_OUTPUT_LOUDSPEAKER)
   806 
   833         {
   807     if (iActiveCallType == TMS_CALL_CS)
   834         iEffectSettings->GetLoudSpkrVolume(vol);
   808         {
   835         }
   809 
   836     else
   810         iCurrentRouting = routingpckg().iOutput;
   837         {
   811         if (iCurrentRouting == TMS_AUDIO_OUTPUT_PUBLIC || 
   838         iEffectSettings->GetEarPieceVolume(vol);
   812         	  iCurrentRouting == TMS_AUDIO_OUTPUT_LOUDSPEAKER)
   839         }
   813             {
   840 
   814             iEffectSettings->GetLoudSpkrVolume(vol);
   841     TInt status = SendMessageToCallServ(TMS_EFFECT_GLOBAL_VOL_SET, vol);
   815             TRACE_PRN_N1(_L("TMSServer::NotifyTarClients loudspkr vol %d"),vol);
       
   816             }
       
   817         else
       
   818             {
       
   819             iEffectSettings->GetEarPieceVolume(vol);
       
   820             TRACE_PRN_N1(_L("TMSServer::NotifyTarClients ear vol %d"),vol);
       
   821             }
       
   822 
       
   823         status = SendMessageToCallServ(TMS_EFFECT_GLOBAL_VOL_SET, vol);
       
   824         }
   842 
   825 
   843     iSessionIter.SetToFirst();
   826     iSessionIter.SetToFirst();
   844     TMSServerSession* serverSession =
   827     TMSServerSession* ss = static_cast<TMSServerSession*> (iSessionIter++);
   845             static_cast<TMSServerSession*> (iSessionIter++);
   828     while (ss != NULL)
   846     while (serverSession != NULL)
       
   847         {
   829         {
   848         // Send only if there is a subscriber to TMS routing notifications.
   830         // Send only if there is a subscriber to TMS routing notifications.
   849         if (iTarHandlerCount > 1)
   831         if (iTarHandlerCount > 1)
   850             {
   832             {
   851             serverSession->HandleRoutingChange(routingpckg);
   833             ss->HandleRoutingChange(routingpckg);
   852             }
   834             }
   853         serverSession->HandleGlobalEffectChange(TMS_EVENT_EFFECT_VOL_CHANGED,
   835         if (iActiveCallType == TMS_CALL_CS)
   854                 vol, ETrue, iCurrentRouting);
   836             {
   855         serverSession = static_cast<TMSServerSession*> (iSessionIter++);
   837             ss->HandleGlobalEffectChange(TMS_EVENT_EFFECT_VOL_CHANGED, vol,
   856         }
   838                     ETrue, iCurrentRouting);
   857 
   839             }
   858     TRACE_PRN_FN_EXT;
   840         ss = static_cast<TMSServerSession*> (iSessionIter++);
   859     return status;
   841         }
       
   842 
       
   843     TRACE_PRN_FN_EXT;
       
   844     return status;
       
   845     }
       
   846 
       
   847 // -----------------------------------------------------------------------------
       
   848 // TMSServer::InitDTMF
       
   849 //
       
   850 // -----------------------------------------------------------------------------
       
   851 //
       
   852 TInt TMSServer::InitDTMF(const RMessage2& aMessage)
       
   853     {
       
   854     TRACE_PRN_FN_ENT;
       
   855     TInt status(TMS_RESULT_SUCCESS);
       
   856     TMSStreamType strmtype;
       
   857     strmtype = (TMSStreamType) aMessage.Int0();
       
   858 
       
   859     if (strmtype == TMS_STREAM_UPLINK)
       
   860         {
       
   861         if (!iDTMFUplinkPlayerEtel) //CS call
       
   862             {
       
   863             // Uses ETel for uplink
       
   864             TRAP(status, iDTMFUplinkPlayerEtel = TMSDTMFProvider::NewL());
       
   865             if (iDTMFUplinkPlayerEtel && status == TMS_RESULT_SUCCESS)
       
   866                 {
       
   867                 iDTMFUplinkPlayerEtel->AddObserver(*this);
       
   868                 }
       
   869             }
       
   870         if (!iDTMFUplinkPlayer) //IP call
       
   871             {
       
   872             TRAP(status, iDTMFUplinkPlayer = TMSAudioDtmfTonePlayer::NewL(*this,
       
   873                     KAudioDTMFString, KAudioPriorityDTMFString));
       
   874             }
       
   875         }
       
   876     else if (strmtype == TMS_STREAM_DOWNLINK)
       
   877         {
       
   878         if (!iDTMFDnlinkPlayer) //CS or IP call
       
   879             {
       
   880             TRAP(status, iDTMFDnlinkPlayer = TMSAudioDtmfTonePlayer::NewL(*this,
       
   881                     KAudioDTMFString, KAudioPriorityDTMFString));
       
   882             }
       
   883         }
       
   884 
       
   885     aMessage.Complete(status);
       
   886     TRACE_PRN_FN_EXT;
       
   887     return status;
       
   888     }
       
   889 
       
   890 // -----------------------------------------------------------------------------
       
   891 // TMSServer::StartDTMF
       
   892 //
       
   893 // -----------------------------------------------------------------------------
       
   894 //
       
   895 TInt TMSServer::StartDTMF(const RMessage2& aMessage)
       
   896     {
       
   897     TRACE_PRN_FN_ENT;
       
   898 
       
   899     TInt status(TMS_RESULT_SUCCESS);
       
   900     TInt len(0);
       
   901     TMSStreamType strmtype;
       
   902     strmtype = (TMSStreamType) aMessage.Int0();
       
   903     len = aMessage.GetDesLength(1);
       
   904     if (len > 0)
       
   905         {
       
   906         HBufC* tone(NULL);
       
   907         TRAP(status, tone = HBufC::NewL(len));
       
   908         if (status == TMS_RESULT_SUCCESS)
       
   909             {
       
   910             TPtr ptr = tone->Des();
       
   911             status = aMessage.Read(1, ptr);
       
   912             TRACE_PRN_N(ptr);
       
   913 
       
   914             if (strmtype == TMS_STREAM_UPLINK)
       
   915                 {
       
   916 #ifdef __WINSCW__
       
   917                 // Just to hear DTMF tones in Wins
       
   918                 iActiveCallType = TMS_CALL_IP;
       
   919 #else
       
   920                 FindActiveCallType();
       
   921 #endif
       
   922                 if (iActiveCallType == TMS_CALL_IP && iDTMFUplinkPlayer)
       
   923                     {
       
   924                     iDTMFUplinkPlayer->PlayDtmfTone(ptr);
       
   925                     status = TMS_RESULT_SUCCESS;
       
   926                     }
       
   927                 else if (iActiveCallType == TMS_CALL_CS &&
       
   928                         iDTMFUplinkPlayerEtel)
       
   929                     {
       
   930                     status = iDTMFUplinkPlayerEtel->SendDtmfToneString(ptr);
       
   931                     }
       
   932                 else
       
   933                     {
       
   934                     status = TMS_RESULT_INVALID_STATE;
       
   935                     }
       
   936                 NotifyDtmfClients(ECmdDTMFToneUplPlayStarted, status);
       
   937                 }
       
   938             else if (strmtype == TMS_STREAM_DOWNLINK)
       
   939                 {
       
   940                 status = TMS_RESULT_INVALID_STATE;
       
   941                 if (iDTMFDnlinkPlayer)
       
   942                     {
       
   943                     iDTMFDnlinkPlayer->PlayDtmfTone(ptr);
       
   944                     status = TMS_RESULT_SUCCESS;
       
   945                     }
       
   946                 NotifyDtmfClients(ECmdDTMFToneDnlPlayStarted, status);
       
   947                 }
       
   948             else
       
   949                 {
       
   950                 status = TMS_RESULT_STREAM_TYPE_NOT_SUPPORTED;
       
   951                 }
       
   952             }
       
   953         delete tone;
       
   954         tone = NULL;
       
   955         }
       
   956 
       
   957     aMessage.Complete(status);
       
   958     TRACE_PRN_FN_EXT;
       
   959     return status;
       
   960     }
       
   961 
       
   962 // -----------------------------------------------------------------------------
       
   963 // TMSServer::StopDTMF
       
   964 //
       
   965 // -----------------------------------------------------------------------------
       
   966 //
       
   967 TInt TMSServer::StopDTMF(const RMessage2& aMessage)
       
   968     {
       
   969     TRACE_PRN_FN_ENT;
       
   970 
       
   971     TInt status(TMS_RESULT_INVALID_STATE);
       
   972     TMSStreamType streamtype;
       
   973     streamtype = (TMSStreamType) aMessage.Int0();
       
   974 
       
   975     if (streamtype == TMS_STREAM_UPLINK)
       
   976         {
       
   977         if (iActiveCallType == TMS_CALL_IP && iDTMFUplinkPlayer)
       
   978             {
       
   979             iDTMFUplinkPlayer->Cancel();
       
   980             status = TMS_RESULT_SUCCESS;
       
   981             }
       
   982         else if (iActiveCallType == TMS_CALL_CS &&
       
   983                 iDTMFUplinkPlayerEtel)
       
   984             {
       
   985             status = iDTMFUplinkPlayerEtel->StopDtmfTone();
       
   986             status = TMSUtility::EtelToTMSResult(status);
       
   987             }
       
   988         }
       
   989     else if (streamtype == TMS_STREAM_DOWNLINK)
       
   990         {
       
   991         if (iDTMFDnlinkPlayer)
       
   992             {
       
   993             iDTMFDnlinkPlayer->Cancel();
       
   994             status = TMS_RESULT_SUCCESS;
       
   995             }
       
   996         }
       
   997     iActiveCallType = -1;
       
   998     NotifyDtmfClients(ECmdDTMFTonePlayFinished, status);
       
   999     aMessage.Complete(status);
       
  1000     TRACE_PRN_FN_EXT;
       
  1001     return status;
       
  1002     }
       
  1003 
       
  1004 // -----------------------------------------------------------------------------
       
  1005 // TMSServer::ContinueSendingDTMF
       
  1006 //
       
  1007 // -----------------------------------------------------------------------------
       
  1008 //
       
  1009 TInt TMSServer::ContinueSendingDTMF(const RMessage2& aMessage)
       
  1010     {
       
  1011     TRACE_PRN_FN_ENT;
       
  1012     TInt status(TMS_RESULT_INVALID_STATE);
       
  1013     if (iActiveCallType == TMS_CALL_CS && iDTMFUplinkPlayerEtel)
       
  1014         {
       
  1015         TBool continuesnd = (TBool) aMessage.Int0();
       
  1016         status = iDTMFUplinkPlayerEtel->ContinueDtmfStringSending(continuesnd);
       
  1017         status = TMSUtility::EtelToTMSResult(status);
       
  1018         }
       
  1019     aMessage.Complete(status);
       
  1020     TRACE_PRN_FN_EXT;
       
  1021     return status;
       
  1022     }
       
  1023 
       
  1024 // -----------------------------------------------------------------------------
       
  1025 // TMSServer::NotifyDtmfClients
       
  1026 //
       
  1027 // -----------------------------------------------------------------------------
       
  1028 //
       
  1029 TInt TMSServer::NotifyDtmfClients(gint aEventType, gint aError)
       
  1030     {
       
  1031     TRACE_PRN_FN_ENT;
       
  1032     iSessionIter.SetToFirst();
       
  1033     TMSServerSession* ss = static_cast<TMSServerSession*> (iSessionIter++);
       
  1034     while (ss != NULL)
       
  1035         {
       
  1036         ss->NotifyClient(aEventType, aError);
       
  1037         ss = static_cast<TMSServerSession*> (iSessionIter++);
       
  1038         }
       
  1039     TRACE_PRN_FN_EXT;
       
  1040     return TMS_RESULT_SUCCESS;
       
  1041     }
       
  1042 
       
  1043 //From DTMFTonePlayerObserver
       
  1044 // -----------------------------------------------------------------------------
       
  1045 // TMSServer::DTMFInitCompleted
       
  1046 //
       
  1047 // -----------------------------------------------------------------------------
       
  1048 //
       
  1049 void TMSServer::DTMFInitCompleted(gint status)
       
  1050     {
       
  1051     TRACE_PRN_FN_ENT;
       
  1052     if (status != TMS_RESULT_SUCCESS)
       
  1053         {
       
  1054         NotifyDtmfClients(ECmdDTMFTonePlayFinished, status);
       
  1055         }
       
  1056     TRACE_PRN_FN_EXT;
       
  1057     }
       
  1058 
       
  1059 // -----------------------------------------------------------------------------
       
  1060 // TMSServer::DTMFToneFinished
       
  1061 //
       
  1062 // -----------------------------------------------------------------------------
       
  1063 //
       
  1064 void TMSServer::DTMFToneFinished(gint status)
       
  1065     {
       
  1066     TRACE_PRN_FN_ENT;
       
  1067     TRACE_PRN_IF_ERR(status);
       
  1068 
       
  1069     // KErrUnderflow indicates end of DTMF playback.
       
  1070     if (status == KErrUnderflow /*|| status == KErrInUse*/)
       
  1071         {
       
  1072         status = TMS_RESULT_SUCCESS;
       
  1073         }
       
  1074     NotifyDtmfClients(ECmdDTMFTonePlayFinished, status);
       
  1075     TRACE_PRN_FN_EXT;
       
  1076     }
       
  1077 
       
  1078 // -----------------------------------------------------------------------------
       
  1079 // TMSServer::FindActiveCallType
       
  1080 //
       
  1081 // -----------------------------------------------------------------------------
       
  1082 //
       
  1083 gint TMSServer::FindActiveCallType()
       
  1084     {
       
  1085     TInt status(TMS_RESULT_INVALID_STATE);
       
  1086     iActiveCallType = -1;
       
  1087     TInt i = 0;
       
  1088     while (i < iTMSCallServList.Count())
       
  1089         {
       
  1090         TMSStartAndMonitorTMSCallThread* callThread = iTMSCallServList[i];
       
  1091         if (callThread)
       
  1092             {
       
  1093             TmsCallMsgBufPckg pckg;
       
  1094             TIpcArgs args(&pckg);
       
  1095             status = callThread->iTMSCallProxyLocal.ReceiveFromCallServer(
       
  1096                     TMS_GET_ACTIVE_CALL_PARAMS, args);
       
  1097             if (pckg().iBool || status != TMS_RESULT_SUCCESS)
       
  1098                 {
       
  1099                 iActiveCallType = static_cast<TMSCallType> (pckg().iInt);
       
  1100                 break;
       
  1101                 }
       
  1102             }
       
  1103         i++;
       
  1104         }
       
  1105     return status;
       
  1106     }
       
  1107 
       
  1108 // -----------------------------------------------------------------------------
       
  1109 // TMSServer::HandleDTMFEvent
       
  1110 //
       
  1111 // -----------------------------------------------------------------------------
       
  1112 //
       
  1113 void TMSServer::HandleDTMFEvent(const TMSDTMFObserver::TCCPDtmfEvent event,
       
  1114         const gint status, const TChar /*tone*/)
       
  1115     {
       
  1116     TRACE_PRN_FN_ENT;
       
  1117     TRACE_PRN_IF_ERR(status);
       
  1118     gint cmd = ECmdDTMFTonePlayFinished;
       
  1119 
       
  1120     switch (event)
       
  1121         {
       
  1122         case ECCPDtmfUnknown:               //Unknown
       
  1123             break;
       
  1124         case ECCPDtmfManualStart:           //DTMF sending started manually
       
  1125         case ECCPDtmfSequenceStart:         //Automatic DTMF sending initialized
       
  1126             cmd = ECmdDTMFToneUplPlayStarted;
       
  1127             break;
       
  1128         case ECCPDtmfManualStop:            //DTMF sending stopped manually
       
  1129         case ECCPDtmfManualAbort:           //DTMF sending aborted manually
       
  1130         case ECCPDtmfSequenceStop:          //Automatic DTMF sending stopped
       
  1131         case ECCPDtmfSequenceAbort:         //Automatic DTMF sending aborted
       
  1132         case ECCPDtmfStopInDtmfString:      //There was stop mark in DTMF string
       
  1133         case ECCPDtmfStringSendingCompleted://DTMF sending success
       
  1134         default:
       
  1135             break;
       
  1136         }
       
  1137 
       
  1138     NotifyDtmfClients(cmd, status);
       
  1139     TRACE_PRN_FN_EXT;
       
  1140     }
       
  1141 
       
  1142 // -----------------------------------------------------------------------------
       
  1143 // TMSServer::InitRingTonePlayerL
       
  1144 //
       
  1145 // -----------------------------------------------------------------------------
       
  1146 //
       
  1147 void TMSServer::InitRingTonePlayerL()
       
  1148     {
       
  1149     TRACE_PRN_FN_ENT;
       
  1150 
       
  1151     DeinitRingTonePlayer();
       
  1152 
       
  1153     if (!iTMSRtPlayer)
       
  1154         {
       
  1155         iTMSRtPlayer = TMSRingTonePlayer::NewL(*this);
       
  1156         }
       
  1157 
       
  1158     TRACE_PRN_FN_EXT;
       
  1159     }
       
  1160 
       
  1161 // -----------------------------------------------------------------------------
       
  1162 // TMSServer::DeinitRingTonePlayer
       
  1163 //
       
  1164 // -----------------------------------------------------------------------------
       
  1165 //
       
  1166 void TMSServer::DeinitRingTonePlayer()
       
  1167     {
       
  1168     TRACE_PRN_FN_ENT;
       
  1169 
       
  1170     if (iTMSRtPlayer)
       
  1171         {
       
  1172         iTMSRtPlayer->DeinitRingTonePlayer();
       
  1173         }
       
  1174 
       
  1175     delete iRtFile;
       
  1176     iRtFile = NULL;
       
  1177     delete iRtSequence;
       
  1178     iRtSequence = NULL;
       
  1179     delete iTtsText;
       
  1180     iTtsText = NULL;
       
  1181 
       
  1182     TRACE_PRN_FN_EXT;
       
  1183     }
       
  1184 
       
  1185 // -----------------------------------------------------------------------------
       
  1186 // TMSServer::OpenRingTonePlayerFromFileL
       
  1187 //
       
  1188 // -----------------------------------------------------------------------------
       
  1189 //
       
  1190 void TMSServer::OpenRingTonePlayerFromFileL(const RMessage2& aMessage)
       
  1191     {
       
  1192     TRACE_PRN_FN_ENT;
       
  1193 
       
  1194     gint status(TMS_RESULT_INVALID_ARGUMENT);
       
  1195     gint len = aMessage.GetDesLength(0);
       
  1196     if (len > 0)
       
  1197         {
       
  1198         InitRingTonePlayerL();
       
  1199 
       
  1200         if (iTMSRtPlayer)
       
  1201             {
       
  1202             iRtFile = HBufC::NewL(len);
       
  1203             TPtr ptr = iRtFile->Des();
       
  1204             aMessage.ReadL(0, ptr);
       
  1205             iTMSRtPlayer->CreateRingTonePlayerL(EPlayerAudio, *iRtFile);
       
  1206             len = aMessage.GetDesLength(1);
       
  1207             if (len > 0)
       
  1208                 {
       
  1209                 delete iTtsText;
       
  1210                 iTtsText = NULL;
       
  1211                 iTtsText = HBufC::NewL(len);
       
  1212                 TPtr ptr1 = iTtsText->Des();
       
  1213                 aMessage.ReadL(1, ptr1);
       
  1214                 iTMSRtPlayer->CreateTTSPlayerL(ptr1);
       
  1215                 }
       
  1216             status = TMS_RESULT_SUCCESS;
       
  1217             }
       
  1218         }
       
  1219     aMessage.Complete(status);
       
  1220 
       
  1221     TRACE_PRN_FN_EXT;
       
  1222     }
       
  1223 
       
  1224 // -----------------------------------------------------------------------------
       
  1225 // TMSServer::OpenRingTonePlayerFromProfileL
       
  1226 //
       
  1227 // -----------------------------------------------------------------------------
       
  1228 //
       
  1229 void TMSServer::OpenRingTonePlayerFromProfileL(const RMessage2& aMessage)
       
  1230     {
       
  1231     TRACE_PRN_FN_ENT;
       
  1232 
       
  1233     gint status(TMS_RESULT_INVALID_ARGUMENT);
       
  1234     InitRingTonePlayerL();
       
  1235 
       
  1236     if (iTMSRtPlayer)
       
  1237         {
       
  1238         iTMSRtPlayer->CreateRingTonePlayerL(EPlayerDefault);
       
  1239         gint len = aMessage.GetDesLength(1);
       
  1240         if (len > 0)
       
  1241             {
       
  1242             delete iTtsText;
       
  1243             iTtsText = NULL;
       
  1244             iTtsText = HBufC::NewL(len);
       
  1245             TPtr ptr = iTtsText->Des();
       
  1246             aMessage.ReadL(1, ptr);
       
  1247             iTMSRtPlayer->CreateTTSPlayerL(ptr);
       
  1248             }
       
  1249         status = TMS_RESULT_SUCCESS;
       
  1250         }
       
  1251     aMessage.Complete(status);
       
  1252 
       
  1253     TRACE_PRN_FN_EXT;
       
  1254     }
       
  1255 
       
  1256 // -----------------------------------------------------------------------------
       
  1257 // TMSServer::OpenRingToneSequencePlayerL
       
  1258 //
       
  1259 // -----------------------------------------------------------------------------
       
  1260 //
       
  1261 void TMSServer::OpenRingToneSequencePlayerL(const RMessage2& aMessage)
       
  1262     {
       
  1263     TRACE_PRN_FN_ENT;
       
  1264 
       
  1265     gint status(TMS_RESULT_INVALID_ARGUMENT);
       
  1266     gint len = aMessage.GetDesLength(0);
       
  1267     if (len > 0)
       
  1268         {
       
  1269         InitRingTonePlayerL();
       
  1270         iRtSequence = HBufC8::NewL(len);
       
  1271         TPtr8 ptr = iRtSequence->Des();
       
  1272         aMessage.ReadL(0, ptr);
       
  1273 
       
  1274         if (iTMSRtPlayer)
       
  1275             {
       
  1276             iTMSRtPlayer->CreateCustomSequencePlayerL(ptr);
       
  1277             status = TMS_RESULT_SUCCESS;
       
  1278             }
       
  1279         }
       
  1280     aMessage.Complete(status);
       
  1281 
       
  1282     TRACE_PRN_FN_EXT;
       
  1283     }
       
  1284 
       
  1285 // -----------------------------------------------------------------------------
       
  1286 // TMSServer::OpenRingToneBeepOnceL
       
  1287 //
       
  1288 // -----------------------------------------------------------------------------
       
  1289 //
       
  1290 void TMSServer::OpenRingToneBeepOnceL()
       
  1291     {
       
  1292     TRACE_PRN_FN_ENT;
       
  1293 
       
  1294     InitRingTonePlayerL();
       
  1295 
       
  1296     if (iTMSRtPlayer)
       
  1297         {
       
  1298         iTMSRtPlayer->CreateSequencePlayerL(EPlayerBeepOnce);
       
  1299         }
       
  1300 
       
  1301     TRACE_PRN_FN_EXT;
       
  1302     }
       
  1303 
       
  1304 // -----------------------------------------------------------------------------
       
  1305 // TMSServer::DeinitRingTone
       
  1306 //
       
  1307 // -----------------------------------------------------------------------------
       
  1308 //
       
  1309 void TMSServer::OpenRingToneSilentL()
       
  1310     {
       
  1311     TRACE_PRN_FN_ENT;
       
  1312 
       
  1313     InitRingTonePlayerL();
       
  1314 
       
  1315     if (iTMSRtPlayer)
       
  1316         {
       
  1317         iTMSRtPlayer->CreateSequencePlayerL(EPlayerSilent);
       
  1318         }
       
  1319 
       
  1320     TRACE_PRN_FN_EXT;
       
  1321     }
       
  1322 
       
  1323 // -----------------------------------------------------------------------------
       
  1324 // TMSServer::OpenRingToneUnsecureVoipL
       
  1325 //
       
  1326 // -----------------------------------------------------------------------------
       
  1327 //
       
  1328 void TMSServer::OpenRingToneUnsecureVoipL()
       
  1329     {
       
  1330     TRACE_PRN_FN_ENT;
       
  1331 
       
  1332     InitRingTonePlayerL();
       
  1333 
       
  1334     if (iTMSRtPlayer)
       
  1335         {
       
  1336         iTMSRtPlayer->CreateSequencePlayerL(EPlayerUnsecureVoIP);
       
  1337         }
       
  1338 
       
  1339     TRACE_PRN_FN_EXT;
       
  1340     }
       
  1341 
       
  1342 // -----------------------------------------------------------------------------
       
  1343 // TMSServer::PlayRingToneL
       
  1344 //
       
  1345 // -----------------------------------------------------------------------------
       
  1346 //
       
  1347 void TMSServer::PlayRingToneL()
       
  1348     {
       
  1349     TRACE_PRN_FN_ENT;
       
  1350 
       
  1351     if (iTMSRtPlayer)
       
  1352         {
       
  1353         iTMSRtPlayer->PlayRingToneL();
       
  1354         }
       
  1355     else
       
  1356         {
       
  1357         User::Leave(TMS_RESULT_UNINITIALIZED_OBJECT);
       
  1358         }
       
  1359 
       
  1360     TRACE_PRN_FN_EXT;
       
  1361     }
       
  1362 
       
  1363 // -----------------------------------------------------------------------------
       
  1364 // TMSServer::PauseVideoRingTone
       
  1365 //
       
  1366 // -----------------------------------------------------------------------------
       
  1367 //
       
  1368 void TMSServer::PauseVideoRingTone()
       
  1369     {
       
  1370     StopRingTone();
       
  1371     }
       
  1372 
       
  1373 // -----------------------------------------------------------------------------
       
  1374 // TMSServer::StopRingTone
       
  1375 //
       
  1376 // -----------------------------------------------------------------------------
       
  1377 //
       
  1378 void TMSServer::StopRingTone()
       
  1379     {
       
  1380     TRACE_PRN_FN_ENT;
       
  1381 
       
  1382     if (iTMSRtPlayer)
       
  1383         {
       
  1384         iTMSRtPlayer->StopPlaying();
       
  1385         }
       
  1386 
       
  1387     TRACE_PRN_FN_EXT;
       
  1388     }
       
  1389 
       
  1390 // -----------------------------------------------------------------------------
       
  1391 // TMSServer::MuteRingTone
       
  1392 //
       
  1393 // -----------------------------------------------------------------------------
       
  1394 //
       
  1395 void TMSServer::MuteRingTone()
       
  1396     {
       
  1397     TRACE_PRN_FN_ENT;
       
  1398 
       
  1399     if (iTMSRtPlayer)
       
  1400         {
       
  1401         iTMSRtPlayer->MuteRingTone();
       
  1402         }
       
  1403 
       
  1404     TRACE_PRN_FN_EXT;
       
  1405     }
       
  1406 
       
  1407 // -----------------------------------------------------------------------------
       
  1408 // TMSServer::RtPlayerEvent
       
  1409 //
       
  1410 // -----------------------------------------------------------------------------
       
  1411 //
       
  1412 void TMSServer::RtPlayerEvent(gint aEventType, gint aError)
       
  1413     {
       
  1414     TRACE_PRN_FN_ENT;
       
  1415 
       
  1416     iSessionIter.SetToFirst();
       
  1417     TMSServerSession* ss = static_cast<TMSServerSession*> (iSessionIter++);
       
  1418 
       
  1419     while (ss != NULL)
       
  1420         {
       
  1421         ss->NotifyClient(aEventType, aError);
       
  1422         ss = static_cast<TMSServerSession*> (iSessionIter++);
       
  1423         }
       
  1424 
       
  1425     TRACE_PRN_FN_EXT;
       
  1426     }
       
  1427 
       
  1428 // -----------------------------------------------------------------------------
       
  1429 // TMSServer::HandleNotifyPSL
       
  1430 //
       
  1431 // -----------------------------------------------------------------------------
       
  1432 //
       
  1433 void TMSServer::HandleNotifyPSL(const TUid aUid, const TInt& aKey,
       
  1434             const TRequestStatus& aStatus)
       
  1435     {
       
  1436     TRACE_PRN_FN_ENT;
       
  1437     if(iEffectSettings)
       
  1438         {
       
  1439         iEffectSettings->ResetDefaultVolume();
       
  1440         }
       
  1441     TRACE_PRN_FN_EXT;
   860     }
  1442     }
   861 
  1443 
   862 // -----------------------------------------------------------------------------
  1444 // -----------------------------------------------------------------------------
   863 // TMSServer::RunServerL
  1445 // TMSServer::RunServerL
   864 //
  1446 //
  1141         }
  1723         }
  1142     __UHEAP_MARKEND;
  1724     __UHEAP_MARKEND;
  1143     return r;
  1725     return r;
  1144     }
  1726     }
  1145 
  1727 
  1146 // End of file