localisation/apparchitecture/apgrfx/apgnotif.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "apgnotif.h"
       
    17 #include "APGSTD.H"
       
    18 
       
    19 EXPORT_C CApaAppListNotifier::~CApaAppListNotifier()
       
    20 /** The destructor calls Cancel() and closes the session with the server. 
       
    21 
       
    22 @see CActive::Cancel() */
       
    23 	{
       
    24 	Cancel();
       
    25 	iLsSession.Close();
       
    26 	}
       
    27 
       
    28 
       
    29 EXPORT_C CApaAppListNotifier* CApaAppListNotifier::NewL(MApaAppListServObserver* aObserver, TPriority aPriority)
       
    30 /** Allocates and constructs an application list change notifier. 
       
    31 
       
    32 It creates a session with the application architecture server (RApaLsSession), 
       
    33 issues the notification request to the server and adds itself to the active scheduler.
       
    34 
       
    35 @param aObserver Observer whose HandleAppListEvent() function is called when an 
       
    36 application is added or deleted.
       
    37 @param aPriority The active object priority.
       
    38 @return The application list change notifier. */
       
    39 	{
       
    40 	__ASSERT_DEBUG(aObserver!=NULL,Panic(EDPanicInvalidObserver));
       
    41 	CApaAppListNotifier* self=new(ELeave) CApaAppListNotifier(*aObserver, aPriority);
       
    42 	CleanupStack::PushL(self);
       
    43 	self->ConstructL();
       
    44 	CleanupStack::Pop(); // self
       
    45 	return self;
       
    46 	}
       
    47 
       
    48 CApaAppListNotifier::CApaAppListNotifier(MApaAppListServObserver& aObserver, TPriority aPriority)
       
    49 	:CActive(aPriority),
       
    50 	iObserver(aObserver)
       
    51 	{	
       
    52 	}
       
    53 
       
    54 void CApaAppListNotifier::ConstructL()
       
    55 	{
       
    56 	User::LeaveIfError(iLsSession.Connect());
       
    57 	iLsSession.SetNotify(EFalse, iStatus);
       
    58 	CActiveScheduler::Add(this);
       
    59 	SetActive();
       
    60 	}
       
    61 
       
    62 void CApaAppListNotifier::DoCancel()
       
    63 	{
       
    64 	iLsSession.CancelNotify();
       
    65 	}
       
    66 
       
    67 void CApaAppListNotifier::RunL()
       
    68 	{
       
    69 	TInt status=iStatus.Int();
       
    70 	User::LeaveIfError(status);
       
    71 	iLsSession.SetNotify(EFalse, iStatus); // requeue before handling in case the handling changes things
       
    72 	SetActive();
       
    73 	iObserver.HandleAppListEvent(status);
       
    74 	}
       
    75 
       
    76 //
       
    77 // MApaAppListServObserver
       
    78 //
       
    79 /** Constructor for MApaAppListServObserver */
       
    80 EXPORT_C MApaAppListServObserver::MApaAppListServObserver()
       
    81 	{
       
    82 	}
       
    83 
       
    84 /** Reserved for future use */	
       
    85 EXPORT_C void MApaAppListServObserver::MApaAppListServObserver_Reserved1()
       
    86 	{
       
    87 	}
       
    88 
       
    89 /** Reserved for future use */	
       
    90 EXPORT_C void MApaAppListServObserver::MApaAppListServObserver_Reserved2()
       
    91 	{
       
    92 	}