usbuis/usbuinotif/src/usbavkonmain.cpp
author Shabe Razvi <shaber@symbian.org>
Mon, 01 Feb 2010 18:51:11 +0000
changeset 6 b3ec2b24c806
parent 3 47c263f7e521
permissions -rw-r--r--
Merge

/*
 * 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