phoneengine/phonemodel/src/cpepubsubmonitor.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Contains phone engine central repository monitor base class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cpepubsubmonitor.h"
       
    21 #include <centralrepository.h>
       
    22 #include <pepanic.pan>
       
    23 #include <talogger.h>
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CPEPubSubMonitor::CPEPubSubMonitor
       
    27 // C++ default constructor can NOT contain any code, that
       
    28 // might leave.
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CPEPubSubMonitor::CPEPubSubMonitor(
       
    32         MPEPhoneModelInternal& aModel
       
    33         ) : CActive( EPriorityStandard ),
       
    34             iModel(aModel)
       
    35     {
       
    36     CActiveScheduler::Add( this );
       
    37     }
       
    38 
       
    39 // Destructor
       
    40 CPEPubSubMonitor::~CPEPubSubMonitor(
       
    41         // None
       
    42         )
       
    43     {
       
    44     Cancel();
       
    45     iProperty.Close();
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CPEPubSubMonitor::BaseConstructL
       
    50 // Symbian 2nd phase constructor can leave.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 void CPEPubSubMonitor::BaseConstructL(
       
    54         TUid  aCategory,  // category of the property
       
    55         TUint aKey,       // key of the property
       
    56         TUint /*aType*/ ) // type of the property
       
    57     {
       
    58     #ifdef TF_LOGGING_ENABLED    
       
    59     TUidName name = aCategory.Name();
       
    60     
       
    61     TEFLOGSTRING3( KTAOBJECT, "CPEPubSubMonitor::BaseConstructL: Category %S, key %d", 
       
    62                    &name, aKey );                   
       
    63     
       
    64     iCategory = aCategory;
       
    65     iKey = aKey;
       
    66     #endif
       
    67            
       
    68     TInt error = iProperty.Attach( aCategory, aKey  );   
       
    69     if ( ( error!=KErrNone ) )
       
    70         {
       
    71         TEFLOGSTRING3( KTAOBJECT, 
       
    72             "PE CPEPubSubMonitor::BaseConstructL: Error while attaching. Category %S, key %d", 
       
    73                    &name, aKey );
       
    74         User::Leave(error);
       
    75         }
       
    76     
       
    77 
       
    78     SubmitNotifyRequestL();
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CPEPubSubMonitor::Get
       
    83 // Getting an integer value
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 TInt CPEPubSubMonitor::Get(
       
    87         TInt& aValue
       
    88         )
       
    89     {
       
    90     return ( iProperty.Get( aValue ) );
       
    91     }
       
    92 
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CPEPubSubMonitor::Get
       
    96 // Getting a binary value
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 TInt CPEPubSubMonitor::Get(
       
   100         TDes8& aValue
       
   101         )
       
   102     {
       
   103     return ( iProperty.Get( aValue ) );
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CPEPubSubMonitor::Get
       
   108 // Getting a text value
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 TInt CPEPubSubMonitor::Get(
       
   112         TDes16& aValue
       
   113         )
       
   114     {
       
   115     return ( iProperty.Get( aValue ) );
       
   116     }
       
   117 
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CPEPubSubMonitor::SubmitNotifyRequestL
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 void CPEPubSubMonitor::SubmitNotifyRequestL(
       
   124         // None
       
   125         )
       
   126     {
       
   127     #ifdef TEF_LOGGING_ENABLED    
       
   128     TUidName name = iCategory.Name();
       
   129     #endif    
       
   130     TEFLOGSTRING3( KTAINT, "CPEPubSubMonitor::SubmitNotifyRequestL: Category %S, key %d", 
       
   131                    &name, iKey );
       
   132     
       
   133     __ASSERT_DEBUG( !IsActive(), Panic( EPEPanicPropertyAlreadyActive ) );
       
   134     iProperty.Subscribe( iStatus );
       
   135     SetActive( );
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CPEPubSubMonitor::DoCancel
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void CPEPubSubMonitor::DoCancel(
       
   143         // None
       
   144         )
       
   145     {
       
   146     #ifdef TF_LOGGING_ENABLED    
       
   147     TUidName name = iCategory.Name();
       
   148     #endif    
       
   149     TEFLOGSTRING3( KTAINT, "CPEPubSubMonitor::DoCancel: Category %S, key %d", 
       
   150                    &name, iKey );
       
   151     
       
   152     iProperty.Cancel();
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CPEPubSubMonitor::RunError
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 TInt CPEPubSubMonitor::RunError(
       
   160         #ifdef TEF_LOGGING_ENABLED
       
   161         TInt aError // Log the leavecode from RunL
       
   162         #else
       
   163         TInt /*aError*/
       
   164         #endif
       
   165         )
       
   166     {
       
   167     #ifdef TEF_LOGGING_ENABLED
       
   168     TUidName name = iCategory.Name(); 
       
   169     TEFLOGSTRING4( KTAERROR, "CPEPubSubMonitor::RunError %d, Category: %S, key %d",
       
   170                    aError, &name, iKey );
       
   171                    
       
   172     #endif
       
   173     return ( KErrNone );
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // CPEPubSubMonitor::RunL
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 void CPEPubSubMonitor::RunL(
       
   181         // None
       
   182         )
       
   183     {
       
   184     TEFLOGSTRING2( KTAREQEND, "CPEPubSubMonitor::RunL, status: %d", iStatus.Int() );
       
   185 
       
   186     // Don't resubmit the request on error
       
   187     User::LeaveIfError(iStatus.Int());
       
   188     SubmitNotifyRequestL();
       
   189     UpdateL();
       
   190     }
       
   191 
       
   192 // End of file