usbuis/usbuinotif/src/usbuinmain.cpp
changeset 0 1e05558e2206
child 3 47c263f7e521
equal deleted inserted replaced
-1:000000000000 0:1e05558e2206
       
     1 /*
       
     2  * Copyright (c) 2005-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:  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 #include <AknNotifierWrapper.h>
       
    24 #include <usbuinotif.h>
       
    25 
       
    26 #include "usbuincableconnectednotifier.h"
       
    27 #include "usbuinqueriesnotifier.h"
       
    28 
       
    29 
       
    30 #include "usbuinotifdebug.h"
       
    31 #include "usbuinotifotgwarning.h"    
       
    32 #include "usbuinotifotgerror.h"    
       
    33 #include "usbuinotifmsmmerror.h" 
       
    34 
       
    35 // CONSTANTS
       
    36 const TInt KUSBUINotifierArrayIncrement = 4;
       
    37 _LIT( KUSBUINotifdll, "usbavkonnotif.dll" ); 
       
    38 // ================= EXPORTED FUNCTIONS =======================================
       
    39 // ----------------------------------------------------------------------------
       
    40 //
       
    41 // Instantiate notifiers
       
    42 //
       
    43 // ----------------------------------------------------------------------------
       
    44 
       
    45 void CreateUSBUINotifiersL(CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers)
       
    46     {
       
    47     FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL"));
       
    48 
       
    49     /* The CableconnectionNotifier is created on the Avkon Wrapper
       
    50  * because it contains the discreet popups which are only possible
       
    51  * to be launched in a UI framework
       
    52  */
       
    53     CAknCommonNotifierWrapper* master = 
       
    54                 CAknCommonNotifierWrapper::NewL(KCableConnectedNotifierUid,
       
    55                                                 KCableConnectedNotifierUid,
       
    56                                                 MEikSrvNotifierBase2::ENotifierPriorityVHigh,
       
    57                                                 KUSBUINotifdll,
       
    58                                                 1); // no synchronous reply used.
       
    59         CleanupStack::PushL(master);
       
    60         
       
    61         aNotifiers->AppendL(master ); 
       
    62         CleanupStack::Pop( master );
       
    63     CUSBUIQueriesNotifier* queriesNotifier = CUSBUIQueriesNotifier::NewL();
       
    64     CleanupStack::PushL( queriesNotifier );
       
    65     aNotifiers->AppendL( queriesNotifier );
       
    66     CleanupStack::Pop( queriesNotifier );
       
    67 
       
    68     CUsbUiNotifOtgWarning* generalNote = CUsbUiNotifOtgWarning::NewL();
       
    69     CleanupStack::PushL( generalNote );
       
    70     aNotifiers->AppendL( generalNote );
       
    71     CleanupStack::Pop( generalNote );
       
    72 
       
    73     CUsbUiNotifOtgError* generalQuery = CUsbUiNotifOtgError::NewL();
       
    74     CleanupStack::PushL( generalQuery );
       
    75     aNotifiers->AppendL( generalQuery );
       
    76     CleanupStack::Pop( generalQuery );
       
    77     
       
    78     CUsbUiNotifMSMMError* msmmerrorQuery = CUsbUiNotifMSMMError::NewL();
       
    79     CleanupStack::PushL( msmmerrorQuery );
       
    80     aNotifiers->AppendL( msmmerrorQuery );
       
    81     CleanupStack::Pop( msmmerrorQuery );
       
    82 
       
    83     FLOG(_L("[USBUINOTIF]\t CreateUSBUINotifiersL completed"));
       
    84     }
       
    85 
       
    86 // ----------------------------------------------------------------------------
       
    87 // Creates a notifiers array.
       
    88 // ----------------------------------------------------------------------------
       
    89 CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
       
    90     {
       
    91     FLOG(_L("[USBUINOTIF]\t NotifierArray"));
       
    92 
       
    93     CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = NULL;
       
    94     TRAPD( err, notifiers =
       
    95             new (ELeave)CArrayPtrFlat<MEikSrvNotifierBase2>(
       
    96                     KUSBUINotifierArrayIncrement ));
       
    97 
       
    98     if (err == KErrNone)
       
    99         {
       
   100         if (notifiers)
       
   101             {
       
   102             TRAPD( errCreate, CreateUSBUINotifiersL( notifiers ));
       
   103             if (errCreate)
       
   104                 {
       
   105                 TInt count = notifiers->Count();
       
   106                 while (count--)
       
   107                     {
       
   108                     (*notifiers)[count]->Release();
       
   109                     }
       
   110                 delete notifiers;
       
   111                 notifiers = NULL;
       
   112                 }
       
   113 
       
   114             FLOG(_L("[USBUINOTIF]\t NotifierArray completed"));
       
   115             }
       
   116         }
       
   117     else
       
   118         {
       
   119         FLOG(_L("[USBUINOTIF]\t NotifierArray Failed!!!"));
       
   120         }
       
   121 
       
   122     return notifiers;
       
   123     }
       
   124 
       
   125 // ----------------------------------------------------------------------------
       
   126 // ECOM 
       
   127 // ----------------------------------------------------------------------------
       
   128 
       
   129 const TImplementationProxy ImplementationTable[] =
       
   130     {
       
   131 #ifdef __EABI__
       
   132     {{0x10281F23},(TFuncPtr)NotifierArray},
       
   133 #else
       
   134     {{0x10281F23},NotifierArray},
       
   135 #endif
       
   136     };
       
   137 
       
   138 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
       
   139         TInt& aTableCount)
       
   140     {
       
   141     FLOG(_L("[USBUINOTIF]\t ImplementationGroupProxy"));
       
   142     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   143     return ImplementationTable;
       
   144     }
       
   145 
       
   146 //  End of File