bluetoothengine/btaudioman/src/basrvaccstatedetach.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 Attach state.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32property.h>
       
    21 #include <ctsydomainpskeys.h>
       
    22 #include "basrvaccstatedetach.h"
       
    23 #include "basrvaccstatedisconnect.h"
       
    24 #include "BTAccFwIf.h"
       
    25 #include "debug.h"
       
    26 
       
    27 const TInt KDetachRequestId = 10;
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =======================
       
    30 
       
    31 CBasrvAccStateDetach* CBasrvAccStateDetach::NewL(CBasrvAcc& aParent)
       
    32     {
       
    33     CBasrvAccStateDetach* self=new(ELeave) CBasrvAccStateDetach(aParent);
       
    34     return self;
       
    35     }
       
    36 
       
    37 CBasrvAccStateDetach::~CBasrvAccStateDetach()
       
    38     {
       
    39     delete iActive;
       
    40     delete iAccfw;
       
    41     TRACE_FUNC
       
    42     }
       
    43 
       
    44 void CBasrvAccStateDetach::EnterL()
       
    45     {
       
    46     StatePrint(_L("Detach"));
       
    47     // Stop any volume control
       
    48     AccInfo().iAudioOpenedProfiles = EUnknownProfile;
       
    49     Parent().NotifyLinkChange2Rvc();
       
    50     iAccfw = Parent().AccMan().NewAccfwConnectionInstanceL();
       
    51     iActive = CBasrvActive::NewL(*this, CActive::EPriorityStandard, KDetachRequestId);
       
    52     iAccfw->DetatchAccessory(AccInfo().iAddr, iActive->iStatus);
       
    53     iActive->GoActive();
       
    54     }
       
    55 
       
    56 CBasrvAccState* CBasrvAccStateDetach::ErrorOnEntry(TInt aReason)
       
    57     {
       
    58     TRACE_FUNC
       
    59     TRAP_IGNORE(Parent().AccMan().ConnectCompletedL(AccInfo().iAddr, aReason, AccInfo().iSuppProfiles));
       
    60     CBasrvAccState* next = NULL;
       
    61     TRAP_IGNORE(next = CBasrvAccStateDisconnect::NewL(Parent()));
       
    62     return next;
       
    63     }
       
    64 
       
    65 TBTEngConnectionStatus CBasrvAccStateDetach::ConnectionStatus() const
       
    66     {
       
    67     return EBTEngDisconnecting;
       
    68     }
       
    69     
       
    70 void CBasrvAccStateDetach::AccessoryDisconnectedL(TProfiles aProfile)
       
    71     {
       
    72     TRACE_FUNC
       
    73     ProfileDisconnected(aProfile);
       
    74     StatePrint(_L("Detach"));    
       
    75     }
       
    76 
       
    77 void CBasrvAccStateDetach::OpenAudioL(TAccAudioType /*aType*/)
       
    78     {
       
    79     TRACE_FUNC
       
    80     LEAVE(KErrDisconnected);
       
    81     }
       
    82 
       
    83 void CBasrvAccStateDetach::CloseAudioL(TAccAudioType /*aType*/)
       
    84     {
       
    85     TRACE_FUNC
       
    86     LEAVE(KErrDisconnected);    
       
    87     }
       
    88 
       
    89 void CBasrvAccStateDetach::RequestCompletedL(CBasrvActive& /*aActive*/)
       
    90     {
       
    91     TRACE_FUNC
       
    92     Parent().AccMan().PluginMan().AccOutOfUse();
       
    93     TInt callState;
       
    94     TInt err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState);
       
    95     if(!err && (callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized))
       
    96         {
       
    97 	    Parent().AccMan().ShowNote(EBTClosed, AccInfo().iAddr); 				  		
       
    98         }
       
    99     
       
   100     if (AccInfo().iConnProfiles)
       
   101         {
       
   102         Parent().ChangeStateL(CBasrvAccStateDisconnect::NewL(Parent()));
       
   103         }
       
   104     else
       
   105         {
       
   106         Parent().ChangeStateL(NULL);
       
   107         }
       
   108     }
       
   109     
       
   110 void CBasrvAccStateDetach::CancelRequest(CBasrvActive& /*aActive*/)
       
   111     {
       
   112     }
       
   113 
       
   114 CBasrvAccStateDetach::CBasrvAccStateDetach(CBasrvAcc& aParent)
       
   115     : CBasrvAccState(aParent, NULL)
       
   116     {
       
   117     }
       
   118