bluetoothengine/btaudioman/src/BTAccInfoRequester.cpp
changeset 0 f63038272f30
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:  Retrieves accessory information from Bluetooth Accessory Server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <btaccTypes.h>
       
    21 #include "BTAccInfoRequester.h"
       
    22 #include "debug.h"
       
    23 
       
    24 // ============================= LOCAL FUNCTIONS ===============================
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CBTAccInfoRequester::NewL
       
    30 // Two-phased constructor.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CBTAccInfoRequester* CBTAccInfoRequester::NewL(MBTAccInfoNotifier& aNotifier)
       
    34     {
       
    35     CBTAccInfoRequester* self = new (ELeave) CBTAccInfoRequester(aNotifier);
       
    36     return self;
       
    37     }
       
    38     
       
    39 // Destructor
       
    40 CBTAccInfoRequester::~CBTAccInfoRequester()
       
    41     {
       
    42     TRACE_FUNC_ENTRY
       
    43     Cancel();
       
    44     iBTAccClient.Close();
       
    45     TRACE_FUNC_EXIT
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CBTAccInfoRequester::GetBTAccInfo
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void CBTAccInfoRequester::GetBTAccInfoL(const TBTDevAddr& aAddr)
       
    53     {
       
    54     TRACE_FUNC;
       
    55     if (IsActive())
       
    56         {
       
    57         LEAVE(KErrInUse);
       
    58         }
       
    59 
       
    60     TInt err = iBTAccClient.Connect();
       
    61     if (err != KErrNone && err != KErrAlreadyExists)
       
    62         {
       
    63         LEAVE(err);
       
    64         }
       
    65         
       
    66     iAccInfo.iAddr = aAddr; 
       
    67     iAccInfo.iSuppProfiles = 0x00;
       
    68     iAccInfo.iConnProfiles = 0x00; 
       
    69     iAccInfo.iModel = 0x00;
       
    70     iAccInfo.iCapturingSupport = EFalse;
       
    71     for (TInt x=0; x<iAccInfo.iSupportedFeatures.Count(); x++)
       
    72         {
       
    73         iAccInfo.iSupportedFeatures.At(x) = 0x00;    
       
    74         }
       
    75     iBTAccClient.GetInfoOfConnectedAcc(iAccInfoPckg, iStatus);
       
    76     SetActive();
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CBTAccInfoRequester::RunL
       
    81 // ?implementation_description
       
    82 // (other items were commented in a header).
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CBTAccInfoRequester::RunL()
       
    86     {
       
    87     TRACE_FUNC;
       
    88     TASYBTAccInfo asyInfo;
       
    89     if (iStatus == KErrNone)
       
    90         {
       
    91         asyInfo.iDeviceInfo = iAccInfo.iModel;
       
    92         asyInfo.iDeviceType = iAccInfo.iDeviceType;
       
    93         TUint32 supportedProfiles = iAccInfo.iSuppProfiles;
       
    94         asyInfo.iProfiles = 0;
       
    95         asyInfo.iReserved = 0;
       
    96         
       
    97         if (supportedProfiles & (TUint32)EHSP)
       
    98             {
       
    99             asyInfo.iProfiles |= KAccInfoHSP;
       
   100             }
       
   101         if (supportedProfiles & (TUint32)EHFP)
       
   102             {
       
   103             asyInfo.iProfiles |= KAccInfoHFP;
       
   104             asyInfo.iReserved |= KAccInfoLatency;
       
   105             }
       
   106         if (supportedProfiles & (TUint32)EStereo)
       
   107             {
       
   108             asyInfo.iProfiles |= KAccInfoA2DP;
       
   109             }
       
   110         if (supportedProfiles & (TUint32)ERemConTG)
       
   111             {
       
   112             asyInfo.iProfiles |= KAccInfoAVRCP;
       
   113             }        
       
   114 
       
   115         asyInfo.iSupportedFeatures[EAccInfoHSPIndex] = iAccInfo.iSupportedFeatures[TAccInfo::EHSPIndex];
       
   116         asyInfo.iSupportedFeatures[EAccInfoHFPIndex] = iAccInfo.iSupportedFeatures[TAccInfo::EHFPIndex];
       
   117         asyInfo.iSupportedFeatures[EAccInfoAVRCPIndex] = iAccInfo.iSupportedFeatures[TAccInfo::ERemConTGIndex];
       
   118         asyInfo.iSupportedFeatures[EAccInfoA2DPIndex] = iAccInfo.iSupportedFeatures[TAccInfo::EStereoIndex];
       
   119         
       
   120 
       
   121         if (iAccInfo.iCapturingSupport)
       
   122             {
       
   123             asyInfo.iReserved |= KAccInfoDRM;
       
   124             }
       
   125         
       
   126         TRACE_INFO_SEG(
       
   127             Trace(_L("ORG Model %d, Type %d, DRM %d, Profiles 0x%08X, SF: HS %d, HF %d, AVRCP %d, A2DP %d"),
       
   128                 iAccInfo.iModel, 
       
   129                 iAccInfo.iDeviceType,
       
   130                 iAccInfo.iCapturingSupport,
       
   131                 iAccInfo.iSuppProfiles,
       
   132                 iAccInfo.iSupportedFeatures[TAccInfo::EHSPIndex],
       
   133                 iAccInfo.iSupportedFeatures[TAccInfo::EHFPIndex],
       
   134                 iAccInfo.iSupportedFeatures[TAccInfo::ERemConTGIndex],
       
   135                 iAccInfo.iSupportedFeatures[TAccInfo::EStereoIndex]);
       
   136             Trace(_L("ASY Model %d, Type %d, DRM %d, Profiles 0x%08X, SF: HS %d, HF %d, AVRCP %d, A2DP %d"),
       
   137                 asyInfo.iDeviceInfo, 
       
   138                 asyInfo.iDeviceType, 
       
   139                 asyInfo.iReserved,
       
   140                 asyInfo.iProfiles,
       
   141                 asyInfo.iSupportedFeatures[EAccInfoHSPIndex],
       
   142                 asyInfo.iSupportedFeatures[EAccInfoHFPIndex],
       
   143                 asyInfo.iSupportedFeatures[EAccInfoAVRCPIndex],
       
   144                 asyInfo.iSupportedFeatures[EAccInfoA2DPIndex]);
       
   145            );
       
   146         }
       
   147     iNotifier.GetBTAccInfoCompletedL(iStatus.Int(), asyInfo);
       
   148     }
       
   149     
       
   150 // -----------------------------------------------------------------------------
       
   151 // CBTAccInfoRequester::DoCancel
       
   152 // ?implementation_description
       
   153 // (other items were commented in a header).
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 void CBTAccInfoRequester::DoCancel()
       
   157     {
       
   158     TRACE_FUNC;
       
   159     }
       
   160     
       
   161 // -----------------------------------------------------------------------------
       
   162 // CBTAccInfoRequester::CBTAccInfoRequester
       
   163 // C++ default constructor can NOT contain any code, that
       
   164 // might leave.
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 CBTAccInfoRequester::CBTAccInfoRequester(MBTAccInfoNotifier& aNotifier) 
       
   168     : CActive(EPriorityStandard), iNotifier(aNotifier), iAccInfoPckg(iAccInfo)
       
   169     {
       
   170     CActiveScheduler::Add(this);
       
   171     }
       
   172 
       
   173 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   174     
       
   175 //  End of File