Revision: 201011 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 31 Mar 2010 21:15:36 +0300
branchRCL_3
changeset 16 4eb398b07b07
parent 14 4699373c9af8
child 19 f2fc39bc30a5
Revision: 201011 Kit: 201013
omadm/omadmappui/conf/nsmldmsync.confml
omadm/omadmappui/conf/nsmldmsync_101F6DE5.crml
omadm/omadmappui/data/NSmlDMSync.rss
omadm/omadmappui/inc/NSmlDMSyncAppUi.h
omadm/omadmappui/inc/NSmlDMSyncPrivateCRKeys.h
omadm/omadmappui/loc/NSmlDMSyncFota.loc
omadm/omadmappui/src/NSmlDMSyncAppUi_fota.cpp
omadm/omadmappui/src/NSmlDMSyncAppUi_nofota.cpp
package_definition.xml
Binary file omadm/omadmappui/conf/nsmldmsync.confml has changed
Binary file omadm/omadmappui/conf/nsmldmsync_101F6DE5.crml has changed
--- a/omadm/omadmappui/data/NSmlDMSync.rss	Mon Mar 15 12:39:36 2010 +0200
+++ b/omadm/omadmappui/data/NSmlDMSync.rss	Wed Mar 31 21:15:36 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -1270,6 +1270,6 @@
 RESOURCE TBUF r_qtn_browser_version                            { buf = "\t"qtn_dm_list_browser_version"\t%U\t"; }
 RESOURCE TBUF r_qtn_java_version                               { buf = "\t"qtn_dm_list_java_version"\t%U\t"; }
 RESOURCE TBUF r_qtn_flash_version                              { buf = "\t"qtn_dm_list_flash_version"\t%U\t"; }
-
+RESOURCE TBUF r_qtn_fota_note_time_restriction                 { buf = qtn_fota_note_time_restriction; }
 
 // End of File
--- a/omadm/omadmappui/inc/NSmlDMSyncAppUi.h	Mon Mar 15 12:39:36 2010 +0200
+++ b/omadm/omadmappui/inc/NSmlDMSyncAppUi.h	Wed Mar 31 21:15:36 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -301,6 +301,15 @@
         */        
         void HandleCommandEraseProfileL();
 
+       /**
+        * Determines whether Fota update is allowed.
+        * @param    Server profile to check
+        * @return   ETrue if allowed
+        *           EFalse if not not allowed
+        */
+        TBool IsUpdateAllowedL( CNSmlDMSyncProfile& aProfile );
+
+
 	private: //Data
 	    CNSmlDMProfilesView*        iProfilesView;
 	
--- a/omadm/omadmappui/inc/NSmlDMSyncPrivateCRKeys.h	Mon Mar 15 12:39:36 2010 +0200
+++ b/omadm/omadmappui/inc/NSmlDMSyncPrivateCRKeys.h	Wed Mar 31 21:15:36 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -77,6 +77,13 @@
 // or not.Default value is 0 which makes it off 
 const TUint32 KNsmlDmRuntimeVerSupport = 0x00000008;
 
+// CenRep key that limits how often users may initiate a FOTA check.  
+// The value is specified in hours and should be bigger than 0.  
+// The default value is 24 hours.  This key only has an effect when 
+// FF_FOTA_CHECK_LIMITATION is configured ON in the product's 
+// configuration.
+const TUint32 KNsmlDmFotaCheckLimitation = 0x00000009;
+
 #endif // NSMLDMSYNCAPP_PRIVATE_CR_KEYS_H
             
 // End of File
--- a/omadm/omadmappui/loc/NSmlDMSyncFota.loc	Mon Mar 15 12:39:36 2010 +0200
+++ b/omadm/omadmappui/loc/NSmlDMSyncFota.loc	Wed Mar 31 21:15:36 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -241,5 +241,12 @@
 //      
 #define qtn_fota_list_release	"Release"
 
+//d: Message text shown when the user attempts to initiate a FOTA session but is restricted because not enough time has elapsed.
+//d: %0N is replaced with the number of hours which the user is restricted to attempt a FOTA session.
+//d: %1N is replaced with the number of hours remaining until the next allowed FOTA session.
+//d: %2N is replaced with the number of minutes remaining until the next allowed FOTA session.
+//l: popup_note_window
+//r: 5.2
+#define qtn_fota_note_time_restriction	"Sorry. %0N hours has not elapsed since you made your last request for a software update. Time before you can make a new request: %1N hr %2N min"
 
 // End of File
--- a/omadm/omadmappui/src/NSmlDMSyncAppUi_fota.cpp	Mon Mar 15 12:39:36 2010 +0200
+++ b/omadm/omadmappui/src/NSmlDMSyncAppUi_fota.cpp	Wed Mar 31 21:15:36 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -44,6 +44,13 @@
 #include <hlplch.h>
 #include <csxhelp/dm.hlp.hrh>
 
+#include <aknmessagequerydialog.h>     // For CAknMessageQueryDialog
+
+// For KCalenHoursInDay = 24 and other time-related constants.
+#include <calenconstants.h>           
+
+// Array granuality for displaying R_QTN_FOTA_NOTE_TIME_RESTRICTION note.
+const TInt KNSmlDMFotaNoteArrayGranuality = 3;
 
 // ============================ MEMBER FUNCTIONS ==============================
 //
@@ -416,6 +423,18 @@
 			}
 		}
 
+    // If Fota check limitation feature is enabled, users are allowed to check
+    // updates only once within the limitation set in the CenRep
+    // (24 hours by default).
+    if ( FeatureManager::FeatureSupported( KFeatureIdFfFotaCheckLimitation ) 
+        && !IsUpdateAllowedL( *profile ) )
+        {
+        FLOG( "[OMADM] CNSmlDMSyncAppUi::StartSyncL Checking update is limited.\
+            Can not proceed sync." );
+        iSyncAppEngine->CloseProfile();
+        return;
+        }
+
     iSyncAppEngine->CloseProfile();		
     TRAPD( error, iSyncAppEngine->SynchronizeL( serverName, 
                                                 iConfedProfileId, 
@@ -876,4 +895,134 @@
      		} 
   	
   }
+
+TBool CNSmlDMSyncAppUi::IsUpdateAllowedL( CNSmlDMSyncProfile& aProfile )
+    {
+    FLOG( "CNSmlDMSyncAppUi::IsUpdateAllowedL : Start" );
+
+    // Get the last successful sync time. It's a UTC time.
+    // Note: LastSuccessSync() returns the time when the last successful check
+    // for Fota update.
+    TTime utcLastSuccessSync = aProfile.LastSuccessSync();
+
+    // If utcLastSuccessSync is 0, there is no log available. Continue
+    // sync.
+    // Note: CNSmlDMSyncProfile::LastSuccessSync() returns 0 not Time::NullTTime().
+    if ( utcLastSuccessSync.Int64() == 0 )
+        {
+        FLOG( "[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() LastSuccessSync is 0." );
+        return ETrue;
+        }
+
+#ifdef _DEBUG
+    TDateTime dt = utcLastSuccessSync.DateTime();
+    FTRACE( FPrint(
+        _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() utcLastSuccessSync \
+        %04d-%02d-%02d %02d:%02d:%02d"),
+        dt.Year(), dt.Month(), dt.Day(), dt.Hour(), dt.Minute(), dt.Second() ) );
+#endif
+
+    // Read Fota check limitation value in hours from CenRep.
+    // If failed to get the value, the default value is 24 hours.
+    TInt fotaCheckLimitation( KCalenHoursInDay );
+    CRepository* cenrep = CRepository::NewL( KCRUidNSmlDMSyncApp );
+    cenrep->Get( KNsmlDmFotaCheckLimitation, fotaCheckLimitation );
+    delete cenrep;
+    FTRACE( FPrint(
+        _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() Fota check limitation = %d"),
+        fotaCheckLimitation ) );
+
+    // Check the get value.
+    if ( fotaCheckLimitation <= 0 )
+        {
+        // Something wrong with the value.  Set it to the default value.
+        fotaCheckLimitation = KCalenHoursInDay;
+        }
+
+    // Read the current time for comparison. Also universal time.
+    TTime utcCurrentTime;
+    utcCurrentTime.UniversalTime();
+
+#ifdef _DEBUG
+    dt = utcCurrentTime.DateTime();
+    FTRACE( FPrint(
+        _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() utcCurrentTime \
+        %04d-%02d-%02d %02d:%02d:%02d"),
+        dt.Year(), dt.Month(), dt.Day(), dt.Hour(), dt.Minute(), dt.Second() ) );
+#endif
+
+    // Calculate the remainig time for the next available update check.
+    TTimeIntervalMinutes passedMinutes;
+    utcCurrentTime.MinutesFrom( utcLastSuccessSync, passedMinutes );
+    FTRACE( FPrint(
+        _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() passedMinutes.Int() = %d"), 
+        passedMinutes.Int() ) );
+
+    // If Fota check limit is passed or passedMinutes is invalid, return EFalse
+    // to proceed sync process.
+    if ( passedMinutes.Int() > fotaCheckLimitation * KCalenMinutesInHour
+        || passedMinutes.Int() < 0 )
+        {
+        FLOG( "[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() Proceed sync process." );
+        return ETrue;
+        }
+
+    // Calculate the next available update check time.
+    TInt remainingMinutes ( ( fotaCheckLimitation * KCalenMinutesInHour ) 
+        - passedMinutes.Int() );
+    TInt remainingHours( remainingMinutes / KCalenMinutesInHour );
+        remainingMinutes -= remainingHours * KCalenMinutesInHour;
+    FTRACE( FPrint(
+        _L("[OMADM] CNSmlDMSyncAppUi::IsUpdateAllowedL() \
+        remainingHours = %d, remainingMinutes = %d"), 
+        remainingHours, remainingMinutes ) );
+    __ASSERT_DEBUG( ( remainingHours >= 0 ) && ( remainingMinutes >= 0 ), 
+        _L("CNSmlDMSyncAppUi::IsUpdateAllowedL - Problem with Remaining \
+        time calculation.") );
+
+    // If calculated remaining time is valid, show the sorry note with
+    // remaining time until next available time for checking update then
+    // return ETrue to stop sync process.
+    if ( remainingHours > 0 || remainingMinutes > 0 )
+        {
+        CArrayFix< TInt >* timeArray = 
+            new( ELeave ) CArrayFixFlat< TInt >( KNSmlDMFotaNoteArrayGranuality );
+        CleanupStack::PushL( timeArray );
+
+        timeArray->AppendL( fotaCheckLimitation );
+        timeArray->AppendL( remainingHours );
+        timeArray->AppendL( remainingMinutes );
+
+        HBufC* stringHolder =
+            StringLoader::LoadLC( R_QTN_FOTA_NOTE_TIME_RESTRICTION, 
+            *timeArray, iEikonEnv );
+
+        CAknMessageQueryDialog* infoDialog = 
+            CAknMessageQueryDialog::NewL( *stringHolder );
+ 
+        // infoDialog is added to the cleanup stack in PrepareLC().
+        // And the dialog is popped and destroyed in RunLD().
+        infoDialog->PrepareLC( R_AVKON_MESSAGE_QUERY_DIALOG );
+
+        // Only OK button should be shown since this is just a note.
+        infoDialog->ButtonGroupContainer().MakeCommandVisible( 
+            EAknSoftkeyCancel, EFalse );
+
+        // Return value of RunLD() is ignored.
+        infoDialog->RunLD();
+  
+        CleanupStack::PopAndDestroy( stringHolder );
+        CleanupStack::PopAndDestroy( timeArray );
+ 
+        // Return EFalse to stop sync process.
+        FLOG( "CNSmlDMSyncAppUi::IsUpdateAllowedL : End - EFalse" );
+        return EFalse;
+        }
+
+    // No remaining time left (or invalid calculation).
+    // Proceed checking update process.
+    FLOG( "CNSmlDMSyncAppUi::IsUpdateAllowedL : End - ETrue" );
+    return ETrue;
+    }
+
 // End of File
--- a/omadm/omadmappui/src/NSmlDMSyncAppUi_nofota.cpp	Mon Mar 15 12:39:36 2010 +0200
+++ b/omadm/omadmappui/src/NSmlDMSyncAppUi_nofota.cpp	Wed Mar 31 21:15:36 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -722,4 +722,11 @@
      } 
   	
   }
+
+TBool CNSmlDMSyncAppUi::IsUpdateAllowedL( CNSmlDMSyncProfile& aProfile )
+    {
+    //Dummy Should not be used if fota disabled
+    return ETrue;
+    }
+
 // End of File
--- a/package_definition.xml	Mon Mar 15 12:39:36 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<SystemDefinition schema="3.0.0">
-  <package id="devicecontrol" name="Device Control Daemons" levels="oma mid app">
-    <collection id="devicediagnostics" name="Device Diagnostics" level="app">
-      <component id="devdiagapp" filter="s60" name="Device Diagnostics App">
-        <unit bldFile="devicediagnostics/devdiagapp/group"/>
-      </component>
-      <component id="devdiaggsplugin" filter="s60" name="Device Diagnostics GS Plugin" class="plugin">
-        <unit bldFile="devicediagnostics/devdiaggsplugin/group"/>
-      </component>
-      <component id="diagplugins" filter="s60" name="Diagnostics Plugins" class="plugin">
-        <unit bldFile="devicediagnostics/diagplugins/group"/>
-      </component>
-      <component id="diagsuites" filter="s60" name="Diagnostics Suites" class="plugin">
-        <unit bldFile="devicediagnostics/diagsuites/group"/>
-      </component>
-      <component id="devicediagnostics_build" filter="s60" name="Device Diagnostics Build">
-      	<!-- can the exports be moved to one of the other components? -->
-        <unit bldFile="devicediagnostics/group"/>
-      </component>
-    </collection>
-    <collection id="omadm" name="OMA Device Management" level="oma">
-      <component id="omadmappui" filter="s60" name="OMA DM Application UI">
-        <unit bldFile="omadm/omadmappui/group"/>
-        	<!--  can this test unit be safely removed from here? -->
-        <!-- <unit bldFile="omadm/omadmappui/tsrc/group"/> -->
-      </component>
-      <component id="omadmextensions" filter="s60" name="OMA DM Extensions" class="plugin">
-        <unit bldFile="omadm/omadmextensions/group"/>
-        	<!--  can these test units be safely removed from here? -->
-        <!-- <unit bldFile="omadm/omadmextensions/adapters/email/tsrc/group"/> -->
-        <!-- <unit bldFile="omadm/omadmextensions/adapters/mms/tsrc/group"/> -->
-        <!-- <unit bldFile="omadm/omadmextensions/adapters/syncmldm/tsrc/group"/> -->
-        <!-- <unit bldFile="omadm/omadmextensions/adapters/syncmldm12/tsrc/group"/> -->
-        <!-- <unit bldFile="omadm/omadmextensions/adapters/syncmlds/tsrc/group"/> -->
-      </component>
-    </collection>
-    <collection id="pnpmobileservices" name="PnP Mobile Services" level="mid">
-      <component id="pnpms" filter="s60" name="PnP MS">
-        <unit bldFile="pnpmobileservices/pnpms/group"/>
-        	<!-- can the unit be #included or removed? -->  
-        <!-- <unit bldFile="pnpmobileservices/pnpms/tsrc/group"/> -->
-      </component>
-    </collection>
-    <collection id="omacp" name="OMA Content Provisioning" level="oma">
-      <component id="omacpadapters" filter="s60" name="OMA CP Adapters" class="plugin">
-        <unit bldFile="omacp/omacpadapters/group"/>
-      </component>
-    </collection>
-  </package>
-</SystemDefinition>