114
|
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 "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 |
// System includes
|
|
19 |
#include <ecom/implementationproxy.h>
|
|
20 |
#include <eikenv.h>
|
|
21 |
#include <sendui.h>
|
|
22 |
#include <SendUiConsts.h>
|
|
23 |
#include <viewcli.h> // For CVwsSessionWrapper
|
|
24 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
25 |
#include <viewclipartner.h>
|
|
26 |
#endif
|
|
27 |
|
|
28 |
#include <vwsdef.h> // For TVwsViewId
|
|
29 |
#include <mcsmenuutils.h>
|
|
30 |
#include <mcsmenuitem.h>
|
|
31 |
#include <mcspluginparamval.h>
|
|
32 |
#include <LogsUiCmdStarter.h>
|
|
33 |
|
|
34 |
// User includes
|
|
35 |
#include "mcsplugincompletedoperation.h"
|
|
36 |
#include "mcspluginhandler.h"
|
|
37 |
#include "mcspluginuids.hrh"
|
|
38 |
|
|
39 |
// Constants
|
|
40 |
_LIT( KMenuTypeShortcut, "menu:shortcut" ); ///< Menu folder type.
|
|
41 |
_LIT( KMenuAttrParamLogs, "logs:dialed" );
|
|
42 |
|
|
43 |
/** Argument value for parameter*/
|
|
44 |
_LIT( KMenuAttrParam, "param" );
|
|
45 |
|
|
46 |
#define KMCSCmailUidValue 0x2001E277
|
|
47 |
#define KMCSCmailMailboxDefaultViewIdValue 0x1
|
|
48 |
#define KMCSCmailMailboxViewIdValue 0x2
|
|
49 |
#define KMCSCmailMtmUidValue 0x2001F406
|
|
50 |
|
|
51 |
const TInt KImplUidMCSPluginHandler = AI_UID_ECOM_IMPLEMENTATION_MCSPLUGIN_HANDLER;
|
|
52 |
|
|
53 |
const TImplementationProxy ImplementationTable[] =
|
|
54 |
{
|
|
55 |
IMPLEMENTATION_PROXY_ENTRY( KImplUidMCSPluginHandler, CMCSPluginHandler::NewL)
|
|
56 |
};
|
|
57 |
|
|
58 |
// ================= MEMBER FUNCTIONS =======================
|
|
59 |
|
|
60 |
// ---------------------------------------------------------
|
|
61 |
// CMCSPluginHandler::~CMCSPluginHandler
|
|
62 |
// ---------------------------------------------------------
|
|
63 |
//
|
|
64 |
CMCSPluginHandler::~CMCSPluginHandler()
|
|
65 |
{
|
|
66 |
delete iVwsSession;
|
|
67 |
delete iMsvSession;
|
|
68 |
}
|
|
69 |
|
|
70 |
// ---------------------------------------------------------
|
|
71 |
// CMCSPluginHandler::NewL
|
|
72 |
// ---------------------------------------------------------
|
|
73 |
//
|
|
74 |
CMCSPluginHandler* CMCSPluginHandler::NewL( RMenu &aMenu )
|
|
75 |
{
|
|
76 |
CMCSPluginHandler* handler = new (ELeave) CMCSPluginHandler( aMenu );
|
|
77 |
CleanupStack::PushL( handler );
|
|
78 |
handler->ConstructL();
|
|
79 |
CleanupStack::Pop( handler );
|
|
80 |
return handler;
|
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------
|
|
84 |
// CMCSPluginHandler::CMCSPluginHandler
|
|
85 |
// ---------------------------------------------------------
|
|
86 |
//
|
|
87 |
CMCSPluginHandler::CMCSPluginHandler( RMenu &aMenu )
|
|
88 |
: CMenuHandlerPlugin( aMenu )
|
|
89 |
{
|
|
90 |
iEikEnv = CEikonEnv::Static();
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------
|
|
94 |
// CMCSPluginHandler::ConstructL
|
|
95 |
// ---------------------------------------------------------
|
|
96 |
//
|
|
97 |
void CMCSPluginHandler::ConstructL()
|
|
98 |
{
|
|
99 |
BaseConstructL();
|
|
100 |
iVwsSession = CVwsSessionWrapper::NewL();
|
|
101 |
iMsvSession = CMsvSession::OpenAsObserverL(*this);
|
|
102 |
}
|
|
103 |
|
|
104 |
// ---------------------------------------------------------
|
|
105 |
// Supported menu item types
|
|
106 |
// ---------------------------------------------------------
|
|
107 |
//
|
|
108 |
TBool CMCSPluginHandler::SupportsType( const TDesC& aType )
|
|
109 |
{
|
|
110 |
if ( !aType.Compare( KMenuTypeFolder() ) ||
|
|
111 |
!aType.Compare( KMenuTypeSuite() ) ||
|
|
112 |
!aType.Compare( KMenuTypeShortcut ) )
|
|
113 |
{
|
|
114 |
return ETrue;
|
|
115 |
}
|
|
116 |
return EFalse;
|
|
117 |
}
|
|
118 |
|
|
119 |
// ---------------------------------------------------------
|
|
120 |
// Main command handler
|
|
121 |
// ---------------------------------------------------------
|
|
122 |
//
|
|
123 |
CMenuOperation* CMCSPluginHandler::HandleCommandL(
|
|
124 |
CMenuItem& aItem,
|
|
125 |
const TDesC8& aCommand,
|
|
126 |
const TDesC8& /*aParams*/,
|
|
127 |
TRequestStatus& aStatus )
|
|
128 |
{
|
|
129 |
if ( aCommand != KMenuCmdOpen() )
|
|
130 |
{
|
|
131 |
User::Leave ( KErrNotSupported );
|
|
132 |
}
|
|
133 |
|
|
134 |
if( aItem.Type() == KMenuTypeFolder() )
|
|
135 |
{
|
|
136 |
|
|
137 |
return CMCSPluginCompletedOperation::NewL
|
|
138 |
( iMenu, CActive::EPriorityStandard, aStatus, KErrNone );
|
|
139 |
}
|
|
140 |
else if ( aItem.Type() == KMenuTypeSuite() )
|
|
141 |
{
|
|
142 |
return CMCSPluginCompletedOperation::NewL
|
|
143 |
( iMenu, CActive::EPriorityStandard, aStatus, KErrNone );
|
|
144 |
}
|
|
145 |
else if ( aItem.Type() == KMenuTypeShortcut() )
|
|
146 |
{
|
|
147 |
LaunchShortcutL( aItem );
|
|
148 |
return CMCSPluginCompletedOperation::NewL
|
|
149 |
( iMenu, CActive::EPriorityStandard, aStatus, KErrNone );
|
|
150 |
}
|
|
151 |
else
|
|
152 |
{
|
|
153 |
User::Leave ( KErrNotSupported );
|
|
154 |
}
|
|
155 |
return NULL;
|
|
156 |
}
|
|
157 |
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
// From class MMsvSessionObserver.
|
|
160 |
// Handles an event from the message server.
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
void CMCSPluginHandler::HandleSessionEventL(
|
|
164 |
TMsvSessionEvent /*aEvent*/,
|
|
165 |
TAny* /*aArg1*/,
|
|
166 |
TAny* /*aArg2*/,
|
|
167 |
TAny* /*aArg3*/ )
|
|
168 |
{
|
|
169 |
// No event handling
|
|
170 |
}
|
|
171 |
|
|
172 |
// ---------------------------------------------------------
|
|
173 |
// Handles menu:shortcut specific commands
|
|
174 |
// Must be extended to launch e.g. MailBoxes
|
|
175 |
// caiscuttargetmessagingview.cpp implements the mailbox launching in old shortcut plugin
|
|
176 |
// ---------------------------------------------------------
|
|
177 |
//
|
|
178 |
void CMCSPluginHandler::LaunchShortcutL( CMenuItem& aItem )
|
|
179 |
{
|
|
180 |
|
|
181 |
// menu:shortcut type of items are launched based on attribute param
|
|
182 |
TBool attrExists = ETrue;
|
|
183 |
TPtrC param = aItem.GetAttributeL( KMenuAttrParam, attrExists );
|
|
184 |
|
|
185 |
if ( !attrExists )
|
|
186 |
{
|
|
187 |
User::Leave( KErrCorrupt );
|
|
188 |
}
|
|
189 |
|
|
190 |
// Messaging specific commands
|
|
191 |
CSendUi* sendUi = CSendUi::NewLC();
|
|
192 |
if ( param == KParamValueSelType ) // Select message type
|
|
193 |
{
|
|
194 |
TSendingCapabilities capabs( 0, 0, TSendingCapabilities::ESupportsEditor );
|
|
195 |
|
|
196 |
TUid uid = sendUi->ShowTypedQueryL( CSendUi::EWriteMenu, NULL, capabs, NULL, KNullDesC );
|
|
197 |
if ( uid != KNullUid )
|
|
198 |
{
|
|
199 |
sendUi->ServiceCapabilitiesL( uid, capabs );
|
|
200 |
sendUi->CreateAndSendMessageL( uid, NULL, KNullUid, EFalse ); // launch standalone
|
|
201 |
}
|
|
202 |
}
|
|
203 |
else if ( param == KParamValueMsg ) // New text message
|
|
204 |
{
|
|
205 |
sendUi->CreateAndSendMessageL(KSenduiMtmUniMessageUid, NULL, KNullUid, EFalse);
|
|
206 |
}
|
|
207 |
else if ( param == KParamValueEmail ) // New email
|
|
208 |
{
|
|
209 |
if ( GetEmailAccountCountL() > 0 )
|
|
210 |
{
|
|
211 |
sendUi->CreateAndSendMessageL( KSenduiMtmSmtpUid, NULL, KNullUid, EFalse );
|
|
212 |
}
|
|
213 |
else
|
|
214 |
{
|
|
215 |
const TVwsViewId viewId( TUid::Uid( KMCSCmailUidValue ),
|
|
216 |
TUid::Uid( KMCSCmailMailboxDefaultViewIdValue ) );
|
|
217 |
iVwsSession->CreateActivateViewEvent( viewId,
|
|
218 |
TUid::Uid( KMCSCmailUidValue ), KNullDesC8() );
|
|
219 |
}
|
|
220 |
|
|
221 |
}
|
|
222 |
#ifdef __SYNCML_DS_EMAIL
|
|
223 |
else if ( param == KParamValueSyncMLMail ) // New SyncML mail
|
|
224 |
{
|
|
225 |
sendUi->CreateAndSendMessageL( KSenduiMtmSyncMLEmailUid, NULL, KNullUid, EFalse );
|
|
226 |
}
|
|
227 |
#endif
|
|
228 |
else if ( param == KParamValuePostcard ) // New postcard
|
|
229 |
{
|
|
230 |
sendUi->CreateAndSendMessageL( KSenduiMtmPostcardUid, NULL, KNullUid, EFalse );
|
|
231 |
}
|
|
232 |
else if ( param == KParamValueAudioMsg ) // New audio message
|
|
233 |
{
|
|
234 |
sendUi->CreateAndSendMessageL( KSenduiMtmAudioMessageUid, NULL, KNullUid, EFalse );
|
|
235 |
}
|
|
236 |
else if ( param.Find( KParamValueMailbox ) != KErrNotFound ) // Mailbox
|
|
237 |
{
|
|
238 |
TInt pos = param.Locate( TChar( ':' ) ) + 1;
|
|
239 |
TPtrC mailboxId = param.Mid( pos );
|
|
240 |
TInt number;
|
|
241 |
TLex16 lextmp( mailboxId );
|
|
242 |
lextmp.Val( number );
|
|
243 |
TUid uId = TUid::Uid( number );
|
|
244 |
const TVwsViewId viewId( TUid::Uid( KMCSCmailUidValue ), TUid::Uid( KMCSCmailMailboxViewIdValue ) );
|
|
245 |
iVwsSession->CreateActivateViewEvent( viewId, uId, KNullDesC8() );
|
|
246 |
}
|
|
247 |
else if ( param.Find( KMenuAttrParamLogs ) != KErrNotFound )
|
|
248 |
{
|
|
249 |
LogsUiCmdStarter::CmdStartL( LogsUiCmdStarterConsts::KDialledView() );
|
|
250 |
}
|
|
251 |
CleanupStack::PopAndDestroy( sendUi );
|
|
252 |
}
|
|
253 |
|
|
254 |
// ---------------------------------------------------------------------------
|
|
255 |
// Returns count of Email accounts
|
|
256 |
// ---------------------------------------------------------------------------
|
|
257 |
//
|
|
258 |
TInt CMCSPluginHandler::GetEmailAccountCountL()
|
|
259 |
{
|
|
260 |
CMsvEntry* rootEntry = iMsvSession->GetEntryL( KMsvRootIndexEntryIdValue );
|
|
261 |
CleanupStack::PushL(rootEntry);
|
|
262 |
|
|
263 |
TInt cnt = rootEntry->Count();
|
|
264 |
if ( cnt > 0 )
|
|
265 |
{
|
|
266 |
cnt = 0;
|
|
267 |
rootEntry->SetSortTypeL( TMsvSelectionOrdering(
|
|
268 |
KMsvGroupByType | KMsvGroupByStandardFolders,
|
|
269 |
EMsvSortByDetailsReverse, ETrue ) );
|
|
270 |
|
|
271 |
for ( TInt i = rootEntry->Count(); --i >= 0; )
|
|
272 |
{
|
|
273 |
const TMsvEntry& tentry = (*rootEntry)[i];
|
|
274 |
|
|
275 |
if (tentry.iMtm.iUid == KMCSCmailMtmUidValue )
|
|
276 |
{
|
|
277 |
cnt++;
|
|
278 |
}
|
|
279 |
}
|
|
280 |
}
|
|
281 |
CleanupStack::PopAndDestroy(rootEntry);
|
|
282 |
return cnt;
|
|
283 |
}
|
|
284 |
|
|
285 |
// ============================ GLOBAL FUNCTIONS ===============================
|
|
286 |
|
|
287 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
|
|
288 |
{
|
|
289 |
aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
|
|
290 |
return ImplementationTable;
|
|
291 |
}
|