syncmlfw/syncmlnotifier/src/SyncMLAppLaunchNotifier.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 to parse the server alert messages for data sync and device
       
    15 *                Management frameworks. Launches respective application 
       
    16 *                in appropriate conditions
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <eikenv.h>          // Eikon environment
       
    24 #include <AknQueryDialog.h>
       
    25 #include <StringLoader.h>    // Localisation stringloader
       
    26 #include <SyncMLClientDS.h>
       
    27 #include <SyncMLClientDM.h>
       
    28 #include <SyncMLClient.h>
       
    29 #include <rconnmon.h>
       
    30 #include <centralrepository.h>
       
    31 #include <SyncMLNotifierDomainCRKeys.h>
       
    32 #include <SyncMLNotifier.rsg>           // Own resources
       
    33 #include "SyncMLAppLaunchNotifier.h"    // Class declaration
       
    34 #include "SyncMLTimedMessageQuery.h"
       
    35 #include "SyncMLTimedQueryDialog.h"
       
    36 #include "SyncMLNotifDebug.h"
       
    37 #include <aknnotewrappers.h>
       
    38 #include <DevManInternalCRKeys.h>
       
    39 #include "nsmlconstantdefs.h"
       
    40 
       
    41 
       
    42 // CONSTANTS
       
    43 _LIT( KSmlNPanicCategory, "SyncMLNotifier");
       
    44 
       
    45 // medium type uids
       
    46 //const TUid KUidNSmlMediumTypeInternet  = { 0x101F99F0 };
       
    47 const TUid KUidNSmlMediumTypeBluetooth = { 0x101F99F1 };
       
    48 const TUid KUidNSmlMediumTypeUSB       = { 0x101F99F2 };
       
    49 const TUid KUidNSmlMediumTypeIrDA      = { 0x101F99F3 };
       
    50 
       
    51 
       
    52 enum TASpBearerType
       
    53     {
       
    54     EAspBearerInternet = 0,
       
    55     EAspBearerUsb = 1,
       
    56     EAspBearerBlueTooth = 2,
       
    57     EAspBearerIrda = 3,
       
    58     EAspBearerWsp = 4,
       
    59     EAspBearerSmlUsb = 5,
       
    60     EAspBearerLast = 6
       
    61     };
       
    62 
       
    63 // ============================ MEMBER FUNCTIONS ===============================
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CSyncMLAppLaunchNotifier::CSyncMLAppLaunchNotifier
       
    67 // C++ default constructor can NOT contain any code, that
       
    68 // might leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 CSyncMLAppLaunchNotifier::CSyncMLAppLaunchNotifier() :
       
    72     iAlwaysAsk( EFalse )
       
    73     {
       
    74     iBearerType = KErrNotFound;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CSyncMLDSNotifier::NewL
       
    79 // Two-phased constructor.
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 CSyncMLAppLaunchNotifier* CSyncMLAppLaunchNotifier::NewL()
       
    83     {
       
    84     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::NewL()"));
       
    85     CSyncMLAppLaunchNotifier* self = new (ELeave) CSyncMLAppLaunchNotifier();
       
    86     CleanupStack::PushL( self );
       
    87     self->ConstructL();
       
    88     CleanupStack::Pop( self );
       
    89     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::NewL() completed"));
       
    90     return self;
       
    91     }
       
    92 
       
    93     
       
    94 // -----------------------------------------------------------------------------
       
    95 // Destructor
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 CSyncMLAppLaunchNotifier::~CSyncMLAppLaunchNotifier()
       
    99     {
       
   100     delete iDMSyncService;
       
   101     delete iDSSyncService;
       
   102     Cancel();   // Free own resources
       
   103     }
       
   104 
       
   105 // -----------------------------------------------------------------------------
       
   106 // CSyncMLAppLaunchNotifier::RetrieveSyncParams
       
   107 // Leaves if the job identifier is not found.
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CSyncMLAppLaunchNotifier::RetrieveSyncParamsL(
       
   111     TSyncServiceParam& aParam,
       
   112     TDes& aServerName,
       
   113     TSmlServerAlertedAction& aUserInteraction )
       
   114     {
       
   115     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveSyncParamsL()"));
       
   116     TSmlJobId currentJobId;
       
   117     TSmlUsageType usageType;
       
   118     
       
   119     // sync session
       
   120     RSyncMLSession syncSession;
       
   121     syncSession.OpenL();
       
   122     CleanupClosePushL( syncSession );
       
   123     syncSession.CurrentJobL( currentJobId, usageType );
       
   124 
       
   125     if ( currentJobId == iJobId &&
       
   126          usageType == ESmlDataSync )
       
   127         {
       
   128         RSyncMLDataSyncProfile syncProfile;
       
   129         syncProfile.OpenL( syncSession, iProfileId, ESmlOpenRead );
       
   130         CleanupClosePushL( syncProfile );
       
   131         
       
   132         aParam.iProfileId = iProfileId;
       
   133         aParam.iJobId = iJobId;
       
   134         aServerName = syncProfile.DisplayName();
       
   135         aUserInteraction = syncProfile.SanUserInteraction();
       
   136         
       
   137         // Check if always ask is selected as accesspoint
       
   138         RSyncMLConnection connection;
       
   139         TRAPD( iapError, connection.OpenL( syncProfile, KUidNSmlMediumTypeInternet.iUid ) );
       
   140         CleanupClosePushL( connection );
       
   141 
       
   142         if ( !iapError )
       
   143             {
       
   144             const TDesC8& iap = connection.GetPropertyL( KNSmlIAPId );
       
   145             if ( iap.Compare( KNSmlAlwaysAsk() ) == 0 )
       
   146                 {
       
   147                 iAlwaysAsk = ETrue;
       
   148                 }            
       
   149             
       
   150             TInt id = connection.Identifier();
       
   151             if (id == KUidNSmlMediumTypeInternet.iUid)
       
   152                 {
       
   153                 iBearerType = EAspBearerInternet;
       
   154                 }
       
   155             else if (id == KUidNSmlMediumTypeBluetooth.iUid)
       
   156                 {
       
   157                 iBearerType = EAspBearerBlueTooth;
       
   158                 }
       
   159             else if (id == KUidNSmlMediumTypeUSB.iUid)
       
   160                 {
       
   161                 iBearerType = EAspBearerUsb;
       
   162                 }
       
   163             else if (id == KUidNSmlMediumTypeIrDA.iUid)
       
   164                 {
       
   165                 iBearerType = EAspBearerIrda;
       
   166                 }
       
   167             else
       
   168                 {
       
   169                 iBearerType = KErrNotFound;
       
   170                 }            
       
   171             }
       
   172 
       
   173         connection.Close();
       
   174         CleanupStack::Pop( &connection );
       
   175         
       
   176         syncProfile.Close();
       
   177         CleanupStack::Pop( &syncProfile );
       
   178         }
       
   179     else
       
   180         {
       
   181         FTRACE( FPrint(
       
   182             _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveSyncParamsL() Could not find job %d"),
       
   183             iJobId ) );
       
   184         User::Leave( KErrNotFound );
       
   185         }
       
   186     
       
   187     syncSession.Close();
       
   188     CleanupStack::Pop( &syncSession );
       
   189 
       
   190     FTRACE( FPrint(
       
   191         _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveSyncParamsL() completed, aServerName = \"%S\""),
       
   192         &aServerName ) );
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL
       
   197 // Leaves if the job identifier is not found.
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 void CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL(
       
   201     TSyncServiceParam& aParam,
       
   202     TDes& aServerName,
       
   203     TSmlServerAlertedAction& aUserInteraction )
       
   204     {
       
   205     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL()"));
       
   206 
       
   207     TSmlJobId currentJobId;
       
   208     TSmlUsageType usageType;
       
   209     
       
   210     RSyncMLSession syncSession;
       
   211     
       
   212     syncSession.OpenL();
       
   213     CleanupClosePushL( syncSession );
       
   214     
       
   215     syncSession.CurrentJobL( currentJobId, usageType );
       
   216     
       
   217     if ( currentJobId == iJobId &&
       
   218          usageType == ESmlDevMan )
       
   219         {
       
   220         RSyncMLDevManProfile syncProfile;
       
   221         syncProfile.OpenL( syncSession, iProfileId, ESmlOpenRead );
       
   222         CleanupClosePushL( syncProfile );
       
   223         
       
   224         aParam.iProfileId = iProfileId;
       
   225         aParam.iJobId = iJobId;
       
   226         aServerName = syncProfile.DisplayName();
       
   227         aUserInteraction = syncProfile.SanUserInteraction();
       
   228         
       
   229         // Check if always ask is selected as accesspoint
       
   230         RSyncMLConnection connection;
       
   231         TRAPD( iapError, connection.OpenL( syncProfile, KUidNSmlMediumTypeInternet.iUid ) );
       
   232         CleanupClosePushL( connection );
       
   233 
       
   234         if ( !iapError )
       
   235             {
       
   236             const TDesC8& iap = connection.GetPropertyL( KNSmlIAPId );
       
   237             if ( iap.Compare( KNSmlAlwaysAsk() ) == 0 )
       
   238                 {
       
   239                 iAlwaysAsk = ETrue;
       
   240                 }            
       
   241             }
       
   242 
       
   243         connection.Close();
       
   244         CleanupStack::Pop( &connection );
       
   245         
       
   246         syncProfile.Close();
       
   247         CleanupStack::Pop( &syncProfile );
       
   248         }
       
   249     else
       
   250         {
       
   251         FTRACE( FPrint(
       
   252             _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL() Could not find job %d"),
       
   253             iJobId ) );
       
   254         User::Leave( KErrNotFound );
       
   255         }
       
   256     
       
   257     syncSession.Close();
       
   258     CleanupStack::Pop( &syncSession );
       
   259 
       
   260     FTRACE( FPrint(
       
   261         _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RetrieveMgmtParamsL() completed, aServerName = \"%S\""),
       
   262         &aServerName ) );
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // CSyncMLAppLaunchNotifier::IsSilent
       
   267 // Only automatic acception from the profile is checked, since notifier has no
       
   268 // information about the preferences included in the server alert.
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 TBool CSyncMLAppLaunchNotifier::IsSilent(
       
   272     TSmlServerAlertedAction& aUserInteraction )
       
   273     {
       
   274     TBool retval = EFalse;
       
   275     if ( aUserInteraction == ESmlEnableSync )
       
   276         {
       
   277         retval = ETrue;
       
   278         }
       
   279     return retval;
       
   280     }
       
   281     
       
   282 // -----------------------------------------------------------------------------
       
   283 // CSyncMLAppLaunchNotifier::RegisterL
       
   284 // -----------------------------------------------------------------------------
       
   285 //
       
   286 CSyncMLAppLaunchNotifier::TNotifierInfo CSyncMLAppLaunchNotifier::RegisterL()
       
   287     {
       
   288     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RegisterL()"));
       
   289     iInfo.iUid = KSyncMLAppLaunchNotifierUid;
       
   290     iInfo.iChannel = KSmlAppLaunchChannel;
       
   291     iInfo.iPriority = ENotifierPriorityVHigh;
       
   292     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RegisterL() completed"));
       
   293     return iInfo;
       
   294     }
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 // CSyncMLAppLaunchNotifier::Cancel
       
   298 // Release all own resources (member variables)
       
   299 // -----------------------------------------------------------------------------
       
   300 //
       
   301 void CSyncMLAppLaunchNotifier::Cancel()
       
   302     {
       
   303     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::Cancel()"));
       
   304 
       
   305     CSyncMLNotifierBase::Cancel();
       
   306 
       
   307     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::Cancel() completed"));
       
   308     }
       
   309 
       
   310 // -----------------------------------------------------------------------------
       
   311 // CSyncMLAppLaunchNotifier::GetParamsL
       
   312 // Initialize parameters and check if device is already
       
   313 // in registry. Jump to RunL as soon as possible.
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 void CSyncMLAppLaunchNotifier::GetParamsL( const TDesC8& aBuffer,
       
   317                                                  TInt aReplySlot,
       
   318                                            const RMessagePtr2& aMessage )
       
   319     {
       
   320     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::GetParamsL()"));
       
   321 
       
   322     if( iReplySlot != NULL || iNeedToCompleteMessage )
       
   323         {
       
   324         User::Leave( KErrInUse );
       
   325         }
       
   326     
       
   327     iMessage = aMessage;
       
   328     iNeedToCompleteMessage = ETrue;
       
   329     iReplySlot = aReplySlot;
       
   330     iAlwaysAsk = EFalse;
       
   331 
       
   332 	TSyncMLAppLaunchNotifParams param;
       
   333  	TPckgC<TSyncMLAppLaunchNotifParams> pckg( param );
       
   334  	pckg.Set(aBuffer);
       
   335 
       
   336     iSmlProtocol = pckg().iSessionType;
       
   337     iJobId = pckg().iJobId;
       
   338     iProfileId = pckg().iProfileId;
       
   339  TInt SanSupport( KErrNone );
       
   340 CRepository* centrep = NULL;
       
   341     TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys) );    
       
   342     User::LeaveIfError( err );
       
   343     centrep->Get( KDevManSANUIBitVariation, SanSupport );
       
   344     delete centrep;
       
   345 	if( SanSupport == EON )
       
   346    	{
       
   347      iUimode = pckg().iUimode;
       
   348    	}    
       
   349     // Call SetActive() so RunL() will be called by the active scheduler
       
   350     //
       
   351     SetActive();
       
   352     iStatus = KRequestPending;
       
   353     TRequestStatus* stat = &iStatus;
       
   354     User::RequestComplete( stat, KErrNone );
       
   355 
       
   356     FTRACE( FPrint(
       
   357         _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::GetParamsL() completed, iSmlProtocol = %d, iJobId = %d, iProfileId = %d"),
       
   358         iSmlProtocol, iJobId, iProfileId ) );
       
   359     }
       
   360 
       
   361 // -----------------------------------------------------------------------------
       
   362 // CAspSyncHandler::ReadRepositoryL
       
   363 //
       
   364 // -----------------------------------------------------------------------------
       
   365 //
       
   366 void CSyncMLAppLaunchNotifier::ReadRepositoryL(TInt aKey, TInt& aValue)
       
   367     {
       
   368     CRepository* rep = CRepository::NewLC(KCRUidNSmlDSApp);
       
   369     TInt err = rep->Get(aKey, aValue);
       
   370     User::LeaveIfError(err);
       
   371     
       
   372     CleanupStack::PopAndDestroy(rep);
       
   373     }
       
   374 
       
   375 // -----------------------------------------------------------------------------
       
   376 // CSyncMLAppLaunchNotifier::RunL
       
   377 // Ask user response and return it to caller.
       
   378 // -----------------------------------------------------------------------------
       
   379 //
       
   380 void CSyncMLAppLaunchNotifier::RunL()
       
   381     {
       
   382     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL()"));
       
   383 		stringholder =NULL;
       
   384 		centrep = NULL;
       
   385     TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys) );    
       
   386     if(err)
       
   387     {
       
   388     	centrep = NULL;
       
   389     }
       
   390 
       
   391     TLanguage language = User::Language();  
       
   392     // Load the parameters and set the query text according to the session type.
       
   393     switch( iSmlProtocol )
       
   394         {
       
   395         case ESyncMLSyncSession:
       
   396             {
       
   397             FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() Synchronisation session") );
       
   398 
       
   399             TBuf<KSyncMLMaxProfileNameLength> serverName;
       
   400             RetrieveSyncParamsL( param, serverName, uiAction );
       
   401             stringholder = StringLoader::LoadL( R_SML_INIT_DS_SERVER_PROMPT,
       
   402                                                 serverName );
       
   403             }
       
   404 			break;
       
   405         case ESyncMLMgmtSession:
       
   406             {
       
   407             	TBool status = HandleDMSessionL();
       
   408             	if( !status )
       
   409             		return;
       
   410             }
       
   411             break;
       
   412         default: // Unknown value
       
   413             {
       
   414             FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() unknown protocol value"));
       
   415             User::Leave( KErrArgument ); // Leave handling completes the message
       
   416             return;
       
   417             }
       
   418         }
       
   419 
       
   420     CleanupStack::PushL( stringholder );
       
   421 
       
   422     TInt keypress( 0 );
       
   423     TBool  silent = EFalse;
       
   424 		TInt SanSupport( KErrNone ),Timeout( KErrNone),CustomNotes(KErrNone);;
       
   425     if(centrep)
       
   426     {centrep->Get( KDevManSANUIBitVariation, SanSupport );
       
   427      centrep->Get( KDevManServerAlertTimeout, Timeout );
       
   428      centrep->Get( KDevManUINotesCustomization, CustomNotes);	
       
   429     }
       
   430     else
       
   431     {
       
   432     	  SanSupport = KErrNone;
       
   433         Timeout = KDefaultTimeoutforNotes; 
       
   434         CustomNotes = KErrNone ;
       
   435     }   
       
   436     Timeout = Timeout * 60 ;// converting to mins
       
   437     delete centrep;
       
   438 		if(( SanSupport == EON )&& ( iSmlProtocol == ESyncMLMgmtSession))
       
   439    	{
       
   440     if( iUimode > ESANUserInteractive && iUimode < ESANNotSpecified )
       
   441     	{
       
   442     	iUimode = ESANNotSpecified;
       
   443     	}
       
   444     switch( iUimode ) 	
       
   445     	{
       
   446     		case ESANNotSpecified://not specified
       
   447     		case ESANUserInteractive://user interactive session
       
   448     		      silent = EFalse;    		      
       
   449     		      break;
       
   450     		case ESANSilent://Background
       
   451     		case ESANUserInformative://Informative session
       
   452     		      silent =  ETrue;//IsSilent( uiAction );     		      
       
   453     		      break;  
       
   454     	}
       
   455    }
       
   456    else
       
   457        {
       
   458        	silent =  IsSilent( uiAction );
       
   459        }
       
   460     if ( iAlwaysAsk && iSmlProtocol == ESyncMLMgmtSession )	//check with synergy    
       
   461     	{
       
   462     	silent = EFalse;
       
   463     	}
       
   464     if ( !silent || iAlwaysAsk )
       
   465         {
       
   466         // Turn lights on and deactivate apps -key
       
   467         TurnLightsOn();  
       
   468         SuppressAppSwitching( ETrue );
       
   469 
       
   470         CSyncMLTimedQueryDialog* dlg =
       
   471                 CSyncMLTimedQueryDialog::NewL( *stringholder,
       
   472                                                Timeout );    
       
   473             
       
   474         // Pushed dialog is popped inside RunLD
       
   475         dlg->PrepareLC( R_SML_CONFIRMATION_QUERY );
       
   476         
       
   477         	dlg->ButtonGroupContainer().SetCommandSetL(
       
   478         	        					R_AVKON_SOFTKEYS_YES_NO__YES );
       
   479         keypress = dlg->RunLD();
       
   480         dlg = NULL;
       
   481         // Activate apps -key again
       
   482         //
       
   483         SuppressAppSwitching( EFalse );
       
   484         }
       
   485 
       
   486     CleanupStack::PopAndDestroy( stringholder );
       
   487     
       
   488     if ( iNeedToCompleteMessage ) // Notifier is not cancelled
       
   489         {
       
   490         	HandleCompleteMessageL(keypress, silent, SanSupport, Timeout, CustomNotes);
       
   491         }
       
   492 
       
   493     iNeedToCompleteMessage = EFalse;
       
   494     iReplySlot = NULL;
       
   495 
       
   496     iSmlProtocol = ESyncMLUnknownSession;
       
   497     iJobId = 0;
       
   498 
       
   499     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() completed"));
       
   500     }
       
   501 
       
   502 // -----------------------------------------------------------------------------
       
   503 // CSyncMLNotifierBase::SyncServiceL
       
   504 // -----------------------------------------------------------------------------
       
   505 //
       
   506 CSyncService* CSyncMLAppLaunchNotifier::SyncServiceL( TUint aServiceId )
       
   507     {
       
   508     FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::SyncService"));
       
   509 
       
   510     if ( aServiceId == KDevManServiceStart )
       
   511         {
       
   512         if ( !iDMSyncService )
       
   513             {
       
   514             FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::SyncServiceL() DM NewL"));
       
   515             iDMSyncService = CSyncService::NewL( NULL, KDevManServiceStart );
       
   516             }
       
   517         return iDMSyncService;
       
   518         }
       
   519     else
       
   520         {
       
   521         if ( !iDSSyncService )
       
   522             {
       
   523             FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::SyncServiceL() DS NewL"));
       
   524             iDSSyncService = CSyncService::NewL( NULL, KDataSyncServiceStart );
       
   525             }
       
   526         return iDSSyncService;
       
   527         }
       
   528     }
       
   529 //------------------------------------------------------------------------------
       
   530 //CSyncMLAppLaunchNotifier::IsRoaming(TBool& ret)
       
   531 //Returns true if roaming otherwise returns false
       
   532  
       
   533 //------------------------------------------------------------------------------
       
   534 
       
   535 void CSyncMLAppLaunchNotifier::IsRoamingL(TBool &ret)
       
   536 	{
       
   537 	  FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoaming() Begin"));
       
   538 		RConnectionMonitor monitor;
       
   539 	  TRequestStatus status;
       
   540 		// open RConnectionMonitor object
       
   541 		monitor.ConnectL();
       
   542 		CleanupClosePushL( monitor );
       
   543 		TInt netwStatus(0);
       
   544 		monitor.GetIntAttribute( EBearerIdGPRS, // See bearer ids from TConnMonBearerId
       
   545 	                         0, 
       
   546 	                         KNetworkRegistration,
       
   547 	                         netwStatus, 
       
   548 	                         status );
       
   549 	  User::WaitForRequest( status );
       
   550 	  if ( status.Int() == KErrNone )
       
   551 	 	   {
       
   552 				switch(netwStatus)
       
   553 				{
       
   554 					case ENetworkRegistrationRoaming :
       
   555 					{
       
   556 						FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoaming() ENetworkRegistrationRoaming"));
       
   557 						ret=true;
       
   558 						break;
       
   559 					}
       
   560 		   		default:
       
   561 			 		{
       
   562 			 			FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoaming() Roaming status "));
       
   563 			 			FTRACE( FPrint(
       
   564 					  _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoamingL() cell is not in roaming, network status is  %d"), netwStatus ) );
       
   565 			 			break;	
       
   566 			 		}
       
   567 			}
       
   568 			CleanupStack::PopAndDestroy();
       
   569 		}
       
   570 		else
       
   571 			{
       
   572 				FTRACE( FPrint(
       
   573 			  _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsRoamingL() RConnectinMonitor status.Int() returned error %d"), status.Int() ) );
       
   574 			}
       
   575 	}
       
   576 //------------------------------------------------------------------------------
       
   577 //CSyncMLAppLaunchNotifier::HandleDMSessionL()
       
   578 //Handles the DM Session 
       
   579 //------------------------------------------------------------------------------
       
   580 
       
   581 TBool CSyncMLAppLaunchNotifier::HandleDMSessionL()
       
   582 {
       
   583 		FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::HandleDMSessionL begins"));
       
   584 		TBool ret(ETrue);
       
   585 		TInt dmroamingBlock = 0;
       
   586     TBool roaming = EFalse;
       
   587     TLanguage language = User::Language();
       
   588 	  FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() Management session") );
       
   589 		CRepository* cRepository=NULL;
       
   590 		TRAPD ( error, cRepository = CRepository::NewL ( KCRUidNSmlNotifierDomainKeys ) );
       
   591 		if ( error == KErrNone )
       
   592 		{
       
   593 			CleanupStack::PushL( cRepository );
       
   594 			cRepository->Get ( KNSmlDMBlockedInRoaming, dmroamingBlock );
       
   595 			if(dmroamingBlock==1)
       
   596 			{
       
   597 				FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() roaming feature is enabled") );
       
   598 				TRAPD(rError,IsRoamingL(roaming));
       
   599 				if( (rError==KErrNone) && roaming )
       
   600 				{
       
   601 					FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() phone is in roaming, DM session is blocked ") );
       
   602 					CleanupStack::PopAndDestroy( cRepository );//cRepository
       
   603 					iNeedToCompleteMessage=EFalse;
       
   604 					iReplySlot = NULL;
       
   605 					ret = EFalse;
       
   606 					return ret;
       
   607 				}
       
   608 				else
       
   609 				{
       
   610 					FTRACE( FPrint(
       
   611 								_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() error in getting Network status  %d"), rError ) );
       
   612           FTRACE( FPrint(
       
   613           			_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() error in getting Network status  %d"),roaming ) );
       
   614 									}
       
   615 				}
       
   616 				else
       
   617 				{
       
   618 					FLOG( _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() DM blocking feature disabled ") );
       
   619 				}
       
   620 				CleanupStack::PopAndDestroy( cRepository );//cRepository
       
   621 			}
       
   622 			else
       
   623 			{
       
   624 				FTRACE( FPrint(
       
   625             _L("[SmlNotif]\t CSyncMLAppLaunchNotifier::RunL() cenrep creation error code  %d"),
       
   626             error ) );
       
   627 			}
       
   628       TBuf<KSyncMLMaxProfileNameLength> serverName;
       
   629       RetrieveMgmtParamsL( param, DMSyncServerName, uiAction );            
       
   630       TInt CustomNotes(KErrNone), SanSupport( KErrNone );  
       
   631       CRepository* centrep = NULL;  
       
   632       TRAPD(err1, centrep = CRepository::NewL ( KCRUidDeviceManagementInternalKeys ) );
       
   633       if((centrep) && (err1 == KErrNone))
       
   634       {
       
   635       	centrep->Get( KDevManUINotesCustomization, CustomNotes);
       
   636         centrep->Get( KDevManSANUIBitVariation, SanSupport );
       
   637       }
       
   638       else
       
   639       {
       
   640       	CustomNotes = 0;
       
   641         SanSupport  = 0;	
       
   642       }
       
   643       delete centrep;             
       
   644                                                         
       
   645       if(CustomNotes && SanSupport && IsLanguageSupportedL())
       
   646       {
       
   647       	stringholder = StringLoader::LoadL( R_QTN_DM_QUERY_ACCEPT_POSTSALE);	//This note will be shown in chinese variant itself 
       
   648       }
       
   649       else
       
   650       { 
       
   651       	stringholder = StringLoader::LoadL( R_SML_INIT_DM_SERVER_PROMPT,DMSyncServerName );
       
   652       }      
       
   653       FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::HandleDMSessionL ends"));
       
   654       return ret;
       
   655 }
       
   656 
       
   657 //------------------------------------------------------------------------------
       
   658 //CSyncMLAppLaunchNotifier::HandleCompleteMessageL(TInt &keypress, TBool &silent, TInt &SanSupport, TInt &Timeout, TInt &CustomNotes)
       
   659 // Handle the complete message
       
   660 //------------------------------------------------------------------------------
       
   661 	
       
   662 void CSyncMLAppLaunchNotifier::HandleCompleteMessageL(TInt &keypress, TBool &silent, TInt &SanSupport, TInt &Timeout, TInt &CustomNotes)
       
   663 {
       
   664 	TLanguage language = User::Language();
       
   665 	if( keypress == EAknSoftkeyYes || keypress == EAknSoftkeyOk || silent ) // User has accepted the dialog
       
   666   {
       
   667 		TInt retval = 1; // Default for ESyncMLSyncSession or silent
       
   668     if ( iSmlProtocol == ESyncMLMgmtSession && !silent )
       
   669     {
       
   670     	CRepository* cRepository=NULL;
       
   671 			TRAPD ( error, cRepository = CRepository::NewL ( KCRUidNSmlNotifierDomainKeys ) );
       
   672 		 	if ( error == KErrNone )
       
   673 			{
       
   674 				CleanupStack::PushL( cRepository );
       
   675 				TInt dmChargingNote(1);
       
   676 				cRepository->Get ( KNSmlDMChargingNote, dmChargingNote );
       
   677 				if(dmChargingNote==1)
       
   678 				{
       
   679 			    	stringholder = StringLoader::LoadLC( R_FOTA_CONF_QUERY_CONNECTION_IS_NEEDED );
       
   680 			    	CSyncMLTimedQueryDialog* dlg = CSyncMLTimedQueryDialog::NewL( *stringholder, Timeout );			    
       
   681 			    	dlg->PrepareLC( R_SML_CONFIRMATION_QUERY );
       
   682         		dlg->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_YES_NO );
       
   683        			keypress = dlg->RunLD();
       
   684          		if( keypress == EAknSoftkeyYes ||	keypress == EAknSoftkeyOk ) 
       
   685          			retval = 1;
       
   686          		else retval = 0;   
       
   687 			    	dlg = NULL;
       
   688 			    	CleanupStack::PopAndDestroy( stringholder );
       
   689         }
       
   690         CleanupStack::PopAndDestroy( cRepository );//cRepository
       
   691       }
       
   692     }
       
   693 	if( iSmlProtocol == ESyncMLMgmtSession && SanSupport == EON && silent && iUimode == ESANUserInformative )
       
   694 	{
       
   695 		// Turn lights on and deactivate apps -key
       
   696   	TurnLightsOn(); 	  
       
   697    	if(CustomNotes && IsLanguageSupportedL()) 
       
   698    	{
       
   699    		FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::informative session inside if "));
       
   700   		stringholder = StringLoader::LoadLC(R_QTN_DM_INFO_NOTE_POSTSALE);	 //This note will be shown in chinese variant only
       
   701    	}
       
   702    	else
       
   703    	{
       
   704     	stringholder = StringLoader::LoadLC(R_QTN_DM_INFO_NOTE_UPDATING , DMSyncServerName );
       
   705     }   
       
   706 		CAknInformationNote* informationNote = new (ELeave) CAknInformationNote ();
       
   707 		informationNote->ExecuteLD ( stringholder->Des() );
       
   708 		informationNote = NULL;
       
   709 		CleanupStack::PopAndDestroy( stringholder );	
       
   710    }
       
   711 
       
   712 	if ( retval )
       
   713 	{
       
   714 		const TUid KUidFakeUID = { 0 };
       
   715 	  TSyncMLAppLaunchNotifRetVal pckg;
       
   716 	  pckg.iSecureId = KUidFakeUID;
       
   717 	           
       
   718 	  switch( iSmlProtocol )
       
   719 	  {
       
   720 	  	case ESyncMLSyncSession:
       
   721 	    					param.iServiceId = KDataSyncServiceStart;
       
   722 	             	break;
       
   723 	    case ESyncMLMgmtSession:
       
   724 	              param.iServiceId = KDevManServiceStart;
       
   725 								if( SanSupport == EON )
       
   726 								{													
       
   727 	              	param.iSilent = iUimode;	                    	                               
       
   728 								}
       
   729 			          pckg.iSecureId = SyncServiceL( param.iServiceId )->StartSyncL( param );
       
   730 	              break;
       
   731 	    default:
       
   732 	              // This branch should never be reached, since the option
       
   733 	              // is handled in the previous switch statement.
       
   734 	              User::Panic( KSmlNPanicCategory, KErrCorrupt );
       
   735 	              break;
       
   736 	  }	
       
   737 	                
       
   738 	  iMessage.WriteL( iReplySlot, TPckgBuf<TSyncMLAppLaunchNotifRetVal>(pckg) );
       
   739 	  iMessage.Complete( KErrNone );
       
   740 	 }
       
   741 	 else
       
   742 	 {
       
   743 	  	// Complete the message with result code indicating that
       
   744 		  // the user cancelled the query.
       
   745 	    iMessage.Complete( KErrCancel );
       
   746 	 }
       
   747   }
       
   748   else
       
   749   {
       
   750   	// Complete the message with result code indicating that
       
   751     // the user cancelled the query.
       
   752     iMessage.Complete( KErrCancel );
       
   753   }
       
   754 }
       
   755 
       
   756 // -----------------------------------------------------------------------------
       
   757 // CSyncMLAppLaunchNotifier::IsLanguageSupportedL
       
   758 // Returns True if the specified language is supported.
       
   759 // -----------------------------------------------------------------------------
       
   760 //
       
   761 TBool CSyncMLAppLaunchNotifier::IsLanguageSupportedL()
       
   762 {
       
   763 	FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsLanguageSupportedL begins"));
       
   764 	TBool retVal(EFalse);
       
   765 	TLanguage language = User::Language();
       
   766 	if(language == ELangEnglish || language == ELangInternationalEnglish ||
       
   767  		   language == ELangTaiwanChinese ||language == ELangHongKongChinese || language == ELangPrcChinese)
       
   768  		   retVal = ETrue;
       
   769  	FLOG(_L("[SmlNotif]\t CSyncMLAppLaunchNotifier::IsLanguageSupportedL ends"));
       
   770  	return retVal;
       
   771 }
       
   772 //  End of File