imagehandlingutilities/thumbnailmanager/tmcommon/src/tmshutdownobserver.cpp
branchRCL_3
changeset 22 9d4d3445ce6e
parent 21 6257223ede8a
equal deleted inserted replaced
21:6257223ede8a 22:9d4d3445ce6e
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 
    20 
    21 #include "tmshutdownobserver.h"
    21 #include "tmshutdownobserver.h"
    22 #include "thumbnailmanagerconstants.h"
    22 #include "thumbnailmanagerconstants.h"
    23 #include "thumbnaillog.h"
    23 #include "thumbnaillog.h"
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "tmshutdownobserverTraces.h"
       
    27 #endif
       
    28 
       
    29 
    24 
    30 // ---------------------------------------------------------------------------
    25 // ---------------------------------------------------------------------------
    31 // CTMShutdownObserver::NewL()
    26 // CTMShutdownObserver::NewL()
    32 // ---------------------------------------------------------------------------
    27 // ---------------------------------------------------------------------------
    33 //
    28 //
    65 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    66 //
    61 //
    67 void CTMShutdownObserver::ConstructL()
    62 void CTMShutdownObserver::ConstructL()
    68     { 
    63     { 
    69     TN_DEBUG1( "CTMShutdownObserver::ConstructL()" );
    64     TN_DEBUG1( "CTMShutdownObserver::ConstructL()" );
    70     OstTrace0( TRACE_NORMAL, CTMSHUTDOWNOBSERVER_CONSTRUCTL, "CTMShutdownObserver::ConstructL" );
       
    71     // define P&S property types
    65     // define P&S property types
    72     if (iDefineKey)
    66     if (iDefineKey)
    73         {
    67         {
    74         TN_DEBUG1( "CTMShutdownObserver::ConstructL() define" );
    68         TN_DEBUG1( "CTMShutdownObserver::ConstructL() define" );
    75         OstTrace0( TRACE_NORMAL, DUP1_CTMSHUTDOWNOBSERVER_CONSTRUCTL, "CTMShutdownObserver::ConstructL - define" );
       
    76         RProperty::Define(iKeyCategory,iPropertyKey,
    69         RProperty::Define(iKeyCategory,iPropertyKey,
    77                           RProperty::EInt,KAllowAllPolicy,KPowerMgmtPolicy);
    70                           RProperty::EInt,KAllowAllPolicy,KPowerMgmtPolicy);
    78         }
    71         }
    79     
    72     
    80     // attach to the property
    73     // attach to the property
    81     TInt err = iProperty.Attach(iKeyCategory,iPropertyKey,EOwnerThread);
    74     TInt err = iProperty.Attach(iKeyCategory,iPropertyKey,EOwnerThread);
    82     TN_DEBUG2( "CTMShutdownObserver::ConstructL() attach err = %d", err );
    75     TN_DEBUG2( "CTMShutdownObserver::ConstructL() attach err = %d", err );
    83     OstTrace1( TRACE_NORMAL, DUP2_CTMSHUTDOWNOBSERVER_CONSTRUCTL, "CTMShutdownObserver::ConstructL - attach;err=%d", err );
       
    84     User::LeaveIfError(err);
    76     User::LeaveIfError(err);
    85     
    77     
    86     // wait for the previously attached property to be updated
    78     // wait for the previously attached property to be updated
    87     iProperty.Subscribe(iStatus);
    79     iProperty.Subscribe(iStatus);
    88     TN_DEBUG1( "CTMShutdownObserver::ConstructL() subscribe" );
    80     TN_DEBUG1( "CTMShutdownObserver::ConstructL() subscribe" );
    89     OstTrace0( TRACE_NORMAL, DUP3_CTMSHUTDOWNOBSERVER_CONSTRUCTL, "CTMShutdownObserver::ConstructL - subscribe" );
       
    90     SetActive();
    81     SetActive();
    91     }
    82     }
    92 
    83 
    93 // ---------------------------------------------------------------------------
    84 // ---------------------------------------------------------------------------
    94 // CTMShutdownObserver::~CTMShutdownObserver()
    85 // CTMShutdownObserver::~CTMShutdownObserver()
    95 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    96 //
    87 //
    97 CTMShutdownObserver::~CTMShutdownObserver()
    88 CTMShutdownObserver::~CTMShutdownObserver()
    98     {
    89     {
    99     TN_DEBUG1( "CTMShutdownObserver::~CTMShutdownObserver()" );
    90     TN_DEBUG1( "CTMShutdownObserver::~CTMShutdownObserver()" );
   100     OstTrace0( TRACE_NORMAL, CTMSHUTDOWNOBSERVER_CTMSHUTDOWNOBSERVER, "CTMShutdownObserver::~CTMShutdownObserver" );
       
   101     Cancel();
    91     Cancel();
   102     iProperty.Close();
    92     iProperty.Close();
   103     }
    93     }
   104 
    94 
   105 // ---------------------------------------------------------------------------
    95 // ---------------------------------------------------------------------------
   107 // ---------------------------------------------------------------------------
    97 // ---------------------------------------------------------------------------
   108 //
    98 //
   109 void CTMShutdownObserver::RunL()
    99 void CTMShutdownObserver::RunL()
   110     {
   100     {
   111     TN_DEBUG2( "CTMShutdownObserver::RunL(%d)", iStatus.Int() );
   101     TN_DEBUG2( "CTMShutdownObserver::RunL(%d)", iStatus.Int() );
   112     OstTrace1( TRACE_NORMAL, CTMSHUTDOWNOBSERVER_RUNL, "CTMShutdownObserver::RunL;iStatus.Int()=%d", iStatus.Int() );
       
   113     // resubscribe before processing new value to prevent missing updates
   102     // resubscribe before processing new value to prevent missing updates
   114     iProperty.Subscribe(iStatus);
   103     iProperty.Subscribe(iStatus);
   115     SetActive();
   104     SetActive();
   116     
   105     
   117     // retrieve the value
   106     // retrieve the value
   118     TInt value = 0;
   107     TInt value = 0;
   119     TInt err = iProperty.Get(value);
   108     TInt err = iProperty.Get(value);
   120     
   109     
   121     TN_DEBUG2( "CTMShutdownObserver::RunL() Get err = %d", err );
   110     TN_DEBUG2( "CTMShutdownObserver::RunL() Get err = %d", err );
   122     OstTrace1( TRACE_NORMAL, DUP1_CTMSHUTDOWNOBSERVER_RUNL, "CTMShutdownObserver::RunL - get err;err=%d", err );
       
   123 
   111 
   124     // observer callback
   112     // observer callback
   125     if (value)
   113     if (value)
   126         {
   114         {
   127         iObserver.ShutdownNotification();
   115         iObserver.ShutdownNotification();
   133 // ---------------------------------------------------------------------------
   121 // ---------------------------------------------------------------------------
   134 //
   122 //
   135 void CTMShutdownObserver::DoCancel()
   123 void CTMShutdownObserver::DoCancel()
   136     {
   124     {
   137     TN_DEBUG1( "CTMShutdownObserver::DoCancel()" );
   125     TN_DEBUG1( "CTMShutdownObserver::DoCancel()" );
   138     OstTrace0( TRACE_NORMAL, CTMSHUTDOWNOBSERVER_DOCANCEL, "CTMShutdownObserver::DoCancel" );
       
   139     iProperty.Cancel();
   126     iProperty.Cancel();
   140     }
   127     }
   141 
   128 
   142 // End of file
   129 // End of file