|
1 /* |
|
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html." |
|
8 * Initial Contributors: |
|
9 * Nokia Corporation - initial contribution. |
|
10 * Contributors: |
|
11 * |
|
12 * Description: |
|
13 * MSRP Implementation |
|
14 * |
|
15 */ |
|
16 |
|
17 #ifndef MMMSRPCONNECTION_H |
|
18 #define MMMSRPCONNECTION_H |
|
19 |
|
20 // INCLUDES |
|
21 #include <e32base.h> |
|
22 #include <in_sock.h> |
|
23 #include "MMSRPConnectionManager.h" |
|
24 #include "MMSRPConnectionObserver.h" |
|
25 #include "MMSRPWriterObserver.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class MMSRPConnectionObserver; |
|
29 class MMSRPWriterObserver; |
|
30 class MMSRPConnectionManager; |
|
31 |
|
32 // CLASS DECLARATIONS |
|
33 |
|
34 |
|
35 |
|
36 class MMSRPConnection |
|
37 { |
|
38 public: |
|
39 //move to CMSRPConn |
|
40 enum TMSRPConnectionState |
|
41 { |
|
42 EError = -1, |
|
43 ENotConnected = 0, |
|
44 EConnecting, |
|
45 EListening, |
|
46 //EListenConnected, |
|
47 EConnected, |
|
48 EListenTimedOut, |
|
49 EConnectTimedOut, |
|
50 EDisconnecting, //cancel issued on connecting socket |
|
51 EDisconnected//EConnectCancelling/ed |
|
52 //EListenConnected (as opposed to connect connected)//validation to be taken care by session |
|
53 //EListenValidated (received bodiless msg) //per session basis, hence these 2 states not needed |
|
54 }; |
|
55 // |
|
56 inline virtual ~MMSRPConnection(){} |
|
57 |
|
58 /** |
|
59 * Connect to remote address |
|
60 */ |
|
61 virtual TInt ConnectL(MMSRPConnectionObserver& aSubsession) = 0; |
|
62 |
|
63 /** |
|
64 * Listen to remote address |
|
65 * add observer and start listener, if not started |
|
66 * if new conn object i.e. single observer conn then |
|
67 * update listen count |
|
68 */ |
|
69 virtual TInt ListenL(MMSRPConnectionObserver& aSubsession) = 0; |
|
70 |
|
71 |
|
72 virtual TInt getConnectionState()=0; |
|
73 |
|
74 |
|
75 /** |
|
76 * Cancel the connect request if pending, else disconnect subsession |
|
77 */ |
|
78 //virtual void ConnectCancel(MMSRPConnectionObserver& aSubsession) = 0; //state == not connected means error |
|
79 //connecting : issue cancel connect on socket if only subsession pending |
|
80 //if connected: disconnect if only subsession pending |
|
81 //else listening, panic client |
|
82 /** |
|
83 * Cancel the listen request if pending, else disconnect subsession |
|
84 */ |
|
85 //virtual void ListenCancel(MMSRPConnectionObserver& aSubsession) = 0; |
|
86 |
|
87 /** |
|
88 * The particular subsession wishes to cease using the connection/ disconnect |
|
89 */ |
|
90 virtual void ReleaseConnection(MMSRPConnectionObserver& aSubsession) = 0; |
|
91 |
|
92 |
|
93 /** |
|
94 * Sends the buffer content |
|
95 * the observer cud be implemented by msg or subsession |
|
96 * connection observer deemed unnecessary in send call |
|
97 */ |
|
98 virtual void SendL( MMSRPWriterObserver& aMsg ) = 0; |
|
99 |
|
100 |
|
101 /** |
|
102 * use case unknown : connection failure detected, parse error on the connection |
|
103 * Send failed , goes directly to subsession. |
|
104 * In that scenario, subession could ask mngr to close connection itself as part of error recovery |
|
105 */ |
|
106 /** |
|
107 * mngr/server decides to close all subsessions on connection |
|
108 */ |
|
109 //virtual void CloseConnection() = 0; |
|
110 |
|
111 |
|
112 /*move to CMSrpConn*/ |
|
113 virtual TBool CheckConnection(TInetAddr& aRemoteAddr, TBool aOnlyListen) = 0; |
|
114 |
|
115 /** |
|
116 * connection observer is available with every request |
|
117 * NewL used to get a reference to connection mgr, |
|
118 * call delete connection entry in conn mngr on disconnect |
|
119 */ |
|
120 //virtual MMSRPConnection* NewL( TInetAddr& aRemoteAddr, MMSRPConnectionManager& aConnMngr) = 0; |
|
121 |
|
122 /** |
|
123 * called on listen complete by connection manager |
|
124 */ |
|
125 virtual void ConnectionEstablishedL( TInt aNewState, RSocket* aSocket, TInt aStatus ) = 0; |
|
126 |
|
127 |
|
128 /** |
|
129 * Cancel the send |
|
130 */ |
|
131 //Send called on subsession with message |
|
132 //Send cancel should be called on message (subsession with message id) |
|
133 //msg state modified to cancel next fetch of message by writer |
|
134 //but if the writer is sending same msg currently and send abort is issued then socket will need to be |
|
135 //shutdown with stopoutput and then restarted |
|
136 //Things cud get complicated , support not really necessary |
|
137 //virtual void SendCancel( MMSRPConnectionObserver& aSubsession, MsgPTr, TDesC8& aBuf ) = 0; |
|
138 |
|
139 }; |
|
140 |
|
141 #endif // MMMSRPCONNECTION_H |
|
142 |
|
143 // End of file |