bluetoothengine/btaudioman/src/BTAccSession.cpp
branchRCL_3
changeset 6 6a29d5ad0713
parent 0 f63038272f30
child 9 a42ed326b458
equal deleted inserted replaced
2:0b192a3a05a4 6:6a29d5ad0713
    25 #include "BTAccClientSrv.h"
    25 #include "BTAccClientSrv.h"
    26 #include "debug.h"
    26 #include "debug.h"
    27 #include "BTAccServer.h"
    27 #include "BTAccServer.h"
    28 #include "basrvaccman.h"
    28 #include "basrvaccman.h"
    29 #include "BTAccInfo.h"
    29 #include "BTAccInfo.h"
       
    30 #include "btaccpanic.h"
    30 
    31 
    31 typedef TPckgBuf<TBTDevAddr> TBTDevAddrPckgBuf;
    32 typedef TPckgBuf<TBTDevAddr> TBTDevAddrPckgBuf;
    32 
    33 
    33 // ================= MEMBER FUNCTIONS =======================
    34 // ================= MEMBER FUNCTIONS =======================
    34 CBTAccSession* CBTAccSession::NewL(CBasrvAccMan& aAccMan)
    35 CBTAccSession* CBTAccSession::NewL(CBasrvAccMan& aAccMan)
    62     if (iNotifyProfileMsg.Handle())
    63     if (iNotifyProfileMsg.Handle())
    63         {
    64         {
    64         iNotifyProfileMsg.Complete(KErrAbort);
    65         iNotifyProfileMsg.Complete(KErrAbort);
    65         }
    66         }
    66     iProfileStatusCache.Close();
    67     iProfileStatusCache.Close();
    67     DestructVariant();
       
    68     
    68     
    69     //clear the accessory managers pointer to this session if it has one
    69     //clear the accessory managers pointer to this session if it has one
    70     iAccMan.ClearProfileNotifySession(*this);
    70     iAccMan.ClearProfileNotifySession(*this);
    71     
    71     
    72     //clear the servers reference to this session
    72     //clear the servers reference to this session
    76 void CBTAccSession::CreateL()
    76 void CBTAccSession::CreateL()
    77     {
    77     {
    78     TRACE_FUNC
    78     TRACE_FUNC
    79     //use CreateL instead of NewSessionL when using Server() to ensure the
    79     //use CreateL instead of NewSessionL when using Server() to ensure the
    80     //session has been created correctly and Server() returns a valid pointer
    80     //session has been created correctly and Server() returns a valid pointer
    81     Server().ClientOpened(*this);
    81     Server().ClientOpenedL(*this);
    82     }
    82     }
    83 
    83 
    84 void CBTAccSession::ConnectCompleted(TInt aErr, TInt aProfile, const RArray<TBTDevAddr>* aConflicts)
    84 void CBTAccSession::ConnectCompleted(TInt aErr, TInt aProfile, const RArray<TBTDevAddr>* aConflicts)
    85     {
    85     {
    86     TRACE_FUNC
    86     TRACE_FUNC
    87     if (iConnectMsg.Handle())
    87     if (iConnectMsg.Handle())
    88         {
    88         {
    89         TRACE_INFO((_L("CBTAccSession::ConnectCompleted err %d"), aErr))
    89         TRACE_INFO((_L("CBTAccSession::ConnectCompleted err %d"), aErr))
    90         if (aConflicts)
    90         if (aConflicts)
    91             {
    91             {
    92             TBuf8<KBTDevAddrSize * 2> buf;
    92             if (aErr == KErrNone)
       
    93                 {
       
    94                 //we need to error so the client knows there are conflicts which need handling
       
    95                 aErr = KErrGeneral; 
       
    96                 }
       
    97             
       
    98             const TInt KMaxNumberOfConflicts = 2;
       
    99             
       
   100             TBuf8<KBTDevAddrSize * KMaxNumberOfConflicts> buf;
    93             TInt count = aConflicts->Count();
   101             TInt count = aConflicts->Count();
       
   102             __ASSERT_DEBUG(count <= KMaxNumberOfConflicts, BTACC_PANIC(EMaxNumberOfConflictsExceeded));
       
   103             
    94             for (TInt i = 0; i < count; i++)
   104             for (TInt i = 0; i < count; i++)
    95                 {
   105                 {
       
   106                 if(i >= KMaxNumberOfConflicts)
       
   107                     {
       
   108                     break; //prevent descriptor overflow
       
   109                     }
    96                 buf.Append((*aConflicts)[i].Des());
   110                 buf.Append((*aConflicts)[i].Des());
    97                 }
   111                 }
    98             
   112             
    99             if (buf.Length())
   113             if (buf.Length())
   100                 {
   114                 {
   101                 iConnectMsg.Write(1, buf);
   115                 iConnectMsg.Write(1, buf);
   102                 }
   116                 }
   103             }
   117             }
   104         else if (!aErr)
   118         else if (aErr == KErrNone)
   105             {
   119             {
   106             TPckgBuf<TInt> buf(aProfile);
   120             TPckgBuf<TInt> buf(aProfile);
   107             iConnectMsg.Write(1, buf);
   121             aErr = iConnectMsg.Write(1, buf);
   108             }
   122             }
   109         iConnectMsg.Complete(aErr);
   123         iConnectMsg.Complete(aErr);
   110         }
   124         }
   111     }
   125     }
   112     
   126     
   114     {
   128     {
   115     TRACE_FUNC
   129     TRACE_FUNC
   116     if (iDisconnectMsg.Handle())
   130     if (iDisconnectMsg.Handle())
   117         {
   131         {
   118         TRACE_FUNC
   132         TRACE_FUNC
   119         if (!aErr)
   133         if (aErr == KErrNone)
   120             {
   134             {
   121             TPckgBuf<TInt> buf(aProfile);
   135             TPckgBuf<TInt> buf(aProfile);
   122             iDisconnectMsg.Write(1, buf);
   136             aErr = iDisconnectMsg.Write(1, buf);
   123             }
   137             }
   124         iDisconnectMsg.Complete(aErr);
   138         iDisconnectMsg.Complete(aErr);
   125         }
   139         }
   126     }
   140     }
   127 
   141 
   449         case EBTAccSrvGetInfoOfConnectedAcc:
   463         case EBTAccSrvGetInfoOfConnectedAcc:
   450             {
   464             {
   451             GetInfoOfConnectedAcc(aMessage);
   465             GetInfoOfConnectedAcc(aMessage);
   452             break;
   466             break;
   453             }
   467             }
   454         case EBTAccSrvAudioToPhone:
       
   455         case EBTAccSrvAudioToAccessory:
       
   456         case EBTAccSrvCancelAudioToAccessory:
       
   457             {
       
   458             HandleAudio4DosRequest(aMessage);
       
   459             break;
       
   460             }
       
   461         default:
   468         default:
   462             {
   469             {
   463             PanicClient(aMessage, EBTAccBadRequest);
   470             PanicClient(aMessage, EBTAccBadRequest);
   464             break;
   471             break;
   465             }
   472             }