|
1 /* |
|
2 * Copyright (c) 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: Mail viewer contact caller. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cmsgmailviewercontactcaller.h" |
|
19 #include "cmsgmailviewercontactmatcher.h" |
|
20 #include "MailLog.h" |
|
21 #include "MailUtils.h" |
|
22 #include "msgmailviewer.hrh" |
|
23 #include <MsgMailViewer.rsg> |
|
24 #include <AiwServiceHandler.h> |
|
25 #include <eikmenup.h> |
|
26 #include <aiwdialdataext.h> |
|
27 |
|
28 // Constants |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CMsgMailViewerContactCaller |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CMsgMailViewerContactCaller::CMsgMailViewerContactCaller( |
|
35 CAiwServiceHandler& aServiceHandler, |
|
36 CMsgMailViewerContactMatcher& aContactMatcher ) |
|
37 : iServiceHandler( aServiceHandler ), |
|
38 iContactMatcher( aContactMatcher ) |
|
39 { |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // ConstructL |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 inline void CMsgMailViewerContactCaller::ConstructL() |
|
47 { |
|
48 iServiceHandler.AttachMenuL ( R_MSGMAILVIEWER_CALL_MENU, |
|
49 R_MSGMAILVIEWER_CALL_INTEREST ); |
|
50 |
|
51 // Attach also base interest |
|
52 iServiceHandler.AttachL( R_MSGMAILVIEWER_CALL_INTEREST ); |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // NewL |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CMsgMailViewerContactCaller* CMsgMailViewerContactCaller::NewL( |
|
60 CAiwServiceHandler& aServiceHandler, |
|
61 CMsgMailViewerContactMatcher& aContactMatcher ) |
|
62 { |
|
63 CMsgMailViewerContactCaller* self = |
|
64 new( ELeave ) CMsgMailViewerContactCaller( aServiceHandler, |
|
65 aContactMatcher ); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // ~CMsgMailViewerContactCaller |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CMsgMailViewerContactCaller::~CMsgMailViewerContactCaller() |
|
78 { |
|
79 } |
|
80 |
|
81 // ------------------------------------------------------------------------------ |
|
82 // CMsgMailViewerContactCaller::DynInitMenuPaneL() |
|
83 // ------------------------------------------------------------------------------ |
|
84 // |
|
85 void CMsgMailViewerContactCaller::DynInitMenuPaneL( |
|
86 TInt aResourceId, |
|
87 CEikMenuPane* aMenuPane, |
|
88 TBool aShowCallOption ) |
|
89 { |
|
90 if ( iServiceHandler.HandleSubmenuL( *aMenuPane ) ) |
|
91 { |
|
92 return; |
|
93 } |
|
94 if ( aResourceId == R_MSGMAILVIEWER_CALL_MENU ) |
|
95 { |
|
96 if ( aShowCallOption ) |
|
97 { |
|
98 iServiceHandler.InitializeMenuPaneL( |
|
99 *aMenuPane, |
|
100 R_MSGMAILVIEWER_CALL_MENU, |
|
101 EMsgMailViewerCmdAIWRangeStart, |
|
102 iServiceHandler.InParamListL() ); |
|
103 } |
|
104 else |
|
105 { |
|
106 aMenuPane->SetItemDimmed( KAiwCmdCall, ETrue ); |
|
107 } |
|
108 } |
|
109 } |
|
110 |
|
111 // ------------------------------------------------------------------------------ |
|
112 // CMsgMailViewerContactCaller::CanHandleCommand() |
|
113 // ------------------------------------------------------------------------------ |
|
114 // |
|
115 TBool CMsgMailViewerContactCaller::CanHandleCommand( TInt aCommand ) const |
|
116 { |
|
117 TBool retVal( EFalse ); |
|
118 |
|
119 if(aCommand == EMsgMailViewerCmdCall) |
|
120 { |
|
121 retVal = ETrue; |
|
122 } |
|
123 else |
|
124 { |
|
125 TInt aiwCommand = iServiceHandler.ServiceCmdByMenuCmd( aCommand ); |
|
126 LOG1("iServiceHandler.ServiceCmdByMenuCmd:%d", aiwCommand ); |
|
127 retVal = ( aiwCommand == KAiwCmdCall ); |
|
128 } |
|
129 |
|
130 return retVal; |
|
131 } |
|
132 |
|
133 // ------------------------------------------------------------------------------ |
|
134 // CMsgMailViewerContactCaller::CallToContactL() |
|
135 // ------------------------------------------------------------------------------ |
|
136 // |
|
137 void CMsgMailViewerContactCaller::CallToContactL( |
|
138 TInt aCommand, |
|
139 const TDesC& aEmailAddress ) |
|
140 { |
|
141 ASSERT( CanHandleCommand( aCommand ) ); |
|
142 iCommand = aCommand; |
|
143 iContactMatcher.FindContactL( aEmailAddress, |
|
144 CMsgMailViewerContactMatcher::ECallToContact, |
|
145 TCallBack( MatchDoneL, this ) ); |
|
146 } |
|
147 |
|
148 // ------------------------------------------------------------------------------ |
|
149 // CMsgMailViewerContactCaller::MatchDoneL() |
|
150 // ------------------------------------------------------------------------------ |
|
151 // |
|
152 TInt CMsgMailViewerContactCaller::MatchDoneL( TAny* aCaller ) // CSI: 40 # We must return |
|
153 // the integer value although this |
|
154 // is a leaving method. |
|
155 { |
|
156 CMsgMailViewerContactCaller* caller = |
|
157 static_cast<CMsgMailViewerContactCaller*>( aCaller ); |
|
158 caller->DoCallToContactL(); |
|
159 return 0; |
|
160 } |
|
161 |
|
162 // ------------------------------------------------------------------------------ |
|
163 // CMsgMailViewerContactCaller::DoCallToContactL() |
|
164 // ------------------------------------------------------------------------------ |
|
165 // |
|
166 void CMsgMailViewerContactCaller::DoCallToContactL() |
|
167 { |
|
168 HBufC* number = iContactMatcher.GetDataL(); |
|
169 if ( number ) |
|
170 { |
|
171 CleanupStack::PushL( number ); |
|
172 CAiwGenericParamList& paramList = iServiceHandler.InParamListL(); |
|
173 |
|
174 CAiwDialDataExt* dialData = CAiwDialDataExt::NewLC(); |
|
175 |
|
176 dialData->SetPhoneNumberL( *number ); |
|
177 HBufC* name = iContactMatcher.GetNameL(); |
|
178 if ( name ) |
|
179 { |
|
180 CleanupStack::PushL( name ); |
|
181 |
|
182 dialData->SetNameL( name->Left( AIWDialDataExt::KMaximumNameLength ) ); |
|
183 CleanupStack::PopAndDestroy( name ); |
|
184 } |
|
185 |
|
186 dialData->SetWindowGroup( CCoeEnv::Static()->RootWin().Identifier() ); |
|
187 dialData->FillInParamListL( paramList ); |
|
188 |
|
189 //Internal command which comes when user has pressed send key. |
|
190 if ( iCommand == EMsgMailViewerCmdCall ) |
|
191 { |
|
192 iServiceHandler.ExecuteServiceCmdL( KAiwCmdCall, |
|
193 paramList, |
|
194 iServiceHandler.OutParamListL() ); |
|
195 |
|
196 } |
|
197 //Aiw command from menu |
|
198 else |
|
199 { |
|
200 iServiceHandler.ExecuteMenuCmdL( iCommand, |
|
201 paramList, |
|
202 iServiceHandler.OutParamListL() ); |
|
203 } |
|
204 |
|
205 CleanupStack::PopAndDestroy(2); // CSI: 47 # number, dial |
|
206 } |
|
207 else |
|
208 { |
|
209 MailUtils::InformationNoteL( R_MSGMAILVIEWER_NO_MATCHES_NOTE ); |
|
210 } |
|
211 |
|
212 } |
|
213 |
|
214 // End of File |
|
215 |