usbuis/usbuinotif/src/usbavkonmain.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:20:49 +0100
branchRCL_3
changeset 80 e02eb84a14d2
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

/*
 * Copyright (c) 2005-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:  Methods for USB UI notifiers.
 *
 */

// INCLUDE FILES
#include <eiknotapi.h>
#include <eikenv.h>

#include "usbuincableconnectednotifier.h"
#include "usbuinqueriesnotifier.h"
#include "usbuinotifdebug.h"

// CONSTANTS
const TInt KUSBUINotifierArrayIncrement = 1;


// ================= EXPORTED FUNCTIONS =======================================

// ----------------------------------------------------------------------------
//
// Instantiate notifiers
//
// ----------------------------------------------------------------------------

LOCAL_C void CreateUSBUINotifiersL( 
    CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers )
    {
    FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL"));
    
    CUSBUICableConnectedNotifier* cableConnectedNotifier = 
        CUSBUICableConnectedNotifier::NewL();
    CleanupStack::PushL( cableConnectedNotifier );
    aNotifiers->AppendL( cableConnectedNotifier );
    CleanupStack::Pop( cableConnectedNotifier );


    FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL completed"));
    }

// ----------------------------------------------------------------------------
//
// Lib main entry point: Creates a notifiers array.
//
// ----------------------------------------------------------------------------

EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
    {
    FLOG(_L("[USBUINOTIF]\t NotifierArray"));
    
    CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = NULL;
    
    TRAPD( err, notifiers = 
        new (ELeave)CArrayPtrFlat<MEikSrvNotifierBase2>( 
            KUSBUINotifierArrayIncrement ));
            
    if ( err == KErrNone )
        {
        if( notifiers )
            {
            TRAPD( errCreate, CreateUSBUINotifiersL( notifiers ));
            if( errCreate )
                {
                TInt count = notifiers->Count();
                while(count--)
                    {
                    (*notifiers)[count]->Release();
                    }
                delete notifiers;
                notifiers = NULL;
                }
                
            FLOG(_L("[USBUINOTIF]\t NotifierArray completed"));
            }
        }
    else
        {
        FLOG(_L("[USBUINOTIF]\t NotifierArray Failed!!!"));
        }  
        
    return notifiers;
    }

//  End of File