predictivesearch/PcsServerClientAPI/src/CPsPropertyHandler.cpp
branchRCL_3
changeset 35 4ae315f230bc
parent 0 e686773b3f54
child 64 c1e8ba0c2b16
equal deleted inserted replaced
32:2828b4d142c0 35:4ae315f230bc
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  This is the client side internal file to handle
    14 * Description:  This is the client side internal file to handle
    15 *                property used in Publish and Subscribe framework.
    15 *               property used in Publish and Subscribe framework.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 //SYSTEM INCLUDES
    19 //SYSTEM INCLUDES
    20 #include <CPsRequestHandler.h>
    20 #include <CPsRequestHandler.h>
    22 
    22 
    23 // USER INCLUDES
    23 // USER INCLUDES
    24 #include "CPsPropertyHandler.h"
    24 #include "CPsPropertyHandler.h"
    25 #include "CPcsDebug.h"
    25 #include "CPcsDebug.h"
    26 
    26 
    27 // UID used for Publish and Subscribe mechanism
       
    28 // This should be same as the one defined in CPcsAlgorithm.cpp
       
    29 // Server UID3 has to be used for this framework
       
    30 const TUid KCStatus = {0x2000B5B6};
       
    31 
    27 
    32 // ========================= MEMBER FUNCTIONS ==================================
    28 // ========================= MEMBER FUNCTIONS ==================================
    33 
    29 
    34 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
    35 // CPsPropertyHandler::NewL()
    31 // CPsPropertyHandler::NewL()
    51 
    47 
    52 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    53 // CPsPropertyHandler::ConstructL()
    49 // CPsPropertyHandler::ConstructL()
    54 // Symbian 2nd phase constructor can leave.
    50 // Symbian 2nd phase constructor can leave.
    55 // -----------------------------------------------------------------------------
    51 // -----------------------------------------------------------------------------
    56 void CPsPropertyHandler::ConstructL(  )
    52 void CPsPropertyHandler::ConstructL()
    57 {
    53 {
    58     PRINT ( _L("Enter CPsPropertyHandler::ConstructL") );
    54     PRINT ( _L("Enter CPsPropertyHandler::ConstructL") );
    59     
    55     
    60     TInt err = iCacheStatusProperty.Attach(KCStatus, 0 );
    56     TInt err = iCacheStatusProperty.Attach( KPcsInternalUidCacheStatus, EPsKeyCacheStatus );
    61     User::LeaveIfError(err);   
    57     User::LeaveIfError(err);
    62     
    58     
    63     // Attach the cache error property
    59     // Attach the cache error property
    64     err = iCacheErrorProperty.Attach(KCStatus, 1);
    60     err = iCacheErrorProperty.Attach( KPcsInternalUidCacheStatus, EPsKeyCacheError );
    65     User::LeaveIfError(err); 
    61     User::LeaveIfError(err);
    66     
    62     
    67     iCacheStatusProperty.Subscribe(iStatus);
    63     iCacheStatusProperty.Subscribe(iStatus);
    68     
    64     
    69     SetActive();
    65     SetActive();
    70     
    66     
    95     PRINT ( _L("Enter CPsPropertyHandler::~CPsPropertyHandler") );
    91     PRINT ( _L("Enter CPsPropertyHandler::~CPsPropertyHandler") );
    96 
    92 
    97     Cancel(); // Causes call to DoCancel()
    93     Cancel(); // Causes call to DoCancel()
    98     
    94     
    99     iCacheStatusProperty.Close();
    95     iCacheStatusProperty.Close();
   100 
    96     iCacheErrorProperty.Close();
   101 }
    97 }
   102 
    98 
   103 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
   104 // CPsPropertyHandler::RunL()
   100 // CPsPropertyHandler::RunL()
   105 // Invoked to handle responses from the server.
   101 // Invoked to handle responses from the server.
   106 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
   107 void CPsPropertyHandler::RunL()
   103 void CPsPropertyHandler::RunL()
   108 {
   104 {
   109 	iCacheStatusProperty.Subscribe(iStatus);
   105     iCacheStatusProperty.Subscribe(iStatus);
   110 	SetActive();
   106     SetActive();
   111 	
   107     
   112 	//Get the value
   108     //Get the value
   113 	TCachingStatus status; 
   109     TCachingStatus status; 
   114 	TInt statusValue;
   110     TInt statusValue;
   115 	iCacheStatusProperty.Get(statusValue);
   111     iCacheStatusProperty.Get(statusValue);
   116 	status = (TCachingStatus)statusValue;
   112     status = (TCachingStatus)statusValue;
   117 	
   113     
   118 	TInt cacheError;
   114     TInt cacheError;
   119 	iCacheErrorProperty.Get(cacheError);
   115     iCacheErrorProperty.Get(cacheError);
   120 	
   116     
   121 	if( (status == ECachingComplete) || (status == ECachingCompleteWithErrors))
   117     if ( (status == ECachingComplete) || (status == ECachingCompleteWithErrors) )
   122 	{
   118     {
   123 		for(TInt i = 0; i < iRequestHandler->iObservers.Count(); i++)
   119         iRequestHandler->NotifyCachingStatus( status, cacheError );
   124 			iRequestHandler->iObservers[i]->CachingStatus(status, cacheError);
   120     }
   125 	}
       
   126 }
   121 }
   127 
   122 
   128 // -----------------------------------------------------------------------------
   123 // -----------------------------------------------------------------------------
   129 // CPsPropertyHandler::DoCancel()
   124 // CPsPropertyHandler::DoCancel()
   130 // Cancels any outstanding operation.
   125 // Cancels any outstanding operation.