|
1 /* |
|
2 * Copyright (c) 2005 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 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "sip.h" |
|
22 #include "siperr.h" |
|
23 #include "sipnotifydialogassoc.h" |
|
24 #include "sipservertransaction.h" |
|
25 #include "siprequestelements.h" |
|
26 #include "sipmessageelements.h" |
|
27 #include "sipeventheader.h" |
|
28 #include "sipsubscriptionstateheader.h" |
|
29 #include "sipstrings.h" |
|
30 #include "sipstrconsts.h" |
|
31 #include "sipclienttransaction.h" |
|
32 #include "sipdialog.h" |
|
33 #include "cmcetls.h" |
|
34 |
|
35 #ifdef CPPUNIT_TEST |
|
36 |
|
37 #include "TestCleanupStack.h" |
|
38 |
|
39 #undef EXPORT_C |
|
40 #define EXPORT_C |
|
41 |
|
42 #endif |
|
43 |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CSIPNotifyDialogAssoc::NewL |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C CSIPNotifyDialogAssoc* |
|
50 CSIPNotifyDialogAssoc::NewL(CSIPServerTransaction& aTransaction, |
|
51 CSIPEventHeader* aEvent, |
|
52 CSIPSubscriptionStateHeader* aState) |
|
53 { |
|
54 CSIPNotifyDialogAssoc* self = |
|
55 CSIPNotifyDialogAssoc::NewLC(aTransaction, aEvent, aState); |
|
56 CleanupStack::Pop(self); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CSIPNotifyDialogAssoc::NewLC |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C CSIPNotifyDialogAssoc* |
|
65 CSIPNotifyDialogAssoc::NewLC(CSIPServerTransaction& aTransaction, |
|
66 CSIPEventHeader* aEvent, |
|
67 CSIPSubscriptionStateHeader* aState) |
|
68 { |
|
69 __ASSERT_ALWAYS( |
|
70 aTransaction.Type() == SIPStrings::StringF(SipStrConsts::ESubscribe) || |
|
71 aTransaction.Type() == SIPStrings::StringF(SipStrConsts::ERefer), |
|
72 User::Leave(KErrArgument)); |
|
73 |
|
74 __ASSERT_ALWAYS(aEvent && aState, User::Leave(KErrArgument)); |
|
75 |
|
76 CSIPNotifyDialogAssoc* self = new (ELeave) CSIPNotifyDialogAssoc(); |
|
77 CleanupStack::PushL(self); |
|
78 const CSIPRequestElements* req = aTransaction.RequestElements(); |
|
79 CSIPDialog* dlg = CSIPDialog::NewL( req->RemoteUri(), *req->FromHeader(), *req->ToHeader() ); |
|
80 CleanupStack::PushL( dlg ); |
|
81 self->ConstructL( SIPStrings::StringF( SipStrConsts::ENotify ), dlg, aTransaction ); |
|
82 CleanupStack::Pop( dlg ); |
|
83 |
|
84 self->iEvent = aEvent; |
|
85 self->iSubscriptionState = aState; |
|
86 |
|
87 return self; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CSIPNotifyDialogAssoc::NewL |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 EXPORT_C CSIPNotifyDialogAssoc* |
|
95 CSIPNotifyDialogAssoc::NewL(CSIPServerTransaction& aTransaction, |
|
96 const MSIPRegistrationContext& /*aContext*/, |
|
97 CSIPEventHeader* aEvent, |
|
98 CSIPSubscriptionStateHeader* aState) |
|
99 { |
|
100 return CSIPNotifyDialogAssoc::NewL(aTransaction,aEvent,aState); |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CSIPNotifyDialogAssoc::NewLC |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 EXPORT_C CSIPNotifyDialogAssoc* |
|
108 CSIPNotifyDialogAssoc::NewLC(CSIPServerTransaction& aTransaction, |
|
109 const MSIPRegistrationContext& /*aContext*/, |
|
110 CSIPEventHeader* aEvent, |
|
111 CSIPSubscriptionStateHeader* aState) |
|
112 { |
|
113 return CSIPNotifyDialogAssoc::NewLC(aTransaction,aEvent,aState); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CSIPNotifyDialogAssoc::CSIPNotifyDialogAssoc |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 CSIPNotifyDialogAssoc::CSIPNotifyDialogAssoc() |
|
121 { |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CSIPNotifyDialogAssoc::~CSIPNotifyDialogAssoc |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C CSIPNotifyDialogAssoc::~CSIPNotifyDialogAssoc() |
|
129 { |
|
130 delete iEvent; |
|
131 delete iSubscriptionState; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CSIPNotifyDialogAssoc::Event |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C const CSIPEventHeader& CSIPNotifyDialogAssoc::Event() const |
|
139 { |
|
140 return *iEvent; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CSIPNotifyDialogAssoc::SubscriptionState |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C CSIPSubscriptionStateHeader& CSIPNotifyDialogAssoc::SubscriptionState() |
|
148 { |
|
149 return *iSubscriptionState; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CSIPNotifyDialogAssoc::SubscriptionState |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 EXPORT_C const CSIPSubscriptionStateHeader& |
|
157 CSIPNotifyDialogAssoc::SubscriptionState() const |
|
158 { |
|
159 return *iSubscriptionState; |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CSIPNotifyDialogAssoc::SendNotifyL |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 EXPORT_C CSIPClientTransaction* |
|
167 CSIPNotifyDialogAssoc::SendNotifyL(CSIPMessageElements* aElements) |
|
168 { |
|
169 |
|
170 CSIPClientTransaction* trx = CSIPClientTransaction::NewL( SIPStrings::StringF( SipStrConsts::ENotify ) ); |
|
171 |
|
172 if ( CMCETls::Storage() ) |
|
173 { |
|
174 CMCETls::Storage()->SIPSends( SIPStrings::StringF( SipStrConsts::ENotify ), |
|
175 aElements ); |
|
176 } |
|
177 else |
|
178 { |
|
179 delete aElements; |
|
180 } |
|
181 |
|
182 return trx; |
|
183 |
|
184 } |