|
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 : RSIP.cpp |
|
15 // Part of : SIPClient |
|
16 // Version : SIP/3.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include "sipclient.h" |
|
23 #include "RSIP.h" |
|
24 #include "sipclientserver.h" |
|
25 #include "SIPServerStarter.h" |
|
26 #include "sipclient.pan" |
|
27 #include "apaid.h" |
|
28 #include "apgcli.h" |
|
29 |
|
30 #define RETURN_IF_ERROR(err) {TInt _err=err; if(_err!=KErrNone) {return _err;}} |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // RSIP::RSIP |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 RSIP::RSIP() |
|
37 : RSessionBase (), |
|
38 iConnected (EFalse) |
|
39 { |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // RSIP::Version |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 TVersion RSIP::Version(void) const |
|
47 { |
|
48 TVersion version (KSipServerMajorVersionNumber, |
|
49 KSipServerMinorVersionNumber, |
|
50 KSipServerBuildVersionNumber); |
|
51 return version; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // RSIP::Connect |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 TInt RSIP::Connect (const TUid& aUid) |
|
59 { |
|
60 RETURN_IF_ERROR (SIPServerStarter::Start ()) |
|
61 |
|
62 RETURN_IF_ERROR (CreateSession (KSipServerName,Version())) |
|
63 |
|
64 RETURN_IF_ERROR (SendClientUid(aUid)) |
|
65 |
|
66 iConnected = ETrue; |
|
67 return KErrNone; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // RSIP::Connect |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 TInt RSIP::Connect () |
|
75 { |
|
76 RETURN_IF_ERROR (SIPServerStarter::Start ()) |
|
77 |
|
78 RETURN_IF_ERROR (CreateSession (KSipServerName,Version())) |
|
79 |
|
80 iConnected = ETrue; |
|
81 return KErrNone; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // RSIP::Close |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void RSIP::Close() |
|
89 { |
|
90 iConnected = EFalse; |
|
91 RHandleBase::Close(); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // RSIP::Send |
|
96 // From MSIPITC |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TInt RSIP::Send (TSipItcFunctions aFunction, TIpcArgs& aArgs) const |
|
100 { |
|
101 __ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected)); |
|
102 |
|
103 return SendReceive(aFunction, aArgs); |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // RSIP::Receive |
|
108 // From MSIPITC |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void RSIP::Receive (TIpcArgs& aArgs, TRequestStatus& aStatus) |
|
112 { |
|
113 __ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected)); |
|
114 |
|
115 SendReceive(ESipItcClientReadyToReceive,aArgs,aStatus); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // RSIP::Receive |
|
120 // From MSIPITC |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 TInt RSIP::Receive (TIpcArgs& aArgs) |
|
124 { |
|
125 __ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected)); |
|
126 |
|
127 return SendReceive(ESipItcClientReceiveSipMessage,aArgs); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // RSIP::CancelReceive |
|
132 // From MSIPITC |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void RSIP::CancelReceive () |
|
136 { |
|
137 __ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected)); |
|
138 |
|
139 SendReceive(ESipItcClientCancelReceive, TIpcArgs()); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // RSIP::SendAppUid |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TInt RSIP::SendClientUid (const TUid& aUid) const |
|
147 { |
|
148 TPckgBuf<TInt> clientUidPckg(aUid.iUid); |
|
149 TIpcArgs itcMsgArgs; |
|
150 itcMsgArgs.Set (ESipItcArgAppUid, &clientUidPckg); |
|
151 |
|
152 return SendReceive(ESipItcSetAppUid, itcMsgArgs); |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // RSIP::Panic |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void RSIP::Panic (TInt aReason) const |
|
160 { |
|
161 User::Panic(KSipClient, aReason); |
|
162 } |