syncmlfw/syncmlnotifier/src/SyncMLNotifierMain.cpp
changeset 49 689a71addb96
parent 48 7e865e817571
child 50 a36219ae6585
equal deleted inserted replaced
48:7e865e817571 49:689a71addb96
     1 /*
       
     2 * Copyright (c) 2005 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 the SyncML Appserver starter notifier
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <eikenv.h>
       
    22 
       
    23 // All provided notifiers
       
    24 #include    "SyncMLAppLaunchNotifier.h"
       
    25 #include    "SyncMLDlgNotifier.h"
       
    26 #include    "SyncMLFwUpdNotifier.h"
       
    27 
       
    28 #include    "SyncMLNotifDebug.h"
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // ============================= LOCAL FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CleanupArray
       
    36 // Deletes notifiers
       
    37 // -----------------------------------------------------------------------------
       
    38 LOCAL_C void CleanupArray( TAny* aArray )
       
    39     {
       
    40     FLOG(_L("[SmlNotif]\t CleanupArray()"));
       
    41     
       
    42     CArrayPtrFlat<MEikSrvNotifierBase2>*     
       
    43         subjects = static_cast<CArrayPtrFlat<MEikSrvNotifierBase2>*>(aArray);
       
    44     TInt lastInd = subjects->Count() - 1;
       
    45     for ( TInt i = lastInd; i >= 0; i-- )
       
    46         {
       
    47         subjects->At(i)->Release();	    	    
       
    48         }
       
    49     delete subjects;
       
    50     
       
    51     FLOG(_L("[SmlNotif]\t CleanupArray() completed"));
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CreateSmlNotifiersL
       
    56 // Instantiate notifiers
       
    57 // -----------------------------------------------------------------------------
       
    58 LOCAL_C CArrayPtrFlat<MEikSrvNotifierBase2>* CreateSmlNotifiersL()
       
    59     {
       
    60     FLOG(_L("[SmlNotif]\t CreateSmlNotifiersL"));
       
    61 
       
    62     CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers =
       
    63         new ( ELeave ) CArrayPtrFlat<MEikSrvNotifierBase2>
       
    64         ( KSmlNotifierArrayIncrement );
       
    65     
       
    66     CleanupStack::PushL( TCleanupItem( CleanupArray, notifiers ) );
       
    67     
       
    68     CSyncMLAppLaunchNotifier* appLaunchNotifier = CSyncMLAppLaunchNotifier::NewL();
       
    69     CleanupStack::PushL( appLaunchNotifier );
       
    70     notifiers->AppendL( appLaunchNotifier );
       
    71     CleanupStack::Pop( appLaunchNotifier );
       
    72 
       
    73     CSyncMLDlgNotifier* dlgNotifier = CSyncMLDlgNotifier::NewL( appLaunchNotifier );
       
    74     CleanupStack::PushL( dlgNotifier );
       
    75     notifiers->AppendL( dlgNotifier );
       
    76     CleanupStack::Pop( dlgNotifier );
       
    77 
       
    78     CSyncMLFwUpdNotifier* fwUpdNotifier = CSyncMLFwUpdNotifier::NewL();
       
    79     CleanupStack::PushL( fwUpdNotifier );
       
    80     notifiers->AppendL( fwUpdNotifier );
       
    81     CleanupStack::Pop( fwUpdNotifier );
       
    82 
       
    83     CleanupStack::Pop( notifiers );
       
    84     
       
    85     FLOG(_L("[SmlNotif]\t CreateSmlNotifiersL completed"));
       
    86     return notifiers;
       
    87     }
       
    88 
       
    89 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // NotifierArray
       
    93 // Lib main entry point: Creates a notifiers array.
       
    94 // -----------------------------------------------------------------------------
       
    95 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
       
    96     {
       
    97     FLOG( _L("[SMLNOTIF]\t NotifierArray") );
       
    98 
       
    99     CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers = NULL;
       
   100     TRAPD( err, notifiers = CreateSmlNotifiersL() );
       
   101 
       
   102     if( err != KErrNone )
       
   103         {
       
   104         FTRACE(FPrint(_L("[SmlNotif]\t Notifier creation failure! Error code: %d"), err));
       
   105         err = KErrNone;
       
   106         }
       
   107 
       
   108     FLOG(_L("[SmlNotif]\t NotifierArray completed"));
       
   109 
       
   110     return notifiers;
       
   111     }
       
   112 
       
   113 //  End of File