|
1 /* |
|
2 * Copyright (c) 2010 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: Implementation of the im operation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "edcontactorheaders.h" |
|
22 |
|
23 // ============================ MEMBER FUNCTIONS =============================== |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CEDContactorIMOperation::CEDContactorIMOperation() |
|
27 // ----------------------------------------------------------------------------- |
|
28 // |
|
29 CEDContactorIMOperation::CEDContactorIMOperation(const TDesC& aParam) : CEDContactorOperation(aParam) |
|
30 { |
|
31 iPlugin = NULL; |
|
32 } |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CEDContactorIMOperation::~CEDContactorIMOperation() |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CEDContactorIMOperation::~CEDContactorIMOperation() |
|
39 { |
|
40 delete iPlugin; |
|
41 iPlugin = NULL; |
|
42 REComSession::FinalClose(); |
|
43 delete iSPSettings; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CEDContactorIMOperation::NewLC() |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CEDContactorIMOperation* CEDContactorIMOperation::NewLC(const TDesC& aParam) |
|
51 { |
|
52 CEDContactorIMOperation* self = new (ELeave)CEDContactorIMOperation(aParam); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CEDContactorIMOperation::NewL() |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CEDContactorIMOperation* CEDContactorIMOperation::NewL(const TDesC& aParam) |
|
63 { |
|
64 CEDContactorIMOperation* self=CEDContactorIMOperation::NewLC(aParam); |
|
65 CleanupStack::Pop(); // self; |
|
66 return self; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CEDContactorIMOperation::ConstructL() |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CEDContactorIMOperation::ConstructL() |
|
74 { |
|
75 iSPSettings = CSPSettings::NewL(); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CEDContactorIMOperation::ExecuteLD() |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CEDContactorIMOperation::ExecuteLD() |
|
83 { |
|
84 CleanupStack::PushL(this); |
|
85 TPtrC aXspId = iParam; |
|
86 |
|
87 TUid dllUid = ResolveEcomUidL( ExtractService(aXspId) ); |
|
88 LoadEcomL( dllUid, aXspId ); |
|
89 CleanupStack::PopAndDestroy(this); |
|
90 } |
|
91 |
|
92 // -------------------------------------------------------------------------- |
|
93 // CEDContactorIMOperation::ResolveEcomUidL |
|
94 // -------------------------------------------------------------------------- |
|
95 // |
|
96 TUid CEDContactorIMOperation::ResolveEcomUidL( const TDesC& aServiceId ) |
|
97 { |
|
98 // Resolve ECom UID from SP settings |
|
99 TInt launchId = KErrNotFound; |
|
100 |
|
101 launchId = DoResolveEcomUidL( aServiceId ); |
|
102 TUid launchUid = {launchId }; |
|
103 return launchUid; |
|
104 } |
|
105 |
|
106 // -------------------------------------------------------------------------- |
|
107 // CEDContactorIMOperation::DoResolveEcomUidL |
|
108 // -------------------------------------------------------------------------- |
|
109 // |
|
110 TInt CEDContactorIMOperation::DoResolveEcomUidL( const TDesC& aServiceId ) |
|
111 { |
|
112 // Resolve ECom UID from SP settings |
|
113 TInt err = KErrNone; |
|
114 TInt launchId = KErrNotFound; |
|
115 CDesCArrayFlat* nameArray = NULL; |
|
116 |
|
117 RIdArray ids; |
|
118 CleanupClosePushL( ids ); |
|
119 |
|
120 nameArray = new (ELeave) CDesCArrayFlat(2); |
|
121 CleanupStack::PushL( nameArray ); |
|
122 |
|
123 err = iSPSettings->FindServiceIdsL( ids ); |
|
124 User::LeaveIfError( err ); |
|
125 err = iSPSettings->FindServiceNamesL( ids, *nameArray ); |
|
126 User::LeaveIfError( err ); |
|
127 |
|
128 TInt count = nameArray->MdcaCount(); |
|
129 for ( TInt i(0); i < count; i++) |
|
130 { |
|
131 // search the mathching service name |
|
132 TPtrC p = nameArray->MdcaPoint( i ); |
|
133 if (!p.CompareF( aServiceId )) |
|
134 { |
|
135 // We have found the service, now get the plugin id |
|
136 CSPProperty* IMLaunchIdProperty = CSPProperty::NewLC(); |
|
137 err = iSPSettings->FindPropertyL( ids[i], ESubPropertyIMLaunchUid, *IMLaunchIdProperty ); |
|
138 User::LeaveIfError( err ); |
|
139 err = IMLaunchIdProperty->GetValue( launchId ); |
|
140 User::LeaveIfError( err ); |
|
141 CleanupStack::PopAndDestroy( IMLaunchIdProperty ); |
|
142 break; |
|
143 } |
|
144 } |
|
145 CleanupStack::PopAndDestroy( nameArray ); |
|
146 CleanupStack::PopAndDestroy( ); // >>> ids |
|
147 |
|
148 return launchId; |
|
149 } |
|
150 |
|
151 // -------------------------------------------------------------------------- |
|
152 // CEDContactorIMOperation::LoadEcomL |
|
153 // -------------------------------------------------------------------------- |
|
154 // |
|
155 void CEDContactorIMOperation::LoadEcomL( TUid aUidImp, const TDesC& aXspId ) |
|
156 { |
|
157 TUid destructorId; |
|
158 |
|
159 TAny* volatile implementation = |
|
160 REComSession::CreateImplementationL( aUidImp, |
|
161 destructorId ); |
|
162 |
|
163 iPlugin = reinterpret_cast< CCmsContactorImPluginBase* >( implementation ); |
|
164 iPlugin->SetDestructorId( destructorId ); |
|
165 iPlugin->ExecuteL( aXspId ); |
|
166 } |
|
167 |
|
168 // -------------------------------------------------------------------------- |
|
169 // CEDContactorIMOperation::ExtractService |
|
170 // -------------------------------------------------------------------------- |
|
171 // |
|
172 TPtrC CEDContactorIMOperation::ExtractService( const TDesC& aXspId ) |
|
173 { |
|
174 TInt pos = aXspId.Find(KColon); |
|
175 if ( pos >= 0) |
|
176 { |
|
177 // ok input |
|
178 return aXspId.Left(pos); |
|
179 } |
|
180 else |
|
181 { |
|
182 // return something in illegal input case |
|
183 return TPtrC(KNullDesC); |
|
184 } |
|
185 } |
|
186 // End of File |