usbuis/usbuinotif/src/usbuinmain.cpp
changeset 34 7858bc6ead78
parent 31 dfdd8240f7c8
child 35 9d8b04ca6939
equal deleted inserted replaced
31:dfdd8240f7c8 34:7858bc6ead78
     1 /*
       
     2  * Copyright (c) 2005-2010 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:  Methods for USB UI notifiers
       
    15  *
       
    16  */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <ecom/ecom.h>
       
    20 #include <ecom/implementationproxy.h>
       
    21 #include <eiknotapi.h>
       
    22 #include <eikenv.h>
       
    23 
       
    24 #include "usbuincableconnectednotifier.h"
       
    25 #include "usbuinqueriesnotifier.h"
       
    26 #include "usbuinotifdebug.h"
       
    27 #include "usbuinotifotgwarning.h"    
       
    28 #include "usbuinotifotgerror.h"    
       
    29 #include "usbuinotifmsmmerror.h" 
       
    30 
       
    31 // CONSTANTS
       
    32 const TInt KUSBUINotifierArrayIncrement = 5;
       
    33 
       
    34 // ================= EXPORTED FUNCTIONS =======================================
       
    35 // ----------------------------------------------------------------------------
       
    36 //
       
    37 // Instantiate notifiers
       
    38 //
       
    39 // ----------------------------------------------------------------------------
       
    40 
       
    41 void CreateUSBUINotifiersL(CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers)
       
    42     {
       
    43     FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL"));
       
    44 
       
    45     CUSBUICableConnectedNotifier* cableConnectedNotifier =
       
    46         CUSBUICableConnectedNotifier::NewL();
       
    47     CleanupStack::PushL( cableConnectedNotifier );
       
    48     aNotifiers->AppendL( cableConnectedNotifier );
       
    49     CleanupStack::Pop( cableConnectedNotifier );
       
    50 
       
    51     CUSBUIQueriesNotifier* queriesNotifier = CUSBUIQueriesNotifier::NewL();
       
    52     CleanupStack::PushL( queriesNotifier );
       
    53     aNotifiers->AppendL( queriesNotifier );
       
    54     CleanupStack::Pop( queriesNotifier );
       
    55 
       
    56     CUsbUiNotifOtgWarning* generalNote = CUsbUiNotifOtgWarning::NewL();
       
    57     CleanupStack::PushL( generalNote );
       
    58     aNotifiers->AppendL( generalNote );
       
    59     CleanupStack::Pop( generalNote );
       
    60 
       
    61     CUsbUiNotifOtgError* generalQuery = CUsbUiNotifOtgError::NewL();
       
    62     CleanupStack::PushL( generalQuery );
       
    63     aNotifiers->AppendL( generalQuery );
       
    64     CleanupStack::Pop( generalQuery );
       
    65     
       
    66     CUsbUiNotifMSMMError* msmmerrorQuery = CUsbUiNotifMSMMError::NewL();
       
    67     CleanupStack::PushL( msmmerrorQuery );
       
    68     aNotifiers->AppendL( msmmerrorQuery );
       
    69     CleanupStack::Pop( msmmerrorQuery );
       
    70 
       
    71     FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL completed"));
       
    72     }
       
    73 
       
    74 // ----------------------------------------------------------------------------
       
    75 // Creates a notifiers array.
       
    76 // ----------------------------------------------------------------------------
       
    77 CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
       
    78     {
       
    79     FLOG(_L("[USBUINOTIF]\t NotifierArray"));
       
    80 
       
    81     CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = NULL;
       
    82     TRAPD( err, notifiers =
       
    83             new (ELeave)CArrayPtrFlat<MEikSrvNotifierBase2>(
       
    84                     KUSBUINotifierArrayIncrement ));
       
    85 
       
    86     if (err == KErrNone)
       
    87         {
       
    88         if (notifiers)
       
    89             {
       
    90             TRAPD( errCreate, CreateUSBUINotifiersL( notifiers ));
       
    91             if (errCreate)
       
    92                 {
       
    93                 TInt count = notifiers->Count();
       
    94                 while (count--)
       
    95                     {
       
    96                     (*notifiers)[count]->Release();
       
    97                     }
       
    98                 delete notifiers;
       
    99                 notifiers = NULL;
       
   100                 }
       
   101 
       
   102             FLOG(_L("[USBUINOTIF]\t NotifierArray completed"));
       
   103             }
       
   104         }
       
   105     else
       
   106         {
       
   107         FLOG(_L("[USBUINOTIF]\t NotifierArray Failed!!!"));
       
   108         }
       
   109 
       
   110     return notifiers;
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // ECOM 
       
   115 // ----------------------------------------------------------------------------
       
   116 
       
   117 const TImplementationProxy ImplementationTable[] =
       
   118     {
       
   119     IMPLEMENTATION_PROXY_ENTRY( 0x10281F23, NotifierArray )
       
   120     };
       
   121 
       
   122 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
       
   123         TInt& aTableCount)
       
   124     {
       
   125     FLOG(_L("[USBUINOTIF]\t ImplementationGroupProxy"));
       
   126     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   127     return ImplementationTable;
       
   128     }
       
   129 
       
   130 //  End of File