|
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 : CSIPRegistrarStore.cpp |
|
15 // Part of : Registration |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "CSIPRegistrarStore.h" |
|
22 #include "CSIPRegistrar.h" |
|
23 #include "uricontainer.h" |
|
24 #include "DeleteMgr.h" |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CSIPRegistrarStore::NewL |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CSIPRegistrarStore* CSIPRegistrarStore::NewL() |
|
31 { |
|
32 CSIPRegistrarStore* self = CSIPRegistrarStore::NewLC(); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CSIPRegistrarStore::NewLC |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CSIPRegistrarStore* CSIPRegistrarStore::NewLC() |
|
42 { |
|
43 CSIPRegistrarStore* self = new (ELeave) CSIPRegistrarStore(); |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CSIPRegistrarStore::CSIPRegistrarStore |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CSIPRegistrarStore::CSIPRegistrarStore() |
|
54 { |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CSIPRegistrarStore::ConstructL |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CSIPRegistrarStore::ConstructL() |
|
62 { |
|
63 iDeleteMgr = CDeleteMgr::NewL(); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSIPRegistrarStore::~CSIPRegistrarStore |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CSIPRegistrarStore::~CSIPRegistrarStore() |
|
71 { |
|
72 iRegistrars.ResetAndDestroy(); |
|
73 delete iDeleteMgr; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CSIPRegistrarStore::CreateRegistrarL |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CSIPRegistrar* CSIPRegistrarStore::CreateRegistrarL( |
|
81 const CURIContainer& aRegistrarName, |
|
82 const TDesC8& aCallId, |
|
83 TUint aCSeq, |
|
84 const TRegistrationId aRegistrationId) |
|
85 { |
|
86 CSIPRegistrar* registrar = CSIPRegistrar::NewLC( |
|
87 aRegistrarName, aCallId, aCSeq, aRegistrationId, *this); |
|
88 iRegistrars.AppendL(registrar); |
|
89 CleanupStack::Pop(registrar); |
|
90 return registrar; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CSIPRegistrarStore::FindRegistrar |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CSIPRegistrar* CSIPRegistrarStore::FindRegistrar( |
|
98 const CURIContainer& aRegistrarName) |
|
99 { |
|
100 CSIPRegistrar* returnValue = NULL; |
|
101 |
|
102 for (TInt i=iRegistrars.Count()-1; (i>=0 && !returnValue); i--) |
|
103 { |
|
104 if ((iRegistrars[i])->Registrar() == aRegistrarName) |
|
105 { |
|
106 returnValue = iRegistrars[i]; |
|
107 } |
|
108 } |
|
109 |
|
110 return returnValue; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CSIPRegistrarStore::RemoveRegistrar |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 TInt CSIPRegistrarStore::RemoveRegistrar(CSIPRegistrar* aRegistrar) |
|
118 { |
|
119 TInt err = KErrGeneral; |
|
120 TInt index = iRegistrars.Find(aRegistrar); |
|
121 |
|
122 if (index != KErrNotFound) |
|
123 { |
|
124 err = iDeleteMgr->AddDeleteRequest(aRegistrar); |
|
125 |
|
126 if (err == KErrNone) |
|
127 { |
|
128 // remove it from registrars array |
|
129 iRegistrars.Remove(index); |
|
130 } |
|
131 } |
|
132 |
|
133 return err; |
|
134 } |
|
135 |