photosgallery/commonui/src/glxerrorposter.cpp
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Singleton that posts errors to the framework
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxerrorposter.h"
       
    22 
       
    23 #include <glxsingletonstore.h>
       
    24 
       
    25 #include <glxlog.h>
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // Provides instance of error poster and increments ref count
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 EXPORT_C CGlxErrorPoster* CGlxErrorPoster::InstanceL()
       
    32     {
       
    33     GLX_LOG_INFO( "CGlxErrorPoster::InstanceL" );
       
    34 
       
    35     return CGlxSingletonStore::InstanceL( &NewL );
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // Removes instance of error poster and decrements ref count
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C void CGlxErrorPoster::Close()
       
    43     {
       
    44     GLX_LOG_INFO( "CGlxErrorPoster::Close" );
       
    45 
       
    46     CGlxSingletonStore::Close( this );
       
    47     }
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // Two phase constructor.
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CGlxErrorPoster* CGlxErrorPoster::NewL()
       
    54     {
       
    55     GLX_LOG_INFO( "CGlxErrorPoster::NewL" );
       
    56 
       
    57     CGlxErrorPoster* self = new ( ELeave ) CGlxErrorPoster();
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop( self );
       
    61     return self;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // Constructor.
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CGlxErrorPoster::CGlxErrorPoster() :
       
    69         CActive(EPriorityStandard)
       
    70     {
       
    71     GLX_LOG_INFO( "CGlxErrorPoster::CGlxErrorPoster" );
       
    72 
       
    73     CActiveScheduler::Add( this );
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // Destructor
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CGlxErrorPoster::~CGlxErrorPoster()
       
    81     {
       
    82     GLX_LOG_INFO( "CGlxErrorPoster::~CGlxErrorPoster" );
       
    83 
       
    84     Cancel();
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // 2nd phase constructor.
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CGlxErrorPoster::ConstructL()
       
    92     {
       
    93     GLX_LOG_INFO( "CGlxErrorPoster::ConstructL" );
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // Post an error
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 EXPORT_C void CGlxErrorPoster::PostError(TInt aError)
       
   101     {
       
   102     GLX_LOG_INFO1( "CGlxErrorPoster::PostError %d" , aError);
       
   103 
       
   104     iLatestError = aError;
       
   105     if ( !IsActive() )
       
   106         {
       
   107         TRequestStatus* requestStatus = &iStatus;
       
   108         User::RequestComplete( requestStatus, KErrNone );
       
   109         SetActive();
       
   110         }
       
   111   }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CActive::RunL
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CGlxErrorPoster::RunL()
       
   118     {
       
   119     GLX_LOG_INFO( "CGlxErrorPoster::RunL" );
       
   120 
       
   121     TInt error = iLatestError;
       
   122     iLatestError = KErrNone;
       
   123     User::Leave( error );
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CActive::DoCancel
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CGlxErrorPoster::DoCancel()
       
   131     {
       
   132     GLX_LOG_INFO( "CGlxErrorPoster::DoCancel" );
       
   133     // No need to do anything 
       
   134     // CActive::Cancel() will wait for the request to complete
       
   135     }