engine/inc/ConnectionEngine.h
author skip
Thu, 25 Feb 2010 14:29:19 +0000
changeset 2 29cda98b007e
child 13 f58e3c482bd9
permissions -rw-r--r--
Initial import of Podcatcher from the Bergamot project
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
#ifndef PODCAST_CONNECTIONENGINE_H
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#define PODCAST_CONNECTIONENGINE_H
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
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
// Connect using mobility extension
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
#include <in_sock.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
#include <connpref.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
#include <commdbconnpref.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
#include <comms-infras/cs_mobility_apiext.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    28
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    29
// Using connection manager settings UI
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
#include <cmapplicationsettingsui.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
class CPodcastModel;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
class MConnectionObserver
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
public:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
	virtual void ConnectCompleteL(TInt aErrorCode) = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
	virtual void Disconnected() = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
	};
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
/**
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
 * This class helps to connect using three available methods
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
 * SNAP, Mobility extension and Connection manager UI
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
class CConnectionEngine:public CActive, public MMobilityProtocolResp
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    46
public:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
	enum TConnectionType
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
		EUserSelectConnection,		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
		ESNAPConnection,		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
		EMobilityConnection,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
		EDefaultConnection,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
		EIAPConnection
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
		};
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
	enum TConnectionState
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
		ENotConnected,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
		EConnecting,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
		EConnected
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
		};
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
	static CConnectionEngine* NewL(CPodcastModel& aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
	~CConnectionEngine();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
	void StartL(TConnectionType aConnectionType);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
	RConnection& Connection();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
	TConnectionState ConnectionState();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
	void AddObserver(MConnectionObserver* aObserver);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
	RSocketServ& SockServ();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
private: // Methods
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
	CConnectionEngine(CPodcastModel& aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
	void ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
protected:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
	// From CActive
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
	void RunL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
	void DoCancel();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	TInt RunError( TInt aError );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    78
protected:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    79
	// From MMobilityProtocolResp
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    80
	void PreferredCarrierAvailable( TAccessPointInfo aOldAPInfo,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    81
			TAccessPointInfo aNewAPInfo,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    82
			TBool aIsUpgrade,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
			TBool aIsSeamless );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	void NewCarrierActive( TAccessPointInfo aNewAPInfo, TBool aIsSeamless );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
	void Error( TInt aError );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
protected:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    88
	// UI Setting
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
	TBool ConnectionSettingL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
	void ReportConnection(TInt aError);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
private:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
	RConnection                   iConnection;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
	RSocketServ                   iSocketServer;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    95
	// Connect using mobility extension
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    96
	CActiveCommsMobilityApiExt*   iMobility;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    97
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    98
	// Using connection manager settings UI
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
	TCmSettingSelection   iUserSelection;
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
	// Connect using Commdb
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
	TCommDbConnPref iCommdbPreference;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
	// Connect using SNAP setting
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
	TConnSnapPref iSnapPreference;
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
	TConnectionType iConnectionType;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
	TConnectionState iConnectionState;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
	RPointerArray<MConnectionObserver> iObserverArray;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
	CPodcastModel &iPodcastModel; 	// reference to the model
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   111
	};
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   112
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   113
#endif // PODCAST_CONNECTIONENGINE_H