fotaapplication/fmserver/src/fmsserversession.cpp
author hgs
Fri, 15 Oct 2010 11:46:45 +0530
changeset 73 ae69c2e8bc34
parent 51 2e64dc50f295
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     1
/*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     3
* All rights reserved.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     8
*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     9
* Initial Contributors:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    11
*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    12
* Contributors:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    13
*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    14
* Description: Implementation of fotaserver component
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    15
* 	This is part of fotaapplication.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    16
*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    17
*/
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    18
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    19
#include <f32file.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    20
#include <cmconnectionmethoddef.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    21
#include <cmmanagerext.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    22
#include <cmpluginwlandef.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    23
#include <cmpluginpacketdatadef.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    24
#include <etel.h> //for telephone mode
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    25
#include <etelmm.h> //for telephone mode
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    26
#include <fotaConst.h> 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    27
#include "fmsserversession.h"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    28
#include "fmsclientserver.h"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    29
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    30
#if defined (__WINS__)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    31
#include <cmpluginlanbasedef.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    32
#endif
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    33
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    34
// CFMSSession::CFMSSession
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    35
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    36
CFMSSession::CFMSSession()
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    37
	{	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    38
	iStopServer  =  EFalse;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    39
	iWlanbearer  =  EFalse;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    40
	iWcdmaBearer =  EFalse;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    41
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    42
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    43
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    44
// CFMSSession::~CFMSSession
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    45
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    46
CFMSSession::~CFMSSession()
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    47
	{	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    48
	FLOG(_L("CFMSSession::~CFMSSession-- begin"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    49
	if( iStopServer )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    50
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    51
		FLOG(_L("Stop fmserver CFMSSession::~CFMSSession"));	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    52
		Server().DropSession();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    53
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    54
	FLOG(_L("CFMSSession::~CFMSSession-- end"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    55
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    56
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    57
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    58
// CFMSSession::Server
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    59
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    60
CFMSServer& CFMSSession::Server()
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    61
	{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    62
	return *static_cast<CFMSServer*>(const_cast<CServer2*>(CSession2::Server()));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    63
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    64
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    65
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    66
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    67
// CFMSSession::CheckClientSecureIdL
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    68
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    69
TBool CFMSSession::CheckClientSecureIdL (
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    70
		const RMessage2& aMessage)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    71
	{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    72
	TUid    fota            = TUid::Uid( KFotaServerUid );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    73
	TUid    starter         = TUid::Uid( KStarterUid );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    74
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    75
	// Fotaserver
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    76
	if ( aMessage.SecureId() == fota.iUid ) 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    77
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    78
		FLOG(_L("[CFMSSession] CheckClientSecureIdL client is \
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    79
		fotaserver!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    80
		return ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    81
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    82
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    83
	// Starter
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    84
	if ( aMessage.SecureId() == starter.iUid )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    85
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    86
		return ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    87
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    88
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    89
	// test app
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    90
	if ( aMessage.SecureId() == 0x01D278B9 )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    91
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    92
		return ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    93
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    94
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    95
	FLOG(_L("[CFMSSession] CheckClientSecureIdL client 0x%X is unknown \
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    96
	(msg %d), bailing out"),aMessage.SecureId().iId, aMessage.Function());
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    97
	iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    98
	User::Leave( KErrAccessDenied );    
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    99
	return EFalse; // compiler warning otherwise
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   100
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   101
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   102
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   103
// CFMSSession::ServiceL
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   104
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   105
void CFMSSession::ServiceL(const RMessage2& aMessage)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   106
	{	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   107
	RThread clt; aMessage.ClientL(clt); TFullName cltnm = clt.FullName();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   108
	FLOG(_L( "CFMSSession::ServiceL      %d   serving for %S?" )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   109
			,aMessage.Function(), &cltnm );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   110
	if( CheckClientSecureIdL( aMessage ) )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   111
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   112
		//already one request pending
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   113
		if( Server().RequestPending() && 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   114
				aMessage.Function() !=  ECancelOutstandingRequest )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   115
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   116
			aMessage.Complete(KErrCancel);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   117
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   118
		else //For no pending request case
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   119
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   120
			TRAPD(err,DispatchMessageL(aMessage));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   121
			if(err != KErrNone ) 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   122
				{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   123
				iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   124
				}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   125
			aMessage.Complete(err);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   126
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   127
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   128
	else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   129
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   130
		aMessage.Complete(KErrAccessDenied);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   131
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   132
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   133
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   134
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   135
// CFMSSession::ServiceError
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   136
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   137
void CFMSSession::ServiceError(const RMessage2& aMessage,TInt aError)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   138
	{		
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   139
	CSession2::ServiceError(aMessage,aError);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   140
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   141
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   142
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   143
// CFMSSession::DispatchMessageL
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   144
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   145
void CFMSSession::DispatchMessageL(const RMessage2& aMessage)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   146
	{	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   147
	FLOG(_L("CFMSSession::DispatchMessageL-begin"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   148
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   149
	if( aMessage.Function() != EFotaStartUpPlugin && 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   150
			aMessage.Function() != ECancelOutstandingRequest && 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   151
			aMessage.Function() != EUpdMonitorbattery &&
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   152
			aMessage.Function() != EUpdPhoneCallActive &&
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   153
	        aMessage.Function() != EUpdMonitorPhoneCallEnd )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   154
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   155
		 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   156
		 HandleBasedOnBearertypeL(aMessage);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   157
		
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   158
			
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   159
						
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   160
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   161
	switch(aMessage.Function())
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   162
	{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   163
	case EDLUserInterrupt:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   164
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   165
		Server().CreateScheduledReminderL();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   166
		
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   167
		if(Server().ChargerTobeMonitered())
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   168
			{	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   169
			FLOG(_L("FMSSErver::EUserInterrupt"));			
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   170
			Server().WriteToFile(EDLUserInterrupt,aMessage.Int0(),
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   171
					(TDriveNumber)aMessage.Int1(),aMessage.Int2(),iWcdmaBearer);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   172
			Server().StartMonitoringL(EDLUserInterrupt);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   173
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   174
		else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   175
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   176
			WriteDummyFile();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   177
			iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   178
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   179
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   180
		break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   181
	case EDLNetworkInterrupt:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   182
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   183
		if(Server().NetworkTobeMonitered())
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   184
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   185
			FLOG(_L("FMSSErver::ENetworkInterrupt"));						
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   186
			//If wlan = on & network interrupt, then stop the server and dont monitor
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   187
			//mean other wlan n/w's present but this wlan gone off
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   188
			if(iWlanbearer && Server().CheckWlanL())
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   189
				{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   190
				WriteDummyFile();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   191
				Server().DeleteFile(EFalse);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   192
				iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   193
				break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   194
				}			
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   195
			Server().WriteToFile(EDLNetworkInterrupt,aMessage.Int0(),
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   196
					(TDriveNumber)aMessage.Int1(),aMessage.Int2(),iWcdmaBearer);			
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   197
			Server().AsyncSessionRequestL();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   198
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   199
		else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   200
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   201
			WriteDummyFile();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   202
			iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   203
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   204
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   205
		break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   206
	case EDLMemoryInterrupt:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   207
		{			
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   208
		if(Server().MemoryTobeMonitered())
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   209
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   210
			FLOG(_L("FMSSErver::EMemoryInterrupt"));				
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   211
			Server().MemoryToMonitorL(aMessage.Int2(),(TDriveNumber)aMessage.Int1()); 		
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   212
			Server().WriteToFile(EDLMemoryInterrupt,aMessage.Int0(),
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   213
					(TDriveNumber)aMessage.Int1(),aMessage.Int2(),iWcdmaBearer);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   214
			Server().StartMonitoringL(EDLMemoryInterrupt);		
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   215
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   216
		else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   217
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   218
			WriteDummyFile();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   219
			iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   220
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   221
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   222
		break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   223
	case EDLGeneralInterrupt:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   224
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   225
		if(Server().ChargerTobeMonitered())
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   226
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   227
			FLOG(_L("FMSSErver::GeneralInterrupt"));	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   228
			Server().WriteToFile(EDLUserInterrupt,aMessage.Int0(),
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   229
					(TDriveNumber)aMessage.Int1(),aMessage.Int2(),iWcdmaBearer);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   230
			Server().StartMonitoringL(EDLUserInterrupt);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   231
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   232
		else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   233
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   234
			WriteDummyFile();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   235
			iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   236
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   237
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   238
		break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   239
	case EFotaStartUpPlugin:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   240
		{	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   241
		if(Server().MoniterAfterPhoneRestart())				
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   242
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   243
			FLOG(_L("CFMSSession::EFotaStartUpPlugin"));	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   244
			TInt intrreason(-1),bearer(-1),size(0);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   245
			TInt drive(-1), wcdmabearer(-1);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   246
			//if loop for Hard reboot--no file or size is empty
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   247
#if defined(__WINS__)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   248
        if(ETrue)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   249
#else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   250
			if(Server().ReadFromFile(intrreason,bearer,drive,size,wcdmabearer) == EFalse )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   251
#endif
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   252
				{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   253
				FLOG(_L("CFMSSession::EFotaStartUpPlugin no file or size is empty"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   254
				if(!Server().RequestPending())
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   255
					{	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   256
					FLOG(_L("CFMSSession::EFotaStartUpPlugin-no request pending"));						  					  	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   257
					TRAPD(err,PhoneModeL());
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   258
					if(err); // remove compiler warning
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   259
					FLOG(_L("PhoneModeL() fotastartup returns err as %d"),err);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   260
					if(iWcdmaBearer)						 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   261
						Server().NetworkTypeL( (TInt)EBearerIdWCDMA );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   262
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   263
					else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   264
						Server().NetworkTypeL( (TInt)EBearerIdGPRS );	  					  					  
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   265
					Server().LockSession();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   266
					Server().TriggerFotaL(); //checks n/w & trigger FOTA DL						
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   267
					}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   268
				break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   269
				}												
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   270
			TUint32 BearerId = FindBearerIdL(bearer);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   271
			FLOG(_L("CFMSSession::EFotaStartUpPlugin wcdma bearer is %d"),wcdmabearer);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   272
			if( BearerId == KUidWlanBearerType )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   273
				{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   274
				FLOG(_L("CFMSSession::EFotaStartUpPlugin-wlan bearer"));	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   275
				Server().NetworkTypeL(EBearerIdWLAN);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   276
				if(intrreason == EDLNetworkInterrupt)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   277
					{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   278
					//stop the server , but dont delete file to support in second reboot
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   279
					FLOG(_L("wlan bearer & n/w interrupt--stopping the server"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   280
					Server().DeleteFile(EFalse);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   281
					iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   282
					break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   283
					}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   284
				}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   285
			else if( BearerId == KUidPacketDataBearerType )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   286
				{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   287
				FLOG(_L("CFMSSession::EFotaStartUpPlugin-bearer is packet data"));	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   288
				if( wcdmabearer == 1 )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   289
					{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   290
					Server().NetworkTypeL(EBearerIdWCDMA);	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   291
					FLOG(_L("CFMSSession::EFotaStartUpPlugin-packet data and 3G"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   292
					}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   293
				else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   294
					{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   295
					Server().NetworkTypeL(EBearerIdGPRS);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   296
					FLOG(_L("CFMSSession::EFotaStartUpPlugin-packet data and 2G"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   297
					}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   298
				}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   299
			else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   300
				{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   301
				FLOG(_L("CFMSSession::EFotaStartUpPlugin-unknown bearer"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   302
				Server().DeleteFile(EFalse);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   303
				iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   304
				break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   305
				}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   306
			//when there is dummy file in the store
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   307
			if( intrreason < EDLUserInterrupt || intrreason > EDLGeneralInterrupt )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   308
				{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   309
				FLOG(_L("CFMSSession::EFotaStartUpPlugin-Interrupt unknown"));	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   310
				Server().DeleteFile(EFalse); //used when variation support & reboot again
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   311
				iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   312
				break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   313
				}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   314
			if( intrreason == EDLUserInterrupt || intrreason == EDLGeneralInterrupt )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   315
				{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   316
				FLOG(_L("CFMSSession::EFotaStartUpPlugin-Check n/w & trigger fotaengine"));	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   317
				Server().CheckNetworkL(bearer,drive,size,wcdmabearer);//3 params used in monitoring if no n/w
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   318
				break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   319
				} 				
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   320
			//for other interrupts it will monitor
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   321
			Server().StartMonitoringL((TFmsIpcCommands)intrreason);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   322
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   323
		else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   324
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   325
			iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   326
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   327
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   328
		break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   329
	case ECancelOutstandingRequest:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   330
		{					
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   331
		FLOG(_L("CFMSSession::DispatchMessageL ECancelOutstandingRequest case:"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   332
		Server().DeleteScheduledRemindersL();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   333
		iStopServer = ETrue; 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   334
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   335
		break;	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   336
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   337
	case EUpdMonitorbattery:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   338
	   {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   339
	    FLOG(_L("CFMSSession::DispatchMessageL EUpdMonitorbattery case:"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   340
	 	Server().StartBatteryMonitoringL(EUpdMonitorbattery, aMessage.Int0());
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   341
	   }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   342
	 	break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   343
	   
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   344
	case EUpdPhoneCallActive:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   345
	    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   346
	    FLOG(_L("CFMSSession::DispatchMessageL EUpdPhoneCallActive case:"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   347
	    Server().LockSession();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   348
	    TInt reason =EFalse;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   349
	    Server().CheckPhoneCallActiveL(reason);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   350
	    TPckgBuf<TInt> callactive(reason);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   351
	    aMessage.WriteL(0,callactive);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   352
	    Server().iSessionCount = 0;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   353
	    FLOG(_L("CFMSSession::DispatchMessageL EUpdPhoneCallActive case:%d"),reason);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   354
	    iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   355
	    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   356
	    break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   357
	    
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   358
	case EUpdMonitorPhoneCallEnd:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   359
	    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   360
	    FLOG(_L("CFMSSession::DispatchMessageL EUpdMonitorPhoneCallEnd case:%d,%d"),aMessage.Int0(),aMessage.Int1());
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   361
	    Server().LockSession();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   362
	    if(Server().MonitorPhoneCallEndL())
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   363
	        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   364
	        iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   365
	        Server().iSessionCount = 0;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   366
	        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   367
	    else //let server monitor for active call end
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   368
	        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   369
	        iStopServer = EFalse;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   370
	        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   371
	   }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   372
	 	break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   373
	default:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   374
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   375
		FLOG(_L("CFMSSession::DispatchMessageL default case:and a leave happened"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   376
		iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   377
		User::Leave(KErrArgument);			
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   378
		}			
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   379
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   380
	FLOG(_L("CFMSSession::DispatchMessageL:end"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   381
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   382
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   383
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   384
// CFMSSession::FindBearerId
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   385
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   386
TUint32 CFMSSession::FindBearerIdL(TInt aIapId)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   387
	{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   388
	FLOG(_L("CFMSSession::FindBearerId: % d"),aIapId);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   389
	TUint32 bearer = 0;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   390
	TInt err( KErrNone );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   391
	// Query CM Id
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   392
	TInt cmId ( aIapId );			        
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   393
	RCmManagerExt  CmManagerExt;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   394
	TRAP( err, CmManagerExt.OpenL() );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   395
	if( err == KErrNone )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   396
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   397
		RCmConnectionMethodExt cm;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   398
		TRAP( err, cm = CmManagerExt.ConnectionMethodL( cmId ) );			        	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   399
		if ( err == KErrNone )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   400
			{	        
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   401
			CleanupClosePushL( cm );	  
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   402
			bearer = cm.GetIntAttributeL( CMManager::ECmBearerType );	        			        
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   403
			CleanupStack::PopAndDestroy();  // cm	        
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   404
			}	    	        
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   405
		CmManagerExt.Close();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   406
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   407
	return bearer;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   408
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   409
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   410
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   411
// CFMSSession::WriteDummyFile
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   412
// This method used when the variation wouldn't support and startup called
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   413
// and also differentiates hard reeboot(with empty or no file)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   414
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   415
void CFMSSession::WriteDummyFile()
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   416
	{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   417
	FLOG(_L("CFMSSession::WriteDummyFile--begin"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   418
	Server().WriteToFile(KErrNotFound,KErrNotFound,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   419
			(TDriveNumber)KErrNotFound,KErrNotFound,EFalse);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   420
	Server().DeleteFile(EFalse);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   421
	FLOG(_L("CFMSSession::WriteDummyFile--End"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   422
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   423
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   424
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   425
// CFMSSession::PhoneMode
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   426
// This method used to know the current phone mode
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   427
// If the phone is in dual mode it will check GPRS bearer only
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   428
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   429
void CFMSSession::PhoneModeL()
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   430
	{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   431
	FLOG(_L("CFMSSession::PhoneModeL--begin"));	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   432
	// find out if we are in 2G or in 3G - it is needed for calculating bearer availability
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   433
	__UHEAP_MARK; 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   434
	RTelServer telServer;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   435
	User::LeaveIfError( telServer.Connect());
73
hgs
parents: 51
diff changeset
   436
	CleanupClosePushL( telServer );
51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   437
	FLOG(_L("CFMSSession::PhoneModeL--telServer Connected"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   438
	RTelServer::TPhoneInfo teleinfo;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   439
	User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   440
	FLOG(_L("CFMSSession::PhoneModeL--telServer getting tel info"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   441
	RMobilePhone phone;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   442
	User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
73
hgs
parents: 51
diff changeset
   443
	CleanupClosePushL( phone );
51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   444
	FLOG(_L("CFMSSession::PhoneModeL--RMobilePhone opened"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   445
	User::LeaveIfError(phone.Initialise());	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   446
	FLOG(_L("CFMSSession::PhoneModeL--phone.Initialise() success"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   447
	RMobilePhone::TMobilePhoneNetworkMode mode;        	        	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   448
	TInt err = phone.GetCurrentMode( mode );
73
hgs
parents: 51
diff changeset
   449
	CleanupStack::PopAndDestroy(); // phone
hgs
parents: 51
diff changeset
   450
	CleanupStack::PopAndDestroy(); // telServer
51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   451
	__UHEAP_MARKEND;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   452
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   453
	if( KErrNone == err )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   454
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   455
		switch(mode)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   456
		{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   457
		case RMobilePhone::ENetworkModeGsm:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   458
		//case RMobilePhone::ENetworkModeUnknown:  // emulator default
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   459
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   460
			FLOG(_L("CFMSSession::PhoneModeL-begin-GSM Mode"));	                		
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   461
			iWcdmaBearer = EFalse;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   462
			Server().NetworkTypeL(EBearerIdGPRS);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   463
			break;		
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   464
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   465
		case RMobilePhone::ENetworkModeWcdma:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   466
			{                		     		
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   467
			FLOG(_L("CFMSSession::PhoneModeL-begin-3G Mode"));	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   468
			iWcdmaBearer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   469
			Server().SetWcdma();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   470
			Server().NetworkTypeL(EBearerIdWCDMA);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   471
			break;	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   472
			}	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   473
		default:        	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   474
		FLOG(_L("unknown"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   475
		}        				
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   476
		}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   477
	FLOG(_L("CFMSSession::PhoneModeL--end"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   478
	}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   479
	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   480
//----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   481
// CFMSSession::HandleBasedOnBearertypeL
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   482
// Handles based on bearer type
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   483
//----------------------------------------------------------------------------------------	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   484
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   485
void  CFMSSession::HandleBasedOnBearertypeL(const RMessage2& aMessage)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   486
{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   487
    TUint32 bearer = FindBearerIdL(aMessage.Int0());
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   488
		if( bearer == KUidPacketDataBearerType )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   489
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   490
			FLOG(_L("CFMSSession::DispatchMessageL bearer is packet data"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   491
			TRAPD(err,PhoneModeL());
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   492
			if(err); // remove compiler warning
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   493
			FLOG(_L("PhoneModeL() returns err as %d"),err);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   494
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   495
		else if	(	bearer == KUidWlanBearerType )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   496
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   497
			FLOG(_L("CFMSSession::DispatchMessageL bearer is WLAN"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   498
			iWlanbearer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   499
			Server().NetworkTypeL(EBearerIdWLAN);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   500
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   501
#if defined(__WINS__)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   502
		else if (   bearer == KUidLanBearerType )
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   503
		    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   504
            FLOG(_L("CFMSSession::DispatchMessageL bearer is LAN"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   505
            Server().NetworkTypeL(EBearerIdLAN);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   506
		    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   507
#endif
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   508
		else	
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   509
			{
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   510
			FLOG(_L("CFMSSession::DispatchMessageL bearer is not known and a leave happened "));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   511
			iStopServer = ETrue;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   512
			User::Leave(KErrArgument);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   513
			}
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   514
}				
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   515
//End of file