photosgallery/commonui/src/glxerrorposter.cpp
author William Roberts <williamr@symbian.org>
Thu, 08 Apr 2010 20:18:37 +0100
branchCompilerCompatibility
changeset 20 d1bdfdf534bd
parent 0 4e91876724a2
permissions -rw-r--r--
Add missing EXPORT_C in cpp files, and reinstate the DEF file additions, to fix Bug 2473 Mystery solved - RVCT 2.2 only exports functions on the basis of EXPORT_C, but RVCT 4.0 is triggered by the IMPORT_C as well

/*
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:    Singleton that posts errors to the framework
*
*/




#include "glxerrorposter.h"

#include <glxsingletonstore.h>

#include <glxlog.h>

// ---------------------------------------------------------------------------
// Provides instance of error poster and increments ref count
// ---------------------------------------------------------------------------
//
EXPORT_C CGlxErrorPoster* CGlxErrorPoster::InstanceL()
    {
    GLX_LOG_INFO( "CGlxErrorPoster::InstanceL" );

    return CGlxSingletonStore::InstanceL( &NewL );
    }

// ---------------------------------------------------------------------------
// Removes instance of error poster and decrements ref count
// ---------------------------------------------------------------------------
//
EXPORT_C void CGlxErrorPoster::Close()
    {
    GLX_LOG_INFO( "CGlxErrorPoster::Close" );

    CGlxSingletonStore::Close( this );
    }

// ---------------------------------------------------------------------------
// Two phase constructor.
// ---------------------------------------------------------------------------
//
CGlxErrorPoster* CGlxErrorPoster::NewL()
    {
    GLX_LOG_INFO( "CGlxErrorPoster::NewL" );

    CGlxErrorPoster* self = new ( ELeave ) CGlxErrorPoster();
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );
    return self;
    }

// ---------------------------------------------------------------------------
// Constructor.
// ---------------------------------------------------------------------------
//
CGlxErrorPoster::CGlxErrorPoster() :
        CActive(EPriorityStandard)
    {
    GLX_LOG_INFO( "CGlxErrorPoster::CGlxErrorPoster" );

    CActiveScheduler::Add( this );
    }

// ---------------------------------------------------------------------------
// Destructor
// ---------------------------------------------------------------------------
//
CGlxErrorPoster::~CGlxErrorPoster()
    {
    GLX_LOG_INFO( "CGlxErrorPoster::~CGlxErrorPoster" );

    Cancel();
    }

// ---------------------------------------------------------------------------
// 2nd phase constructor.
// ---------------------------------------------------------------------------
//
void CGlxErrorPoster::ConstructL()
    {
    GLX_LOG_INFO( "CGlxErrorPoster::ConstructL" );
    }

// ---------------------------------------------------------------------------
// Post an error
// ---------------------------------------------------------------------------
//
EXPORT_C void CGlxErrorPoster::PostError(TInt aError)
    {
    GLX_LOG_INFO1( "CGlxErrorPoster::PostError %d" , aError);

    iLatestError = aError;
    if ( !IsActive() )
        {
        TRequestStatus* requestStatus = &iStatus;
        User::RequestComplete( requestStatus, KErrNone );
        SetActive();
        }
  }

// ---------------------------------------------------------------------------
// CActive::RunL
// ---------------------------------------------------------------------------
//
void CGlxErrorPoster::RunL()
    {
    GLX_LOG_INFO( "CGlxErrorPoster::RunL" );

    TInt error = iLatestError;
    iLatestError = KErrNone;
    User::Leave( error );
    }

// ---------------------------------------------------------------------------
// CActive::DoCancel
// ---------------------------------------------------------------------------
//
void CGlxErrorPoster::DoCancel()
    {
    GLX_LOG_INFO( "CGlxErrorPoster::DoCancel" );
    // No need to do anything 
    // CActive::Cancel() will wait for the request to complete
    }