locationcentre/lcservice/src/lcserviceimpl.cpp
changeset 0 522cd55cc3d7
child 9 91123d004e8f
equal deleted inserted replaced
-1:000000000000 0:522cd55cc3d7
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Location Centre API interface.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 #include <s32mem.h>
       
    21 #include <aknsutils.h>
       
    22 #include <gulicon.h>
       
    23 #include <aknlists.h>
       
    24 #include <aknpopup.h>
       
    25 #include <avkon.rsg>
       
    26 
       
    27 // USER INCLUDES
       
    28 #include "lcserviceimpl.h"
       
    29 #include "lclocationappfilter.h"
       
    30 #include "lcappexitobserver.h"
       
    31 #include "lcnotification.h"
       
    32 #include "lcapplauncher.h"
       
    33 #include "lcipcparams.h"
       
    34 #include "lcnotificationao.h"
       
    35 #include "lciconloader.h"
       
    36 #include "lcsyncoperation.h"
       
    37 #include "lcpopuplistbox.h"
       
    38 #include "lcdebug.h"
       
    39 
       
    40 // ----- Member funtions for CLcServiceImpl ---------------------------------
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CLcServiceImpl::CLcServiceImpl
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CLcServiceImpl::CLcServiceImpl()
       
    47     {
       
    48     // C++ Default constructor. No allocations or functions which can Leave
       
    49     // should be called from here.
       
    50     }
       
    51          
       
    52 // ---------------------------------------------------------------------------
       
    53 // CLcServiceImpl::~CLcServiceImpl
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CLcServiceImpl::~CLcServiceImpl()
       
    57     {
       
    58     // C++ Destructor. Free all resources associated with this class.
       
    59     if ( iPopUp )
       
    60         {
       
    61         iPopUp->CancelPopup();
       
    62         }
       
    63     
       
    64     // Delele the Pop-up list    
       
    65     delete iPopUpListBox;
       
    66     
       
    67     // Delete the Selected ID buffer   
       
    68     delete iSelectedAppId;
       
    69                 
       
    70     // Delete filter parameters
       
    71     delete iFilter;
       
    72     
       
    73     // Delete the Application information array
       
    74     iAppArray.Reset();
       
    75     iAppArray.Close();
       
    76 
       
    77     // Delete the Notification Active object
       
    78     delete iNotificationAO;
       
    79     
       
    80     // Delete the Application launcher
       
    81     delete iAppLauncher;
       
    82     
       
    83     // If there is an outstanding request then complete the same with KErrCancel.
       
    84     if ( iAsyncOperation )
       
    85     	{
       
    86     	iAsyncOperation->CancelGetLocationApplications();
       
    87     	User::RequestComplete( iStatus, KErrCompletion );
       
    88     	
       
    89     	// We can now delete the asynchronous operation
       
    90     	delete iAsyncOperation;
       
    91     	iAsyncOperation = NULL;
       
    92     	} 
       
    93     	    
       
    94     // Close the session handle. The session handle is active throughout the
       
    95     // lifetime of this class
       
    96     iSession.Close();
       
    97     
       
    98     }
       
    99         
       
   100 // ---------------------------------------------------------------------------
       
   101 // CLcServiceImpl* CLcServiceImpl::NewL
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 CLcServiceImpl* CLcServiceImpl::NewL()
       
   105     {
       
   106     CLcServiceImpl* self = NewLC();
       
   107     CleanupStack::Pop( self );
       
   108     return self;         
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // CLcServiceImpl* CLcServiceImpl::NewLC
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 CLcServiceImpl* CLcServiceImpl::NewLC()
       
   116     {
       
   117     // Symbian Two phased constructor. Leaves the object on the Clean-up
       
   118     // stack.
       
   119     CLcServiceImpl* self = 
       
   120                 new ( ELeave )CLcServiceImpl();
       
   121     CleanupStack::PushL( self );
       
   122     self->ConstructL();
       
   123     return self;         
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // void CLcServiceImpl::ConstructL
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CLcServiceImpl::ConstructL()
       
   131     {
       
   132     // Second phase of the two phase constructor.
       
   133     
       
   134     // Open a connection to the Location Centre Server
       
   135     // The connection is opened at the class construction and Closed at the
       
   136     // class deletion. This is done inorder to avoid delays during every
       
   137     // operation
       
   138     User::LeaveIfError( iSession.CreateSession());
       
   139     
       
   140     // Create the Location application launcher.
       
   141     iAppLauncher = CLcAppLauncher::NewL();
       
   142     
       
   143     // Create the Notification AO
       
   144     iNotificationAO = CLcNotificationAO::NewL( *this, iSession );
       
   145     }
       
   146                     
       
   147 // ---------------------------------------------------------------------------
       
   148 // void CLcServiceImpl::LaunchLocationCentreL
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CLcServiceImpl::LaunchLocationCentreL( 
       
   152               const TLcLocationAppFilter&             aLocationAppFilter,
       
   153                     CLcLocationAppInfo::TLcLaunchMode aLaunchMode,                        
       
   154                     MLcAppExitObserver*               aChainedAppExitObserver )
       
   155     {
       
   156     DEBUG("+ CLcServiceImpl::LaunchLocationCentreL")
       
   157     // First select a Location based Application from the list
       
   158     TPtrC identifier = SelectLocationApplicationL( aLocationAppFilter );
       
   159     if ( !identifier.Length())
       
   160         {
       
   161         return;
       
   162         }    
       
   163     
       
   164     // Launch the corresponding application.
       
   165     LaunchLocationApplicationL( identifier, aLaunchMode, aChainedAppExitObserver );
       
   166     DEBUG("- CLcServiceImpl::LaunchLocationCentreL")
       
   167     }
       
   168     
       
   169 // ---------------------------------------------------------------------------
       
   170 // void CLcServiceImpl::LaunchLocationCentreL
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 void CLcServiceImpl::LaunchLocationCentreL(
       
   174       const RPointerArray<CLcService::CLcLaunchParam>& aIncludeAppArray,
       
   175       MLcAppExitObserver*                              aChainedAppExitObserver )
       
   176     {
       
   177     // Form an array of applications identifiers which can be passed to the
       
   178     // selection function
       
   179     RArray<TPtrC>  appArray;
       
   180     CleanupClosePushL( appArray );
       
   181     
       
   182     TInt count = aIncludeAppArray.Count();    
       
   183     for( TInt i = 0; i < count; i++ )
       
   184         {
       
   185         User::LeaveIfError( appArray.Append( aIncludeAppArray[i]->Id()));
       
   186         }
       
   187         
       
   188     // First select a Location based Application from the list
       
   189     TPtrC identifier = SelectLocationApplicationL( appArray, ETrue );    
       
   190     if ( !identifier.Length())
       
   191         {
       
   192         return;
       
   193         }
       
   194         
       
   195     CLcLocationAppInfo::TLcLaunchMode launchmode = CLcLocationAppInfo::EDefaultMode;
       
   196     // Obtain the launch mode for that application            
       
   197     for ( TInt i = 0; i < count; i++ )
       
   198         {
       
   199         if ( !appArray[i].Compare( identifier ))
       
   200             {
       
   201             launchmode = aIncludeAppArray[i]->LaunchMode();
       
   202             break;
       
   203             }
       
   204         }
       
   205         
       
   206     // Launch the corresponding application.
       
   207     LaunchLocationApplicationL( identifier, launchmode, aChainedAppExitObserver ); 
       
   208     
       
   209     // Pop and Destroy the application array        
       
   210     CleanupStack::PopAndDestroy();
       
   211     }
       
   212     
       
   213 // ---------------------------------------------------------------------------
       
   214 // void CLcServiceImpl::LaunchLocationCentreL
       
   215 // ---------------------------------------------------------------------------
       
   216 //
       
   217 void CLcServiceImpl::LaunchLocationCentreL( 
       
   218                     const RArray<TPtrC>&              aExcludeAppArray,
       
   219                     CLcLocationAppInfo::TLcLaunchMode aLaunchMode,
       
   220                     MLcAppExitObserver*               aChainedAppExitObserver )
       
   221     {
       
   222     // First select a Location based Application from the list
       
   223     TPtrC identifier = SelectLocationApplicationL( aExcludeAppArray, EFalse );
       
   224     if ( !identifier.Length())
       
   225         {
       
   226         return;
       
   227         }    
       
   228     
       
   229     // Launch the corresponding application.
       
   230     LaunchLocationApplicationL( identifier, aLaunchMode, aChainedAppExitObserver );    
       
   231     }
       
   232 
       
   233 // ---------------------------------------------------------------------------
       
   234 // void CLcServiceImpl::SelectLocationApplicationL
       
   235 // ---------------------------------------------------------------------------
       
   236 //
       
   237 TPtrC CLcServiceImpl::SelectLocationApplicationL(
       
   238                         const TLcLocationAppFilter&     aLocationAppFilter )
       
   239     {
       
   240     // If the pop-up dialog is currently being displayed then cannot proceed with
       
   241     // the request.
       
   242     if ( iPopUp )
       
   243         {
       
   244         User::Leave( KErrInUse );
       
   245         }
       
   246     
       
   247     iPopupOutStanding = ELcPopupWithFiltering;
       
   248     
       
   249     // Delete any existing filter. This condition should never occur. Just a safe
       
   250     // check.
       
   251     delete iFilter;
       
   252     iFilter = NULL;
       
   253     
       
   254     // Copy the filter contents
       
   255     iFilter = new ( ELeave ) TLcLocationAppFilter( aLocationAppFilter );
       
   256       
       
   257     // Obtain the list of applications from the Location Centre Server and
       
   258     // launch the Location Centre pop-up with that list.    
       
   259     CLcLocationAppInfoArray* array = GetLocationApplicationsL( aLocationAppFilter );
       
   260                                   
       
   261     // The ownership of the array is transferred.
       
   262     TPtrC  appId(KNullDesC());
       
   263     TRAPD( error, appId.Set( SelectLocationApplicationL( array )));
       
   264     
       
   265     // Delete the filter before any operation on the result        
       
   266     delete iFilter;
       
   267     iFilter = NULL;
       
   268      
       
   269     // Handle Error 
       
   270     if ( error )
       
   271         {
       
   272         if ( iPopUp )
       
   273             {
       
   274             iPopUp->CancelPopup();            
       
   275             }
       
   276         iPopUp = NULL;
       
   277         
       
   278         delete iPopUpListBox;
       
   279         iPopUpListBox = NULL;
       
   280         
       
   281         User::Leave( error );        
       
   282         }        
       
   283     return appId;        
       
   284     }
       
   285     
       
   286 // ---------------------------------------------------------------------------
       
   287 // void CLcServiceImpl::SelectLocationApplicationL
       
   288 // ---------------------------------------------------------------------------
       
   289 //
       
   290 TPtrC CLcServiceImpl::SelectLocationApplicationL(
       
   291                             const RArray<TPtrC>&      aAppArray,
       
   292                                   TBool               aIncludeFlag )
       
   293     {
       
   294     // If the pop-up dialog is currently being displayed then cannot proceed with
       
   295     // the request.
       
   296     if ( iPopUp )
       
   297         {
       
   298         User::Leave( KErrInUse );
       
   299         }
       
   300      
       
   301     // Reset and Destroy the existing array.
       
   302     iAppArray.Reset();
       
   303     
       
   304     if ( aIncludeFlag )
       
   305         {
       
   306         iPopupOutStanding = ELcPopupWithSpecifiedApps;
       
   307         }
       
   308     else
       
   309         {
       
   310         iPopupOutStanding = ELcPopupWithoutSpecifedApps;
       
   311         }
       
   312         
       
   313     // Create the array with the new elements
       
   314     TInt count = aAppArray.Count();
       
   315     for ( TInt i = 0; i < count; i++ )
       
   316         {
       
   317         User::LeaveIfError( iAppArray.Append( aAppArray[i] ));
       
   318         }
       
   319         
       
   320     // Obtain the list of applications from the Location Centre Server and
       
   321     // launch the Location Centre pop-up with that list.    
       
   322     CLcLocationAppInfoArray* array = 
       
   323                     LcSyncOperation::GetLocationApplicationsL( iSession,
       
   324                                                                aAppArray,
       
   325                                                                aIncludeFlag );
       
   326                                   
       
   327     // The ownership of the array is transferred.
       
   328     TPtrC  appId(KNullDesC());
       
   329     TRAPD( error, appId.Set( SelectLocationApplicationL( array )));
       
   330     
       
   331     // Reset and destroy the array
       
   332     iAppArray.Reset();
       
   333       
       
   334     // Handle Error    
       
   335     if ( error )
       
   336         {
       
   337         if ( iPopUp )
       
   338             {
       
   339             iPopUp->CancelPopup();            
       
   340             }
       
   341         iPopUp = NULL;
       
   342         
       
   343         delete iPopUpListBox;
       
   344         iPopUpListBox = NULL;
       
   345         
       
   346         User::Leave( error );
       
   347         }
       
   348     return appId;         
       
   349     }
       
   350     
       
   351 // ---------------------------------------------------------------------------
       
   352 // CLcLocationAppInfoArray* CLcServiceImpl::GetLocationApplicationsL
       
   353 // ---------------------------------------------------------------------------
       
   354 //    
       
   355 CLcLocationAppInfoArray* CLcServiceImpl::GetLocationApplicationsL(
       
   356             const TLcLocationAppFilter&         aLocationAppFilter )
       
   357     {
       
   358     return LcSyncOperation::GetLocationApplicationsL( iSession,
       
   359     												  aLocationAppFilter );
       
   360     }
       
   361     
       
   362 // ---------------------------------------------------------------------------
       
   363 // void CLcServiceImpl::GetLocationApplicationsL
       
   364 // ---------------------------------------------------------------------------
       
   365 //    
       
   366 void CLcServiceImpl::GetLocationApplications(
       
   367                             TRequestStatus&             aStatus,
       
   368                       const TLcLocationAppFilter&       aLocationAppFilter,                            
       
   369                             CLcLocationAppInfoArray*&   aAppInfoArray)
       
   370     {
       
   371     TRAPD( error, GetLocationApplicationsL( aStatus,
       
   372     										aLocationAppFilter,
       
   373     										aAppInfoArray ));
       
   374 	if ( error )
       
   375 		{
       
   376 		TRequestStatus* status = &aStatus;
       
   377 		User::RequestComplete( status , error );
       
   378 		}
       
   379     }
       
   380 
       
   381 // ---------------------------------------------------------------------------
       
   382 // void CLcServiceImpl::CancelGetLocationApplications
       
   383 // ---------------------------------------------------------------------------
       
   384 //     
       
   385 void CLcServiceImpl::CancelGetLocationApplications()
       
   386     {
       
   387     // If there is an outstanding request then complete the same with KErrCancel.
       
   388     if ( iAsyncOperation )
       
   389     	{
       
   390     	iAsyncOperation->CancelGetLocationApplications();
       
   391     	User::RequestComplete( iStatus, KErrCancel );
       
   392     	
       
   393     	// We can now delete the asynchronous operation
       
   394     	delete iAsyncOperation;
       
   395     	iAsyncOperation = NULL;
       
   396     	} 
       
   397     }
       
   398 
       
   399 // ---------------------------------------------------------------------------
       
   400 // void CLcServiceImpl::LaunchLocationApplicationL
       
   401 // ---------------------------------------------------------------------------
       
   402 // 
       
   403 void CLcServiceImpl::LaunchLocationApplicationL( 
       
   404                 const TDesC&                      aAppIdentifier,
       
   405                 CLcLocationAppInfo::TLcLaunchMode aLaunchMode,
       
   406                 MLcAppExitObserver*               aChainedAppExitObserver )
       
   407     {
       
   408     DEBUG("+ CLcServiceImpl::LaunchLocationApplicationL" )
       
   409     
       
   410     // Obtain the Location Application Information from Location Centre Server.
       
   411     CLcBasicAppInfo* appInfo = 
       
   412     	LcSyncOperation::GetLocationAppInfoL( iSession, aAppIdentifier );
       
   413     CleanupStack::PushL( appInfo );
       
   414    
       
   415     // Resolve the model in which the Application must be launched.
       
   416     if ( aLaunchMode == CLcLocationAppInfo::EDefaultMode )
       
   417     	{
       
   418     	// Since this is a Local copy we can use the same for handling
       
   419     	// Launch mode changes.
       
   420     	aLaunchMode = 
       
   421     		static_cast<CLcLocationAppInfo::TLcLaunchMode>( appInfo->LaunchMode());
       
   422     	}
       
   423     	    	
       
   424 	// Now Launch the Location based Application or Content/Service    	
       
   425     iAppLauncher->LaunchLocationApplicationL( 
       
   426 			appInfo->ApplicationType(),
       
   427             appInfo->ApplicationData(),
       
   428             ( aLaunchMode == CLcLocationAppInfo::EStandAloneMode ) ? ETrue : EFalse,
       
   429             appInfo->CommandLineParamters(),
       
   430             aChainedAppExitObserver );
       
   431 
       
   432 	CleanupStack::PopAndDestroy( appInfo );                                          
       
   433 	
       
   434 	DEBUG("- CLcServiceImpl::LaunchLocationApplicationL" )                                          
       
   435     }
       
   436 
       
   437 // ---------------------------------------------------------------------------
       
   438 // void CLcServiceImpl::SetObserverL
       
   439 // ---------------------------------------------------------------------------
       
   440 // 
       
   441 void CLcServiceImpl::SetObserverL( MLcNotification&     aObserver )
       
   442     {
       
   443     if ( iObserver )
       
   444         {
       
   445         User::Leave( KErrAlreadyExists );
       
   446         }
       
   447     
       
   448     iObserver = &aObserver;
       
   449     
       
   450     iNotificationAO->IssueRequest();
       
   451     }
       
   452 
       
   453 // ---------------------------------------------------------------------------
       
   454 // TInt CLcServiceImpl::RemoveObserver
       
   455 // ---------------------------------------------------------------------------
       
   456 //                                         
       
   457 TInt CLcServiceImpl::RemoveObserver()
       
   458     {
       
   459     if ( !iObserver )
       
   460         {
       
   461         return KErrNotFound;
       
   462         }
       
   463     
       
   464     iObserver = NULL;
       
   465     
       
   466     // If there is a popup outstanding then do nothing. If not remove the
       
   467     // notification
       
   468     if ( !iPopUp )
       
   469         {
       
   470         iNotificationAO->CancelRequest();        
       
   471         }
       
   472         
       
   473     return KErrNone;
       
   474     }
       
   475 
       
   476 // ---------------------------------------------------------------------------
       
   477 // void CLcServiceImpl::LcStatusChangedL
       
   478 // ---------------------------------------------------------------------------
       
   479 // 
       
   480 void CLcServiceImpl::LcStatusChangedL( TInt aErrorCode )
       
   481     {
       
   482     // If we are displaying the pop-up then we need to transfer the changes
       
   483     // to the pop-up first
       
   484     if ( iPopUp )
       
   485         {
       
   486         // Obtain the new list of applications from the Location Centre Server and
       
   487         // update the Location Centre pop-up with that list.    
       
   488         CLcLocationAppInfoArray* array = NULL;
       
   489         TInt error = KErrNone;
       
   490                         
       
   491         switch( iPopupOutStanding )
       
   492             {
       
   493             case ELcPopupWithFiltering:
       
   494                 {                
       
   495                 // Incase we face any errors in retrival then we can Ignore the
       
   496                 // updations
       
   497                 TRAP( error, array = GetLocationApplicationsL( *iFilter ));
       
   498                 break;
       
   499                 }
       
   500             case ELcPopupWithSpecifiedApps:
       
   501             case ELcPopupWithoutSpecifedApps:            
       
   502                 {
       
   503                 TBool includeflag = EFalse;
       
   504                 if ( iPopupOutStanding == ELcPopupWithSpecifiedApps )
       
   505                     {
       
   506                     includeflag = ETrue;
       
   507                     }
       
   508                     
       
   509                 // Incase we face any errors in retrival then we can Ignore the
       
   510                 // updations
       
   511                 TRAP( error, array = LcSyncOperation::GetLocationApplicationsL( 
       
   512                                                         iSession, iAppArray, includeflag ));
       
   513                 break;
       
   514                 }
       
   515             default:
       
   516                 {
       
   517                 break;
       
   518                 }
       
   519             }
       
   520            
       
   521         if ( !error && array )
       
   522             {
       
   523             // The ownership of the array is transferred to the list box.
       
   524             TRAP_IGNORE( CleanupStack::PushL( array ); 
       
   525                          iPopUpListBox->UpdateListBoxL( array );
       
   526                          CleanupStack::Pop( array );
       
   527                        );
       
   528             }
       
   529         else if ( KErrNotFound == error )
       
   530             {
       
   531             if ( iPopUp )
       
   532                 {
       
   533                 iPopUp->CancelPopup();            
       
   534                 }
       
   535             iPopUp = NULL;
       
   536             
       
   537             delete iPopUpListBox;
       
   538             iPopUpListBox = NULL;            
       
   539             }
       
   540         }
       
   541         
       
   542     // Notify the client regarding the changes to Location Centre Registry
       
   543     if ( iObserver )
       
   544         {
       
   545         iObserver->LcStatusChangedL( aErrorCode );
       
   546         }   
       
   547     }
       
   548 
       
   549 // ---------------------------------------------------------------------------
       
   550 // void CLcServiceImpl::OperationComplete
       
   551 // ---------------------------------------------------------------------------
       
   552 // 
       
   553 void CLcServiceImpl::OperationComplete( TInt aError )
       
   554 	{
       
   555 	User::RequestComplete( iStatus, aError );
       
   556 	
       
   557 	// We can now delete the asynchronous operation
       
   558 	delete iAsyncOperation;
       
   559 	iAsyncOperation = NULL;	
       
   560 	}
       
   561 
       
   562 // ---------------------------------------------------------------------------
       
   563 // void CLcServiceImpl::GetLocationApplicationsL
       
   564 // ---------------------------------------------------------------------------
       
   565 // 	
       
   566 void CLcServiceImpl::GetLocationApplicationsL( 
       
   567                 TRequestStatus&             aStatus,
       
   568           const TLcLocationAppFilter&       aLocationAppFilter,
       
   569                 CLcLocationAppInfoArray*&   aAppInfoArray )
       
   570 	{
       
   571     aStatus = KRequestPending;
       
   572     
       
   573     // If there is an asynchronous operation then leave with KErrInUse
       
   574     if ( iAsyncOperation )
       
   575     	{
       
   576     	User::Leave( KErrInUse );
       
   577     	}
       
   578     	
       
   579 	// Create the Asynchronous Operations class
       
   580 	iAsyncOperation = CLcAsyncOperation::NewL( iSession, *this );
       
   581 	    	
       
   582     // Set the status to KRequestPending
       
   583     aStatus = KRequestPending;
       
   584     iStatus = &aStatus;
       
   585     
       
   586     // Issue the request to the ASP
       
   587     iAsyncOperation->GetLocationApplicationsL( aLocationAppFilter,
       
   588     										   aAppInfoArray );	
       
   589 	}
       
   590 
       
   591 // ---------------------------------------------------------------------------
       
   592 // void CLcServiceImpl::SelectLocationApplicationL
       
   593 // ---------------------------------------------------------------------------
       
   594 //
       
   595 TPtrC CLcServiceImpl::SelectLocationApplicationL( 
       
   596                                 CLcLocationAppInfoArray*   aAppInfoArray )
       
   597     {
       
   598     // The App Info arrays ownership is tranferred to the List. So push it
       
   599     // to the Cleanup stack until the ownership is completely transferred.
       
   600     CleanupStack::PushL( aAppInfoArray );
       
   601     
       
   602     iPopUpListBox = new ( ELeave ) CLcPopupListBox( aAppInfoArray );
       
   603     CleanupStack::Pop( aAppInfoArray );
       
   604     
       
   605     // Construct the popup with the list
       
   606     iPopUp = CAknPopupList::NewL( iPopUpListBox, 
       
   607                                   R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT,
       
   608                                   AknPopupLayouts::EMenuGraphicWindow );  
       
   609     iPopUpListBox->ConstructL( iPopUp );    
       
   610     // iPopUp->SetBorder( AknBorderId::EAknBorderMenuPopup );								                          
       
   611     
       
   612     // Set up notification events
       
   613     iNotificationAO->IssueRequest();
       
   614                              
       
   615     // Display the pop-up and let user selection.                             
       
   616     TInt popupOk = iPopUp->ExecuteLD();
       
   617     iPopUp = NULL;
       
   618     
       
   619     // Only we are observing for notifications. We dont need it anymore
       
   620     // Cancel it
       
   621     if ( !iObserver )
       
   622         {
       
   623         iNotificationAO->CancelRequest();
       
   624         }
       
   625         
       
   626     if ( popupOk )
       
   627         {
       
   628         delete iSelectedAppId;        
       
   629         iSelectedAppId = NULL;
       
   630                 
       
   631         iSelectedAppId = iPopUpListBox->AppInfoId().AllocL();
       
   632         
       
   633         delete iPopUpListBox;
       
   634         iPopUpListBox = NULL;
       
   635         
       
   636         return *iSelectedAppId;
       
   637         }
       
   638     else
       
   639         {
       
   640         delete iPopUpListBox;
       
   641         iPopUpListBox = NULL;
       
   642         
       
   643         return TPtrC();
       
   644         }
       
   645     }
       
   646     
       
   647 // End of File