|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "ctransportmanager.h" |
|
17 #include "ctcptransportlayer.h" |
|
18 |
|
19 /** |
|
20 The factory constructor. |
|
21 |
|
22 @return A pointer to a fully constructed object. |
|
23 */ |
|
24 EXPORT_C CTransportManager* CTransportManager::NewL(TInt aSocketServerHandle, RConnection& aConnection) |
|
25 { |
|
26 CTransportManager* self = new(ELeave) CTransportManager(aSocketServerHandle, aConnection); |
|
27 CleanupStack::PushL(self); |
|
28 self->ConstructL(); |
|
29 CleanupStack::Pop(self); |
|
30 return self; |
|
31 } |
|
32 |
|
33 /** |
|
34 Constructor. |
|
35 */ |
|
36 CTransportManager::CTransportManager(TInt aSocketServerHandle, RConnection& aConnection) : |
|
37 iSocketServerHandle(aSocketServerHandle), |
|
38 iConnection(&aConnection) |
|
39 { |
|
40 } |
|
41 |
|
42 /** |
|
43 Second phase constructor. Sets up the TCP layer and |
|
44 assigns the object to iTcpLayer. |
|
45 */ |
|
46 void CTransportManager::ConstructL() |
|
47 { |
|
48 iTcpLayer = CTcpTransportLayer::NewL(*this); |
|
49 } |
|
50 |
|
51 /** |
|
52 Destructor. |
|
53 */ |
|
54 EXPORT_C CTransportManager::~CTransportManager() |
|
55 { |
|
56 delete iTcpLayer; |
|
57 } |
|
58 |
|
59 /** |
|
60 Return the connected sockets to caller. |
|
61 |
|
62 @return Obtain the connected sockets. |
|
63 */ |
|
64 EXPORT_C MSocketFactory& CTransportManager::SocketFactory() |
|
65 { |
|
66 return *iTcpLayer; |
|
67 } |
|
68 |
|
69 /** |
|
70 Supply the comms connection |
|
71 |
|
72 @param aSocketServerHandle The handle to the socket server. |
|
73 @param aConnectionPtr The network connection |
|
74 @return Boolean value stating whether comms connection supplied. |
|
75 */ |
|
76 TBool CTransportManager::SupplyCommsConnection(TInt& aSocketServerHandle, RConnection*& aConnectionPtr) |
|
77 { |
|
78 if (iSocketServerHandle != 0) |
|
79 { |
|
80 aSocketServerHandle = iSocketServerHandle; |
|
81 aConnectionPtr = iConnection; |
|
82 return ETrue; |
|
83 } |
|
84 |
|
85 return EFalse; |
|
86 } |
|
87 |
|
88 /** |
|
89 Set the comms connection |
|
90 |
|
91 @param aSocketServerHandle The handle to the socket server. |
|
92 @param aConnectionPtr The network connection. |
|
93 */ |
|
94 void CTransportManager::SetCommsConnectionL(TInt aSocketServerHandle, RConnection*& aConnectionPtr) |
|
95 { |
|
96 iSocketServerHandle = aSocketServerHandle; |
|
97 iConnection = aConnectionPtr; |
|
98 } |
|
99 |
|
100 /** |
|
101 Provide security preferences |
|
102 |
|
103 @param aDialogPrompt The dialog prompt for security dialogs. |
|
104 */ |
|
105 void CTransportManager::GetSecurityPrefs(TBool& aDialogPrompt) |
|
106 { |
|
107 // Allow security dialogs |
|
108 aDialogPrompt = ETrue; |
|
109 } |