bluetoothengine/btmac/src/BTMonoCmdHandler/btmcnumber.cpp
branchRCL_3
changeset 6 6a29d5ad0713
parent 0 f63038272f30
equal deleted inserted replaced
2:0b192a3a05a4 6:6a29d5ad0713
    55 // CBtmcNumber::GoActive
    55 // CBtmcNumber::GoActive
    56 // -------------------------------------------------------------------------------
    56 // -------------------------------------------------------------------------------
    57 void CBtmcNumber::GoActive()
    57 void CBtmcNumber::GoActive()
    58     {
    58     {
    59     TRACE_ASSERT(!IsActive(), KErrGeneral);
    59     TRACE_ASSERT(!IsActive(), KErrGeneral);
    60     iEntry.iIndex = 1;
    60     GetMsisdnStoreInfo();
       
    61     TRACE_FUNC
       
    62     }
       
    63 
       
    64 // -------------------------------------------------------------------------------
       
    65 // CBtmcNumber::GetMsisdnStoreInfo
       
    66 // -------------------------------------------------------------------------------
       
    67 void CBtmcNumber::GetMsisdnStoreInfo()
       
    68     {
       
    69     TRACE_FUNC_ENTRY
       
    70     iState = EStateGettingMsisdnStoreInfo;
       
    71     iStore.GetInfo(iStatus, iOnStoreInfoPckg);
       
    72     SetActive();
       
    73     TRACE_FUNC_EXIT
       
    74     }
       
    75 
       
    76 // -------------------------------------------------------------------------------
       
    77 // CBtmcNumber::GetMsisdnStoreEntry
       
    78 // -------------------------------------------------------------------------------
       
    79 void CBtmcNumber::GetMsisdnStoreEntry()
       
    80     {
       
    81     TRACE_FUNC_ENTRY
       
    82     iState = EStateGettingMsisdnStoreEntry;
       
    83     iEntry.iIndex = iUsedEntriesCount++;
    61     iStore.Read(iStatus, iPckg);
    84     iStore.Read(iStatus, iPckg);
    62     SetActive();
    85     SetActive();
    63     TRACE_FUNC
    86     TRACE_FUNC_EXIT
    64     }
    87     }
    65 
    88 
    66 // -------------------------------------------------------------------------------
    89 // -------------------------------------------------------------------------------
    67 // CBtmcNumber::RunL
    90 // CBtmcNumber::RunL
    68 // -------------------------------------------------------------------------------
    91 // -------------------------------------------------------------------------------
    69 void CBtmcNumber::RunL()
    92 void CBtmcNumber::RunL()
    70     {
    93     {
    71     TRACE_FUNC_ENTRY
    94     TRACE_FUNC_ENTRY
    72     
    95     
    73     RATResultPtrArray resarr;
    96     switch (iState)
    74     ATObjArrayCleanupResetAndDestroyPushL(resarr);
       
    75     CATResult* okerr = NULL;
       
    76     if (iStatus == KErrNone)
       
    77         {
    97         {
    78         TBuf8<RMobileONStore::KOwnNumberTextSize> nameBuf;
    98         case EStateGettingMsisdnStoreEntry:
    79         nameBuf.Copy(iEntry.iNumber.iTelNumber);
       
    80         
       
    81         TRACE_INFO((_L8("ao status %d, phonebook returned %S"), iStatus.Int(), &nameBuf))
       
    82         RATParamArray params;
       
    83         CleanupClosePushL(params);
       
    84         LEAVE_IF_ERROR(params.Append(TATParam()))
       
    85         LEAVE_IF_ERROR(params.Append(TATParam(nameBuf, EATDQStringParam)))  
       
    86          
       
    87         TBTMonoATPhoneNumberType numType;
       
    88         if (nameBuf.Length() == 0)
       
    89             {
    99             {
    90             numType = EBTMonoATPhoneNumberUnavailable;
   100             if (iStatus == KErrNone)
       
   101                 {
       
   102                 if(iEntry.iNumber.iTelNumber.Length() == 0)
       
   103                     {
       
   104                     GetMsisdnStoreEntry();
       
   105                     break;
       
   106                     }
       
   107               
       
   108                 iCorrectNumbersCount++;
       
   109 
       
   110                 RATResultPtrArray resarr;
       
   111                 ATObjArrayCleanupResetAndDestroyPushL(resarr);
       
   112                 
       
   113                 TBuf8<RMobileONStore::KOwnNumberTextSize> telnumberBuf;
       
   114                 telnumberBuf.Copy(iEntry.iNumber.iTelNumber);
       
   115                 
       
   116                 TRACE_INFO((_L8("ao status %d, phonebook returned %S"), iStatus.Int(), &telnumberBuf))
       
   117                 RATParamArray params;
       
   118                 CleanupClosePushL(params);
       
   119                 LEAVE_IF_ERROR(params.Append(TATParam()))
       
   120                 LEAVE_IF_ERROR(params.Append(TATParam(telnumberBuf, EATDQStringParam)))  
       
   121                  
       
   122                 TBTMonoATPhoneNumberType numType;
       
   123                 if(telnumberBuf.Locate('+') == 0)
       
   124                     {
       
   125                     numType = EBTMonoATPhoneNumberInternational;
       
   126                     }
       
   127                 else
       
   128                     {
       
   129                     numType = EBTMonoATPhoneNumberNational;
       
   130                     }
       
   131                 LEAVE_IF_ERROR(params.Append(TATParam(numType)))
       
   132                 LEAVE_IF_ERROR(params.Append(TATParam()))
       
   133                 LEAVE_IF_ERROR(params.Append(TATParam(4)))
       
   134                 CATResult* code = CATResult::NewL(EATCNUM, EATActionResult, &params);
       
   135                 CleanupStack::PushL(code);
       
   136                 resarr.AppendL(code);
       
   137                 CleanupStack::Pop(code);
       
   138                 CleanupStack::PopAndDestroy(&params);
       
   139                 
       
   140                 if(iCorrectNumbersCount == iOnStoreInfo.iUsedEntries)
       
   141                     {
       
   142                     CATResult* okerr = CATResult::NewL(EATOK);
       
   143                     CleanupStack::PushL(okerr);
       
   144                     resarr.AppendL(okerr);
       
   145                     CleanupStack::Pop(okerr);
       
   146                     iProtocol.SendResponseL(resarr);
       
   147                     CleanupStack::PopAndDestroy(&resarr);
       
   148                     Observer().RequestCompletedL(*this, iStatus.Int());  
       
   149                     }
       
   150                 else
       
   151                     {
       
   152                     iProtocol.SendResponseL(resarr);
       
   153                     CleanupStack::PopAndDestroy(&resarr);
       
   154                     GetMsisdnStoreEntry();
       
   155                     }
       
   156                 }
       
   157             else
       
   158                 {
       
   159                 CATResult* okerr = CATResult::NewL(EATERROR);
       
   160                 CleanupStack::PushL(okerr);
       
   161                 iProtocol.SendResponseL(*okerr);
       
   162                 CleanupStack::PopAndDestroy(okerr);
       
   163                 Observer().RequestCompletedL(*this, iStatus.Int());  
       
   164                 }
       
   165 
       
   166             break;
    91             }
   167             }
    92         else if(nameBuf.Locate('+') == 0)
   168         case EStateGettingMsisdnStoreInfo:
    93             {
   169             {
    94             numType = EBTMonoATPhoneNumberInternational;
   170             if(iStatus==KErrNone && iOnStoreInfo.iUsedEntries>0 && 
       
   171                     (iOnStoreInfo.iCaps & RMobilePhoneStore::KCapsIndividualEntry))
       
   172                 {
       
   173                 GetMsisdnStoreEntry();
       
   174                 }
       
   175             else
       
   176                 {
       
   177                 CATResult* okerr = CATResult::NewL(EATOK);
       
   178                 CleanupStack::PushL(okerr);
       
   179                 iProtocol.SendResponseL(*okerr);
       
   180                 CleanupStack::PopAndDestroy(okerr);
       
   181                 Observer().RequestCompletedL(*this, iStatus.Int());  
       
   182                 }
       
   183             break;
    95             }
   184             }
    96         else
   185             
    97             {
   186         default:
    98             numType = EBTMonoATPhoneNumberNational;
   187             break;        
    99             }
       
   100         LEAVE_IF_ERROR(params.Append(TATParam(numType)))
       
   101         LEAVE_IF_ERROR(params.Append(TATParam()))
       
   102         LEAVE_IF_ERROR(params.Append(TATParam(4)))
       
   103         CATResult* code = CATResult::NewL(EATCNUM, EATActionResult, &params);
       
   104         CleanupStack::PushL(code);
       
   105         resarr.AppendL(code);
       
   106         CleanupStack::Pop(code);
       
   107         CleanupStack::PopAndDestroy(&params);
       
   108         okerr = CATResult::NewL(EATOK);
       
   109         }
   188         }
   110     else
   189     
   111         {
   190     TRACE_FUNC_EXIT
   112         okerr = CATResult::NewL(EATERROR);
   191     }
   113         }
   192 
   114     CleanupStack::PushL(okerr);
       
   115     resarr.AppendL(okerr);
       
   116     CleanupStack::Pop(okerr);
       
   117     iProtocol.SendResponseL(resarr);
       
   118     CleanupStack::PopAndDestroy(&resarr);
       
   119     Observer().RequestCompletedL(*this, iStatus.Int());    
       
   120     TRACE_FUNC_EXIT
       
   121     }
       
   122 
   193 
   123 // -------------------------------------------------------------------------------
   194 // -------------------------------------------------------------------------------
   124 // CBtmcNumber::DoCancel
   195 // CBtmcNumber::DoCancel
   125 // -------------------------------------------------------------------------------
   196 // -------------------------------------------------------------------------------
   126 void CBtmcNumber::DoCancel()
   197 void CBtmcNumber::DoCancel()
   145 CBtmcNumber::CBtmcNumber(
   216 CBtmcNumber::CBtmcNumber(
   146     MBtmcActiveObserver& aObserver, 
   217     MBtmcActiveObserver& aObserver, 
   147     CBtmcProtocol& aProtocol, 
   218     CBtmcProtocol& aProtocol, 
   148     CActive::TPriority aPriority, 
   219     CActive::TPriority aPriority, 
   149     TInt aServiceId)
   220     TInt aServiceId)
   150     : CBtmcActive(aObserver, aPriority, aServiceId), iProtocol(aProtocol), iPckg(iEntry)
   221     : CBtmcActive(aObserver, aPriority, aServiceId), iProtocol(aProtocol), iPckg(iEntry),
       
   222     iOnStoreInfoPckg(iOnStoreInfo), iState(EStateNull), iUsedEntriesCount(1), iCorrectNumbersCount(0)
   151     {
   223     {
   152     }
   224     }
   153 
   225 
   154 void CBtmcNumber::ConstructL()
   226 void CBtmcNumber::ConstructL()
   155     {
   227     {