serviceproviders/sapi_contacts_vpbk/src/contactinterfacecallback.cpp
changeset 10 fc9cf246af83
parent 5 989d2f495d90
child 23 50974a8b132e
equal deleted inserted replaced
5:989d2f495d90 10:fc9cf246af83
   234 	                                      *iEventParamList, 
   234 	                                      *iEventParamList, 
   235 	                                      *iInParamList));
   235 	                                      *iInParamList));
   236     	}
   236     	}
   237     CleanupStack::PopAndDestroy(this);
   237     CleanupStack::PopAndDestroy(this);
   238     }
   238     }
       
   239 
       
   240 void CContactInterfaceCallback :: HandleReturnId(const TInt& aError,HBufC8* acntId , TInt aTransId )
       
   241     {
       
   242     TInt err = 0;
       
   243       CleanupStack::PushL(this);  
       
   244       if( iCallback )
       
   245           {
       
   246           if( iEventParamList )
       
   247               {
       
   248               iEventParamList->Reset();
       
   249               }
       
   250           else
       
   251               {
       
   252               iEventParamList = CLiwGenericParamList::NewL();
       
   253               }
       
   254           //Append Error Code
       
   255           TInt32 sapiError = CContactInterface::SapiError(aError);
       
   256           iEventParamList->AppendL(TLiwGenericParam( KErrorCode, 
       
   257                                    TLiwVariant((TInt32)sapiError)));
       
   258           
       
   259       if(acntId)
       
   260           {
       
   261           HBufC* cntIdUnicode = HBufC::NewL(acntId->Length());
       
   262           CleanupStack :: PushL(cntIdUnicode);
       
   263           cntIdUnicode->Des().Copy(*acntId);
       
   264           delete acntId;
       
   265           acntId = NULL;
       
   266           ContactIDToUTF(cntIdUnicode);           
       
   267           iEventParamList->AppendL(TLiwGenericParam(KReturnValue, 
       
   268                                    TLiwVariant(*cntIdUnicode)));  
       
   269           CleanupStack :: Pop(cntIdUnicode);
       
   270           }
       
   271       
       
   272           //Call HandleNotify
       
   273           TRAP(err,iCallback->HandleNotifyL(aTransId, 
       
   274                                             KLiwEventCompleted, 
       
   275                                             *iEventParamList, 
       
   276                                             *iInParamList));
       
   277           }
       
   278       CleanupStack::PopAndDestroy(this);
       
   279       }
       
   280  
       
   281  
       
   282 
       
   283 void CContactInterfaceCallback::HandleReturnArray(const TInt& aError,
       
   284                                                 RPointerArray<HBufC8>& aArray, 
       
   285                                                  TInt aTransId)
       
   286     {
       
   287     TInt err = 0;
       
   288     CleanupStack::PushL(this);  
       
   289     if( iCallback )
       
   290         {
       
   291         if( iEventParamList )
       
   292             {
       
   293             iEventParamList->Reset();
       
   294             }
       
   295         else
       
   296             {
       
   297             iEventParamList = CLiwGenericParamList::NewL();
       
   298             }
       
   299         //Append Error Code
       
   300         TInt32 sapiError = CContactInterface::SapiError(aError);
       
   301         iEventParamList->AppendL(TLiwGenericParam( KErrorCode, 
       
   302                                  TLiwVariant((TInt32)sapiError)));
       
   303         
       
   304     if(aArray.Count() > 0)
       
   305         {
       
   306         CLiwList* IdList = NULL;
       
   307         TLiwVariant outputVal;
       
   308         TInt count = aArray.Count();
       
   309         TInt i;
       
   310         IdList = CLiwDefaultList::NewL();
       
   311         for(i=0; i<count; i++)
       
   312             {
       
   313             TDesC8* idVal = aArray[i];
       
   314            HBufC8* idBufVal = idVal->AllocL();
       
   315            HBufC* cntIdUnicode = HBufC::NewL(idBufVal->Length());
       
   316            CleanupStack :: PushL(cntIdUnicode);
       
   317            cntIdUnicode->Des().Copy(*idBufVal);
       
   318            delete idBufVal;
       
   319            idBufVal = NULL;
       
   320            ContactIDToUTF(cntIdUnicode);      
       
   321            outputVal.Set(*cntIdUnicode);
       
   322            IdList->AppendL(outputVal);
       
   323            CleanupStack :: Pop(cntIdUnicode);       
       
   324             }
       
   325         CLiwMap* pFieldLinkedMap = CLiwDefaultMap::NewL();
       
   326         CleanupClosePushL(*pFieldLinkedMap);
       
   327         pFieldLinkedMap->InsertL(KIdsLabel,TLiwVariant(IdList));
       
   328         
       
   329         //Append Iterator in case it is valid
       
   330         iEventParamList->AppendL(TLiwGenericParam(KReturnValue, 
       
   331                                  TLiwVariant(pFieldLinkedMap)));
       
   332         CleanupStack::PopAndDestroy(pFieldLinkedMap);
       
   333              
       
   334         }
       
   335 
       
   336         //Call HandleNotify
       
   337         TRAP(err,iCallback->HandleNotifyL(aTransId, 
       
   338                                           KLiwEventCompleted, 
       
   339                                           *iEventParamList, 
       
   340                                           *iInParamList));
       
   341         }
       
   342     CleanupStack::PopAndDestroy(this);
       
   343     }
       
   344 
       
   345 
       
   346 
       
   347 void CContactInterfaceCallback :: ContactIDToUTF(HBufC* aContactID)
       
   348     {
       
   349     TInt len = aContactID->Length();
       
   350     TUint16* ptr16 = const_cast<TUint16*> (aContactID->Des().Ptr());
       
   351     for(TInt i=0; i<len; i++)
       
   352         {
       
   353         ptr16[i] = ptr16[i] | 0xE000;    
       
   354         }
       
   355     }