fotaapplication/inc/FotaIPCTypes.cpp
branchRCL_3
changeset 25 b183ec05bd8c
equal deleted inserted replaced
24:13d7c31c74e0 25:b183ec05bd8c
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:   interprocess messages
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDES
       
    21 #include "FotaIPCTypes.h"
       
    22 #include <centralrepository.h>
       
    23 #include "fotaserverPrivateCRKeys.h"
       
    24 
       
    25 // ======================= MEMBER FUNCTIONS ==================================
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // TDownloadIPCParams::TDownloadIPCParams 
       
    29 // ---------------------------------------------------------------------------
       
    30 TDownloadIPCParams::TDownloadIPCParams () : iPkgId(-1),iProfileId(0)
       
    31         , iSendAlert(ETrue)
       
    32         , iIapId(-1), iPkgSize(0), iSessionType(0), iUpdateLtr (0)
       
    33 {
       
    34     iPkgName        = KNullDesC8;
       
    35     iPkgVersion     = KNullDesC8;
       
    36 }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // TDownloadIPCParams::TDownloadIPCParams 
       
    40 // ---------------------------------------------------------------------------
       
    41 TDownloadIPCParams::TDownloadIPCParams (const TDownloadIPCParams& p )
       
    42                            : iPkgId ( p.iPkgId ), iProfileId (p.iProfileId )
       
    43                            , iSendAlert( p.iSendAlert )
       
    44                            , iIapId(p.iIapId), iPkgSize(p.iPkgSize), iSessionType(p.iSessionType), iUpdateLtr (p.iUpdateLtr)
       
    45     {
       
    46     iPkgName        = p.iPkgName;
       
    47     iPkgVersion     = p.iPkgVersion;
       
    48     }
       
    49 
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // TPackageState::TPackageState
       
    54 // ---------------------------------------------------------------------------
       
    55 TPackageState::TPackageState( RFotaEngineSession::TState aState, TInt aResult)
       
    56     : TDownloadIPCParams (),  iState(aState), iResult(aResult)
       
    57     						,iSmlTryCount( KDefaultSmlTryCount )
       
    58     {
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // TPackageState::TPackageState
       
    64 // ---------------------------------------------------------------------------
       
    65 TPackageState::TPackageState( RFotaEngineSession::TState aState) 
       
    66     : TDownloadIPCParams (), iState(aState), iResult(-1) 
       
    67     						,iSmlTryCount( KDefaultSmlTryCount )
       
    68     {
       
    69 	SetSmlTryCount();
       
    70     }
       
    71 
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // TPackageState::TPackageState
       
    75 // ---------------------------------------------------------------------------
       
    76 TPackageState::TPackageState( TDownloadIPCParams p) : 
       
    77     TDownloadIPCParams(p),iState(RFotaEngineSession::EIdle), iResult(-1)
       
    78     					 ,iSmlTryCount( KDefaultSmlTryCount )
       
    79     {  
       
    80     SetSmlTryCount();
       
    81     
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // TPackageState::TPackageState
       
    87 // ---------------------------------------------------------------------------
       
    88 TPackageState::TPackageState() : TDownloadIPCParams () 
       
    89             ,iState(RFotaEngineSession::EIdle), iResult(-1)
       
    90             ,iSmlTryCount( KDefaultSmlTryCount )
       
    91     {
       
    92     SetSmlTryCount();
       
    93     }
       
    94 
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // TPackageState::SetSmlTryCount()
       
    98 // ---------------------------------------------------------------------------
       
    99 void TPackageState::SetSmlTryCount()
       
   100 {
       
   101 	 TInt err = KErrNone;
       
   102 	 TInt retry = 0;
       
   103 	 CRepository *centrep = NULL;
       
   104       TRAP(err, centrep = CRepository::NewL( KCRUidFotaServer ) );
       
   105     	    if ( centrep ) 
       
   106         	{
       
   107         	err = centrep->Get( KGenericAlertRetries, retry );
       
   108         	delete centrep; centrep = NULL;
       
   109         	}
       
   110         	if(err == KErrNone)
       
   111         	{
       
   112         		
       
   113             	    if(retry < 0 )
       
   114             	    {
       
   115             	    iSmlTryCount = KDefaultSmlTryCount;
       
   116             	    }
       
   117                   	else if( retry == 0 )
       
   118                	    {
       
   119                	     iSmlTryCount = 2 ;
       
   120                	    }
       
   121                 	else if (retry > KMaximumSmlTryCount )
       
   122                	    {
       
   123                	     iSmlTryCount = KMaximumSmlTryCount + 1;
       
   124                	    }
       
   125                    	else
       
   126                     {
       
   127                 	  iSmlTryCount = retry + 1;
       
   128                     }
       
   129         	    }
       
   130         	 else
       
   131         	    {
       
   132         	    iSmlTryCount = KDefaultSmlTryCount;
       
   133         	    }
       
   134 }
       
   135 
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // TPackageState::operator=
       
   139 // ---------------------------------------------------------------------------
       
   140 TPackageState& TPackageState::operator= ( const TDownloadIPCParams& a )
       
   141     {
       
   142     iPkgId      = a.iPkgId;
       
   143     iProfileId  = a.iProfileId;
       
   144     iPkgName    = a.iPkgName;
       
   145     iPkgVersion = a.iPkgVersion;
       
   146     iIapId		= a.iIapId;
       
   147     iPkgSize	= a.iPkgSize;
       
   148     iSessionType= a.iSessionType;
       
   149     iUpdateLtr 	= a.iUpdateLtr;
       
   150 
       
   151     return *this;
       
   152     }
       
   153 
       
   154 
       
   155 // ---------------------------------------------------------------------------
       
   156 // TPackageState::operator=
       
   157 // ---------------------------------------------------------------------------
       
   158 TPackageState& TPackageState::operator=(const TPackageState& a)
       
   159     {
       
   160     iPkgId      = a.iPkgId; 
       
   161     iProfileId  = a.iProfileId; 
       
   162     iPkgName    = a.iPkgName; 
       
   163     iPkgVersion = a.iPkgVersion;
       
   164     iIapId		= a.iIapId;
       
   165     iPkgSize	= a.iPkgSize;
       
   166     iSessionType= a.iSessionType;
       
   167     iUpdateLtr	= a.iUpdateLtr;
       
   168     iState      = a.iState;  
       
   169     iResult     = a.iResult;
       
   170     iSmlTryCount= a.iSmlTryCount;
       
   171     return *this;
       
   172     }
       
   173  
       
   174             
       
   175 // End of File