|
1 /* |
|
2 * Copyright (c) 2002-2006 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: CustomInterfaceUtility Proxy implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <ProxyCustomInterfaceUtility.h> |
|
22 #include "CustomInterfaceBuilderTypes.h" |
|
23 #include "CustomInterfaceProxyFactory.h" |
|
24 |
|
25 |
|
26 EXPORT_C CProxyCustomInterfaceUtility* CProxyCustomInterfaceUtility::NewL(CCustomCommandUtility* aCustomCommandUtility) |
|
27 { |
|
28 CProxyCustomInterfaceUtility* self = new(ELeave) CProxyCustomInterfaceUtility(aCustomCommandUtility); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 EXPORT_C CProxyCustomInterfaceUtility* CProxyCustomInterfaceUtility::NewL(MCustomCommand& aMCustomCommand) |
|
36 { |
|
37 CProxyCustomInterfaceUtility* self = new(ELeave) CProxyCustomInterfaceUtility(aMCustomCommand); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 CProxyCustomInterfaceUtility::CProxyCustomInterfaceUtility(CCustomCommandUtility* aCustomCommandUtility) : |
|
45 CCustomInterfaceUtility(), |
|
46 iCustomCommandUtility(aCustomCommandUtility) |
|
47 { |
|
48 } |
|
49 |
|
50 CProxyCustomInterfaceUtility::CProxyCustomInterfaceUtility(MCustomCommand& aMCustomCommand) : |
|
51 CCustomInterfaceUtility(), |
|
52 iMCustomCommand(&aMCustomCommand) |
|
53 { |
|
54 } |
|
55 |
|
56 |
|
57 CProxyCustomInterfaceUtility::~CProxyCustomInterfaceUtility() |
|
58 { |
|
59 delete iCustomCommandUtility; |
|
60 // Do not delete iMCustomCommand. Unlike iCustomCommandUtility we don't own |
|
61 // iMCustomCommand. |
|
62 } |
|
63 |
|
64 void CProxyCustomInterfaceUtility::ConstructL() |
|
65 { |
|
66 TMMFMessageDestination destination(KUidCustomInterfaceBuilder); |
|
67 TMMFMessageDestinationPckg destinationPckg(destination); |
|
68 TMMFMessageDestination builderHandle; |
|
69 TMMFMessageDestinationPckg builderHandlePckg(builderHandle); |
|
70 iBuilderHandle = builderHandlePckg; |
|
71 |
|
72 if (iCustomCommandUtility) |
|
73 { |
|
74 iCustomCommandUtility->CustomCommandSync(destinationPckg, ECibGetBuilder, KNullDesC8, KNullDesC8, iBuilderHandle); |
|
75 } |
|
76 else if (iMCustomCommand) |
|
77 { |
|
78 iMCustomCommand->CustomCommandSync(destinationPckg, ECibGetBuilder, KNullDesC8, KNullDesC8, iBuilderHandle); |
|
79 } |
|
80 |
|
81 if(iBuilderHandle().InterfaceId() == KNullUid) |
|
82 { |
|
83 User::Leave(KErrNotFound); |
|
84 } |
|
85 } |
|
86 |
|
87 EXPORT_C TAny* CProxyCustomInterfaceUtility::CustomInterface(TUid aInterfaceId) |
|
88 { |
|
89 // Get Handle |
|
90 TMMFMessageDestination handle; |
|
91 TMMFMessageDestinationPckg handlePckg(handle); |
|
92 TPckgBuf<TUid> uidPckg; |
|
93 uidPckg() = aInterfaceId; |
|
94 |
|
95 if (iCustomCommandUtility) |
|
96 { |
|
97 iCustomCommandUtility->CustomCommandSync(iBuilderHandle, ECibBuild, uidPckg, KNullDesC8, handlePckg); |
|
98 } |
|
99 else if (iMCustomCommand) |
|
100 { |
|
101 iMCustomCommand->CustomCommandSync(iBuilderHandle, ECibBuild, uidPckg, KNullDesC8, handlePckg); |
|
102 } |
|
103 |
|
104 TAny* result = NULL; |
|
105 |
|
106 if(handlePckg().InterfaceId() == KNullUid) |
|
107 { |
|
108 result = NULL; |
|
109 } |
|
110 else |
|
111 { |
|
112 if (iCustomCommandUtility) |
|
113 { |
|
114 result = CCustomInterfaceProxyFactory::CreateProxy(aInterfaceId, handlePckg, *iCustomCommandUtility, this); |
|
115 } |
|
116 else if (iMCustomCommand) |
|
117 { |
|
118 result = CCustomInterfaceProxyFactory::CreateProxy(aInterfaceId, handlePckg, *iMCustomCommand, this); |
|
119 } |
|
120 |
|
121 } |
|
122 |
|
123 return result; |
|
124 } |
|
125 |
|
126 |
|
127 EXPORT_C void CProxyCustomInterfaceUtility::RemoveCustomInterface(TMMFMessageDestinationPckg aMessageHandler) |
|
128 { |
|
129 // Get Handle |
|
130 TMMFMessageDestination handle; |
|
131 TMMFMessageDestinationPckg handlePckg(handle); |
|
132 |
|
133 |
|
134 if (iCustomCommandUtility) |
|
135 { |
|
136 iCustomCommandUtility->CustomCommandSync(iBuilderHandle, ECibRemove, aMessageHandler, KNullDesC8); |
|
137 } |
|
138 else if (iMCustomCommand) |
|
139 { |
|
140 iMCustomCommand->CustomCommandSync(iBuilderHandle, ECibRemove, aMessageHandler, KNullDesC8); |
|
141 } |
|
142 } |
|
143 |
|
144 |
|
145 // End of File |