|
1 /* |
|
2 * Copyright (c) 2008 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: This plugin is loaded by the Communication Launcher |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/implementationproxy.h> |
|
20 #include <e32std.h> |
|
21 #include "imcmslauncherplugin.h" |
|
22 #include <imcvlauncher.h> |
|
23 |
|
24 #include <eikappui.h> |
|
25 #include <eikenv.h> |
|
26 |
|
27 #include <apgcli.h> |
|
28 #include <apacmdln.h> |
|
29 |
|
30 #include <spsettings.h> |
|
31 |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Key value pair table to identify correct constructor |
|
38 // function for the requested interface. |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 const TImplementationProxy ImplementationTable[] = |
|
42 { |
|
43 IMPLEMENTATION_PROXY_ENTRY( 0x200255D0, CImCmsLauncherPlugin::NewL ) |
|
44 }; |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Exported function to return the implementation proxy table |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
51 { |
|
52 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
53 return ImplementationTable; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CImCmsLauncherPlugin::CImCmsLauncherPlugin() |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CImCmsLauncherPlugin::CImCmsLauncherPlugin() |
|
61 { |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CImCmsLauncherPlugin::NewL() |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CImCmsLauncherPlugin* CImCmsLauncherPlugin::NewL() |
|
69 { |
|
70 return new( ELeave ) CImCmsLauncherPlugin(); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CImCmsLauncherPlugin::~CImCmsLauncherPlugin() |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CImCmsLauncherPlugin::~CImCmsLauncherPlugin() |
|
78 { |
|
79 |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CImCmsLauncherPlugin::ExecuteL |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CImCmsLauncherPlugin::ExecuteL( const TDesC& aXspId ) |
|
87 { |
|
88 |
|
89 |
|
90 // launch the UI |
|
91 TVwsViewId activeViewId; |
|
92 TInt serviceId = KErrNotFound; |
|
93 |
|
94 //Get the active view id. This used for getting the focus |
|
95 //back to the application which launched the CV |
|
96 CCoeEnv::Static()->AppUi()->GetActiveViewId( activeViewId ); |
|
97 |
|
98 // Call to launch the conversation view |
|
99 TInt serviceIdStart = aXspId.Locate(':'); |
|
100 |
|
101 //Get the User Id |
|
102 HBufC* userId = aXspId.Right(aXspId.Length() - serviceIdStart - 1).AllocLC(); |
|
103 |
|
104 if (serviceIdStart) |
|
105 { |
|
106 //Check to see whether its a valid service id |
|
107 //then there is service id. set it in the RProperty |
|
108 TInt err = KErrNone; |
|
109 CDesCArrayFlat* nameArray = NULL; |
|
110 |
|
111 RIdArray ids; |
|
112 CleanupClosePushL( ids ); |
|
113 |
|
114 HBufC* serviceName = aXspId.Left(serviceIdStart).AllocLC(); |
|
115 |
|
116 CSPSettings* settings = CSPSettings::NewLC(); |
|
117 |
|
118 nameArray = new (ELeave) CDesCArrayFlat(2); |
|
119 CleanupStack::PushL( nameArray ); |
|
120 |
|
121 //Get the service table id's |
|
122 err = settings->FindServiceIdsL( ids ); |
|
123 User::LeaveIfError( err ); |
|
124 |
|
125 //get the service names |
|
126 err = settings->FindServiceNamesL( ids, *nameArray ); |
|
127 User::LeaveIfError( err ); |
|
128 |
|
129 TInt count = nameArray->MdcaCount(); |
|
130 for ( TInt i(0); i < count; i++) |
|
131 { |
|
132 // search the mathching service name |
|
133 TPtrC p = nameArray->MdcaPoint( i ); |
|
134 if (!p.CompareF( *serviceName )) |
|
135 { |
|
136 // We have found the service, |
|
137 serviceId = ids[i]; |
|
138 break; |
|
139 } |
|
140 } |
|
141 CleanupStack::PopAndDestroy( 4 ); |
|
142 |
|
143 } |
|
144 |
|
145 if (KErrNotFound != serviceId) |
|
146 { |
|
147 //if valid service |
|
148 TInt err = IMCVLauncher::LaunchImConversationViewL(activeViewId, serviceId, userId->Des()); |
|
149 CleanupStack::PopAndDestroy(); |
|
150 User::LeaveIfError(err); |
|
151 return; |
|
152 } |
|
153 |
|
154 CleanupStack::PopAndDestroy(); |
|
155 User::LeaveIfError(KErrArgument); |
|
156 |
|
157 } |
|
158 |
|
159 // End of file |
|
160 |