engine/src/ConnectionEngine.cpp
author Sebastian Brannstrom <sebastianb@symbian.org>
Sat, 30 Oct 2010 13:52:07 +0100
branchRCL_3
changeset 310 2e0299e13cbf
parent 285 4d42a5e09930
child 368 b131f7696342
permissions -rw-r--r--
Probable fix for HTTP ESock issues
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     1
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     2
 * Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     3
 *
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     4
 * All rights reserved.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     5
 * This component and the accompanying materials are made available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     6
 * under the terms of the License "Eclipse Public License v1.0"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     7
 * which accompanies this distribution, and is available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     8
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     9
 *
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    10
 * Initial Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    11
 * EmbedDev AB - initial contribution.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    12
 *
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    13
 * Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    14
 *
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    15
 * Description:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    16
 *
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    17
 */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    18
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    19
#include "connectionengine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#include "settingsengine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
#include "podcastmodel.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
CConnectionEngine* CConnectionEngine::NewL(CPodcastModel& aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
	CConnectionEngine* self = new (ELeave) CConnectionEngine(aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
	CleanupStack::PushL(self);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
	self->ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
	CleanupStack::Pop(self);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
	return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
CConnectionEngine::~CConnectionEngine()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
	delete iMobility;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
	Cancel();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
	iConnection.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
	iSocketServer.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
	iObserverArray.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
CConnectionEngine::CConnectionEngine(CPodcastModel& aPodcastModel):
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
					CActive(CActive::EPriorityStandard),iPodcastModel(aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
	CActiveScheduler::Add(this);	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
void CConnectionEngine::ConstructL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
	User::LeaveIfError(iSocketServer.Connect());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
	User::LeaveIfError( iConnection.Open( iSocketServer ) );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
void CConnectionEngine::RunL()
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    58
	{
310
2e0299e13cbf Probable fix for HTTP ESock issues
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 285
diff changeset
    59
	DP2("CConnectionEngine::RunL BEGIN, iStatus.Int()=%d, iConnectionState=%d", iStatus.Int(), iConnectionState);
2e0299e13cbf Probable fix for HTTP ESock issues
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 285
diff changeset
    60
	if ( iStatus.Int() == KErrNone && iMobility == NULL && iConnectionState == EConnected)
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    61
		{
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    62
		TRAPD(err, iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this ));
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    63
		
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    64
		if (err != KErrNone)
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    65
			{
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    66
			DP1("Leave in CActiveCommsMobilityApiExt::NewL, err=%d", err);
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    67
			}
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
	iConnectionState = iStatus.Int() == KErrNone?CConnectionEngine::EConnected:CConnectionEngine::ENotConnected;
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 13
diff changeset
    71
	ReportConnectionL( iStatus.Int() );
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    72
	DP("CConnectionEngine::RunL END");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
void CConnectionEngine::DoCancel()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
TInt CConnectionEngine::RunError( TInt /*aError*/ )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
	return KErrNone;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
void CConnectionEngine::PreferredCarrierAvailable( TAccessPointInfo /*aOldAPInfo*/,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
		TAccessPointInfo /*aNewAPInfo*/,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
		TBool aIsUpgrade,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
		TBool aIsSeamless )
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    88
	{
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
    89
	DP("CConnectionEngine::PreferredCarrierAvailable");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
	if ( aIsUpgrade )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
		{        
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
		{       
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
	if ( aIsSeamless )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
		// in S60 3.2, this situation cannot occur.        
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
		{       
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
		// Sockets have to be closed at this point.        
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
		iMobility->MigrateToPreferredCarrier();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
void CConnectionEngine::NewCarrierActive( TAccessPointInfo /*aNewAPInfo*/, TBool aIsSeamless )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
	{    
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   112
	DP("CConnectionEngine::NewCarrierActive");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
	if ( aIsSeamless )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   114
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   115
		// in S60 3.2, this situation cannot occur.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   116
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   117
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   118
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   119
		{        
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   120
		// Sockets have to be re-opened and check they can connect
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
		// to their server at this point.        
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
		iMobility->NewCarrierAccepted();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   125
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   126
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   127
void CConnectionEngine::Error( TInt /*aError*/ )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   128
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   129
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   130
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
TBool CConnectionEngine::ConnectionSettingL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
	{
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   134
	DP("CConnectionEngine::ConnectionSettingL");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
	TBool selected( EFalse );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   137
	CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   138
	CleanupStack::PushL( settings );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   139
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   140
	TUint listedItems = 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
	CMManager::EShowDefaultConnection |
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
	CMManager::EShowDestinations;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
	TBearerFilterArray filter;
13
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   145
	ReportConnectionSelectionStart();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
	selected = settings->RunApplicationSettingsL( iUserSelection,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
			listedItems,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
			filter );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   150
	CleanupStack::PopAndDestroy( settings );
13
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   151
	ReportConnectionSelectionEnd();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
	return selected;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
void CConnectionEngine::StartL(TConnectionType aConnectionType)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   157
	{
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   158
	DP1("CConnectionEngine::StartL BEGIN, aConnectionType=%d", aConnectionType);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   160
	iConnection.Close();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   161
	User::LeaveIfError( iConnection.Open( iSocketServer ) );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
	// Connect using UI Setting
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
	if(aConnectionType == EDefaultConnection)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   165
		iConnection.Start( iStatus );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
		SetActive();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   167
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
	else if(aConnectionType == EUserSelectConnection)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   169
		{				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   170
		TBool selected = ConnectionSettingL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
		if ( selected )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
			switch ( iUserSelection.iResult )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   176
				case CMManager::EDestination:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
					{					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   178
					iSnapPreference.SetSnap( iUserSelection.iId );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   179
					iConnection.Start( iSnapPreference, iStatus );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
					aConnectionType = ESNAPConnection;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   181
					break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   182
					}				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   183
				default: // CMManager::EAlwaysAsk
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   184
				case CMManager::EDefaultConnection:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   185
					{					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
					iConnection.Start( iStatus );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
					break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   188
					}									
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   189
				}						
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   192
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
			TRequestStatus* status = &iStatus;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
			User::RequestComplete(status, KErrCancel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   195
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   196
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   197
			SetActive();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   198
		}	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
	else if (aConnectionType == EIAPConnection)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
		iCommdbPreference.SetIapId((iPodcastModel.SettingsEngine().SpecificIAP()& KUseIAPMask));
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
		iCommdbPreference.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
		iCommdbPreference.SetDirection(ECommDbConnectionDirectionOutgoing);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
		iConnection.Start( iCommdbPreference, iStatus );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   205
		SetActive();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   206
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
	// Connect using SNAP 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
		iSnapPreference.SetSnap(iPodcastModel.SettingsEngine().SpecificIAP());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
		iConnection.Start( iSnapPreference, iStatus );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
		SetActive();	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
		}		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
	iConnectionType = aConnectionType;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
	iConnectionState = CConnectionEngine::EConnecting;
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   217
	DP1("CConnectionEngine::StartL END, iConnectionState=%d", iConnectionState);	
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   218
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   219
163
f94dbd678dda Fix for bug 3183; merging minor differences with symbian1 branch
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 96
diff changeset
   220
void CConnectionEngine::Stop()
f94dbd678dda Fix for bug 3183; merging minor differences with symbian1 branch
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 96
diff changeset
   221
	{
f94dbd678dda Fix for bug 3183; merging minor differences with symbian1 branch
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 96
diff changeset
   222
	DP("CConnectionEngine::Stop");
f94dbd678dda Fix for bug 3183; merging minor differences with symbian1 branch
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 96
diff changeset
   223
	iConnection.Stop();
f94dbd678dda Fix for bug 3183; merging minor differences with symbian1 branch
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 96
diff changeset
   224
	iConnectionState = CConnectionEngine::ENotConnected;
f94dbd678dda Fix for bug 3183; merging minor differences with symbian1 branch
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 96
diff changeset
   225
	}
f94dbd678dda Fix for bug 3183; merging minor differences with symbian1 branch
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 96
diff changeset
   226
f94dbd678dda Fix for bug 3183; merging minor differences with symbian1 branch
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 96
diff changeset
   227
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   228
RConnection& CConnectionEngine::Connection()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   229
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
	return iConnection;	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   231
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   232
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   233
CConnectionEngine::TConnectionState CConnectionEngine::ConnectionState()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   234
	{
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   235
	DP("CConnectionEngine::ConnectionState BEGIN");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   236
	TInt selectedConn = (TInt) iSnapPreference.Snap();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   237
	TInt specIAPSNAP = iPodcastModel.SettingsEngine().SpecificIAP();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
	// If we have IAP preference then get that from our current connection and mask out the selected iap
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   239
	if((specIAPSNAP&KUseIAPFlag))
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   240
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
		selectedConn = iCommdbPreference.IapId();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   242
		specIAPSNAP = specIAPSNAP&KUseIAPMask;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   243
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   244
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
	// IAPSNAP must be > 0 and then  if the IAP/Sel conn IAP differs
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
	if(specIAPSNAP >0 && specIAPSNAP !=  selectedConn )
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   247
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   248
		if(iConnection.SubSessionHandle() != 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   249
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
			iConnection.Stop();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   251
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   252
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
		iConnectionState = CConnectionEngine::ENotConnected;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   254
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   255
	else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   256
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   257
		// We have a user selection or default selction, check our current connection state.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   258
		TNifProgress progress;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   259
		if(iConnection.Progress(progress) == KErrNone)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   260
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   261
			if(progress.iError == KErrNone && progress.iStage != 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   262
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   263
				if(progress.iStage == KLinkLayerOpen)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   264
					{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   265
					iConnectionState = CConnectionEngine::EConnected;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   266
					}				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   267
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   268
			else if(iConnectionState != CConnectionEngine::EConnecting)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   269
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   270
				iConnectionState = CConnectionEngine::ENotConnected;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   271
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   272
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   273
		else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   274
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   275
			iConnectionState = CConnectionEngine::ENotConnected;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   276
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   277
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   278
	
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   279
	DP("CConnectionEngine::ConnectionState END");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   280
	return iConnectionState;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   281
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   282
59
9569ea080d5a Export the proper functions for DLL usage
Lars Persson <lars.persson@embeddev.se>
parents: 13
diff changeset
   283
EXPORT_C void CConnectionEngine::AddObserver(MConnectionObserver* aObserver)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   284
	{
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   285
	DP("CConnectionEngine::AddObserver");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   286
	iObserverArray.Append(aObserver);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   287
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   288
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   289
EXPORT_C void CConnectionEngine::RemoveObserver(MConnectionObserver* aObserver)
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   290
	{
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   291
	DP("CConnectionEngine::RemoveObserver");
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   292
	for (int i=0;i<iObserverArray.Count();i++)
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   293
		{
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   294
		if (iObserverArray[i] == aObserver)
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   295
			{
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   296
			iObserverArray.Remove(i);
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   297
			}
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   298
			
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   299
		}
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   300
	}
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   301
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   302
RSocketServ& CConnectionEngine::SockServ()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   303
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   304
	return iSocketServer;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   305
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   306
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   307
35
66c5303f3610 A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents: 13
diff changeset
   308
void CConnectionEngine::ReportConnectionL(TInt aError)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   309
	{
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   310
	DP1("CConnectionEngine::ReportConnectionL, aError=%d", aError);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   311
	TInt noObservers = iObserverArray.Count();
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   312
	DP1("    noObservers=%d", noObservers);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   313
	while(noObservers)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   314
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   315
		noObservers--;
285
4d42a5e09930 Significant robustness improvements for ConnectionEngine
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 163
diff changeset
   316
		DP("    calling callback");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   317
		iObserverArray[noObservers]->ConnectCompleteL(aError);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   318
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   319
	}
13
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   320
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   321
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   322
void CConnectionEngine::ReportConnectionSelectionStart()
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   323
	{
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   324
	TInt noObservers = iObserverArray.Count();
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   325
	while(noObservers)
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   326
		{
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   327
		noObservers--;
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   328
		iObserverArray[noObservers]->ConnectionSelectionStart();
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   329
		}
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   330
	}
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   331
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   332
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   333
void CConnectionEngine::ReportConnectionSelectionEnd()
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   334
	{
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   335
	TInt noObservers = iObserverArray.Count();
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   336
	while(noObservers)
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   337
		{
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   338
		noObservers--;
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   339
		iObserverArray[noObservers]->ConnectionSelectionEnd();
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   340
		}
f58e3c482bd9 Toolbars now hide when connection query appears
teknolog
parents: 2
diff changeset
   341
	}