|
1 // Copyright (c) 2003-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 // Name : RSIPConnection.cpp |
|
15 // Part of : SIPClient |
|
16 // Version : SIP/3.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "RSIPConnection.h" |
|
22 #include "RSIP.h" |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // RSIPConnection::RSIPConnection |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 RSIPConnection::RSIPConnection(TUint32 aIapId) |
|
29 : RSubSessionBase (), |
|
30 iOpen (EFalse), |
|
31 iIapId (aIapId), |
|
32 iState (CSIPConnection::EInit) |
|
33 { |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // RSIPConnection::Open |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 TInt RSIPConnection::Open (RSIP& aSip) |
|
41 { |
|
42 TPckgBuf<TSIPIds> sipIdsPckg; |
|
43 sipIdsPckg().iIapId = iIapId; |
|
44 |
|
45 TIpcArgs args; |
|
46 args.Set (ESipItcArgIds, &sipIdsPckg); |
|
47 |
|
48 TPckgBuf<CSIPConnection::TState> statePckg; |
|
49 args.Set (ESipItcArgConnectionState, &statePckg); |
|
50 |
|
51 TInt err = CreateSubSession (aSip,ESipItcOpenSubSession,args); |
|
52 if (err == KErrNone) |
|
53 { |
|
54 iOpen = ETrue; |
|
55 iState = statePckg(); |
|
56 } |
|
57 return err; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // RSIPConnection::Close |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void RSIPConnection::Close() |
|
65 { |
|
66 if (iOpen) |
|
67 { |
|
68 iOpen = EFalse; |
|
69 CloseSubSession(ESipItcCloseSubSession); |
|
70 } |
|
71 iState = CSIPConnection::EInit; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // RSIPConnection::SetState |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void RSIPConnection::SetState (CSIPConnection::TState aState) |
|
79 { |
|
80 iState = aState; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // RSIPConnection::State |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CSIPConnection::TState RSIPConnection::State () const |
|
88 { |
|
89 return iState; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // RSIPConnection::Send |
|
94 // From MSIPITC |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 TInt RSIPConnection::Send(TSipItcFunctions aFunction, TIpcArgs& aArgs) const |
|
98 { |
|
99 // Sockopts can be set already before connection is active |
|
100 if (!iOpen || |
|
101 ( iState != CSIPConnection::EActive && |
|
102 aFunction != ESipItcSetSIPSockOpt && |
|
103 aFunction != ESipItcGetConnectionError) ) |
|
104 { |
|
105 return KErrNotReady; |
|
106 } |
|
107 return SendReceive(aFunction,aArgs); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // RSIPConnection::Receive |
|
112 // From MSIPITC |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void RSIPConnection::Receive (TIpcArgs& aArgs, |
|
116 TRequestStatus& aStatus) |
|
117 { |
|
118 SendReceive(ESipItcConnectionReadyToReceive,aArgs,aStatus); |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // RSIPConnection::Receive |
|
123 // From MSIPITC |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 TInt RSIPConnection::Receive (TIpcArgs& aArgs) |
|
127 { |
|
128 return SendReceive(ESipItcConnectionReceiveSipMessage,aArgs); |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // RSIPConnection::CancelReceive |
|
133 // From MSIPITC |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void RSIPConnection::CancelReceive () |
|
137 { |
|
138 // Add dummy parameters. Server expects TSIPIds for every request. |
|
139 TPckgBuf<TSIPIds> sipIdsPckg; |
|
140 TIpcArgs args; |
|
141 args.Set (ESipItcArgIds, &sipIdsPckg); |
|
142 |
|
143 SendReceive (ESipItcConnectionCancelReceive,args); |
|
144 } |