bluetoothengine/btaudioman/src/basrvaccstatedisconnect.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 Disconnect state.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "basrvaccstatedisconnect.h"
       
    21 #include "debug.h"
       
    22 
       
    23 // ================= MEMBER FUNCTIONS =======================
       
    24 
       
    25 CBasrvAccStateDisconnect* CBasrvAccStateDisconnect::NewL(CBasrvAcc& aParent, TInt aConnErr)
       
    26     {
       
    27     CBasrvAccStateDisconnect* self=new(ELeave) CBasrvAccStateDisconnect(aParent, aConnErr);
       
    28     return self;
       
    29     }
       
    30 
       
    31 CBasrvAccStateDisconnect::~CBasrvAccStateDisconnect()
       
    32     {
       
    33     delete iActive;
       
    34     TRACE_FUNC
       
    35     }
       
    36 
       
    37 void CBasrvAccStateDisconnect::EnterL()
       
    38     {
       
    39     StatePrint(_L("Disconnect"));
       
    40     iProfiles = AccInfo().iConnProfiles;
       
    41     Parent().RequestActiveMode();
       
    42     DoDisconnectL();
       
    43     }
       
    44 
       
    45 CBasrvAccState* CBasrvAccStateDisconnect::ErrorOnEntry(TInt /*aReason*/)
       
    46     {
       
    47     TRACE_FUNC
       
    48     return NULL;
       
    49     }
       
    50 
       
    51 TBTEngConnectionStatus CBasrvAccStateDisconnect::ConnectionStatus() const
       
    52     {
       
    53     if (iConnErr)
       
    54         return EBTEngConnecting;
       
    55     return EBTEngDisconnecting;
       
    56     }
       
    57 
       
    58 void CBasrvAccStateDisconnect::RequestCompletedL(CBasrvActive& aActive)
       
    59     {
       
    60     TRACE_INFO((_L("Disconnect 0x%02x done, err %d"), aActive.RequestId(), iDiscErr))
       
    61     if (!iDiscErr)
       
    62         iDiscErr = aActive.iStatus.Int();
       
    63     AccInfo().iConnProfiles &= ~(aActive.RequestId());
       
    64     StatePrint(_L("Disconnect"));
       
    65     if (!AccInfo().iConnProfiles)
       
    66         {
       
    67         if (iConnErr)
       
    68             Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, iConnErr, AccInfo().iSuppProfiles);
       
    69         else
       
    70             Parent().AccMan().DisconnectCompletedL(AccInfo().iAddr, iProfiles, KErrNone);
       
    71         Parent().ChangeStateL(NULL);
       
    72         }
       
    73     else
       
    74         {
       
    75         DoDisconnectL();
       
    76         }
       
    77     }
       
    78     
       
    79 void CBasrvAccStateDisconnect::CancelRequest(CBasrvActive& /*aActive*/)
       
    80     {
       
    81     }
       
    82 
       
    83 CBasrvAccStateDisconnect::CBasrvAccStateDisconnect(CBasrvAcc& aParent, TInt aConnErr)
       
    84     : CBasrvAccState(aParent, NULL), iConnErr(aConnErr)
       
    85     {
       
    86     }
       
    87  
       
    88 void CBasrvAccStateDisconnect::DoDisconnectL()
       
    89     {
       
    90     TRACE_FUNC
       
    91     TProfiles profile = EUnknownProfile;
       
    92     CBTAccPlugin* plugin = NULL;
       
    93     if (AccInfo().iConnProfiles & EStereo)
       
    94         {
       
    95         profile = EStereo;
       
    96         }
       
    97     else if (AccInfo().iConnProfiles & EAnyRemConProfiles)
       
    98         {
       
    99         profile = EAnyRemConProfiles;
       
   100         }
       
   101     else if (AccInfo().iConnProfiles & EAnyMonoAudioProfiles )
       
   102         {
       
   103         profile = EAnyMonoAudioProfiles;
       
   104         }
       
   105     plugin = Parent().AccMan().PluginMan().Plugin(profile);
       
   106     if (plugin)
       
   107         {
       
   108         if (!iActive)
       
   109             {
       
   110             iActive = CBasrvActive::NewL(*this, CActive::EPriorityStandard, profile);
       
   111             }
       
   112         iActive->SetRequestId(profile);
       
   113         plugin->DisconnectAccessory(AccInfo().iAddr, iActive->iStatus);
       
   114         iActive->GoActive();
       
   115         TRACE_INFO((_L("Disconnect 0x%02x ..."), profile))
       
   116         }
       
   117     }
       
   118