209 if ( retTemp != KErrNone ) |
209 if ( retTemp != KErrNone ) |
210 { |
210 { |
211 TRACE_FUNC_EXIT |
211 TRACE_FUNC_EXIT |
212 return retTemp; |
212 return retTemp; |
213 } |
213 } |
|
214 // First check if in editor mode |
|
215 if ( iCmdData.iEditorHandler ) |
|
216 { |
|
217 iCmdData.iReplyExpected = EFalse; |
|
218 iCmdData.iHandler = iCmdData.iEditorHandler; |
|
219 iCmdData.iHandler->iInstance->HandleCommand( iCmdData.iCmdBuffer, |
|
220 iCmdData.iCmdReplyBuffer, |
|
221 EFalse ); |
|
222 aComplInfo.iProcessed = ETrue; |
|
223 aComplInfo.iReplyExpected = ETrue; |
|
224 // Note: The aComplInfo.iReplyExpected is used only for normal mode and |
|
225 // is set to ETrue here to skip a check in CATExtSession::IpcHandleCommand(). |
|
226 TRACE_FUNC_EXIT |
|
227 return KErrNone; |
|
228 } |
|
229 // Not in editor so handle in normal mode |
214 TRACE_INFO(( _L8("Received command '%S'"), &iCmdData.iCmdBuffer )); |
230 TRACE_INFO(( _L8("Received command '%S'"), &iCmdData.iCmdBuffer )); |
215 // Now the command exists. Load the plugins for a command and check support. |
231 // Now the command exists. Load the plugins for a command and check support. |
216 TRAPD( retTrap, CreateAndFindSupportL(iCmdData.iCmdBuffer, |
232 TRAPD( retTrap, CreateAndFindSupportL(iCmdData.iCmdBuffer, |
217 aMessage, |
233 aMessage, |
218 aComplInfo ) ); |
234 aComplInfo ) ); |
325 if ( aPlugin && iCmdData.iHandler && iCmdData.iHandler->iInstance!=aPlugin ) |
341 if ( aPlugin && iCmdData.iHandler && iCmdData.iHandler->iInstance!=aPlugin ) |
326 { |
342 { |
327 TRACE_FUNC_EXIT |
343 TRACE_FUNC_EXIT |
328 return KErrInUse; |
344 return KErrInUse; |
329 } |
345 } |
|
346 if ( !iCmdData.iCmdMessage.Handle() ) |
|
347 { |
|
348 TRACE_FUNC_EXIT |
|
349 return KErrBadHandle; |
|
350 } |
|
351 TBool startOfEditor = EFalse; |
|
352 if ( aReplyType == EReplyTypeEditor) |
|
353 { |
|
354 // If completion is for editor command then set iCmdData.iEditorHandler |
|
355 // for the first time only |
|
356 if ( !iCmdData.iEditorHandler ) |
|
357 { |
|
358 iCmdData.iEditorHandler = FindInstanceFromPlugindata( aPlugin ); |
|
359 iCmdData.iReplyExpected = ETrue; // reply expected when first reply in editor mode |
|
360 startOfEditor = ETrue; |
|
361 } |
|
362 } |
|
363 else |
|
364 { |
|
365 // If completion was something else than EReplyTypeEditor then just end |
|
366 // editor mode (no need to check iEditorHandler) |
|
367 if ( iCmdData.iEditorHandler ) |
|
368 { |
|
369 iCmdData.iReplyExpected = ETrue; // reply expected when last reply in editor mode |
|
370 } |
|
371 iCmdData.iEditorHandler = NULL; |
|
372 } |
330 // Next check if aPlugin is set (the call comes from a plugin and not from |
373 // Next check if aPlugin is set (the call comes from a plugin and not from |
331 // ATEXT) and a reply is not needed. In this case do nothing as it is wrong |
374 // ATEXT) and a reply is not needed. In this case do nothing as it is wrong |
332 // behavior from the plugin (a plugin must not complete messages where no |
375 // behavior from the plugin (a plugin must not complete messages where no |
333 // reply is expected; this is done by ATEXT) |
376 // reply is expected; this is done by ATEXT) |
334 if ( aPlugin && !iCmdData.iReplyExpected ) |
377 if ( aPlugin && !iCmdData.iReplyExpected && !iCmdData.iEditorHandler ) |
335 { |
378 { |
336 TRACE_FUNC_EXIT |
379 TRACE_FUNC_EXIT |
337 return KErrAlreadyExists; |
380 return KErrAlreadyExists; |
338 } |
|
339 if ( !iCmdData.iCmdMessage.Handle() ) |
|
340 { |
|
341 TRACE_FUNC_EXIT |
|
342 return KErrBadHandle; |
|
343 } |
381 } |
344 // Finally write the data and complete the message |
382 // Finally write the data and complete the message |
345 TPckg<TATExtensionReplyType> replyType( aReplyType ); |
383 TPckg<TATExtensionReplyType> replyType( aReplyType ); |
346 TInt writeError = iCmdData.iCmdMessage.Write( EATExtHandleCmdParamReplyType, |
384 TInt writeError = iCmdData.iCmdMessage.Write( EATExtHandleCmdParamReplyType, |
347 replyType ); |
385 replyType ); |
354 } |
392 } |
355 if ( !aPlugin ) |
393 if ( !aPlugin ) |
356 { |
394 { |
357 CreateEmptyOrErrorBuffer( iCmdData.iCmdReplyBuffer, aErrorReply ); |
395 CreateEmptyOrErrorBuffer( iCmdData.iCmdReplyBuffer, aErrorReply ); |
358 } |
396 } |
359 if ( aMultiPart ) |
397 WriteHandleCmdReplyBuffer( aMultiPart, startOfEditor ); |
360 { |
|
361 WriteReplyBufferToClient( iCmdData.iCmdReplyBuffer, |
|
362 EATExtHandleCmdParamReply, |
|
363 iCmdData.iCmdMessage, |
|
364 ETrue, |
|
365 EATExtHandleCmdParamLength ); |
|
366 } |
|
367 else |
|
368 { |
|
369 WriteReplyBufferToClient( iCmdData.iCmdReplyBuffer, |
|
370 EATExtHandleCmdParamReply, |
|
371 iCmdData.iCmdMessage ); |
|
372 } |
|
373 } |
398 } |
374 iCmdData.iCmdStarted = EFalse; |
399 iCmdData.iCmdStarted = EFalse; |
375 iCmdData.iReplyExpected = EFalse; |
400 iCmdData.iReplyExpected = EFalse; |
376 iCmdData.iCmdMessage.Complete( aError ); |
401 iCmdData.iCmdMessage.Complete( aError ); |
377 ClearInitializedCmdHandlerData( aMultiPart ); |
402 ClearInitializedCmdHandlerData( aMultiPart ); |
|
403 TRACE_FUNC_EXIT |
|
404 return KErrNone; |
|
405 } |
|
406 |
|
407 // --------------------------------------------------------------------------- |
|
408 // Writes multipart or single part reply buffer to client for handle. |
|
409 // Used for creating a reply for HandleCommand(). |
|
410 // --------------------------------------------------------------------------- |
|
411 // |
|
412 TInt CATExtMetadata::WriteHandleCmdReplyBuffer( TBool aMultiPart, |
|
413 TBool aStartOfEditor ) |
|
414 { |
|
415 TRACE_FUNC_ENTRY |
|
416 if ( iCmdData.iEditorHandler && !aStartOfEditor ) |
|
417 { |
|
418 TRACE_FUNC_EXIT |
|
419 return KErrNotReady; |
|
420 } |
|
421 if ( aMultiPart ) |
|
422 { |
|
423 WriteReplyBufferToClient( iCmdData.iCmdReplyBuffer, |
|
424 EATExtHandleCmdParamReply, |
|
425 iCmdData.iCmdMessage, |
|
426 ETrue, |
|
427 EATExtHandleCmdParamLength ); |
|
428 } |
|
429 else |
|
430 { |
|
431 WriteReplyBufferToClient( iCmdData.iCmdReplyBuffer, |
|
432 EATExtHandleCmdParamReply, |
|
433 iCmdData.iCmdMessage ); |
|
434 } |
378 TRACE_FUNC_EXIT |
435 TRACE_FUNC_EXIT |
379 return KErrNone; |
436 return KErrNone; |
380 } |
437 } |
381 |
438 |
382 // --------------------------------------------------------------------------- |
439 // --------------------------------------------------------------------------- |
962 iPluginData = NULL; |
1019 iPluginData = NULL; |
963 iCmdData.iCmdStarted = EFalse; |
1020 iCmdData.iCmdStarted = EFalse; |
964 iCmdData.iReplyExpected = EFalse; |
1021 iCmdData.iReplyExpected = EFalse; |
965 iCmdData.iHandler = NULL; |
1022 iCmdData.iHandler = NULL; |
966 iCmdData.iOldHandler = NULL; |
1023 iCmdData.iOldHandler = NULL; |
|
1024 iCmdData.iEditorHandler = NULL; |
967 iCarriageReturn = KDefaultCarriageReturn; |
1025 iCarriageReturn = KDefaultCarriageReturn; |
968 iLineFeed = KDefaultLineFeed; |
1026 iLineFeed = KDefaultLineFeed; |
969 iQuietMode = EFalse; |
1027 iQuietMode = EFalse; |
970 iVerboseMode = ETrue; |
1028 iVerboseMode = ETrue; |
971 iSupportAuxFind = 0; |
1029 iSupportAuxFind = 0; |
1246 return KErrAccessDenied; |
1305 return KErrAccessDenied; |
1247 } |
1306 } |
1248 if ( iCmdData.iHandler && iCmdData.iHandler->iInstance ) |
1307 if ( iCmdData.iHandler && iCmdData.iHandler->iInstance ) |
1249 { |
1308 { |
1250 iCmdData.iHandler->iInstance->HandleCommandCancel(); |
1309 iCmdData.iHandler->iInstance->HandleCommandCancel(); |
|
1310 iCmdData.iEditorHandler = NULL; |
1251 } |
1311 } |
1252 CompleteCommandMessage( NULL, |
1312 CompleteCommandMessage( NULL, |
1253 aError, |
1313 aError, |
1254 EFalse, |
1314 EFalse, |
1255 EReplyTypeUndefined, |
1315 EReplyTypeUndefined, |
2334 if ( aReplyNeeded ) |
2394 if ( aReplyNeeded ) |
2335 { |
2395 { |
2336 iCmdData.iCmdStarted = ETrue; |
2396 iCmdData.iCmdStarted = ETrue; |
2337 iCmdData.iCmdMessage = aEntrySupport.iMessage; |
2397 iCmdData.iCmdMessage = aEntrySupport.iMessage; |
2338 iCmdData.iHandler = aEntrySupport.iEntry; |
2398 iCmdData.iHandler = aEntrySupport.iEntry; |
|
2399 iCmdData.iEditorHandler = NULL; |
2339 } |
2400 } |
2340 // No "else" here as HandleCommandL() is used also with observer plugins |
2401 // No "else" here as HandleCommandL() is used also with observer plugins |
2341 if ( !aAtCmdFull ) |
2402 if ( !aAtCmdFull ) |
2342 { |
2403 { |
2343 TRACE_INFO(( _L8("Handling command '%S' for UID:0x%08X, aReplyNeeded=%d..."), &iCmdData.iCmdBuffer, aEntrySupport.iEntry->iPluginUid, aReplyNeeded )); |
2404 TRACE_INFO(( _L8("Handling command '%S' for UID:0x%08X, aReplyNeeded=%d..."), &iCmdData.iCmdBuffer, aEntrySupport.iEntry->iPluginUid, aReplyNeeded )); |
2370 if ( !aEntrySupport.iSupport ) |
2431 if ( !aEntrySupport.iSupport ) |
2371 { |
2432 { |
2372 TRACE_FUNC_EXIT |
2433 TRACE_FUNC_EXIT |
2373 User::Leave( KErrGeneral ); |
2434 User::Leave( KErrGeneral ); |
2374 } |
2435 } |
|
2436 if ( !aEntrySupport.iSupportFound ) |
|
2437 { |
|
2438 // No initial support found -> do nothing |
|
2439 TRACE_FUNC_EXIT |
|
2440 return; |
|
2441 } |
2375 TInt i; |
2442 TInt i; |
2376 TInt count = aEntrySupport.iSupport->Count(); |
2443 TInt count = aEntrySupport.iSupport->Count(); |
2377 for ( i=aEntrySupport.iStartIndex; i<count; i++ ) |
2444 for ( i=aEntrySupport.iStartIndex; i<count; i++ ) |
2378 { |
2445 { |
2379 TATExtOneCmdSupport& oneCmdSupport = (*aEntrySupport.iSupport)[i]; |
2446 TATExtOneCmdSupport& oneCmdSupport = (*aEntrySupport.iSupport)[i]; |
2380 if ( oneCmdSupport.iSupportType != ESupportTypeObserver ) |
2447 if ( oneCmdSupport.iSupportType != ESupportTypeObserver ) |
2381 { |
2448 { |
2382 continue; |
2449 continue; |
2383 } |
2450 } |
2384 aEntrySupport.iEntry = &(*iPluginData)[oneCmdSupport.iEntryIndex]; |
2451 aEntrySupport.iEntry = &(*iPluginData)[oneCmdSupport.iEntryIndex]; |
2385 TBool supported = EFalse; |
2452 TBool supported = HandleCommandSupportL( aEntrySupport, aAtCmdFull ); |
2386 if ( !aEntrySupport.iSupportFound ) |
|
2387 { |
|
2388 supported = HandleCommandSupportL( aEntrySupport, aAtCmdFull ); |
|
2389 } |
|
2390 if ( supported ) |
2453 if ( supported ) |
2391 { |
2454 { |
2392 HandleCommandL( aEntrySupport, EFalse, aAtCmdFull ); |
2455 HandleCommandL( aEntrySupport, EFalse, aAtCmdFull ); |
2393 aEntrySupport.iSupportFound = ETrue; |
2456 aEntrySupport.iSupportFound = ETrue; |
2394 } |
2457 } |