bluetoothengine/btaudioman/src/basrvaccstateconnect.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 Connect state.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "basrvaccstateconnect.h"
       
    21 #include "basrvaccstateattach.h"
       
    22 #include "basrvaccstateattached.h"
       
    23 #include "debug.h"
       
    24 
       
    25 const TInt KConnectRequestId = 1;
       
    26 
       
    27 // ================= MEMBER FUNCTIONS =======================
       
    28 
       
    29 CBasrvAccStateConnect* CBasrvAccStateConnect::NewL(CBasrvAcc& aParent)
       
    30     {
       
    31     CBasrvAccStateConnect* self = new (ELeave) CBasrvAccStateConnect(aParent);
       
    32     CleanupStack::PushL(self);
       
    33     self->ConstructL();
       
    34     CleanupStack::Pop(self);
       
    35     return self;
       
    36     }
       
    37 
       
    38 CBasrvAccStateConnect::~CBasrvAccStateConnect()
       
    39     {
       
    40     delete iActive;
       
    41     TRACE_FUNC
       
    42     }
       
    43 
       
    44 void CBasrvAccStateConnect::EnterL()
       
    45     {
       
    46     StatePrint(_L("Connect"));    
       
    47     CBTAccPlugin* plugin = NULL;
       
    48     if (AccInfo().iSuppProfiles & EHFP)
       
    49         {
       
    50         iConnectingProfile = EHFP;
       
    51         }
       
    52     else if (AccInfo().iSuppProfiles & EHSP)
       
    53         {
       
    54         iConnectingProfile = EHSP;
       
    55         }
       
    56     else if (AccInfo().iSuppProfiles & EStereo)
       
    57         {
       
    58         iConnectingProfile = EStereo;
       
    59         }
       
    60     plugin = Parent().AccMan().PluginMan().Plugin(iConnectingProfile);
       
    61     LEAVE_IF_NULL(plugin)
       
    62     plugin->ConnectToAccessory(AccInfo().iAddr, iActive->iStatus);
       
    63     iActive->GoActive();
       
    64     }
       
    65 
       
    66 CBasrvAccState* CBasrvAccStateConnect::ErrorOnEntry(TInt aReason)
       
    67     {
       
    68     TRACE_FUNC
       
    69     TRAP_IGNORE(Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, aReason, AccInfo().iSuppProfiles));
       
    70     return NULL;
       
    71     }
       
    72 
       
    73 TBTEngConnectionStatus CBasrvAccStateConnect::ConnectionStatus() const
       
    74     {
       
    75     return EBTEngConnecting;
       
    76     }
       
    77 
       
    78 
       
    79 void CBasrvAccStateConnect::CancelConnect()
       
    80     {
       
    81     TRACE_FUNC
       
    82     iActive->Cancel();
       
    83     TRAP_IGNORE(Parent().ChangeStateL(NULL));
       
    84     }
       
    85 
       
    86 void CBasrvAccStateConnect::RequestCompletedL(CBasrvActive& aActive)
       
    87     {
       
    88     TRACE_FUNC
       
    89     if (aActive.iStatus == KErrNone)
       
    90         {
       
    91         AccInfo().iConnProfiles |= iConnectingProfile;
       
    92         Parent().ChangeStateL(CBasrvAccStateAttach::NewL(Parent(), ETrue));
       
    93         }
       
    94     else
       
    95         {
       
    96         Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, aActive.iStatus.Int(), AccInfo().iSuppProfiles);
       
    97         Parent().ChangeStateL(NULL);
       
    98         }
       
    99     }
       
   100     
       
   101 void CBasrvAccStateConnect::CancelRequest(CBasrvActive& /*aActive*/)
       
   102     {
       
   103     TRACE_FUNC
       
   104     Parent().AccMan().PluginMan().Plugin(iConnectingProfile)->CancelConnectToAccessory(AccInfo().iAddr);
       
   105     }
       
   106 
       
   107 CBasrvAccStateConnect::CBasrvAccStateConnect(CBasrvAcc& aParent)
       
   108     : CBasrvAccState(aParent, NULL)
       
   109     {
       
   110     }
       
   111     
       
   112 void CBasrvAccStateConnect::ConstructL()
       
   113     {
       
   114     iActive = CBasrvActive::NewL(*this, CActive::EPriorityStandard, KConnectRequestId);
       
   115     }
       
   116