|
1 // Copyright (c) 2007-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 : sipalrhandler.cpp |
|
15 // Part of : SIP / SIP Profile Server |
|
16 // Version : SIP/6.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "sipalrhandler.h" |
|
22 #include "sipalrmonitor.h" |
|
23 #include "SipProfileCacheItem.h" |
|
24 #include "sipprofileerrorhandler.h" |
|
25 |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CSipAlrHandler::NewL |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CSipAlrHandler* CSipAlrHandler::NewL( |
|
32 MSipProfileErrorHandler& aErrorHandler, |
|
33 CSipSystemStateMonitor* aSystemStateMonitor) |
|
34 { |
|
35 return new(ELeave)CSipAlrHandler(aErrorHandler,aSystemStateMonitor); |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CSipAlrHandler::CSipAlrHandler |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CSipAlrHandler::CSipAlrHandler( |
|
43 MSipProfileErrorHandler& aErrorHandler, |
|
44 CSipSystemStateMonitor* aSystemStateMonitor) : |
|
45 iErrorHandler(aErrorHandler), |
|
46 iSystemStateMonitor(aSystemStateMonitor) |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CSipAlrHandler::~CSipAlrHandler |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CSipAlrHandler::~CSipAlrHandler() |
|
55 { |
|
56 delete iAlrMonitor; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CSipAlrHandler::EnableProfileL |
|
61 // If SNAP is not configured, work in the old way. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CSipAlrHandler::EnableProfileL(CSIPProfileCacheItem& aProfile, |
|
65 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
66 { |
|
67 TInt err(KErrNone); |
|
68 TUint32 snapId(0); |
|
69 if (aProfile.IsSNAPConfigured(snapId)) |
|
70 { |
|
71 TRAP(err, aProfile.EnableSnapInUseL(aObserver, snapId)); |
|
72 } |
|
73 else |
|
74 { |
|
75 TRAP(err, aProfile.EnableL(aObserver)); |
|
76 } |
|
77 |
|
78 if (err != KErrNone) |
|
79 { |
|
80 HandleErrorL(aProfile, err, err); |
|
81 } |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CSipAlrHandler::DisableProfileL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CSipAlrHandler::DisableProfileL(CSIPProfileCacheItem& aProfile, |
|
89 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
90 { |
|
91 TRAPD(err, aProfile.DisableL(aObserver)); |
|
92 if (err != KErrNone) |
|
93 { |
|
94 HandleErrorL(aProfile, err, KErrNone); |
|
95 } |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CSipAlrHandler::AllowMigrationL |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CSipAlrHandler::AllowMigrationL(CSIPProfileCacheItem& aProfile, |
|
103 TUint32 aIapId, |
|
104 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
105 { |
|
106 TRAPD(err, aProfile.ClientAllowsMigrationL(aIapId, aObserver)); |
|
107 if (err != KErrNone) |
|
108 { |
|
109 HandleErrorL(aProfile, err, err); |
|
110 } |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CSipAlrHandler::DisallowMigrationL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CSipAlrHandler::DisallowMigrationL(CSIPProfileCacheItem& aProfile, |
|
118 TUint32 aIapId, |
|
119 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
120 { |
|
121 TRAPD(err, aProfile.ClientDisallowsMigrationL(aIapId, aObserver)); |
|
122 if (err != KErrNone) |
|
123 { |
|
124 HandleErrorL(aProfile, err, err); |
|
125 } |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CSipAlrHandler::RefreshIapAvailabilityL |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CSipAlrHandler::RefreshIapAvailabilityL(CSIPProfileCacheItem& aProfile) |
|
133 { |
|
134 TUint32 snapId(0); |
|
135 __ASSERT_ALWAYS(aProfile.IsSNAPConfigured(snapId), |
|
136 User::Leave(KErrArgument)); |
|
137 |
|
138 AlrMonitorL().RefreshIapAvailabilityL(snapId); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CSipAlrHandler::AlrMonitorL |
|
143 // Create the monitor on demand. It must not be loaded on start-up if not needed |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 CSipAlrMonitor& CSipAlrHandler::AlrMonitorL() |
|
147 { |
|
148 if (!iAlrMonitor) |
|
149 { |
|
150 __ASSERT_ALWAYS(iSystemStateMonitor, User::Leave(KErrNotSupported)); |
|
151 iAlrMonitor = CSipAlrMonitor::NewL(*iSystemStateMonitor); |
|
152 } |
|
153 return *iAlrMonitor; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CSipAlrHandler::HandleErrorL |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CSipAlrHandler::HandleErrorL(CSIPProfileCacheItem& aItem, |
|
161 TInt aErr, |
|
162 TInt aOwnError) |
|
163 { |
|
164 if (aItem.ReferenceCount() == 0 && |
|
165 !aItem.Profile().IsAutoRegistrationEnabled()) |
|
166 { |
|
167 iErrorHandler.HandleProfileError(aItem, aOwnError); |
|
168 } |
|
169 User::Leave(aErr); |
|
170 } |