fotaapplication/fotaserver/fmserver/inc/fmsserver.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2009 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: Implementation of fotaserver component
       
    15 * 	This is part of fotaapplication.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef __FMS_SERVER_H__
       
    20 #define __FMS_SERVER_H__
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32std.h>
       
    24 #include <e32property.h>
       
    25 #include <flogger.h>
       
    26 #include <rconnmon.h>
       
    27 #include <f32file.h>
       
    28 #include <fotaengine.h>
       
    29 #include "fmsclientserver.h"
       
    30 #include "fmsinterruptaob.h"
       
    31 #include "fmsdebug.h"
       
    32 
       
    33 _LIT( KFotaInterruptFileName, "fotainterrupt.txt" );
       
    34 const TInt64 KThresholdDiskSpace = 305152;
       
    35 const TInt64 KDiskSpaceNotCL = 102400;
       
    36 const TInt KRequestTriggerWaitTime(1000000);
       
    37 
       
    38 class CFMSSession;
       
    39 class CFMSServer;
       
    40 class CFMSInterruptAob;
       
    41 
       
    42 	
       
    43 class CFMSServer: public CServer2
       
    44 	{
       
    45 	friend class CFMSSession;
       
    46 	friend class CFMSInterruptAob;
       
    47 	
       
    48 	public:
       
    49 	
       
    50 	/**
       
    51 	 * Destructor
       
    52 	 */ 
       
    53 	virtual ~CFMSServer();
       
    54 	
       
    55 	/**
       
    56 	 * Static method which creates the server instance
       
    57 	 * @param None
       
    58 	 * @return CServer2*
       
    59 	 */ 
       
    60 	static CServer2*  NewLC();
       
    61 	
       
    62 	/**
       
    63 	 * Stops the session and closes the server
       
    64 	 * @param None
       
    65 	 * @return None
       
    66 	 */
       
    67 	void DropSession();
       
    68 	
       
    69 	/**
       
    70 	 * Starts Active object to monitor for the interrupt
       
    71 	 * @param aType, Interrupt reason
       
    72 	 * @return None
       
    73 	 */
       
    74 	void StartMonitoringL(TOmaDLInterruptReason aType);
       
    75 
       
    76 	/**
       
    77 	 * Starts Active object to monitor for the update interrupt
       
    78 	 * @param aType, Interrupt reason
       
    79 	 * @param aLevel, Level of the battery charge to monitor
       
    80 	 * @return None
       
    81 	 */
       
    82 	void StartBatteryMonitoringL(TOmaUpdInterruptReason aType, TUint aLevel);
       
    83 
       
    84 /**
       
    85 	 * Starts Active object to monitor for the update interrupt
       
    86 	 * @param aType, Interrupt reason
       
    87 	 * @return None
       
    88 	 */
       
    89 	void StartUpdateInterruptMonitoringL(TOmaUpdInterruptReason aType);
       
    90 	/**
       
    91 	 * Calls Active object's method to set the drive & size 
       
    92 	 * for memory interrupt
       
    93 	 * @param aSize, Interrupt aDrive
       
    94 	 * @return None
       
    95 	 */
       
    96 	void MemoryToMonitorL(TInt aSize, TDriveNumber aDrive);
       
    97 	
       
    98 	/**
       
    99 	 * Calls Active object's method to set the network bearer
       
   100 	 * @param aBearer
       
   101 	 * @return None
       
   102 	 */
       
   103 	void NetworkTypeL(TInt aBearer);
       
   104 	
       
   105 	/**
       
   106 	 * Writes the file with all the interrupt information
       
   107 	 * @param aReason ,Interrupt reason
       
   108 	 * @param aBearer ,Bearer id
       
   109 	 * @param aDrive  ,Drive to Download
       
   110 	 * @param aSize   , memory size to monitor
       
   111 	 * @param aWcdmaBearer , 3G bearer or not
       
   112 	 * @return None
       
   113 	 */
       
   114     void WriteToFile(TInt aReason, TInt aBearer, TDriveNumber aDrive, 
       
   115     		TInt aSize, TBool aWcdmaBearer );
       
   116     
       
   117     /**
       
   118 	 * Reads the file for the interrupt information
       
   119 	 * @param aReason ,Interrupt reason
       
   120 	 * @param aBearer ,Bearer id
       
   121 	 * @param aDrive  ,Drive to Download
       
   122 	 * @param aSize   , memory size to monitor
       
   123 	 * @param aWcdmaBearer , 3G bearer or not
       
   124 	 * @return TBool, says reading success or not
       
   125 	 */
       
   126     TBool ReadFromFile(TInt& aReason, TInt& aBearer, TInt& aDrive, TInt& aSize
       
   127     		 , TInt& aWcdmaBearer );
       
   128     
       
   129     /**
       
   130 	 * Checks for any interrupt pending
       
   131 	 * @param None
       
   132 	 * @return TBool
       
   133 	 */
       
   134     TBool RequestPending();
       
   135     
       
   136     /**
       
   137 	 * Checks the network as part of other interrupts
       
   138 	 * before triggering fota.
       
   139 	 * In case of network down, it keeps network interrupt
       
   140 	 * @param aBearer ,Bearer id
       
   141 	 * @param aDrive  ,Drive to Download
       
   142 	 * @param aSize   , memory size to monitor
       
   143 	 * @param aWcdmaBearer , 3G bearer or not
       
   144 	 * @return None
       
   145 	 */
       
   146     void CheckNetworkL(TInt& aBearerId,TInt& aDrive, TInt& aSize,TBool& aWcdma);
       
   147     
       
   148     /**
       
   149 	 * Locks the session, so that new session will not be started
       
   150 	 * before the previous interrupt monitory completion
       
   151 	 * @param None
       
   152 	 * @return None
       
   153 	 */
       
   154     void LockSession();
       
   155     
       
   156     /**
       
   157 	 * Computes the variation configured
       
   158 	 * @param None
       
   159 	 * @return None
       
   160 	 */
       
   161     void FindVariation();
       
   162     
       
   163     /**
       
   164 	 * Checks Charger monitoring supported or not
       
   165 	 * @param None
       
   166 	 * @return TBool, which says Charger monitory support
       
   167 	 */
       
   168     TBool ChargerTobeMonitered();
       
   169     
       
   170     /**
       
   171 	 * Checks  Network monitoring supported or not
       
   172 	 * @param None
       
   173 	 * @return TBool, which says  Network monitory support
       
   174 	 */
       
   175     TBool NetworkTobeMonitered();
       
   176     
       
   177     /**
       
   178 	 * Checks Phone startup monitoring supported or not
       
   179 	 * @param None
       
   180 	 * @return TBool, which says Phone startup monitory support
       
   181 	 */
       
   182     TBool MoniterAfterPhoneRestart();
       
   183     
       
   184     /**
       
   185 	 * Checks Memory monitoring supported or not
       
   186 	 * @param None
       
   187 	 * @return TBool, which says Memory monitory support
       
   188 	 */
       
   189     TBool MemoryTobeMonitered();
       
   190     
       
   191     /**
       
   192 	 * Checks for WLAN
       
   193 	 * @param None
       
   194 	 * @return TBool, which says WLAN availability
       
   195 	 */
       
   196     TBool CheckWlanL();
       
   197     
       
   198     /**
       
   199 	 * Sets the Bool value which decides file deletion
       
   200 	 * @param aValue, says whether the file to be deletd or not
       
   201 	 * @return None
       
   202 	 */
       
   203     void DeleteFile(TBool aValue);
       
   204     
       
   205     /**
       
   206 	 * Checks network and trigger fota engine in hard reboot case
       
   207 	 * @param None
       
   208 	 * @return None
       
   209 	 */
       
   210     void TriggerFotaL();
       
   211     
       
   212     /**
       
   213 	 * For asynchronous network request to be 
       
   214 	 * logged on active object, using CPeriodic
       
   215 	 * @param None
       
   216 	 * @return None
       
   217 	 */
       
   218 	void AsyncSessionRequestL();
       
   219 		
       
   220 	/**
       
   221 	 * Destroys the CPeriodic object
       
   222 	 * So that not to call the static method again
       
   223 	 * @param None
       
   224 	 * @return None
       
   225 	 */
       
   226 	void StopAsyncRequest();
       
   227 	
       
   228 	/**
       
   229      * Calls Active objects SetWcdma to set the bearer to 3G
       
   230      * @param None
       
   231      * @return None
       
   232      */
       
   233    	void SetWcdma() ;
       
   234    	
       
   235    	/**
       
   236    	 * Checks whether a phone call is active or not
       
   237    	 * @param aStatus, on return contains the call status
       
   238    	 * @return None
       
   239    	 */
       
   240    	void CheckPhoneCallActiveL(TInt& aStatus);
       
   241    	
       
   242    	/**
       
   243    	 * Starts montioring for active phone call end
       
   244    	 * @param aPkgId, package Id of FOTA Update
       
   245    	 * @param aProfileId, Profile ID of FOTA
       
   246    	 * @return phone call active or not at that moment
       
   247    	 */
       
   248    	TBool MonitorPhoneCallEndL(TInt aPkgId, TInt aProfileId);
       
   249    	
       
   250    	/**
       
   251    	 * Logs Asynchronous montioring for active phone call end
       
   252    	 * To avoid performance issues(like thread blocking call)
       
   253    	 * @param None
       
   254    	 * @return None
       
   255    	 */
       
   256    	void LogAsyncCallMonitorL();
       
   257    	
       
   258    	/**
       
   259    	 * Returns the FOTA Update packaged Id
       
   260    	 */ 
       
   261    	TInt& PkgId();
       
   262 
       
   263    	/**
       
   264    	 * Returns the FOTA server profile Id
       
   265    	 */
       
   266    	TInt& ProfileId();
       
   267    	
       
   268 	private:
       
   269 	
       
   270 	/**
       
   271 	 * second phase constructor
       
   272 	 */
       
   273 	void ConstructL();
       
   274 	
       
   275 	/**
       
   276 	 * Default constructor
       
   277 	 */
       
   278 	CFMSServer();
       
   279 	
       
   280 	protected:
       
   281 	
       
   282 	/**
       
   283 	 * Calls when a New session is getting created
       
   284 	 * @param aVersion
       
   285 	 * @param aMessage
       
   286 	 * @return CSession2*
       
   287 	 */
       
   288 	CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage)  const;
       
   289 	
       
   290 	private:
       
   291 	RFs iFs; //for file creation, writing & Deleting
       
   292 	RFile iFile;
       
   293 	TInt iSessionCount;	
       
   294 	CFMSInterruptAob iFMSInterruptAob;
       
   295     TBool iNetworkMon;
       
   296     TBool iChargerMon;
       
   297     TBool iPhoneRestartMon;
       
   298     TBool iMemoryMon;	
       
   299     TBool iDeleteFile;
       
   300     CPeriodic* iLogAsyncRequest;
       
   301     
       
   302     //FOTA Server Profile Id
       
   303     TInt iProfileId;
       
   304     
       
   305     //FOTA Update package Id
       
   306     TInt iPkgId;
       
   307 	};
       
   308 	
       
   309 #endif