pimprotocols/phonebooksync/Server/ActiveNotifications.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2002-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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Contains implementations for the Active Object based notification
       
    15 // classes.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 
       
    24 #include <connect/sbdefs.h>
       
    25 #include <etelmm.h>
       
    26 #include <etelsat.h>
       
    27 #include <satcs.h>
       
    28 
       
    29 #include "common.h"
       
    30 #include "Phonebook.h"
       
    31 #include "PhonebookManager.h"
       
    32 #include "SyncContactICCEntry.h"
       
    33 #include "phbksynclog.h"
       
    34 #include "phbksyncsvr.h"
       
    35 #include "SyncEngineSession.h"
       
    36 #include "SyncEngineServer.h"
       
    37 #include "phbksyncsess.h"
       
    38 #include "ActiveNotifications.h"
       
    39 
       
    40 using namespace conn;
       
    41 
       
    42 
       
    43 //
       
    44 // Some timing constants...
       
    45 //
       
    46 const TInt  KActiveNotificationInitialDelayInSeconds = 5;
       
    47 const TInt  KActiveNotificationMaxDelayInSeconds     = 2560;
       
    48 const TInt  KOneSecondInMS                           = 1000000;
       
    49 
       
    50 
       
    51 //
       
    52 // Definition of the locks used by CNotifyLockInfoChange...
       
    53 //
       
    54 const TInt  KLockInfoNumberOfLocks = 5;
       
    55 const RMobilePhone::TMobilePhoneLock  KLockInfoList[KLockInfoNumberOfLocks] =
       
    56 											{RMobilePhone::ELockICC,
       
    57 											 RMobilePhone::ELockPin2,
       
    58 											 RMobilePhone::ELockHiddenKey,
       
    59 											 RMobilePhone::ELockUSimApp,
       
    60 											 RMobilePhone::ELockUniversalPin};
       
    61 
       
    62 
       
    63 /**
       
    64  *  Standard constructor.
       
    65  *
       
    66  *  @param aServer  Pointer to the front-end server.
       
    67  */
       
    68 CActiveNotificationBase::CActiveNotificationBase(CPhoneBookServer& aServer)
       
    69   : CActive(EPriorityNormal),
       
    70 	iIsNotificationInProgress(EFalse),
       
    71 	iLastDelay(0),
       
    72 	iServer(aServer),
       
    73 	iTimer()
       
    74 	{
       
    75 	CActiveScheduler::Add(this);
       
    76 	} // CActiveNotificationBase::CActiveNotificationBase
       
    77 
       
    78 
       
    79 /**
       
    80  *  Standard destructor. Derived classes will need to implement a destructor
       
    81  *  too, so that the active notification can be cancelled.
       
    82  */
       
    83 CActiveNotificationBase::~CActiveNotificationBase()
       
    84 	{
       
    85 	LOGACTIVE1(_L8("CActiveNotificationBase::~CActiveNotificationBase()"));
       
    86 
       
    87 	iTimer.Close();
       
    88 	} // CActiveNotificationBase::~CActiveNotificationBase
       
    89 
       
    90 
       
    91 /**
       
    92  *  This function starts the Active Notification object. Until it is cancelled
       
    93  *  the CompleteNotification() and PostNotification() functions will be called
       
    94  *  each time the notification triggers.
       
    95  *
       
    96  *  @return Returns KErrNone if the notification starts, a system error
       
    97  *          code otherwise.
       
    98  */
       
    99 TInt CActiveNotificationBase::Start()
       
   100 	{
       
   101 	LOGACTIVE1(_L8("CActiveNotificationBase::Start()"));
       
   102 
       
   103 	//
       
   104 	// Check if this Active Notifier is running...
       
   105 	//
       
   106 	if (IsActive())
       
   107 		{
       
   108 		return KErrInUse;
       
   109 		}
       
   110 	
       
   111 	//
       
   112 	// Create the RTimer...
       
   113 	//
       
   114 	TInt  result;
       
   115 	
       
   116 	result = iTimer.CreateLocal();
       
   117 	if (result != KErrNone)
       
   118 		{
       
   119 		return result;
       
   120 		}
       
   121 		
       
   122 	//
       
   123 	// Start the notifications...
       
   124 	//
       
   125 	PostNotification();
       
   126 	iIsNotificationInProgress = ETrue;
       
   127 	iLastDelay = 0;
       
   128 	
       
   129 	return KErrNone;
       
   130 	} // CActiveNotificationBase::Start
       
   131 
       
   132 
       
   133 /**
       
   134  *  Virtual function, overridden by the derived class, which performs the
       
   135  *  task of issuing the notification.
       
   136  */
       
   137 void CActiveNotificationBase::PostNotification()
       
   138 	{
       
   139 	LOGACTIVE1(_L8("CActiveNotificationBase::PostNotification()"));
       
   140 
       
   141 	//
       
   142 	// To be implemented by the derived class...
       
   143 	//
       
   144 	} // CActiveNotificationBase::PostNotification
       
   145 
       
   146 
       
   147 /**
       
   148  *  Virtual function, overridden by the derived class, which performs the
       
   149  *  task of completing the notification. Normally this means a function call
       
   150  *  is made on the server object to let it know the event has occured.
       
   151  *
       
   152  *  @param aRetVal  Result of the notification.
       
   153  */
       
   154 void CActiveNotificationBase::CompleteNotification(TInt aRetVal)
       
   155 	{
       
   156 	LOGACTIVE2(_L8("CActiveNotificationBase::CompleteNotification(%d)"),
       
   157 			   aRetVal);
       
   158 
       
   159 	//
       
   160 	// To be implemented by the derived class...
       
   161 	//
       
   162 	(void) aRetVal;
       
   163 	} // CActiveNotificationBase::CompleteNotification
       
   164 
       
   165 
       
   166 /**
       
   167  *  Virtual function, overridden by the derived class, which performs the
       
   168  *  task of cancelling the notification.
       
   169  */
       
   170 void CActiveNotificationBase::CancelNotification()
       
   171 	{
       
   172 	LOGACTIVE1(_L8("CActiveNotificationBase::CancelNotification()"));
       
   173 
       
   174 	//
       
   175 	// To be implemented by the derived class...
       
   176 	//
       
   177 	} // CActiveNotificationBase::CancelNotification
       
   178 
       
   179 
       
   180 /**
       
   181  *  Standard Active Object RunL() method to process requests. This function
       
   182  *  is called when either the notification request completes or when the timer
       
   183  *  delay completes.
       
   184  *
       
   185  *  The function decides whether to repost the notification, delay and then
       
   186  *  repost or to just stop the notification altogether.
       
   187  */
       
   188 void CActiveNotificationBase::RunL()
       
   189 	{
       
   190 	LOGACTIVE2(_L8("CActiveNotificationBase::RunL(): iStatus=%d"), iStatus.Int());
       
   191 
       
   192 	//
       
   193 	// Handle the result of the last request or timer request...
       
   194 	//
       
   195 	if (iIsNotificationInProgress)
       
   196 		{
       
   197 		TInt  retVal(iStatus.Int()); // Stored as iStatus may change!
       
   198 
       
   199 		iIsNotificationInProgress = EFalse;
       
   200 		CompleteNotification(retVal);
       
   201 		
       
   202 		//
       
   203 		// Now work out what to do next. If this was successful then repost,
       
   204 		// otherwise stop the notification or delay then repost.
       
   205 		//
       
   206 		if (retVal == KErrNone)
       
   207 			{
       
   208 			//
       
   209 			// The previous notification was successful so repost...
       
   210 			//
       
   211 			LOGACTIVE1(_L8("CActiveNotificationBase::RunL(): Reposting..."));
       
   212 
       
   213 			PostNotification();
       
   214 			iIsNotificationInProgress = ETrue;
       
   215 			iLastDelay = 0;
       
   216 			}
       
   217 		else if (retVal == KErrNotFound  ||  retVal == KErrCancel  ||
       
   218 				 retVal == KErrNotSupported)
       
   219 			{
       
   220 			//
       
   221 			// The previous notification returned an error code that indicates
       
   222 			// it is not worth reposting.
       
   223 			//
       
   224 			LOGACTIVE1(_L8("CActiveNotificationBase::RunL(): Stopping..."));
       
   225 			}
       
   226 		else
       
   227 			{
       
   228 			//
       
   229 			// The previous notification returned an error code that suggests
       
   230 			// we should retry in a while. Delay some seconds.
       
   231 			//
       
   232 			// If this is the first delay since a successful notification then
       
   233 			// delay the initial ammount, otherwise double the delay used last
       
   234 			// time. If we have exceed the maximum delay then stop.
       
   235 			//
       
   236 			LOGACTIVE1(_L8("CActiveNotificationBase::RunL(): Delaying..."));
       
   237 
       
   238 			if (iLastDelay == 0)
       
   239 				{
       
   240 				iLastDelay = KActiveNotificationInitialDelayInSeconds;
       
   241 				}
       
   242 			else
       
   243 				{
       
   244 				iLastDelay = iLastDelay * 2;
       
   245 				}
       
   246 
       
   247 			if (iLastDelay < KActiveNotificationMaxDelayInSeconds)
       
   248 				{
       
   249 				LOGACTIVE2(_L8("CActiveNotificationBase::RunL(): Delaying %d seconds"),
       
   250 						   iLastDelay);
       
   251 
       
   252 				iTimer.After(iStatus, iLastDelay * KOneSecondInMS);
       
   253 				SetActive();
       
   254 				}
       
   255 			else
       
   256 				{
       
   257 				LOGACTIVE1(_L8("CActiveNotificationBase::RunL(): Out of time..."));
       
   258 				}
       
   259 			}
       
   260 		}
       
   261 	else
       
   262 		{
       
   263 		//
       
   264 		// The timer must have expired (either on time or because of some
       
   265 		// other event such as timezone change).
       
   266 		//
       
   267 		// Retry the notification...
       
   268 		//
       
   269 		LOGACTIVE1(_L8("CActiveNotificationBase::RunL(): Reposting again..."));
       
   270 
       
   271 		PostNotification();
       
   272 		iIsNotificationInProgress = ETrue;
       
   273 		}
       
   274 	} // CActiveNotificationBase::RunL
       
   275 
       
   276 
       
   277 /**
       
   278  *  Standard Active Object RunErrorL() function. This is called if the RunL()
       
   279  *  leaves. Hopefully this should not happen!
       
   280  *
       
   281  *  @param aError  Leave code from the RunL().
       
   282  *
       
   283  *  @return KErrNone (although it panics first).
       
   284  */
       
   285 TInt CActiveNotificationBase::RunError(TInt aError)
       
   286 	{
       
   287 #ifdef _DEBUG
       
   288 	LOGACTIVE2(_L8("CActiveNotificationBase::RunError(%d)"), aError);
       
   289 #else
       
   290 	(void) aError;
       
   291 #endif
       
   292 
       
   293 	PhBkSyncPanic(EPhBkSyncPanicUnexpectedLeave);
       
   294 
       
   295 	return KErrNone;	
       
   296 	} // CActiveNotificationBase::RunError
       
   297 
       
   298 
       
   299 /**
       
   300  *  Standard Active Object DoCancel method. This is called when Cancel()
       
   301  *  is called on the object and a request is active.
       
   302  */
       
   303 void CActiveNotificationBase::DoCancel()
       
   304 	{
       
   305 	LOGACTIVE1(_L8("CActiveNotificationBase::DoCancel()"));
       
   306 
       
   307 	if (iIsNotificationInProgress)
       
   308 		{
       
   309 		CancelNotification();
       
   310 		}
       
   311 	else
       
   312 		{
       
   313 		iTimer.Cancel();
       
   314 		}
       
   315 	} // CActiveNotificationBase::DoCancel
       
   316 
       
   317 
       
   318 
       
   319 
       
   320 /**
       
   321  *  Static factory method used to create a CGetPhoneStoreInfo object.
       
   322  *
       
   323  *  @param aServer            Reference to the front-end server object.
       
   324  *  @param aPhonebookManager  Reference to the Phonebook Manager object.
       
   325  *  @param aPhone             Handle to the phone object.
       
   326  *
       
   327  *  @return  Pointer to the created CNotifySecurityEvent object, or NULL.
       
   328  */
       
   329 CGetPhoneStoreInfo* CGetPhoneStoreInfo::NewL(CPhoneBookServer& aServer,
       
   330 											 CPhoneBookManager& aPhonebookManager,
       
   331 											 RMobilePhone& aPhone)
       
   332 	{
       
   333 	CGetPhoneStoreInfo* self = new(ELeave) CGetPhoneStoreInfo(aServer,
       
   334 															  aPhonebookManager,
       
   335 															  aPhone);
       
   336 
       
   337 	return self;
       
   338 	} // CGetPhoneStoreInfo::NewL
       
   339 
       
   340 
       
   341 /**
       
   342  *  Standard constructor.
       
   343  *
       
   344  *  @param aServer            Reference to the front-end server object.
       
   345  *  @param aPhonebookManager  Reference to the Phonebook Manager object.
       
   346  *  @param aPhone             Handle to the phone object.
       
   347  */
       
   348 CGetPhoneStoreInfo::CGetPhoneStoreInfo(CPhoneBookServer& aServer,
       
   349 									   CPhoneBookManager& aPhonebookManager,
       
   350 									   RMobilePhone& aPhone)
       
   351   : CActiveNotificationBase(aServer),
       
   352     iPhonebookManager(aPhonebookManager),
       
   353     iPhone(aPhone),
       
   354     iPhonebookUid(KUidIccPhonebookNotSpecified),
       
   355     iPhonebookCount(-1),
       
   356     iStoreInfoPckgV1(iStoreInfoV1),
       
   357     iStoreInfoPckgV2(iStoreInfoV2),
       
   358     iStoreInfoPckgV5(iStoreInfoV5)
       
   359 	{
       
   360 	SelectNextPhonebook();
       
   361 	} // CGetPhoneStoreInfo::CGetPhoneStoreInfo
       
   362 
       
   363 
       
   364 /**
       
   365  *  Standard destructor.
       
   366  */
       
   367 CGetPhoneStoreInfo::~CGetPhoneStoreInfo()
       
   368 	{
       
   369 	LOGACTIVE1(_L8("CGetPhoneStoreInfo::~CGetPhoneStoreInfo()"));
       
   370 
       
   371 	Cancel();
       
   372 	iPhonebooksToRefresh.Close();
       
   373 	} // CGetPhoneStoreInfo::~CGetPhoneStoreInfo
       
   374 
       
   375 
       
   376 /**
       
   377  *  Virtual method called by the CActiveNotificationBase class to post
       
   378  *  the GetPhoneStoreInfo request.
       
   379  */
       
   380 void CGetPhoneStoreInfo::PostNotification()
       
   381 	{
       
   382 	LOGACTIVE1(_L8("CGetPhoneStoreInfo::PostNotification()"));
       
   383 
       
   384 	//
       
   385 	// Check if a phonebook remains to have it's info retrieved...
       
   386 	//
       
   387 	if (iPhonebookUid != KUidIccPhonebookNotSpecified)
       
   388 		{
       
   389 		//
       
   390 		// Work out the store name...
       
   391 		//
       
   392 		if (iPhonebookUid == KUidIccGlobalAdnPhonebook)
       
   393 			{
       
   394 			LOGACTIVE1(_L8("CGetPhoneStoreInfo::PostNotification(): Getting ADN."));
       
   395 			iStore.iStoreName = KETelIccAdnPhoneBook;
       
   396 			iStore.iMode = KEtelGsmPhoneBookType;
       
   397 			}
       
   398 		else if (iPhonebookUid == KUidIccGlobalSdnPhonebook)
       
   399 			{
       
   400 			LOGACTIVE1(_L8("CGetPhoneStoreInfo::PostNotification(): Getting SDN."));
       
   401 			iStore.iStoreName = KETelIccSdnPhoneBook;
       
   402 			iStore.iMode = KEtelGsmPhoneBookType;
       
   403 			}
       
   404 		else if (iPhonebookUid == KUidIccGlobalLndPhonebook)
       
   405 			{
       
   406 			LOGACTIVE1(_L8("CGetPhoneStoreInfo::PostNotification(): Getting LND."));
       
   407 			iStore.iStoreName = KETelIccLndPhoneBook;
       
   408 			iStore.iMode = KEtelGsmPhoneBookType;
       
   409 			}
       
   410 		else if (iPhonebookUid == KUidUsimAppAdnPhonebook)
       
   411 			{
       
   412 			LOGACTIVE1(_L8("CGetPhoneStoreInfo::PostNotification(): Getting USIM ADN."));
       
   413 			iStore.iStoreName = KETelIccAdnPhoneBook;
       
   414 			iStore.iMode = KEtelUSimPhoneBookType;
       
   415 			}
       
   416 		else if (iPhonebookUid == KUidIccGlobalFdnPhonebook)
       
   417 			{
       
   418 			LOGACTIVE1(_L8("CGetPhoneStoreInfo::PostNotification(): Getting FDN."));
       
   419 			iStore.iStoreName = KETelIccFdnPhoneBook;
       
   420 			iStore.iMode = KEtelGsmPhoneBookType;
       
   421 			}
       
   422 		else
       
   423 			{
       
   424 			PhBkSyncPanic(EPhBkSyncPanicTooManyPhonebooks);
       
   425 			}
       
   426 
       
   427 		//
       
   428 		// Request the phone store info...
       
   429 		//
       
   430 		if (Server().IsV5Tsy())
       
   431 			{
       
   432 			iPhone.GetPhoneStoreInfo(iStatus, iStoreInfoPckgV5,
       
   433 									 iStore.iStoreName, iStore.iMode);
       
   434 			}
       
   435 		else if (Server().IsV2Tsy())
       
   436 			{
       
   437 			iPhone.GetPhoneStoreInfo(iStatus, iStoreInfoPckgV2,
       
   438 									 iStore.iStoreName, iStore.iMode);
       
   439 			}
       
   440 		else
       
   441 			{
       
   442 			iPhone.GetPhoneStoreInfo(iStatus, iStoreInfoPckgV1,
       
   443 									 iStore.iStoreName);
       
   444 			}
       
   445 
       
   446 		SetActive();
       
   447 		}
       
   448 	} // CGetPhoneStoreInfo::PostNotification
       
   449 
       
   450 
       
   451 /**
       
   452  *  Virtual method called by the CActiveNotificationBase class to complete
       
   453  *  the GetPhoneStoreInfo request.
       
   454  *
       
   455  *  @param aRetVal  Result of the notification request.
       
   456  */
       
   457 void CGetPhoneStoreInfo::CompleteNotification(TInt aRetVal)
       
   458 	{
       
   459 	LOGACTIVE2(_L8("CGetPhoneStoreInfo::CompleteNotification(%d)"), aRetVal);
       
   460 
       
   461 	//
       
   462 	// Was this successful???
       
   463 	//
       
   464 	if (aRetVal == KErrNone)
       
   465 		{
       
   466 		//
       
   467 		// PhBkSync cannot deal with phonebooks with no identity as it
       
   468 		// causes later problems with the INI file parsing. So we take
       
   469 		// care of it here before was pass this information to the server.
       
   470 		//
       
   471 		if (Server().IsV5Tsy())
       
   472 			{
       
   473 			if (iStoreInfoV5.iIdentity.Length() == 0)
       
   474 				{
       
   475 				iStoreInfoV5.iIdentity.Copy(KPhonebookIdUnknown);
       
   476 				}
       
   477 				
       
   478 			Server().CompleteGetPhoneStoreInfo(aRetVal, iStoreInfoV5,
       
   479 											   iPhonebookUid);	
       
   480 			}
       
   481 		else if (Server().IsV2Tsy())
       
   482 			{
       
   483 			if (iStoreInfoV2.iIdentity.Length() == 0)
       
   484 				{
       
   485 				iStoreInfoV2.iIdentity.Copy(KPhonebookIdUnknown);
       
   486 				}
       
   487 
       
   488 			Server().CompleteGetPhoneStoreInfo(aRetVal, 
       
   489 											   static_cast<RMobilePhoneBookStore::TMobilePhoneBookInfoV5&>(iStoreInfoV2),
       
   490 											   iPhonebookUid);
       
   491 			}
       
   492 		else
       
   493 			{
       
   494 			if (iStoreInfoV1.iIdentity.Length() == 0)
       
   495 				{
       
   496 				iStoreInfoV1.iIdentity.Copy(KPhonebookIdUnknown);
       
   497 				}
       
   498 
       
   499 			Server().CompleteGetPhoneStoreInfo(aRetVal,
       
   500 											   static_cast<RMobilePhoneBookStore::TMobilePhoneBookInfoV5&>(iStoreInfoV1),
       
   501 											   iPhonebookUid);
       
   502 			}
       
   503 			
       
   504 		if (iAutoSyncRequired)
       
   505 			{
       
   506 			Server().QueueAutoSyncRequest(iPhonebookUid);
       
   507 			}
       
   508 
       
   509 		SelectNextPhonebook();
       
   510 		}
       
   511 	else if (aRetVal == KErrNotFound  ||  aRetVal == KErrCancel  ||
       
   512 		     aRetVal == KErrNotSupported)
       
   513 		{
       
   514 		Server().CompleteGetPhoneStoreInfo(aRetVal, iStoreInfoV5,
       
   515 										   iPhonebookUid);
       
   516 
       
   517 		//
       
   518 		// This will not be retried, so move onto the next phonebook...
       
   519 		//
       
   520 		SelectNextPhonebook();
       
   521 		PostNotification();
       
   522 		}
       
   523 	else
       
   524 		{
       
   525 		//
       
   526 		// This failure will be retried by the CActiveNotificationBase...
       
   527 		//
       
   528 		}
       
   529 	} // CGetPhoneStoreInfo::CompleteNotification
       
   530 
       
   531 
       
   532 /**
       
   533  *  Virtual method called by the CActiveNotificationBase class to cancel
       
   534  *  the GetPhoneStoreInfo request.
       
   535  */
       
   536 void CGetPhoneStoreInfo::CancelNotification()
       
   537 	{
       
   538 	LOGACTIVE1(_L8("CGetPhoneStoreInfo::CancelNotification()"));
       
   539 
       
   540 	iPhone.CancelAsyncRequest(EMobilePhoneGetPhoneStoreInfo);
       
   541 	} // CGetPhoneStoreInfo::CancelNotification
       
   542 
       
   543 
       
   544 /**
       
   545  *  This function triggers a GetPhoneStoreInfo request followed by a sync request.
       
   546  *  It is called when a SAT refresh occurs.
       
   547  *
       
   548  *  @param aPhonebookUid  UID of the ICC phonebook to perform the operation on.
       
   549  */
       
   550 void  CGetPhoneStoreInfo::QueueGetInfoAndSync(TUid aPhonebookUid)
       
   551 	{
       
   552 	LOGACTIVE2(_L8("CGetPhoneStoreInfo::QueueGetInfoAndSync(0x%08x)"), aPhonebookUid);
       
   553 
       
   554 	//
       
   555 	// Store the UID to refresh if it is not in the list and not in progress.
       
   556 	//
       
   557 	if (iPhonebooksToRefresh.Find(aPhonebookUid) == KErrNotFound)
       
   558 		{
       
   559 		if (iPhonebooksToRefresh.Append(aPhonebookUid) != KErrNone)
       
   560 			{
       
   561 			//
       
   562 			// We cannot store this request for later, so best thing is
       
   563 			// is queue a resync now.
       
   564 			//
       
   565 			Server().QueueAutoSyncRequest(aPhonebookUid);
       
   566 			return;
       
   567 			}
       
   568 		}
       
   569 
       
   570 	//
       
   571 	// If the Active Object is currently running, the request will be performed when
       
   572 	// the remaining phonebooks are completed. Otherwise post the notification now.
       
   573 	//
       
   574 	if (!IsActive())
       
   575 		{
       
   576 		SelectNextPhonebook();
       
   577 		PostNotification();
       
   578 		iIsNotificationInProgress = ETrue;
       
   579 		iLastDelay = 0;
       
   580 		}
       
   581 	} // CGetPhoneStoreInfo::QueueGetInfoAndSync
       
   582 
       
   583 
       
   584 /**
       
   585  *  Selects the next phonebook to get the store info for. If no phonebooks
       
   586  *  are left then the iPhonebookUid is set to KUidIccPhonebookNotSpecified.
       
   587  */
       
   588 void CGetPhoneStoreInfo::SelectNextPhonebook()
       
   589 	{
       
   590 	LOGACTIVE1(_L8("CGetPhoneStoreInfo::SelectNextPhonebook()"));
       
   591 
       
   592 	iPhonebookCount++;
       
   593 	
       
   594 	if (iPhonebookCount < iPhonebookManager.GetPhonebookCount())
       
   595 		{
       
   596 		//
       
   597 		// Get the next phonebook UID from the list of phonebooks...
       
   598 		//
       
   599 		LOGACTIVE2(_L8("CGetPhoneStoreInfo::SelectNextPhonebook(): Phonebook %d)"),
       
   600 				   iPhonebookCount);
       
   601 
       
   602 		TInt  result;
       
   603 		
       
   604 		iAutoSyncRequired = EFalse;
       
   605 
       
   606 		result = iPhonebookManager.GetPhonebookUid(iPhonebookCount, iPhonebookUid);
       
   607 		if (result != KErrNone)
       
   608 			{
       
   609 			//
       
   610 			// Not much we can do here!
       
   611 			//
       
   612 			LOGACTIVE2(_L8("CGetPhoneStoreInfo::SelectNextPhonebook(): Error %d!"),
       
   613 					   result);
       
   614 			SelectNextPhonebook();
       
   615 			}
       
   616 		}
       
   617 	else if (iPhonebooksToRefresh.Count() > 0)
       
   618 		{
       
   619 		//
       
   620 		// Get the next phonebook UID from the list of requested refreshes...
       
   621 		//
       
   622 		LOGACTIVE2(_L8("CGetPhoneStoreInfo::SelectNextPhonebook(): Refresh=0x%08x)"),
       
   623 				   iPhonebooksToRefresh[0]);
       
   624 
       
   625 		iPhonebookUid     = iPhonebooksToRefresh[0];
       
   626 		iAutoSyncRequired = ETrue;
       
   627 		iPhonebooksToRefresh.Remove(0);
       
   628 		}
       
   629 	else
       
   630 		{
       
   631 		//
       
   632 		// We are finished...
       
   633 		//
       
   634 		LOGACTIVE1(_L8("CGetPhoneStoreInfo::SelectNextPhonebook(): Finished!"));
       
   635 
       
   636 		iPhonebookUid     = KUidIccPhonebookNotSpecified;
       
   637 		iAutoSyncRequired = EFalse;
       
   638 		}
       
   639 	} // CGetPhoneStoreInfo::SelectNextPhonebook
       
   640 
       
   641 
       
   642 /**
       
   643  *  Standard constructor.  Member variables are initialised.
       
   644  *
       
   645  *  @param aServer  Pointer to the server object.
       
   646  *  @param aPhone   The phone containing the ICC that the server uses.
       
   647  */
       
   648 CNotifyLockInfoChange::CNotifyLockInfoChange(CPhoneBookServer& aServer,
       
   649 											 RMobilePhone& aPhone)
       
   650   : CActiveNotificationBase(aServer),
       
   651     iPhone(aPhone),
       
   652     iLockInfosReceived(0),
       
   653     iLockInfoPckg(iLockInfo)
       
   654 	{
       
   655 	iLockInfo.iSetting = RMobilePhone::ELockSetUnknown;
       
   656 	iLockInfo.iStatus  = RMobilePhone::EStatusLockUnknown;
       
   657 	} // CNotifyLockInfoChange::CNotifyLockInfoChange
       
   658 
       
   659 
       
   660 /**
       
   661  *  Destructor.  Will cancel any pending requests if needed.
       
   662  */
       
   663 CNotifyLockInfoChange::~CNotifyLockInfoChange()
       
   664 	{
       
   665 	LOGACTIVE1(_L8("CNotifyLockInfoChange::~CNotifyLockInfoChange()"));
       
   666 
       
   667 	Cancel();
       
   668 	} // CNotifyLockInfoChange::~CNotifyLockInfoChange
       
   669 
       
   670 
       
   671 /**
       
   672  *  Factory function for creating a CNotifyLockInfoChange object.
       
   673  *
       
   674  *  @param aServer  Pointer to the server object.
       
   675  *  @param aPhone   The phone containing the ICC that the server uses.
       
   676  */
       
   677 CNotifyLockInfoChange* CNotifyLockInfoChange::NewL(CPhoneBookServer& aServer,
       
   678 												   RMobilePhone& aPhone)
       
   679 	{
       
   680 	CNotifyLockInfoChange*  self = new(ELeave) CNotifyLockInfoChange(aServer,
       
   681 																	 aPhone);
       
   682 
       
   683 	return self;
       
   684 	} // CNotifyLockInfoChange::NewL
       
   685 
       
   686 
       
   687 /**
       
   688  *  Virtual method called by the CActiveNotificationBase class to post
       
   689  *  the GetLockInfo or NotifyLockInfoChange request.
       
   690  */
       
   691 void CNotifyLockInfoChange::PostNotification()
       
   692 	{
       
   693 	LOGACTIVE1(_L8("CNotifyLockInfoChange::PostNotification()"));
       
   694 
       
   695 	//
       
   696 	// Either post a GetLockInfo request for the next lock in the list or a
       
   697 	// notify request...
       
   698 	//
       
   699 	if (iLockInfosReceived < KLockInfoNumberOfLocks)
       
   700 		{
       
   701 		iLock = KLockInfoList[iLockInfosReceived];
       
   702 		iPhone.GetLockInfo(iStatus, iLock, iLockInfoPckg);
       
   703 		}
       
   704 	else
       
   705 		{
       
   706 		iPhone.NotifyLockInfoChange(iStatus, iLock, iLockInfoPckg);
       
   707 		}
       
   708 
       
   709 	SetActive();
       
   710 	} // CNotifyLockInfoChange::PostNotification
       
   711 
       
   712 
       
   713 /**
       
   714  *  Virtual method called by the CActiveNotificationBase class to complete
       
   715  *  the GetLockInfo or NotifyLockInfoChange request.
       
   716  *
       
   717  *  @param aRetVal  Result of the notification request.
       
   718  */
       
   719 void CNotifyLockInfoChange::CompleteNotification(TInt aRetVal)
       
   720 	{
       
   721 	LOGACTIVE2(_L8("CNotifyLockInfoChange::CompleteNotification(%d)"), aRetVal);
       
   722 
       
   723 	//
       
   724 	// Was this successful???
       
   725 	//
       
   726 	if (aRetVal == KErrNone)
       
   727 		{
       
   728 		Server().CompleteNotifyLockInfoChange(aRetVal, iLock, iLockInfo);
       
   729 
       
   730 		if (iLockInfosReceived < KLockInfoNumberOfLocks)
       
   731 			{
       
   732 			iLockInfosReceived++;
       
   733 			}
       
   734 		}
       
   735 	else if (aRetVal == KErrNotFound  ||  aRetVal == KErrCancel  ||
       
   736 		     aRetVal == KErrNotSupported)
       
   737 		{
       
   738 		//
       
   739 		// This will not be retried, so move onto the next lock if we are
       
   740 		// still doing the initial list, or otherwise stop...
       
   741 		//
       
   742 		if (iLockInfosReceived < KLockInfoNumberOfLocks)
       
   743 			{
       
   744 			iLockInfosReceived++;
       
   745 			PostNotification();
       
   746 			}
       
   747 		}
       
   748 	else
       
   749 		{
       
   750 		//
       
   751 		// This failure will be retried by the CActiveNotificationBase...
       
   752 		//
       
   753 		}
       
   754 	} // CNotifyLockInfoChange::CompleteNotification
       
   755 
       
   756 
       
   757 /**
       
   758  *  Virtual method called by the CActiveNotificationBase class to cancel
       
   759  *  the GetLockInfo or NotifyLockInfoChange request.
       
   760  */
       
   761 void CNotifyLockInfoChange::CancelNotification()
       
   762 	{
       
   763 	LOGACTIVE1(_L8("CNotifyLockInfoChange::CancelNotification()"));
       
   764 
       
   765 	if (iLockInfosReceived < KLockInfoNumberOfLocks)
       
   766 		{
       
   767 		iPhone.CancelAsyncRequest(EMobilePhoneGetLockInfo);
       
   768 		}
       
   769 	else
       
   770 		{
       
   771 		iPhone.CancelAsyncRequest(EMobilePhoneNotifyLockInfoChange);
       
   772 		}
       
   773 	} // CNotifyLockInfoChange::CancelNotification
       
   774 
       
   775 
       
   776 
       
   777 
       
   778 /**
       
   779  *  Static factory method used to create a CNotifySecurityEvent object.
       
   780  *
       
   781  *  @param aServer  Reference to the front-end server object.
       
   782  *  @param aPhone   Handle to the phone object.
       
   783  *
       
   784  *  @return  Pointer to the created CNotifySecurityEvent object, or NULL.
       
   785  */
       
   786 CNotifySecurityEvent* CNotifySecurityEvent::NewL(CPhoneBookServer& aServer,
       
   787 												 RMobilePhone& aPhone)
       
   788 	{
       
   789 	CNotifySecurityEvent* self = new(ELeave) CNotifySecurityEvent(aServer,
       
   790 																  aPhone);
       
   791 
       
   792 	return self;
       
   793 	} // CPhoneBookNotifySecurityEvent::NewL
       
   794 
       
   795 
       
   796 /**
       
   797  *  Standard constructor.
       
   798  *
       
   799  *  @param aServer  Reference to the front-end server object.
       
   800  *  @param aPhone   Handle to the phone object.
       
   801  */
       
   802 CNotifySecurityEvent::CNotifySecurityEvent(CPhoneBookServer& aServer,
       
   803 										   RMobilePhone& aPhone)
       
   804   : CActiveNotificationBase(aServer),
       
   805     iSecurityEvent(RMobilePhone::ESPCVerified),
       
   806     iPhone(aPhone)
       
   807 	{
       
   808 	// NOP
       
   809 	}
       
   810 
       
   811 
       
   812 /**
       
   813  *  Standard destructor.
       
   814  */
       
   815 CNotifySecurityEvent::~CNotifySecurityEvent()
       
   816 	{
       
   817 	LOGACTIVE1(_L8("CNotifySecurityEvent::~CNotifySecurityEvent()"));
       
   818 
       
   819 	Cancel();
       
   820 	} // CNotifySecurityEvent::CancelNotification
       
   821 
       
   822 
       
   823 /**
       
   824  *  Virtual method called by the CActiveNotificationBase class to post
       
   825  *  the Security Event notification.
       
   826  */
       
   827 void CNotifySecurityEvent::PostNotification()
       
   828 	{
       
   829 	LOGACTIVE1(_L8("CNotifySecurityEvent::PostNotification()"));
       
   830 
       
   831 	iPhone.NotifySecurityEvent(iStatus, iSecurityEvent);
       
   832 	SetActive();
       
   833 	} // CNotifySecurityEvent::PostNotification
       
   834 
       
   835 
       
   836 /**
       
   837  *  Virtual method called by the CActiveNotificationBase class to complete
       
   838  *  the Security Event notification.
       
   839  *
       
   840  *  @param aRetVal  Result of the notification request.
       
   841  */
       
   842 void CNotifySecurityEvent::CompleteNotification(TInt aRetVal)
       
   843 	{
       
   844 	LOGACTIVE2(_L8("CNotifySecurityEvent::CompleteNotification(%d)"), aRetVal);
       
   845 
       
   846 	Server().CompleteNotifySecurityEvent(aRetVal, iSecurityEvent);
       
   847 	} // CNotifySecurityEvent::CompleteNotification
       
   848 
       
   849 
       
   850 /**
       
   851  *  Virtual method called by the CActiveNotificationBase class to cancel
       
   852  *  the Security Event notification.
       
   853  */
       
   854 void CNotifySecurityEvent::CancelNotification()
       
   855 	{
       
   856 	LOGACTIVE1(_L8("CNotifySecurityEvent::CancelNotification()"));
       
   857 
       
   858 	iPhone.CancelAsyncRequest(EMobilePhoneNotifySecurityEvent);
       
   859 	} // CNotifySecurityEvent::CancelNotification
       
   860 
       
   861 
       
   862 
       
   863 
       
   864 /**
       
   865  *  Static factory method used to create a CNotifySATUpdates object.
       
   866  *
       
   867  *  @param aServer  Reference to the front-end server object.
       
   868  *  @param aSat     Handle to the SAT object.
       
   869  *
       
   870  *  @return  Pointer to the created CNotifySATUpdates object, or NULL.
       
   871  */
       
   872 CNotifySATUpdates* CNotifySATUpdates::NewL(CPhoneBookServer& aServer,
       
   873 										   RSat& aSat)
       
   874 	{
       
   875 	CNotifySATUpdates*  self = new(ELeave) CNotifySATUpdates(aServer, aSat);
       
   876 
       
   877 	return self;
       
   878 	} // CPhoneBookNotifySATUpdates::NewL
       
   879 
       
   880 
       
   881 /**
       
   882  *  Standard constructor.
       
   883  *
       
   884  *  @param aServer  Reference to the front-end server object.
       
   885  *  @param aSat     Handle to the SAT object.
       
   886  */
       
   887 CNotifySATUpdates::CNotifySATUpdates(CPhoneBookServer& aServer,
       
   888 									 RSat& aSat)
       
   889   : CActiveNotificationBase(aServer),
       
   890     iRefreshPckgV1(iRefreshV1),
       
   891     iRefreshPckgV2(iRefreshV2),
       
   892     iSat(aSat)
       
   893 	{
       
   894 	// NOP
       
   895 	} // CNotifySATUpdates::CNotifySATUpdates
       
   896 
       
   897 
       
   898 /**
       
   899  *  Standard destructor.
       
   900  */
       
   901 CNotifySATUpdates::~CNotifySATUpdates()
       
   902 	{
       
   903 	LOGACTIVE1(_L8("CNotifySATUpdates::~CNotifySATUpdates()"));
       
   904 
       
   905 	Cancel();
       
   906 	} // CNotifySATUpdates::~CNotifySATUpdates
       
   907 
       
   908 
       
   909 /**
       
   910  *  Virtual method called by the CActiveNotificationBase class to post
       
   911  *  the SAT Update notification.
       
   912  */
       
   913 void CNotifySATUpdates::PostNotification()
       
   914 	{
       
   915 	LOGACTIVE1(_L8("CNotifySATUpdates::PostNotification()"));
       
   916 
       
   917 	if (Server().IsV2Sat())
       
   918 		{
       
   919 		iSat.NotifyRefreshPCmd(iStatus, iRefreshPckgV2); 
       
   920 		}
       
   921 	else
       
   922 		{
       
   923 		iSat.NotifyRefreshPCmd(iStatus, iRefreshPckgV1); 
       
   924 		}
       
   925 
       
   926 	SetActive();
       
   927 	} // CNotifySATUpdates::PostNotification
       
   928 
       
   929 
       
   930 /**
       
   931  *  Virtual method called by the CActiveNotificationBase class to complete
       
   932  *  the SAT Update notification.
       
   933  *
       
   934  *  @param aRetVal  Result of the notification request.
       
   935  */
       
   936 void CNotifySATUpdates::CompleteNotification(TInt aRetVal)
       
   937 	{
       
   938 	LOGACTIVE2(_L8("CNotifySATUpdates::CompleteNotification(%d)"), aRetVal);
       
   939 
       
   940 	//
       
   941 	// Work out the affected phonebooks and whether an update is required...
       
   942 	//
       
   943 	RSat::TRefreshType  refreshType(RSat::ERefreshTypeNotSet);
       
   944 	RArray<TUid>  phonebookList;
       
   945 
       
   946 	if (aRetVal == KErrNone)
       
   947 		{
       
   948 		if (Server().IsV2Sat())
       
   949 			{
       
   950 			for (TInt index = 0;  index < iRefreshV2.iFileList.Length();  index++)
       
   951 				{
       
   952 				if (iRefreshV2.iFileList[index] == RSat::KAdnEf  ||
       
   953 					iRefreshV2.iFileList[index] == RSat::KExt1Ef)
       
   954 					{
       
   955 					phonebookList.Append(KUidIccGlobalAdnPhonebook);
       
   956 					}
       
   957 				else if (iRefreshV2.iFileList[index] == RSat::KSdnEf)
       
   958 					{
       
   959 					phonebookList.Append(KUidIccGlobalSdnPhonebook);
       
   960 					}
       
   961 				else if (iRefreshV2.iFileList[index] == RSat::KLndEf)
       
   962 					{
       
   963 					phonebookList.Append(KUidIccGlobalLndPhonebook);
       
   964 					}
       
   965 				else if (iRefreshV2.iFileList[index] == RSat::KGmsi  ||
       
   966 						 iRefreshV2.iFileList[index] == RSat::KDirEf ||
       
   967 						 iRefreshV2.iFileList[index] == RSat::KHiddenKeyEf)
       
   968 					{
       
   969 					phonebookList.Append(KUidUsimAppAdnPhonebook);
       
   970 					}
       
   971 				else if (iRefreshV2.iFileList[index] == RSat::KFdnEf)
       
   972 					{
       
   973 					phonebookList.Append(KUidIccGlobalFdnPhonebook);
       
   974 					}
       
   975 				}
       
   976 
       
   977 			refreshType = iRefreshV2.iType;
       
   978 			}
       
   979 		else
       
   980 			{
       
   981 			for (TInt index = 0;  index < iRefreshV1.iFileList.Length();  index++)
       
   982 				{
       
   983 				if (iRefreshV1.iFileList[index] == RSat::KAdnEf  ||
       
   984 					iRefreshV1.iFileList[index] == RSat::KExt1Ef)
       
   985 					{
       
   986 					phonebookList.Append(KUidIccGlobalAdnPhonebook);
       
   987 					}
       
   988 				}
       
   989 
       
   990 			refreshType = iRefreshV1.iType;
       
   991 			}
       
   992 		}
       
   993 
       
   994 	//
       
   995 	// Pass the information to the server...
       
   996 	//
       
   997 	Server().CompleteNotifySATUpdates(aRetVal, refreshType, phonebookList);
       
   998 
       
   999 	phonebookList.Close();
       
  1000 	} // CNotifySATUpdates::CompleteNotification
       
  1001 
       
  1002 
       
  1003 /**
       
  1004  *  Virtual method called by the CActiveNotificationBase class to cancel
       
  1005  *  the SAT Update notification.
       
  1006  */
       
  1007 void CNotifySATUpdates::CancelNotification()
       
  1008 	{
       
  1009 	LOGACTIVE1(_L8("CNotifySATUpdates::CancelNotification()"));
       
  1010 
       
  1011 	iSat.CancelAsyncRequest(ESatNotifyRefreshPCmd);
       
  1012 	} // CNotifySATUpdates::CancelNotification
       
  1013 
       
  1014 
       
  1015 
       
  1016 
       
  1017 /**
       
  1018  *  Static factory method used to create a CNotifyAppInfoChange object.
       
  1019  *
       
  1020  *  @param aServer  Reference to the front-end server object.
       
  1021  *  @param aPhone   Handle to the ETel Phone object.
       
  1022  *
       
  1023  *  @return  Pointer to the created CNotifyAppInfoChange object, or NULL.
       
  1024  */
       
  1025 CNotifyAppInfoChange* CNotifyAppInfoChange::NewL(CPhoneBookServer& aServer,
       
  1026 												 RMobilePhone& aPhone)
       
  1027 	{
       
  1028 	CNotifyAppInfoChange*  self = new(ELeave) CNotifyAppInfoChange(aServer,
       
  1029 																   aPhone);
       
  1030 
       
  1031 	return self;
       
  1032 	} // CNotifyAppInfoChange::NewL
       
  1033 
       
  1034 
       
  1035 /**
       
  1036  *  Standard constructor.
       
  1037  *
       
  1038  *  @param aServer  Reference to the front-end server object.
       
  1039  *  @param aPhone   Handle to the ETel Phone object.
       
  1040  */
       
  1041 CNotifyAppInfoChange::CNotifyAppInfoChange(CPhoneBookServer& aServer,
       
  1042 										   RMobilePhone& aPhone)
       
  1043   : CActiveNotificationBase(aServer),
       
  1044     iPhone(aPhone),
       
  1045     iReceivedInitialValue(EFalse),
       
  1046     iAppCount(0)
       
  1047 	{
       
  1048 	// NOP
       
  1049 	} // CNotifyAppInfoChange::CNotifyAppInfoChange
       
  1050 
       
  1051 
       
  1052 /**
       
  1053  *  Standard destructor.
       
  1054  */
       
  1055 CNotifyAppInfoChange::~CNotifyAppInfoChange()
       
  1056 	{
       
  1057 	LOGACTIVE1(_L8("CNotifyAppInfoChange::~CNotifyAppInfoChange()"));
       
  1058 
       
  1059 	Cancel();
       
  1060 	} // CNotifyAppInfoChange::~CNotifyAppInfoChange
       
  1061 
       
  1062 
       
  1063 /**
       
  1064  *  Virtual method called by the CActiveNotificationBase class to post
       
  1065  *  the SAT Update notification.
       
  1066  */
       
  1067 void CNotifyAppInfoChange::PostNotification()
       
  1068 	{
       
  1069 	LOGACTIVE1(_L8("CNotifyAppInfoChange::PostNotification()"));
       
  1070 
       
  1071 	if (iReceivedInitialValue == EFalse)
       
  1072 		{
       
  1073 		iPhone.EnumerateUSimApplications(iStatus, iAppCount, iActiveAID);
       
  1074 		}
       
  1075 	else
       
  1076 		{
       
  1077 		iPhone.NotifyUSimApplicationsInfoChange(iStatus, iAppCount, iActiveAID);
       
  1078 		}
       
  1079 
       
  1080 	SetActive();
       
  1081 	} // CNotifyAppInfoChange::PostNotification
       
  1082 
       
  1083 
       
  1084 /**
       
  1085  *  Virtual method called by the CActiveNotificationBase class to complete
       
  1086  *  the SAT Update notification.
       
  1087  *
       
  1088  *  @param aRetVal  Result of the notification request.
       
  1089  */
       
  1090 void CNotifyAppInfoChange::CompleteNotification(TInt aRetVal)
       
  1091 	{
       
  1092 	LOGACTIVE2(_L8("CNotifyAppInfoChange::CompleteNotification(%d)"), aRetVal);
       
  1093 
       
  1094 	if (iReceivedInitialValue == EFalse)
       
  1095 		{
       
  1096 		Server().CompleteNotifyAppInfoChange(aRetVal, ETrue, iActiveAID);
       
  1097 		iReceivedInitialValue = ETrue;
       
  1098 		}
       
  1099 	else
       
  1100 		{
       
  1101 		Server().CompleteNotifyAppInfoChange(aRetVal, EFalse, iActiveAID);
       
  1102 		}
       
  1103 	} // CNotifyAppInfoChange::CompleteNotification
       
  1104 
       
  1105 
       
  1106 /**
       
  1107  *  Virtual method called by the CActiveNotificationBase class to cancel
       
  1108  *  the SAT Update notification.
       
  1109  */
       
  1110 void CNotifyAppInfoChange::CancelNotification()
       
  1111 	{
       
  1112 	LOGACTIVE1(_L8("CNotifySATUpdates::CancelNotification()"));
       
  1113 
       
  1114 	if (iReceivedInitialValue == EFalse)
       
  1115 		{
       
  1116 		iPhone.CancelAsyncRequest(EMobilePhoneEnumerateUSimApplications);
       
  1117 		}
       
  1118 	else
       
  1119 		{
       
  1120 		iPhone.CancelAsyncRequest(EMobilePhoneNotifyUSimApplicationsInfoChange);
       
  1121 		}
       
  1122 	} // CNotifyAppInfoChange::CancelNotification
       
  1123 
       
  1124 
       
  1125 
       
  1126 
       
  1127 /**
       
  1128  *  Static factory method used to create a CNotifyBackupAndRestore object.
       
  1129  *
       
  1130  *  @param aServer  Reference to the front-end server object.
       
  1131  *
       
  1132  *  @return  Pointer to the created CNotifyBackupAndRestore object, or NULL.
       
  1133  */
       
  1134 CNotifyBackupAndRestore* CNotifyBackupAndRestore::NewL(CPhoneBookServer& aServer)
       
  1135  	{
       
  1136  	CNotifyBackupAndRestore*  self = new(ELeave) CNotifyBackupAndRestore(aServer);
       
  1137  	CleanupStack::PushL(self);
       
  1138  	self->ConstructL();
       
  1139  	CleanupStack::Pop(self);
       
  1140 
       
  1141  	return self;
       
  1142  	} // CBackupAndRestore::NewL
       
  1143  
       
  1144  
       
  1145 /**
       
  1146  *  Standard constructor.
       
  1147  *
       
  1148  *  @param aServer  Reference to the front-end server object.
       
  1149  */
       
  1150 CNotifyBackupAndRestore::CNotifyBackupAndRestore(CPhoneBookServer& aServer)
       
  1151   : CActiveNotificationBase(aServer)
       
  1152  	{
       
  1153  	// NOP
       
  1154  	} // CNotifyBackupAndRestore::CNotifyBackupAndRestore
       
  1155  
       
  1156  
       
  1157 /**
       
  1158  *  Second phase constructor.
       
  1159  */
       
  1160 void CNotifyBackupAndRestore::ConstructL()
       
  1161  	{
       
  1162 	User::LeaveIfError(iBackupProperty.Attach(KUidSystemCategory,
       
  1163 											  KUidBackupRestoreKey));
       
  1164  	} // CNotifyBackupAndRestore::ConstructL
       
  1165  
       
  1166  
       
  1167 /**
       
  1168  *  Standard destructor.
       
  1169  */
       
  1170 CNotifyBackupAndRestore::~CNotifyBackupAndRestore()
       
  1171  	{
       
  1172 	LOGACTIVE1(_L8("CNotifyBackupAndRestore::~CNotifyBackupAndRestore()"));
       
  1173 
       
  1174  	Cancel();
       
  1175 
       
  1176  	iBackupProperty.Close();
       
  1177  	} // CNotifyBackupAndRestore::~CNotifyBackupAndRestore
       
  1178 
       
  1179 
       
  1180 /**
       
  1181  *  Virtual method called by the CActiveNotificationBase class to post
       
  1182  *  the Secure Backup notification.
       
  1183  */
       
  1184 void CNotifyBackupAndRestore::PostNotification()
       
  1185 	{
       
  1186 	LOGACTIVE1(_L8("CNotifyBackupAndRestore::PostNotification()"));
       
  1187 
       
  1188  	iBackupProperty.Subscribe(iStatus);
       
  1189 	SetActive();
       
  1190 	} // CNotifyBackupAndRestore::PostNotification
       
  1191 
       
  1192 
       
  1193 /**
       
  1194  *  Virtual method called by the CActiveNotificationBase class to complete
       
  1195  *  the Secure Backup notification.
       
  1196  *
       
  1197  *  @param aRetVal  Result of the notification request.
       
  1198  */
       
  1199 void CNotifyBackupAndRestore::CompleteNotification(TInt aRetVal)
       
  1200 	{
       
  1201 	LOGACTIVE2(_L8("CNotifyBackupAndRestore::CompleteNotification(%d)"), aRetVal);
       
  1202 
       
  1203 	if (aRetVal == KErrNone)
       
  1204 		{
       
  1205 		//
       
  1206 		// Get the property value.  The last byte contains backup and restore
       
  1207 		// data of interest to us. Re-subscribe straight away!
       
  1208 		//
       
  1209 	 	TInt  backupRestoreFlag;
       
  1210 
       
  1211 	 	iBackupProperty.Get(backupRestoreFlag);
       
  1212 	 	
       
  1213 		LOGACTIVE2(_L8("CNotifyBackupAndRestore::RunL() backupRestoreFlag=0x%08x"),
       
  1214 				   backupRestoreFlag);
       
  1215 		
       
  1216 		//
       
  1217 		// Handle the property value...
       
  1218 		//
       
  1219 		if (backupRestoreFlag & EBURNormal)
       
  1220 			{
       
  1221 			Server().HandleBackupOrRestoreComplete();
       
  1222 			}
       
  1223 		else if (backupRestoreFlag & EBURBackupFull  ||
       
  1224 				 backupRestoreFlag & EBURBackupPartial  ||
       
  1225 				 backupRestoreFlag & EBURRestoreFull  ||
       
  1226 				 backupRestoreFlag & EBURRestorePartial)
       
  1227 			{
       
  1228 			Server().HandleBackupOrRestoreStarting();
       
  1229 			}
       
  1230 		}
       
  1231 	} // CNotifyBackupAndRestore::CompleteNotification
       
  1232 
       
  1233 
       
  1234 /**
       
  1235  *  Virtual method called by the CActiveNotificationBase class to cancel
       
  1236  *  the Secure Backup notification.
       
  1237  */
       
  1238 void CNotifyBackupAndRestore::CancelNotification()
       
  1239 	{
       
  1240 	LOGACTIVE1(_L8("CNotifyBackupAndRestore::CancelNotification()"));
       
  1241 
       
  1242 	iBackupProperty.Cancel();
       
  1243 	} // CNotifyBackupAndRestore::CancelNotification
       
  1244