bluetoothengine/btaudioman/src/basrvaccstate.cpp
changeset 0 f63038272f30
child 6 6a29d5ad0713
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of BT Acc Server accessory base state.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "basrvaccstate.h"
       
    21 #include "debug.h"
       
    22 
       
    23 const TInt KBitAvrcpSupportedFeatureCategory2 = 0x2;
       
    24 
       
    25 
       
    26 // ================= MEMBER FUNCTIONS =======================
       
    27 
       
    28 CBasrvAccState::~CBasrvAccState()
       
    29     {
       
    30     CompleteStateRequest(KErrAbort);
       
    31     }
       
    32     
       
    33 CBasrvAccState* CBasrvAccState::ErrorOnEntry(TInt /*aReason*/)
       
    34     {
       
    35     TRACE_FUNC
       
    36     return NULL;
       
    37     }
       
    38 
       
    39 void CBasrvAccState::ConnectL(const TBTDevAddr& /*aAddr*/)
       
    40     {
       
    41     TRACE_FUNC
       
    42     LEAVE(KErrAlreadyExists);
       
    43     }
       
    44 
       
    45 void CBasrvAccState::CancelConnect()
       
    46     {
       
    47     TRACE_FUNC
       
    48     }
       
    49 
       
    50 void CBasrvAccState::DisconnectL()
       
    51     {
       
    52     TRACE_FUNC
       
    53     LEAVE(KErrDisconnected);
       
    54     }
       
    55 
       
    56 void CBasrvAccState::AccessoryConnected(TProfiles aProfile)
       
    57     {
       
    58     TRACE_FUNC
       
    59     NewProfileConnection(aProfile);    
       
    60     StatePrint(_L("StateXXX"));
       
    61     }
       
    62 
       
    63 void CBasrvAccState::AccOpenedAudio(TProfiles aProfile)
       
    64     {
       
    65     TRACE_FUNC
       
    66     AccInfo().iAudioOpenedProfiles |= aProfile;
       
    67     StatePrint(_L("StateXXX"));
       
    68     }
       
    69 
       
    70 void CBasrvAccState::AccClosedAudio(TProfiles aProfile)
       
    71     {
       
    72     TRACE_FUNC
       
    73     if (aProfile & EAnyMonoAudioProfiles)
       
    74         AccInfo().iAudioOpenedProfiles &= ~EAnyMonoAudioProfiles;
       
    75     else
       
    76         AccInfo().iAudioOpenedProfiles &= ~aProfile;
       
    77     StatePrint(_L("StateXXX"));
       
    78     }
       
    79     
       
    80 void CBasrvAccState::AccessoryDisconnectedL(TProfiles /*aProfile*/)
       
    81     {
       
    82     TRACE_FUNC
       
    83     }
       
    84 
       
    85 void CBasrvAccState::OpenAudioL(TAccAudioType /*aType*/)
       
    86     {
       
    87     TRACE_FUNC
       
    88     }
       
    89 
       
    90 void CBasrvAccState::CloseAudioL(TAccAudioType /*aType*/)
       
    91     {
       
    92     TRACE_FUNC
       
    93     }
       
    94 
       
    95 void CBasrvAccState::RequestCompletedL(CBasrvActive& /*aActive*/)
       
    96     {
       
    97     TRACE_FUNC
       
    98     }
       
    99     
       
   100 void CBasrvAccState::CancelRequest(CBasrvActive& /*aActive*/)
       
   101     {
       
   102     TRACE_FUNC
       
   103     }
       
   104 
       
   105 CBasrvAccState::CBasrvAccState(CBasrvAcc& aParent, TRequestStatus* aRequest)
       
   106     : iParent(aParent), iRequest(aRequest)
       
   107     {
       
   108     }
       
   109 
       
   110 CBasrvAcc& CBasrvAccState::Parent()
       
   111     {
       
   112     return iParent;
       
   113     }
       
   114 
       
   115 void CBasrvAccState::CompleteStateRequest(TInt aErr)
       
   116     {
       
   117     if (iRequest)
       
   118         {
       
   119         User::RequestComplete(iRequest, aErr);
       
   120         TRACE_INFO((_L("Request 0x%08X completed with %d"), iRequest, aErr))
       
   121         iRequest = NULL;
       
   122         }
       
   123     }
       
   124     
       
   125 void CBasrvAccState::CompleteRequest(TRequestStatus* aStatus, TInt aErr)
       
   126     {
       
   127     if (aStatus)
       
   128         {
       
   129         User::RequestComplete(aStatus, aErr);
       
   130         TRACE_INFO((_L("Request 0x%08X completed with %d"), aStatus, aErr))
       
   131         }
       
   132     }
       
   133 
       
   134 void CBasrvAccState::StatePrint(const TDesC& aStateName)
       
   135     {
       
   136     TRACE_INFO_SEG(
       
   137         {
       
   138         TBuf<12> buf;
       
   139         AccInfo().iAddr.GetReadable(buf);
       
   140         Trace(_L("[%S State %S] Profiles %04X, Connected %04X, withAudio %04X"),
       
   141             &aStateName, &buf, AccInfo().iSuppProfiles, AccInfo().iConnProfiles, AccInfo().iAudioOpenedProfiles);
       
   142         }); (void) aStateName;
       
   143     }
       
   144 
       
   145 TAccInfo& CBasrvAccState::AccInfo()
       
   146     {
       
   147     return Parent().AccInfo();
       
   148     }
       
   149 
       
   150 void CBasrvAccState::NewProfileConnection(TProfiles aProfile)
       
   151     {
       
   152     AccInfo().iConnProfiles |= aProfile;
       
   153     AccInfo().iSuppProfiles |= aProfile;
       
   154     if (aProfile == ERemConCT && 
       
   155         Parent().AccMan().IsAvrcpVolCTSupported()&& 
       
   156         IsAvrcpTGCat2SupportedByRemote())
       
   157         {
       
   158         AccInfo().iConnProfiles |= ERemConTG;
       
   159         }
       
   160     TRACE_INFO((_L("Profiles %04X, Connected %04X"), AccInfo().iSuppProfiles, AccInfo().iConnProfiles))
       
   161     }
       
   162 
       
   163 void CBasrvAccState::ProfileDisconnected(TProfiles aProfile)
       
   164     {
       
   165     if (aProfile & EAnyRemConProfiles)
       
   166         {
       
   167         AccInfo().iConnProfiles &= ~EAnyRemConProfiles;
       
   168         }
       
   169     else if (aProfile & EAnyMonoAudioProfiles)
       
   170         {
       
   171         AccInfo().iConnProfiles &= ~EAnyMonoAudioProfiles;
       
   172         }
       
   173     else
       
   174         {
       
   175         AccInfo().iConnProfiles &= ~aProfile;
       
   176         }
       
   177     }
       
   178 
       
   179 TBool CBasrvAccState::IsAvrcpTGCat2SupportedByRemote()
       
   180     {
       
   181     return (AccInfo().iSuppProfiles & ERemConTG) && 
       
   182         (AccInfo().iSupportedFeatures[TAccInfo::ERemConTGIndex] & KBitAvrcpSupportedFeatureCategory2);
       
   183     }
       
   184 
       
   185     
       
   186 //  End of File