|
1 // Copyright (c) 2005-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 : RSIPClientDiscovery.cpp |
|
15 // Part of : SIP Client Resolver |
|
16 // Version : 1.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 #include "RSIPClientDiscovery.h" |
|
23 #include "SIPClientResolverServerStarter.h" |
|
24 #include "sipclientdiscovery.pan" |
|
25 |
|
26 // MACROS |
|
27 #define RETURN_IF_ERROR(err) {TInt _err=err; if(_err!=KErrNone) {return _err;}} |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // RSIPClientDiscoveryClientDiscovery::RSIPClientDiscovery |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 RSIPClientDiscovery::RSIPClientDiscovery() |
|
36 : RSessionBase (), |
|
37 iConnected (EFalse) |
|
38 { |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // RSIPClientDiscovery::Connect |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 TInt RSIPClientDiscovery::Connect (TUid aSelf) |
|
46 { |
|
47 RETURN_IF_ERROR(SIPClientResolverServerStarter::Start()) |
|
48 |
|
49 RETURN_IF_ERROR(CreateSession(KSipClientResolverServerName, Version())) |
|
50 |
|
51 RETURN_IF_ERROR(SendClientUid(aSelf)) |
|
52 |
|
53 iConnected = ETrue; |
|
54 return KErrNone; |
|
55 } |
|
56 |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // RSIPClientDiscovery::Close |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void RSIPClientDiscovery::Close() |
|
63 { |
|
64 RHandleBase::Close(); |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // RSIPClientDiscovery::SendReceive |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 TInt RSIPClientDiscovery::SendReceive(TSIPCRIpcFunctions aFunction, |
|
72 const TIpcArgs& aArgs) const |
|
73 { |
|
74 return RSessionBase::SendReceive(aFunction,aArgs); |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // RSIPClientDiscovery::Send |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 TInt RSIPClientDiscovery::Send (TSIPCRIpcFunctions aFunction, TIpcArgs& aArgs) |
|
82 { |
|
83 __ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected)); |
|
84 |
|
85 return SendReceive (aFunction, aArgs); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // RSIPClientDiscovery::Receive |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void RSIPClientDiscovery::Receive (TIpcArgs& aArgs, TRequestStatus& aStatus) |
|
93 { |
|
94 __ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected)); |
|
95 |
|
96 RSessionBase::SendReceive(ESIPCRIpcClientReadyToReceive,aArgs,aStatus); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // RSIPClientDiscovery::Receive |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 TInt RSIPClientDiscovery::Receive (TIpcArgs& aArgs) |
|
104 { |
|
105 __ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected)); |
|
106 |
|
107 return SendReceive(ESIPCRIpcClientReceiveSipResponse, aArgs); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // RSIPClientDiscovery::CancelReceive |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void RSIPClientDiscovery::CancelReceive () |
|
115 { |
|
116 __ASSERT_ALWAYS (iConnected, Panic(ESipClientNotConnected)); |
|
117 |
|
118 SendReceive (ESIPCRIpcClientCancelReceive, TIpcArgs()); |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // RSIPClientDiscovery::SendClientUid |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 TInt RSIPClientDiscovery::SendClientUid (const TUid& aUid) const |
|
126 { |
|
127 TPckgBuf<TUid> clientUidPckg(aUid); |
|
128 TIpcArgs ipcArgs; |
|
129 ipcArgs.Set (ESIPCRIpcArgClientUid, &clientUidPckg); |
|
130 return SendReceive (ESIPCRIpcSetClientUid, ipcArgs); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // RSIPClientDiscovery::Version |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 TVersion RSIPClientDiscovery::Version(void) const |
|
138 { |
|
139 TVersion version (KSipCRServerMajorVersionNumber, |
|
140 KSipCRServerMinorVersionNumber, |
|
141 KSipCRServerBuildVersionNumber); |
|
142 return version; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // RSIPClientDiscovery::Panic |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void RSIPClientDiscovery::Panic (TInt aReason) const |
|
150 { |
|
151 User::Panic(KSIPClientDiscovery, aReason); |
|
152 } |
|
153 |
|
154 // End of File |