|
1 /* |
|
2 * Copyright (c) 2009 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 the License "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 #include <e32cmn.h> |
|
20 #include <s32mem.h> |
|
21 #include "sisregistryhelperclient.h" |
|
22 |
|
23 using namespace Swi; |
|
24 |
|
25 EXPORT_C RSisRegistryHelper::RSisRegistryHelper() |
|
26 : RScsClientBase() |
|
27 { |
|
28 // empty |
|
29 } |
|
30 |
|
31 EXPORT_C TInt RSisRegistryHelper::Connect() |
|
32 { |
|
33 TVersion version = SisRegistryHelperServerVersion(); |
|
34 TUidType fullUid = SisRegistryHelperServerImageFullUid(); |
|
35 return RScsClientBase::Connect(KSisRegistryHelperServerName(), version, KSisRegistryHelperServerImg(), fullUid); |
|
36 } |
|
37 |
|
38 EXPORT_C void RSisRegistryHelper::Close() |
|
39 { |
|
40 RScsClientBase::Close(); |
|
41 } |
|
42 |
|
43 EXPORT_C void RSisRegistryHelper::GetEquivalentLanguagesL(TLanguage aLangId,RArray<TLanguage>& aEquivLangs) |
|
44 { |
|
45 // calculate the likely size of the data transfer buffer |
|
46 const TInt KMaxBufSize= |
|
47 sizeof(TInt)+ // number of entries |
|
48 KMaxEquivalentLanguages*sizeof(TLanguage); // Languages IDs stored as TLanguage |
|
49 |
|
50 // allocate buffer for the returned arrays |
|
51 HBufC8* buf=HBufC8::NewMaxLC(KMaxBufSize); |
|
52 TPtr8 pBuf=buf->Des(); |
|
53 TInt err = CallSessionFunction(EGetEquivalentLanguages,TIpcArgs(&pBuf,aLangId)); |
|
54 User::LeaveIfError(err); |
|
55 |
|
56 // got the buffer, internalise the arrays |
|
57 RDesReadStream ins(*buf); |
|
58 CleanupClosePushL(ins); |
|
59 |
|
60 // first comes the number of entries (TInt) |
|
61 TInt count=ins.ReadInt32L(); |
|
62 |
|
63 // then language ID's |
|
64 TInt i; |
|
65 for (i = 0; i < count; ++i) |
|
66 { |
|
67 TLanguage langId=(TLanguage)ins.ReadInt32L(); |
|
68 aEquivLangs.AppendL(langId); |
|
69 } |
|
70 // cleanup |
|
71 CleanupStack::PopAndDestroy(2, buf); // buf |
|
72 } |