· 5 years ago · Feb 05, 2020, 01:10 PM
1/*
2* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
3* All rights reserved.
4* This software, including documentation is protected by copyright controlled
5* by Nokia Corporation. Copying, including reproducing, storing, adapting or
6* translating, any or all of this material can only be done in accordance
7* with the Nokia Symbian License version 1.0 (or any subsequent update) or
8* any other license terms expressly agreed between you and Nokia.
9* This material contains Nokia's confidential information which
10* may not be disclosed to others without the prior written consent of Nokia.
11*
12* Initial Contributors:
13* Nokia Corporation - initial contribution.
14*
15* Contributors:
16*
17* Description: Implements the member functions of the class which implements the
18* main hostengine functionality.
19*
20*/
21
22#include "platformbuild.h" // Warning: this *must* the first include of every source file.
23 // It contains all the #define build parameters.
24#include "platformclib.h"
25#include "platformdebug.h"
26#include "saplayer_build.h"
27#include "version.h"
28#include "reent.h"
29#include <flashliteplugin.rsg>
30//TODO::Remove this check while releasing. It is used to compile the same code on PF5250 SDK.
31#ifdef __OPENVGHEADERS_USE_VG_1_1
32 #include <es_enum_partner.h>
33#endif
34
35#include <f32file.h>
36#include <AknQueryDialog.h>
37#include <apgcli.h>
38#include <sacls.h> // for RSystemAgent::GetState()
39#include <hal.h>
40#include <apgtask.h>
41#include <charconv.h>
42#include <bafindf.h>
43#include <miutset.h>
44//#include <mmsconst.h>
45#include <smut.h>
46#include <bautils.h>
47#include <es_enum.h>
48#include <pathinfo.h>
49#include <sysutil.h>
50#include <commdb.h>
51#include <bitdev.h>
52#include <featmgr.h>
53#include <bldvariant.hrh>
54#include <etelmm.h>
55#include <httperr.h>
56#include <AknUtils.h>
57#include <flogger.h>
58#include <string.h> // for using stncmp, string compare
59#include <flash2engine.rsg>
60//Toget keyboard layout
61#include <AvkonInternalCRKeys.h>
62#include <PtiDefs.h>
63#include <pathinfo.h>
64#include <driveinfo.h>
65#include <utf.h>
66
67#if defined(FEATURE_OPENVG) && defined(USE_VPU2)
68#include <alf/alfcompositionclient.h>
69#endif
70
71#include "symbian_engine.h"
72#include "symbian_plugin_interface.h"
73#include "flashliteinterfaces.h"
74#include "symbian_stringutils.h"
75#include "saflash_consts.h"
76#include "symbian_http.h"
77#include "symbian_file.h"
78#include "symbian_videoobject.h"
79#include "symbian_videoengine.h"
80#include "symbian_phonemonitor.h"
81#include "symbian_phonecall.h"
82#include "symbian_sound.h"
83#include "symbian_image.h"
84#include "symbian_ui_interface.h"
85#include "async_event.h"
86#include "engine_data_caging_literals.hrh"
87#include "symbian_localhttp.h"
88#include "item_val_pair_list.h"
89#include "symbian_socket.h"
90#include "amp_textnavigation.h"
91#include "NPNFlashDefs.h"
92#include "symbian_mediarecognizer.h"
93#include "platformconfig.h"
94#include "symbian_platforminfo.h"
95#include "flplatformdecoderinterface.h"
96
97#include "flashengineresourcehandler.h"
98#include "mp3streamstateobserver.h"
99#include "amp_returnstring.h"
100#include "flashrtpolicyclient.h"
101
102#include "mamcextensioncallback.h"
103
104#ifdef SELF_IAD_UPDATE
105#include "symbian_updatecheck.h"
106#endif
107
108
109#ifdef FEATURE_VIDEO_DLL
110#include "flash_video_codec.h"
111#endif
112#define PLAYER_MAJOR_VERSION MAJOR_VERSION
113
114#ifdef FEATURE_BINDING_PREINSTALLED_LIB
115 #include "flashrtbindingaslibraryswf.cpp"
116#endif
117#ifdef FEATURE_EXTENSION
118#include "asextensiondelegate.h"
119#include <ecom/ecom.h>
120#include <ecom/implementationinformation.h>
121#include <escapeutils.h>
122#include "sharedmemorymanager.h"
123_LIT(KASCmdResumePlayer,"ResumePlayer");
124const TUid KASExtInterfaceUid = {0x2001E5C7};
125_LIT(KDisableAutoRoataion, "DisableAutoRotation");
126_LIT(KExpediteConnection, "ExpediteConnection");
127_LIT16(KJPEGMimeType,"image/jpeg");
128 const TInt KASErrNotSupported = -308;
129#endif //FEATURE_EXTENSION
130#include "ipconn_mgr.h"
131
132//#define BLOCK_ADOBE_DISPLAY
133
134// CONSTANTS
135const TUint32 KRAMFreeCheckMark = 5*1024*1024;
136const TInt KDefaultNameLength = 5;
137//const TInt KMaxVideoFramesToProcess = 4;
138const short KPendingUpdateFlag = (short)8;
139const TInt KFrameIntervalDefault = 20; // 20ms
140const TUint8 KAsciiOffset = 10;
141const TInt KMaxSymbianPhoneNumberLength = 256;
142const TInt KDefaultFontSize = 18;
143const TInt KMaxInt = 32768;
144const TInt KPortNumLength = 5;
145const TInt KHttpDefaultPort = 80;
146const TInt KMaxNumberOfRequests = 1;
147//This timer is used to pause the plugin after all mp3 streams are closed
148const TInt KMp3StreamTimer =60*1000*1000;//15 seconds
149//Time interval at which the backlight is extended
150const TInt KBacklightExtensionTime = 2*1000*1000;
151const TUint KMaxVolumeFromFL = 100;
152
153#ifndef USE_VPU2
154const TInt KMaxVideoPositioToBlt = 2*1000*1000; // 2 seconds.
155#endif
156
157_LIT8(KSWFFileFirstFewBytes, "FWS"); // uncompressed SWF
158_LIT8(KSWCFileFirstFewBytes, "CWS"); // compressed SWF
159_LIT (KLitAllocFailure, "AllocFailure");
160_LIT8(KColonChar, ":");
161_LIT(KFlhExtraChar, "?");
162_LIT(KFlhFileExtensionSWF, "swf");
163_LIT(KFlhFileExtensionSVG, "svg");
164
165_LIT(KAllowFullscreen, "allowfullscreen");
166
167_LIT(KCanHandleException, "canHandleException");
168_LIT(KLitPvt,"c:\\private\\");
169_LIT(KTermiChar,"\r\n");
170
171_LIT(KSLeft,"L");
172_LIT(KSRight,"R");
173_LIT(KSTop,"T");
174_LIT(KSBottom,"B");
175
176_LIT(KAllowNetworking, "allownetworking");
177_LIT(KAllowNetInternal, "internal");
178_LIT(KAllowNetAll,"all");
179_LIT(KAllowNetNone, "none");
180_LIT(KAllowNetMax,"max");
181
182_LIT(KFlashId,"id"); // This has to be added into NPNFlashDef.h eventually.
183
184#ifdef FEATURE_OPENVG
185
186 //#define EGL_SINGLE_BUFFERING //When pixmap surface is used, it should always be single buffering
187
188 const EGLint KWinSurfaceAttribList[] =
189 {
190 #ifdef EGL_SINGLE_BUFFERING
191 EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER,
192 #endif
193 EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_sRGB,
194 EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE,
195 EGL_NONE
196 };
197
198 const TUint KMaxSupportedFrameDimension = 2048;
199
200 #include <VG/openvg.h>
201 #include <VG/vgu.h>
202#endif // FEATURE_OPENVG
203
204
205#ifdef NP_DEBUG
206const TUint KMaxLogLength = 512;
207
208#include <flogger.h>
209
210void NPPDebug(TUint8 aLogLevel,TBool aIsPlugin, TRefByValue<const TDesC> aText, ... )
211 {
212
213 if(aLogLevel < CUR_LOG_LEVEL)
214 return;
215
216 VA_LIST args;
217 VA_START( args, aText );
218
219 TBuf<KMaxLogLength> buf;
220 buf.FormatList( aText, args );
221
222 RFileLogger logger;
223
224 TInt ret=logger.Connect();
225
226 if (ret==KErrNone)
227 {
228 logger.SetDateAndTime( EFalse,EFalse );
229 if(aIsPlugin)
230 {
231 logger.CreateLog( _L("FlashLogs"), _L("NPLogFile"), EFileLoggingModeAppend );
232 }
233 else
234 {
235 logger.CreateLog( _L("FlashLogs"), _L("ViewrLogFle"), EFileLoggingModeAppend );
236 }
237
238 logger.Write(buf);
239 }
240
241 logger.Close();
242
243 VA_END( args );
244 }
245
246#else
247
248void NPPDebug(TUint8 /*aLogLevel*/,TBool /*aIsPlugin*/,TRefByValue<const TDesC> /*aText*/, ... )
249 {
250 }
251
252#endif
253
254#ifdef LOG_MESSAGE
255_LIT8(KLitLogSeparator," -- ");
256_LIT8(KLitElapsedTime,"Elapsed Time: ");
257_LIT8(KLitCrCr,"\n\n");
258_LIT8(KLitValSep,"\nVal: ");
259#endif // LOG_MESSAGE
260//This is dummy function added because extern void FcDebugPanic() is declared in generic_debug.h and definition is present in coreplayer
261//If not defined we will get build break for debug builds
262void FcDebugPanic()
263{
264#if 0
265#if defined(DEBUG) || defined(_DEBUG)
266#ifdef __WINS__
267 _asm { int 3h };
268#else
269 User::Panic(_L("ASSERT"), 0);
270#endif // __WINS__
271#endif // DEBUG || _DEBUG
272
273#if 0
274 // crashing is not a good idea as it is unrecoverable... asserts are not always unrecoverable.
275 int *p = 0;
276 *p=1;
277#endif
278#endif
279}
280
281
282
283static int Parse1Hex(TUint c)
284{
285 if (c >= '0' && c <= '9')
286 return c - '0';
287 if (c >= 'a' && c <= 'f')
288 return c - 'a' + 10;
289 if (c >= 'A' && c <= 'F')
290 return c - 'A' + 10;
291 return 0;
292}
293
294inline int Parse2Hex(const TUint16* c)
295{
296 return (Parse1Hex(c[0])<<4) + Parse1Hex(c[1]);
297}
298
299// this class is private to the CPlatformFlashEngine class, and is therefore implemented here
300
301//static
302CPlatformFlashEngine::CQueuedSILaunch* CPlatformFlashEngine::CQueuedSILaunch::NewL(struct MM_Object* aMMObj,
303 TUint16 aArgc,
304 const TDesC** aArgv,
305 TInt16 aIsEmbedded)
306{
307 CQueuedSILaunch* self=new(ELeave) CQueuedSILaunch(aMMObj,aArgc,aIsEmbedded);
308 CleanupStack::PushL(self);
309 self->ConstructL(aArgv);
310 CleanupStack::Pop(self);
311 return self;
312}
313
314CPlatformFlashEngine::CQueuedSILaunch::~CQueuedSILaunch()
315{
316 for(TInt i=0;i<iArgc;i++)
317 {
318 delete iArgv[i];
319 }
320 delete [] iArgv;
321}
322
323
324_LIT(KLitCamera,"camera");
325_LIT(KLitBrowser,"browser");
326_LIT(KLitBrowserExecutable,"browserng.exe");
327void CPlatformFlashEngine::CQueuedSILaunch::ConstructL(const TDesC** aArgv)
328{
329 iArgv=new(ELeave) HBufC*[iArgc];
330
331 for(TInt i=0;i<iArgc;i++)
332 {
333 iArgv[i]=aArgv[i]->AllocL();
334 }
335
336 // do some fundamental checks to make sure there is a good chance we will be able to launch the app...
337 if( iArgc>0)
338 {
339 if( 0 == iArgv[0]->Compare(KLitCamera) || 0==iArgv[0]->Compare(KLitBrowser))
340 {
341 return; // we are OK
342 }
343 else // just have an app by path - better make sure it exists
344 {
345 // const TParsePtrC ptrC(*iArgv[0]);
346 //if(BaflUtils::FolderExists(((FI_Interface*)ipMMObj->pHostObj)->GetEngine()->GetRFs(),ptrC.DriveAndPath()))
347 return; // OK
348 }
349
350 }
351 User::Leave(KErrNotSupported); // cannot launch the app requested
352}
353
354CPlatformFlashEngine::CQueuedSILaunch::CQueuedSILaunch(struct MM_Object* aMMObj, TUint16 aArgc, TInt16 aIsEmbedded)
355:ipMMObj(aMMObj), iArgc(aArgc), iIsEmbedded(aIsEmbedded)
356{}
357
358void CPlatformFlashEngine::CQueuedSILaunch::LaunchL()
359{
360 CPlatformFlashEngine* pEngine = ipMMObj->pHostObj->iFIInterface->GetEngine();
361
362 if(!iArgc)
363 return;
364
365 // we already have a legacy way to run the browser - so use that
366 // iSource 14029: Workaround to support entering name of browser executable "BrowserNG.exe"
367 // to launch the browser with a URL as argument.
368 if(0==iArgv[0]->CompareF(KLitBrowser) || (0 == KLitBrowserExecutable().CompareF(*iArgv[0])))
369 {
370 if(iArgc>1)
371 {
372 pEngine->HandleBrowserURLL(*(iArgv[1]));
373 return;
374 }
375 pEngine->HandleBrowserURLL(KNullDesC);
376 return;
377 }
378
379
380 else
381 {
382 TInt maxLen = 0;
383 const TDesC* argsDes=&KNullDesC;
384 HBufC* args = 0;
385 if(iArgc > 1)
386 {
387 TInt i;
388 for(i=1; i<iArgc; i++)
389 {
390 maxLen += iArgv[i]->Length() + 1;
391 }
392
393 args = HBufC::NewLC(maxLen);
394 TPtr16 argsPtr(args->Des());
395 for(i=1; i<iArgc; i++)
396 {
397 argsPtr.Append(*iArgv[i]);
398 if(i != iArgc-1)
399 {
400 argsPtr.Append(KLitSpace);
401 }
402 }
403 argsDes=args;
404 }
405
406 if (0 ==iArgv[0]->Compare(KLitCamera))
407 {
408 TInt resoffset = FlashEngineRscHandler::LoadEngineResourceFileL();
409 HBufC* cameraAppPath=pEngine->GetEikonEnv()->AllocReadResourceLC(R_FLASH_CAMERA_APP_PATH);
410 pEngine->LaunchAppL(*cameraAppPath,*argsDes);
411 CleanupStack::PopAndDestroy(cameraAppPath);
412 FlashEngineRscHandler::DeleteEngineResourceFile(CEikonEnv::Static(), resoffset);
413 }
414 else
415 {
416 pEngine->LaunchAppL(*iArgv[0], *argsDes);
417 }
418
419 // For Flash Lite 1.1 compatibility, we must also support launching
420 // any application by its path.
421
422 if(args)
423 {
424 CleanupStack::PopAndDestroy(args);
425 }
426 }
427
428 return; // success
429}
430
431// class CPlatformFlashEngine
432
433
434extern "C" void allocFailureHandler( void* /*data*/ )
435{
436 User::Panic(KLitAllocFailure, 1);
437}
438
439
440
441void FpeExceptionHandler(TExcType)
442{
443 return;
444}
445
446
447EXPORT_C MFlashEngine* CreateNewFlashEngineL()
448{
449 CPlatformFlashEngine* eng = new(ELeave) CPlatformFlashEngine();
450 return (MFlashEngine*)eng;
451}
452
453LOCAL_C short GetSoftkeyLocationFromOS()
454{
455 short flashLoc = KSoftKeyLocationBottom; // bottom is default
456
457 AknLayoutUtils::TAknCbaLocation loc=AknLayoutUtils::CbaLocation();
458 if(loc==AknLayoutUtils::EAknCbaLocationBottom)
459 {
460 flashLoc = KSoftKeyLocationBottom; // bottom
461 }
462 else if(loc==AknLayoutUtils::EAknCbaLocationRight)
463 {
464 flashLoc = KSoftKeyLocationRight; // right
465 }
466 else if(loc==AknLayoutUtils::EAknCbaLocationLeft)
467 {
468 flashLoc = KSoftKeyLocationLeft; // left
469 }
470 else
471 {
472 flashLoc = KSoftKeyLocationTop; // top
473 }
474
475 return flashLoc;
476}
477
478CPlatformFlashEngine::CPlatformFlashEngine()
479 : iEnv(CEikonEnv::Static())
480 , iFs(iEnv->FsSession())
481 , iLaunchQueue(_FOFF(CQueuedSILaunch,iLink))
482 , iBrowserUid(KNullUid)
483 , iNotifyEndOfMovie (ETrue)
484 , iSwfSrcPath(NULL,0)
485 , iControlPresent(EFalse)
486 , iFLVStatus(ENetStreamNull)
487 ,iMP3StreamCount(0)
488 ,iTrustStore(NULL)
489 , iItemValuePairArrays(NULL)
490 , iAsyncIPDlgArray(NULL)
491#ifdef FEATURE_INLINE_TEXT_ENTRY
492 , iTextNavigation( NULL )
493#endif //FEATURE_INLINE_TEXT_ENTRY
494 , iUtcReferenceTime(TDateTime(1970, EJanuary, 0, 00,00,00,000000))
495 , iFitVideoToScreen(EFalse)
496 , iIsVideoContent(EFalse)
497 , iWindowMode(EWindow)
498 , iFontMapTable(NULL)
499 , iAllowFullscreen(ETrue)
500 , iAllowNetworking(kAllowNetworkingAll)
501{
502 User::SetExceptionHandler(FpeExceptionHandler, KExceptionFpe);
503
504 iMMObject = NULL;
505
506 // Bitmap
507 iBitmap = NULL;
508 iBitmapGc = NULL;
509 iBitmapDevice = NULL;
510 iIsBitmapLocked = EFalse;
511 iWindowGc = NULL;
512
513#ifdef FEATURE_OPENVG
514 iAuxTextBitmap = NULL;
515 iAuxTextBitmapGc = NULL;
516 iAuxTextBitmapDevice = NULL;
517 iIsAuxTextBitmapLocked = NULL;
518#endif
519
520 iDefaultFontBitmapDevice = NULL;
521
522 iDefaultFont = NULL;
523 iCurrentFontId = 0;
524 iLoop = KDefaultLoop;
525 iReplayFlag = EFalse;
526
527 iTimer = NULL;
528 iMp3Timer = NULL;
529 iIAPTimer = NULL;
530 iBacklightExtensionTimer = NULL;
531
532 iIsRunning = EFalse;
533 //iMustExit = EFalse;
534 iPauseFlags = ENotPaused;
535 iForeground = ETrue;
536 iPassOnException = EFalse;
537 iVideoRect.iRect.SetSize(TSize(0,0));
538
539 iPlayerStaticHeap = NULL;
540 iPlayerDynamicHeapAlloced = 0;
541
542 iIsLastTypefaceValid = EFalse;
543
544 iPlayerState = EPlayerOK;
545 iRedraw = EFalse;
546
547 iBaseURL = NULL;
548 iHTMLBaseURL = NULL;
549 iEngineSecurityContextUrl = NULL;
550 iAllowScriptAccess = 2; //"Samedomain" by default
551 iNewFile = NULL;
552 iDownloading = EFalse;
553
554 iSvgMode = EFalse;
555 iFrameInterval = KFrameIntervalDefault; // default to 20ms.
556 iVibrationHandler = NULL;
557 iDelay=0;
558#ifdef FEATURE_PACK_3
559 iPlatformInfo = NULL;
560 iRegistrationStatus = NULL;
561 iSubscriberInfo = NULL;
562 iNetworkInfo = NULL;
563 iPhoneInfo = NULL;
564 iBatteryInfo = NULL;
565 iSignalInfo = NULL;
566 iChargingInfo = NULL;
567#endif // FEATURE_PACK_3
568
569 iPhoneMonitor = NULL;
570 iSoundHandler = NULL;
571 // Async event variables
572 iGetInputTextRequest = NULL;
573 iIMEControlState = EIMENotInitialized; // state 0 for IME control
574 iChangeScreenSizeRequest = EChangeScreenNull;
575 iChangeKeysRequest = EChangeScreenNull;
576 iSoftkeyArray = NULL;
577 iSoftkeyArraySize = 0;
578
579 iIsInitialized = EFalse;
580 iCharacterConverter = NULL;
581 iNetBufArray.Reset();
582 iFileEngine = NULL;
583 iHttpEngine = NULL;
584 iIPConnMgr = NULL;
585 iLocalHttpEngine = NULL;
586 iVideoEngine = NULL;
587#ifdef FEATURE_XML_SOCKET
588 iSocketEngine = NULL;
589#endif //FEATURE_XML_SOCKET
590 iImageConverter = NULL;
591
592 //iFlashUI = NULL;
593 //iControl = NULL;
594 //iBrowserPluginActive = EFalse;
595
596 iDynamicMemBlocks = NULL;
597
598 // set backlight extension time to the current time.
599 // iBacklightExtensionTime.UniversalTime();
600
601 iZoomFactor = 0;
602 iPanMode = EFalse;
603
604
605 //iMachineUid = 0;
606 //iDeviceName = NULL;
607 //iPlatformName = NULL;
608 iResourceOffset = 0;
609
610 iFileUtils=NULL;
611 iAsyncEventHandler = NULL;
612#ifndef USE_SYNC_MSO
613 iShObjEngine=NULL;
614#else
615 iSharedObjHandler = NULL;
616#endif //USE_SYNC_MSO
617
618 iQuality = FI_QualityMedium;
619 iSoftkeyLocation=GetSoftkeyLocationFromOS();
620 iIsStopped = EFalse;
621
622#ifdef FEATURE_OPENVG
623 iEGLDisplay = NULL;
624 iEGLSurface.surface = NULL;
625 iEGLContext = NULL;
626 iEGLInitialized = EFalse;
627 iCurrentIMIndicatorBounds.SetRect(0,0,0,0);
628 iCurrentTextInputMode = -1;
629 iIMIndicatorBmp = NULL;
630 iIMIndicatorBmpGc = NULL;
631 iIMIndicatorBmpDevice = NULL;
632 iInputModeIndicatorImage = VG_INVALID_HANDLE;
633 iRenderToggleTimer = NULL;
634 iEGLMaxSupportedWidth = 0;
635 iEGLMaxSupportedHeight = 0;
636#endif
637
638#if defined(FEATURE_OPENVG) && defined(USE_VPU2)
639 iCompositionControl = NULL;
640#endif
641
642#ifdef FEATURE_WATCH_GPU_MEM
643 iGPUMemLow = EFalse;
644#endif
645
646 iFLVPlayStat = EFalse;
647#ifdef FEATURE_ATS_AUTOMATION
648 iATSHandler = NULL;
649#endif
650 #ifdef FEATURE_PERFORMANCE_AUTOMATION
651 iPerfTestMode = EFalse;
652 #endif
653 iFrameBufferResized = EFalse;
654 iInDoPlay = EFalse;
655 iMp3PlayStateObserver =NULL;
656
657 iContentOverVideo = EFalse;
658 iNetworkPromptPausedCount = 0;
659 //Set to default mode.Currently we have requirement to recognise widget mode
660 //iInteractionMode = EDefaultMode;
661
662 iFullScreenViaFSCommand = EFalse;
663 iSwfHasVideo = 0;
664 iSwfHasAudio = 0;
665
666 iRequestedScreenChange=EFalse;
667 iSwfPath = NULL;
668 iFrameBufferSize = TSize(0,0);
669
670#ifdef FORCE_REFRESH_WORKAROUND
671 iForceRedrawTimer = NULL;
672 iForceRedraw = EFalse;
673#endif
674
675#ifdef DUMP_DIRTY_RECTS
676 iSurfaceData = NULL;
677 iBitmapToBeDumped = NULL;
678#endif
679
680 iSwfStarted = EFalse;
681
682#ifdef FEATURE_COLLECT_BITMAP
683 iLastRenderedBitmap = NULL;
684 iIgnoreDrawBitBuffer = EFalse;
685#endif
686}
687
688//Removed as this function is not used anywhere
689/*void CPlatformFlashEngine::SetTempPathAndName()
690{
691
692 //Returns the Uid of Application.
693 TUid Identi = User::Identity();
694
695 _LIT(KOpenNetFileName,"net.swf");
696 //uidName consists of Uid name of application. For Ex. [101fd693]
697 TUidName uidName = Identi.Name();
698 //Deleting '[' from the Uid name.
699 uidName.Delete(0,1);
700 //Deleting ']' from the Uid name.
701 uidName.Delete(uidName.Length()-1,1);
702 iTempOpenNetFileName.Copy(KPersistentSubdirName);
703 iTempOpenNetFileName.Append(uidName);
704 iTempOpenNetFileName.Append(KDoubleSlash);
705 iTempOpenNetFileName.Append(KOpenNetFileName);
706}*/
707FlashEngineConfig CPlatformFlashEngine::GetConfig()
708{
709 return iConfig;
710}
711void CPlatformFlashEngine::ConstructL(FlashEngineConfig& aConfig,
712 MFlashClientIf* aClientInterface,
713 EEngineExecutionMode aExecutionMode,
714 EBrPluginExecutionMode aBrPluginMode
715 )
716 {
717 iFlashClientIf = aClientInterface;
718 iExecutionMode = aExecutionMode;
719 iBrPluginMode = aBrPluginMode;
720#ifdef FEATURE_WINDOWLESS
721 iWindowMode = iFlashClientIf->GetWMode();
722#endif //FEATURE_WINDOWLESS
723
724// if( (iExecutionMode==eWidget) || (iExecutionMode==eBrowserPlugin) )
725 // iBrowserPluginActive = ETrue;
726
727 iConfig.iHelixFlvMode = EFalse;
728
729#ifdef FEATURE_OPENVG
730 iHwConfig.hardwareQuality = FI_HardwareQuality_Default;
731 iHwConfig.configFlags = FI_HardwareConfig_UseAuxTextBufferForHWRendering;
732#ifndef EGL_SINGLE_BUFFERING
733 iHwConfig.configFlags |= FI_HardwareConfig_HardwareSurfaceIsDoubleBuffered;
734#endif
735
736 iOpenVgMode = ETrue;
737 iRenderToBitmap = EFalse;
738 iSwitchingToSWRenderingInPrgress = EFalse;
739 if(iWindowMode != EWindow)
740 {
741 iOpenVgMode = EFalse;
742 iRenderToBitmap = ETrue;
743 }
744
745#else
746 iOpenVgMode = EFalse;
747 iRenderToBitmap = ETrue;
748#endif
749#ifdef FEATURE_MANAGER_CHECK
750 // Check if Vibration is allowed for this device
751 FeatureManager::InitializeLibL();
752 iVibraFeatureSupportedByDevice = FeatureManager::FeatureSupported( KFeatureIdVibra );
753 iVibraFeatureSupportedByCenRep = iConfig.iMode & KCenRepVibraFeatureSupport;//IF vibration bit is ON then value will be Non-Zero
754 //Once CenRep is working need to remove this statement
755 iVibraFeatureSupportedByCenRep = ETrue;
756 iVibraFeatureSupported = iVibraFeatureSupportedByDevice & iVibraFeatureSupportedByCenRep;
757
758 // In WebVideo Ph2, helix flv decoders will be used. So let us check for this feature
759 //Once KFeatureIdWebvideoPh2 flag is included, please uncomment the Feature manager call.
760 //aConfig.iHelixFlvMode = FeatureManager::FeatureSupported( KFeatureIdWebvideoPh2 );
761
762 aConfig.iHelixFlvMode = ETrue;
763
764 FeatureManager::UnInitializeLib();
765#endif // FEATURE_MANAGER_CHECK
766
767#ifdef LOG_MESSAGE
768 // Create the log file
769 iLogFile = new RFile;
770
771 if (iLogFile)
772 {
773 int err = iLogFile->Open(iFs, KFlashLogFile, EFileWrite | EFileShareExclusive);
774
775 if (err != KErrNone)
776 {
777
778 err = iLogFile->Create(iFs, KFlashLogFile, EFileWrite | EFileShareExclusive);
779
780 if (err != KErrNone)
781 {
782 delete iLogFile;
783 iLogFile = NULL;
784 }
785 }
786 if (iLogFile)
787 {
788 TInt endOfFile = 0;
789 iLogFile->Seek(ESeekEnd, endOfFile);
790 }
791 }
792#endif // LOG_MESSAGE
793
794 iSoftkeyArraySize = aConfig.iSoftkeyCount;
795
796 if( iSoftkeyArraySize )
797 iSoftkeyArray = new(ELeave) HBufC*[iSoftkeyArraySize];
798
799 TInt i;
800 for(i=0; i<iSoftkeyArraySize; i++)
801 {
802 iSoftkeyArray[i] = NULL;
803 }
804
805 //iFlashUI = NULL;
806 iConfig = aConfig;
807 iPlayerStaticHeapSize = aConfig.iStaticHeapSize;
808 iPlayerDynamicHeapMaxSize = aConfig.iDynamicHeapMaxSize;
809
810 iPlatformConfig = new (ELeave) CPlatformConfig;
811
812 // Initialize SI_FI_Interface by loading library
813 #if defined(FEATURE_PERFORMANCE_AUTOMATION) || defined(FEATURE_TESTAUTOMATION)//this flag can be used for both widget as well as performance automation
814 _LIT8(KWritoLocalFileDllName, "WriteToLocalFile");
815 _LIT8(KCommaSeperator,",");
816
817 if((iConfig.iMode & KPerformanceTestMode))
818 {
819 iConfig.iMode = (iConfig.iMode | KSupportMMI); // Enable support for MMI for the Automation mode so that WriteTolocalfile MMI extension can be loaded
820 TInt lLengthListofPredefinedExtension = 0;
821 if(iConfig.iExtensions)
822 lLengthListofPredefinedExtension = iConfig.iExtensions->Length();
823
824 TInt lLengthListofAutomationExtensions = lLengthListofPredefinedExtension + KWritoLocalFileDllName().Length() + KCommaSeperator().Length()+ 1;
825 HBufC8* lAutomationExtensions = HBufC8::NewLC(lLengthListofAutomationExtensions);
826 TPtr8 lPtr(NULL,0);
827 lPtr.Set(lAutomationExtensions->Des());
828 if(iConfig.iExtensions)
829 {
830 lPtr.Copy(*(iConfig.iExtensions));//only add this is extension to be loaded if already present
831 lPtr.Append(KCommaSeperator); //only add this is extension to be loaded if already present
832 lPtr.Append(KWritoLocalFileDllName);
833 }
834 else
835 {
836 lPtr.Copy(KWritoLocalFileDllName);
837 }
838
839 iConfig.iSMCheckNeeded = EFalse; // Disable SMcheck as there is only WriteToLocal Extension needed for Logging.
840 iFiObject.InitializeL(iConfig.iMode, lAutomationExtensions, *iEnv, iConfig.iSMCheckNeeded);
841
842 //delete this pointer
843 CleanupStack::PopAndDestroy(lAutomationExtensions);
844 }
845 else
846 {
847 iFiObject.InitializeL(iConfig.iMode, iConfig.iExtensions, *iEnv, iConfig.iSMCheckNeeded);
848 }
849 #else
850 iFiObject.InitializeL(iConfig.iMode, iConfig.iExtensions, *iEnv, iConfig.iSMCheckNeeded);
851 #endif
852 /*
853 if (iConfig.iMode & KSupportNetwork)
854 {
855 //Moved to CPlatformFlashEngine::GetHttpEngine()
856 //iHttpEngine = CHttpEngine::NewL(this);
857
858 //Moved to CPlatformFlashEngine::GetLocalHttpEngine()
859 //iLocalHttpEngine = CLocalHttpEngine::NewL();
860
861 //Moved to CPlatformFlashEngine::GetSocketEngine()
862#ifdef FEATURE_XML_SOCKET
863 //iSocketEngine = CFlashSocketEngine::NewL(*this);
864#endif//FEATURE_XML_SOCKET
865 }
866 */
867
868 //Moved to CPlatformFlashEngine::GetFileEngine()
869 /*
870 if (iConfig.iMode & KSupportLocalFile)
871 {
872 iFileEngine = CFileEngine::NewL();
873 }
874 */
875
876 //Moved to CPlatformFlashEngine::GetVideoEngine()
877 /*if (iConfig.iMode & KSupportVideo)
878 {
879 iVideoEngine = CVideoEngine::NewL(*this, iFs);
880 }*/
881
882 //Moved to CPlatformFlashEngine::GetImageConverter()
883 //iImageConverter = CImageConverter::NewL(*this);
884
885#ifdef FEATURE_PACK_3
886
887 //Moved to CPlatformFlashEngine::GetPlatformInfo()
888 /*if(!iPlatformInfo)
889 {
890 iPlatformInfo = CPlatformInfo::NewL(this);
891 }*/
892
893 if(!NoETelSuppport()) //no etel info fetch required then dont create
894 {
895
896 if(!iPhoneInfo)
897 {
898 iPhoneInfo = CPhoneInfo::NewL();
899 }
900
901 //if(iFlashUI)
902 if(eStandAlone==iExecutionMode)
903 {
904 //let us not create for plug-in now, we will do it when AS queries.
905
906 //Moved to CPlatformFlashEngine::GetNetworkInfoL()
907 /*if(!iNetworkInfo)
908 {
909 iNetworkInfo = CNetworkInfo::NewL();
910 }*/
911
912 /*
913 //Moved to CPlatformFlashEngine::GetSubscriberInfoL()
914 if(!iSubscriberInfo)
915 {
916 iSubscriberInfo = CSubscriberInfo::NewL();
917 }
918 */
919 //Moved to CPlatformFlashEngine::GetRegistrationStatusL
920 /*if(!iRegistrationStatus)
921 {
922 iRegistrationStatus = CRegistrationStatus::NewL();
923 }*/
924
925 /*
926 if(!iBatteryInfo)
927 {
928 iBatteryInfo = CPhoneBatteryInfo::NewL();
929 }
930
931 if(!iSignalInfo)
932 {
933 iSignalInfo = CPhoneSignalInfo::NewL();
934 }
935
936 if(!iChargingInfo)
937 {
938 iChargingInfo = CPhoneChargingInfo::NewL();
939 }
940 */
941 }
942 }
943
944#endif // FEATURE_PACK_3
945
946 //Needed to create phone monitor during startup?
947 if(!NoIncomingCallMonitor())
948 {
949 iPhoneMonitor = new(ELeave) CPhoneMonitor();
950 if(iPhoneMonitor)
951 iPhoneMonitor->ConstructL(this);
952 }
953
954 if (iConfig.iMode & KSupportSound)
955 {
956 iSoundHandler = new(ELeave) CSoundHandler();
957 }
958
959 //TODO : Refine this with system lib call
960 iFrameBufferDisplayFormat = (FI_DisplayFormat)iFiObject.FI_GetDisplayFormat(GetMMObject());
961 ASSERT(iFrameBufferDisplayFormat == FI_DisplayFormat_ARGB8888_32);
962 ASSERT(TDisplayModeUtils::NumDisplayModeBitsPerPixel(iEnv->ScreenDevice()->DisplayMode()) == 32);
963 iDisplayFormat = iEnv->ScreenDevice()->DisplayMode();
964
965 CreateCharacterConverterL();
966
967 iAsyncEventHandler = CFlhAsyncEvent::NewL(this);
968
969 iLaunchQueueHandler=CFlhAsyncObject::NewL(CActive::EPriorityHigh,*this); // run before absolutely anything else...
970 iFileUtils = CFlhFileUtils::NewL(iFs);
971
972
973// LoadResourceFileL();
974
975 // Make it low priority, otherwise high frame-rate movies will prevent sound from starting.
976 iTimer = CFlhTimerObject::NewL(CActive::EPriorityStandard,*this);
977 iLowestPriorityActiveObj = CFlhAsyncObject::NewL(CActive::EPriorityLow,*this);
978 //iLowestPriorityActiveObj = CFlhAsyncObject::NewL(KMinTInt32,*this);
979
980 iAsyncIPDlgArray = new (ELeave) CArrayPtrSeg<CFlhAsyncIPSelectDlg>(1);
981 iItemValuePairArrays = new (ELeave) CArrayPtrSeg<CFlhItemValuePairList>(1);
982
983
984 iBkLightHandler = CBackLightHandler::NewL();
985 iSwfInDestruction = EFalse;
986
987#ifdef FEATURE_WEB_BROWSABILITY
988 if(eStandAlone!=iExecutionMode)
989 {
990 //we dont support scripting in viewer mode
991 iHostScriptHandler = CHostScriptHandler::NewL(this);
992 }
993#endif //FEATURE_WEB_BROWSABILITY
994
995 iFlvDecoder = NULL;
996#ifdef FEATURE_ATS_AUTOMATION
997 if(iConfig.iMode & KPlayerInATSMode)
998 {
999 iATSHandler = CATSHandler::NewL(this);
1000 iPerfTestMode = ETrue; //network connection for both performance and ats automation is same. so make a common runtime flag true.
1001 }
1002#endif
1003 //check the engine mode bit for performanceTest Mode
1004#ifdef FEATURE_PERFORMANCE_AUTOMATION
1005 if(aConfig.iMode & KPerformanceTestMode)
1006 {
1007 iPerfTestMode = ETrue;
1008 }
1009 #endif
1010#ifdef FEATURE_TESTAUTOMATION
1011 if(aConfig.iMode & KPlayerInATSMode)
1012 {
1013 iPerfTestMode = ETrue;
1014 }
1015 #endif
1016#ifdef DUMP_DIRTY_RECTS
1017 iDirtyRectLengthsFile.Replace(iFs,_L("C:\\data\\others\\dirtyrectLengths.txt"),EFileWrite);
1018 iDirtyRectNum=0;
1019#endif
1020
1021// HostEngineGlobals
1022 iHostEngineGlobals = CHostEngineGlobals::CreateHostEngineGlobalsL();
1023 iHostEngineGlobals->PlatformFlashEngine(this);
1024
1025#ifdef SELF_IAD_UPDATE
1026 MIadUpdateCallback* iadClient = aClientInterface->GetIADUpdateCallback();
1027 if(iadClient)
1028 HandleIADCheck( iadClient, aConfig );
1029#endif
1030
1031#ifdef FEATURE_WATCH_GPU_MEM
1032 TRAP_IGNORE(
1033 iGPUMemWatch = CGPUMemWatch::NewL(this);
1034 if(iGPUMemWatch)
1035 iGPUMemWatch->WatchL();
1036 );
1037#endif
1038
1039#ifdef FEATURE_OPENVG
1040 TRAP_IGNORE(CCoeEnv::Static()->AddForegroundObserverL(*this));
1041#endif
1042
1043 NPPDebug( LOG_ALL, IsBrowserPluginActive(), _L("Engine::ConstructL()--"));
1044
1045 }
1046/*
1047void CPlatformFlashEngine::ConstructL(MFlashUI* aFlashUI, FlashEngineConfig& aConfig
1048#ifdef SELF_IAD_UPDATE
1049, MIadUpdateCallback* aIADUpdateCompleteCallback
1050#endif
1051 )
1052{
1053 NPPDebug( LOG_ALL, IsBrowserPluginActive(), _L("Engine::ConstructL()++"));
1054 NPPDebug( LOG_ALL, IsBrowserPluginActive(), _L("FlashLite 3.1 Engine"));
1055 iConfig.iHelixFlvMode = EFalse;
1056
1057#ifdef FEATURE_MANAGER_CHECK
1058 // Check if Vibration is allowed for this device
1059 FeatureManager::InitializeLibL();
1060 iVibraFeatureSupportedByDevice = FeatureManager::FeatureSupported( KFeatureIdVibra );
1061 iVibraFeatureSupportedByCenRep = iConfig.iMode & KCenRepVibraFeatureSupport;//IF vibration bit is ON then value will be Non-Zero
1062 //Once CenRep is working need to remove this statement
1063 iVibraFeatureSupportedByCenRep = ETrue;
1064 iVibraFeatureSupported = iVibraFeatureSupportedByDevice & iVibraFeatureSupportedByCenRep;
1065
1066 // In WebVideo Ph2, helix flv decoders will be used. So let us check for this feature
1067 //Once KFeatureIdWebvideoPh2 flag is included, please uncomment the Feature manager call.
1068 //aConfig.iHelixFlvMode = FeatureManager::FeatureSupported( KFeatureIdWebvideoPh2 );
1069
1070 aConfig.iHelixFlvMode = ETrue;
1071
1072 FeatureManager::UnInitializeLib();
1073#endif // FEATURE_MANAGER_CHECK
1074
1075#ifdef LOG_MESSAGE
1076 // Create the log file
1077 iLogFile = new RFile;
1078
1079 if (iLogFile)
1080 {
1081 int err = iLogFile->Open(iFs, KFlashLogFile, EFileWrite | EFileShareExclusive);
1082
1083 if (err != KErrNone)
1084 {
1085
1086 err = iLogFile->Create(iFs, KFlashLogFile, EFileWrite | EFileShareExclusive);
1087
1088 if (err != KErrNone)
1089 {
1090 delete iLogFile;
1091 iLogFile = NULL;
1092 }
1093 }
1094 if (iLogFile)
1095 {
1096 TInt endOfFile = 0;
1097 iLogFile->Seek(ESeekEnd, endOfFile);
1098 }
1099 }
1100#endif // LOG_MESSAGE
1101
1102 iSoftkeyArraySize = aConfig.iSoftkeyCount;
1103
1104 if( iSoftkeyArraySize )
1105 iSoftkeyArray = new(ELeave) HBufC*[iSoftkeyArraySize];
1106
1107 TInt i;
1108 for(i=0; i<iSoftkeyArraySize; i++)
1109 {
1110 iSoftkeyArray[i] = NULL;
1111 }
1112
1113 iFlashUI = aFlashUI;
1114 iConfig = aConfig;
1115 iPlayerStaticHeapSize = aConfig.iStaticHeapSize;
1116 iPlayerDynamicHeapMaxSize = aConfig.iDynamicHeapMaxSize;
1117
1118 iPlatformConfig = new (ELeave) CPlatformConfig;
1119
1120 // Initialize SI_FI_Interface by loading library
1121
1122 iFiObject.InitializeL(iConfig.iMode, iConfig.iExtensions, *iEnv, iConfig.iSMCheckNeeded);
1123
1124 if (iConfig.iMode & KSupportNetwork)
1125 {
1126 iHttpEngine = CHttpEngine::NewL(this);
1127
1128 iLocalHttpEngine = CLocalHttpEngine::NewL();
1129
1130#ifdef FEATURE_XML_SOCKET
1131 iSocketEngine = CFlashSocketEngine::NewL(*this);
1132#endif//FEATURE_XML_SOCKET
1133 }
1134
1135 if (iConfig.iMode & KSupportLocalFile)
1136 {
1137 iFileEngine = CFileEngine::NewL();
1138 }
1139
1140 if (iConfig.iMode & KSupportVideo)
1141 {
1142 iVideoEngine = CVideoEngine::NewL(*this, iFs);
1143 }
1144
1145 iImageConverter = CImageConverter::NewL(*this);
1146
1147#ifdef FEATURE_PACK_3
1148
1149 if(!iPlatformInfo)
1150 {
1151 iPlatformInfo = CPlatformInfo::NewL(this);
1152 }
1153
1154 if(!NoETelSuppport()) //no etel info fetch required then dont create
1155 { //optimaization for performance
1156 if(!iPhoneInfo)
1157 {
1158 iPhoneInfo = CPhoneInfo::NewL();
1159 }
1160
1161 if(iFlashUI)
1162 {
1163 //let us not create for plug-in now, we will do it when AS queries.
1164
1165 if(!iNetworkInfo)
1166 {
1167 iNetworkInfo = CNetworkInfo::NewL();
1168 }
1169
1170 if(!iSubscriberInfo)
1171 {
1172 iSubscriberInfo = CSubscriberInfo::NewL();
1173 }
1174
1175 if(!iRegistrationStatus)
1176 {
1177 iRegistrationStatus = CRegistrationStatus::NewL();
1178 }
1179
1180 if(!iBatteryInfo)
1181 {
1182 iBatteryInfo = CPhoneBatteryInfo::NewL();
1183 }
1184
1185 if(!iSignalInfo)
1186 {
1187 iSignalInfo = CPhoneSignalInfo::NewL();
1188 }
1189
1190 if(!iChargingInfo)
1191 {
1192 iChargingInfo = CPhoneChargingInfo::NewL();
1193 }
1194 }
1195 }
1196
1197#endif // FEATURE_PACK_3
1198
1199 if(!NoIncomingCallMonitor())
1200 {
1201 iPhoneMonitor = new(ELeave) CPhoneMonitor();
1202 if(iPhoneMonitor)
1203 iPhoneMonitor->ConstructL(this);
1204 }
1205
1206 if (iConfig.iMode & KSupportSound)
1207 {
1208 iSoundHandler = new(ELeave) CSoundHandler();
1209 }
1210
1211 TUint16 df = iFiObject.FI_GetDisplayFormat(GetMMObject());
1212 switch (df)
1213 {
1214
1215 case FI_DisplayFormat_RGB666_24:
1216 iDisplayMode = EColor16M;
1217 break;
1218
1219 case FI_DisplayFormat_RGB666_32:
1220 iDisplayMode = EColor16MU;
1221 break;
1222
1223 case FI_DisplayFormat_ARGB8888_32:
1224 {
1225 iDisplayMode = EColor16MA; //EColor16MU;
1226 break;
1227 }
1228 default:
1229 case FI_DisplayFormat_RGB565_16:
1230 iDisplayMode = EColor64K;
1231 break;
1232 }
1233
1234
1235 CreateCharacterConverterL();
1236
1237 iAsyncEventHandler = CFlhAsyncEvent::NewL(this);
1238
1239 iLaunchQueueHandler=CFlhAsyncObject::NewL(CActive::EPriorityHigh,*this); // run before absolutely anything else...
1240 iFileUtils = CFlhFileUtils::NewL(iFs);
1241 if(aConfig.iMode & KSupportSharedObject)
1242 {
1243 TFileName pdir;
1244
1245 CreateFilenameEnsurePath(iFs,pdir,EFalse);
1246 iShObjEngine = CFlhShObjEngine::NewL(iFs, *iFileUtils, pdir);
1247 }
1248
1249// LoadResourceFileL();
1250
1251 // Make it low priority, otherwise high frame-rate movies will prevent sound from starting.
1252 iTimer = CFlhTimerObject::NewL(CActive::EPriorityStandard,*this);
1253 iLowestPriorityActiveObj = CFlhAsyncObject::NewL(KMinTInt32,*this);
1254
1255 iAsyncIPDlgArray = new (ELeave) CArrayPtrSeg<CFlhAsyncIPSelectDlg>(1);
1256 iItemValuePairArrays = new (ELeave) CArrayPtrSeg<CFlhItemValuePairList>(1);
1257
1258
1259 iBkLightHandler = CBackLightHandler::NewL();
1260
1261#ifdef FEATURE_WEB_BROWSABILITY
1262 if(!iFlashUI)
1263 {
1264 //we dont support scripting in viewer mode
1265 iHostScriptHandler = CHostScriptHandler::NewL(this);
1266 }
1267#endif //FEATURE_WEB_BROWSABILITY
1268
1269 iFlvDecoder = NULL;
1270#ifdef FEATURE_ATS_AUTOMATION
1271 if(iConfig.iMode & KPlayerInATSMode)
1272 {
1273 iATSHandler = CATSHandler::NewL();
1274 iPerfTestMode = ETrue; //network connection for both performance and ats automation is same. so make a common runtime flag true.
1275 }
1276#endif
1277 //check the engine mode bit for performanceTest Mode
1278#ifdef FEATURE_PERFORMANCE_AUTOMATION
1279 if(aConfig.iMode & KPerformanceTestMode)
1280 {
1281 iPerfTestMode = ETrue;
1282 }
1283 #endif
1284#ifdef DUMP_DIRTY_RECTS
1285 iDirtyRectLengthsFile.Replace(iFs,_L("C:\\data\\others\\dirtyrectLengths.txt"),EFileWrite);
1286 iDirtyRectNum=0;
1287#endif
1288
1289// HostEngineGlobals
1290 iHostEngineGlobals = CHostEngineGlobals::CreateHostEngineGlobalsL();
1291
1292#ifdef SELF_IAD_UPDATE
1293 HandleIADCheck( aIADUpdateCompleteCallback, aConfig );
1294#endif
1295
1296 NPPDebug( LOG_ALL, IsBrowserPluginActive(), _L("Engine::ConstructL()--"));
1297
1298}
1299*/
1300
1301TBool CPlatformFlashEngine::IsHelixFlvMode()
1302{
1303 return iConfig.iHelixFlvMode;
1304}
1305//This function returns True is mp3stream in progress
1306TBool CPlatformFlashEngine::IsMp3Stream()
1307{
1308 if(iMP3StreamCount)
1309 return ETrue;
1310 else
1311 return EFalse;
1312}
1313//This function is used to change the mp3playstate of plugin and keep count of number of streams
1314//Mp3Streaming
1315void CPlatformFlashEngine::NewMP3StreamStarted()
1316{
1317 if (!iMP3StreamCount)
1318 {
1319 if(!iMp3PlayStateObserver)
1320 {
1321 if(iFlashClientIf)
1322 iMp3PlayStateObserver = iFlashClientIf->GetMp3StateObserver();
1323 }
1324 if (iMp3PlayStateObserver)
1325 {
1326
1327 TRAP_IGNORE(iMp3PlayStateObserver->MP3PlayStateChangedL(EFlashMP3StreamInProgress));
1328 if (iMp3Timer)//if timer is construsted cancel it
1329 {
1330 iMp3Timer->Cancel();
1331 }
1332 }
1333 }
1334 SetSwfHasAudio(ETrue);
1335 iMP3StreamCount ++;
1336}
1337//This function is used to change the mp3playstate of plugin and keep count of number of streams
1338//Mp3Streaming
1339void CPlatformFlashEngine::MP3StreamClosedL()
1340{
1341 iMP3StreamCount--;
1342 SetSwfHasAudio(EFalse);
1343 if (!iMP3StreamCount)
1344 {
1345 if (iMp3PlayStateObserver)
1346 {
1347 iMp3PlayStateObserver->MP3PlayStateChangedL(EFlashMP3StreamClosed);
1348 if (!iMp3Timer)
1349 {
1350 iMp3Timer = CFlhTimerObject::NewL(CActive::EPriorityStandard,
1351 *this);
1352 }
1353 else
1354 {
1355 if(iMp3Timer->IsActive())
1356 {
1357 iMp3Timer->Cancel();
1358 }
1359 }
1360 iMp3Timer->After(KMp3StreamTimer);
1361 }
1362 }
1363}
1364
1365void CPlatformFlashEngine::CreateFilenameEnsurePath(RFs& aFs, TDes& aFileLocation, TBool /*aTemp*/)
1366{
1367 aFileLocation.SetLength(0);
1368
1369 aFileLocation.Copy(KPersistentSubdirName);
1370 // now get the UID for the process we are running in so we can figure the data caged location
1371 TUid uid(User::Identity());
1372
1373 //uidName consists of Uid name of application. For Ex. [101fd693]
1374 TPtrC uidName(uid.Name().Mid(1,8));
1375
1376 aFileLocation.Append(uidName);
1377
1378 aFileLocation.Append(KPathDelimiter);
1379
1380 // if the tree is not present, make it
1381 if (!BaflUtils::FolderExists(aFs, aFileLocation))
1382 {
1383 aFs.MkDirAll(aFileLocation);
1384 }
1385}
1386
1387
1388HBufC* CreateBaseUrlFromFilenameL(const TDesC& aFilename)
1389{
1390 HBufC* tFile = aFilename.AllocLC();
1391
1392 TInt len = aFilename.Length();
1393 TUint16* s = (TUint16*)tFile->Ptr();
1394 // convert to lower case because there is no case insensitive Find().
1395 for (TInt i=0;i<len;i++)
1396 {
1397 if ((*s >= 'A') && (*s <= 'Z'))
1398 {
1399 *s = (TUint16)(*s - 'A' + 'a');
1400 }
1401 s++;
1402 }
1403
1404 HBufC* base = HBufC::NewL(len+KUrlProtocolFileLength);
1405 TPtr16 d = base->Des();
1406 d.Append(KLitUrlProtocolFile);
1407 d.Append(aFilename);
1408
1409 CleanupStack::PopAndDestroy(tFile);
1410
1411 return base;
1412}
1413
1414void CPlatformFlashEngine::Destroy()
1415{
1416 /*RC ou1cimx1#635995 -> Fix for panic due to memory leak.
1417 fmod() funcion from "estlib.dll " leaks memory for "NAN" and "INFINITY" parameters.
1418 CloseSTDLIB() safely releases all the meory references of estdlib and hence avoid memory leak */
1419
1420 CloseSTDLIB();
1421 delete this;
1422}
1423
1424CPlatformFlashEngine::~CPlatformFlashEngine()
1425{
1426#ifdef FEATURE_OPENVG
1427 CCoeEnv::Static()->RemoveForegroundObserver(*this);
1428#endif
1429
1430#ifdef DUMP_DIRTY_RECTS
1431 iDirtyRectLengthsFile.Close();
1432#endif
1433
1434#if defined(FEATURE_OPENVG) && defined(USE_VPU2)
1435 delete iCompositionControl;
1436 iCompositionControl = NULL;
1437#endif
1438
1439#ifdef FEATURE_INLINE_TEXT_ENTRY
1440 delete iTextNavigation;
1441 iTextNavigation = NULL;
1442#endif
1443
1444 delete iTimer;
1445 delete iLowestPriorityActiveObj;
1446 if(iMp3Timer)
1447 {
1448 if(iMp3Timer->IsActive())
1449 {
1450 iMp3Timer->Cancel();
1451 }
1452 delete iMp3Timer;
1453 }
1454 if(iIAPTimer)
1455 {
1456 iIAPTimer->Cancel();
1457 delete iIAPTimer;
1458 iIAPTimer = NULL;
1459 }
1460
1461 if(iBacklightExtensionTimer)
1462 {
1463 delete iBacklightExtensionTimer;
1464 iBacklightExtensionTimer = NULL;
1465 }
1466
1467 if(iFontMapTable)
1468 {
1469 delete iFontMapTable;
1470 iFontMapTable = NULL;
1471 }
1472
1473 FreeBits();
1474
1475 if (iTrustStore)
1476 {
1477 delete iTrustStore;
1478 iTrustStore = NULL;
1479 }
1480
1481 if(iBkLightHandler)
1482 {
1483 delete iBkLightHandler;
1484 iBkLightHandler = NULL;
1485 }
1486
1487 if (iVideoEngine)
1488 {
1489 iVideoEngine->DeleteAllVideoObjects();
1490 }
1491
1492 if(iSoundHandler)
1493 {
1494 iSoundHandler->StopSound();
1495 iSoundHandler->CleanupCachedFiles(iFs);
1496 }
1497
1498 if (iPlayerStaticHeap)
1499 {
1500 User::Free(iPlayerStaticHeap);
1501 }
1502
1503 for(int i=0; i<iSoftkeyArraySize; i++)
1504 {
1505 delete iSoftkeyArray[i];
1506 }
1507 delete iSoftkeyArray;
1508
1509#ifdef FEATURE_PACK_3
1510
1511 if(iPlatformInfo)
1512 {
1513 delete iPlatformInfo;
1514 iPlatformInfo = NULL;
1515 }
1516
1517 if(iRegistrationStatus)
1518 {
1519 delete iRegistrationStatus;
1520 iRegistrationStatus = NULL;
1521 }
1522
1523 if(iSubscriberInfo)
1524 {
1525 delete iSubscriberInfo;
1526 iSubscriberInfo = NULL;
1527 }
1528
1529 if(iNetworkInfo)
1530 {
1531 delete iNetworkInfo;
1532 iNetworkInfo = NULL;
1533 }
1534
1535 if(iPhoneInfo)
1536 {
1537 delete iPhoneInfo;
1538 iPhoneInfo = NULL;
1539 }
1540
1541 if(iBatteryInfo)
1542 {
1543 delete iBatteryInfo;
1544 iBatteryInfo = NULL;
1545 }
1546
1547 if(iSignalInfo)
1548 {
1549 delete iSignalInfo;
1550 iSignalInfo = NULL;
1551 }
1552
1553 if(iChargingInfo)
1554 {
1555 delete iChargingInfo;
1556 iChargingInfo = NULL;
1557 }
1558
1559#endif // FEATURE_PACK_3
1560
1561 if(iPhoneMonitor)
1562 {
1563 delete iPhoneMonitor;
1564 iPhoneMonitor = NULL;
1565 }
1566
1567 if(iSoundHandler)
1568 {
1569 delete iSoundHandler;
1570 iSoundHandler = NULL;
1571 }
1572
1573 if(iFileEngine)
1574 {
1575 delete iFileEngine;
1576 iFileEngine = NULL;
1577 }
1578
1579 if(iIPConnMgr)
1580 {
1581 delete iIPConnMgr;
1582 iIPConnMgr = NULL;
1583 }
1584 delete iHttpEngine;
1585 delete iLocalHttpEngine;
1586 delete iVideoEngine;
1587
1588#ifdef FEATURE_XML_SOCKET
1589 delete iSocketEngine;
1590#endif //FEATURE_XML_SOCKET
1591
1592 delete iImageConverter;
1593 delete iBaseURL;
1594 if(iHTMLBaseURL)
1595 {
1596 delete iHTMLBaseURL;
1597 iHTMLBaseURL = NULL;
1598 }
1599 if (iEngineSecurityContextUrl)
1600 {
1601 delete iEngineSecurityContextUrl;
1602 iEngineSecurityContextUrl = NULL;
1603 }
1604#ifdef LOG_MESSAGE
1605 if (iLogFile)
1606 {
1607 iLogFile->Flush();
1608 iLogFile->Close();
1609
1610 delete iLogFile;
1611 iLogFile = NULL;
1612 }
1613#endif
1614
1615 delete iCharacterConverter;
1616
1617 CQueuedSILaunch* siLaunch;
1618
1619 // flush the launch queue
1620 while(!(iLaunchQueue.IsEmpty()))
1621 {
1622 siLaunch=iLaunchQueue.First();
1623 iLaunchQueue.Remove(*siLaunch);
1624 delete siLaunch;
1625 }
1626 delete iLaunchQueueHandler;
1627#ifndef USE_SYNC_MSO
1628 delete iShObjEngine;
1629#else
1630 if(iSharedObjHandler)
1631 delete iSharedObjHandler;
1632#endif //USE_SYNC_MSO
1633
1634 delete iFileUtils; // must be deleted after iShObjEngine
1635
1636 delete iAsyncEventHandler;
1637
1638 //delete iDeviceName;
1639
1640 /*if(iPlatformName)
1641 {
1642 delete iPlatformName;
1643 iPlatformName = NULL;
1644 }*/
1645
1646
1647/* if (iResourceOffset)
1648 {
1649 iEnv->DeleteResourceFile(iResourceOffset);
1650 }
1651*/
1652 if(iAsyncIPDlgArray)
1653 {
1654 iAsyncIPDlgArray->Reset();
1655 delete iAsyncIPDlgArray;
1656 }
1657
1658 if(iItemValuePairArrays)
1659 {
1660 iItemValuePairArrays->ResetAndDestroy();
1661 delete iItemValuePairArrays;
1662 }
1663
1664 DestroyStreamBuffers();//Changed as Part of HIIN-857FWY
1665
1666 if(iFlashVarVal)
1667 {
1668 delete iFlashVarVal;
1669 }
1670
1671 if(iPlatformConfig)
1672 {
1673 delete iPlatformConfig;
1674 iPlatformConfig = NULL;
1675 }
1676#ifdef FEATURE_WEB_BROWSABILITY
1677
1678 delete iHostScriptHandler;
1679 iHostScriptHandler = NULL;
1680
1681 delete iName;
1682 iName= NULL;
1683
1684#endif //FEATURE_WEB_BROWSABILITY
1685
1686#ifdef FEATURE_ATS_AUTOMATION
1687 if(iATSHandler)
1688 {
1689 delete iATSHandler;
1690 iATSHandler = NULL;
1691 }
1692#endif
1693
1694 if( iFlvDecoderArray.Count() )
1695 {
1696 iFlvDecoderArray.ResetAndDestroy();
1697 }
1698
1699 iFlvDecoderArray.Close();
1700#ifdef FEATURE_AMCEXTENSIONS
1701 iExtensionCallback.Close();
1702#endif
1703
1704
1705 //Not used..
1706 /*
1707#ifdef SELF_IAD_UPDATE
1708 DestroyIADComponents();
1709#endif
1710*/
1711
1712 if(iSwfPath)
1713 {
1714 delete iSwfPath;
1715 iSwfPath = NULL;
1716 }
1717
1718#ifdef FEATURE_OPENVG
1719 FreeInputIndicatorBits();
1720
1721 DestroyEgl();
1722
1723 delete iRenderToggleTimer;
1724 iRenderToggleTimer = NULL;
1725#endif
1726
1727 /* delete iHostEngineGlobals; */
1728 //RC:ou1cimx1#513829 ,DestroyHostEngineGlobals has to be called after DestroyEgl() as this iHostEngineGlobals is used in DestroyEgl
1729
1730 iHostEngineGlobals->DestroyHostEngineGlobals();
1731
1732#ifdef FEATURE_WATCH_GPU_MEM
1733 delete iGPUMemWatch;
1734 iGPUMemWatch = NULL;
1735#endif
1736
1737 iRenderingWindow = NULL;
1738
1739 if(iSharedMemMgr)
1740 {
1741 delete iSharedMemMgr;
1742 iSharedMemMgr = NULL;
1743 }
1744
1745#ifdef FORCE_REFRESH_WORKAROUND
1746 if(iForceRedrawTimer)
1747 {
1748 delete iForceRedrawTimer;
1749 iForceRedrawTimer = NULL;
1750 }
1751#endif
1752
1753#ifdef FEATURE_COLLECT_BITMAP
1754 if(iLastRenderedBitmap)
1755 {
1756 delete iLastRenderedBitmap;
1757 iLastRenderedBitmap = NULL;
1758 }
1759#endif
1760}
1761
1762
1763// Get information about this device -- device UID, name and platform
1764/*void CPlatformFlashEngine::InitializePlatformInfoL()
1765{
1766
1767 TInt i;
1768
1769 // First, find our device UID.
1770 HAL::Get(HALData::EMachineUid, iMachineUid);
1771
1772 LoadResourceFileL();
1773 TResourceReader reader;
1774 iEnv->CreateResourceReaderLC( reader, R_FLASH_DEVICE_DATA );
1775
1776 // get the size of the array
1777 TInt number = reader.ReadInt16();
1778
1779 for (i=0;i<number;i++)
1780 {
1781 TInt uid = reader.ReadInt32();
1782 HBufC* platform = reader.ReadHBufCL();
1783 CleanupStack::PushL(platform);
1784 if (uid == iMachineUid)
1785 {
1786 iPlatformName = platform;
1787 CleanupStack::Pop(platform);
1788 }
1789 else
1790 {
1791 CleanupStack::PopAndDestroy(platform);
1792 }
1793 }
1794
1795 CleanupStack::PopAndDestroy(); // reader
1796
1797 if (!iPlatformName)
1798 {
1799 iPlatformName = iEnv->AllocReadResourceL(R_STR_DEFAULT_PLATFORM_NAME);
1800 }
1801
1802}*/
1803
1804void CPlatformFlashEngine::GetPlatformNameL(HBufC*& aPlatformName)
1805{
1806 TInt iMachineUid(0);
1807
1808 // First, find our device UID.
1809 HAL::Get(HALData::EMachineUid, iMachineUid);
1810
1811 int resoffset = FlashEngineRscHandler::LoadEngineResourceFileL();
1812 TResourceReader reader;
1813 iEnv->CreateResourceReaderLC( reader, R_FLASH_DEVICE_DATA );
1814
1815 // get the size of the array
1816 TInt number = reader.ReadInt16();
1817 TInt i;
1818 for (i=0;i<number;i++)
1819 {
1820 TInt uid = reader.ReadInt32();
1821 HBufC* platform = reader.ReadHBufCL();
1822 CleanupStack::PushL(platform);
1823 if (uid == iMachineUid)
1824 {
1825 aPlatformName = platform;
1826 CleanupStack::Pop(platform);
1827 }
1828 else
1829 {
1830 CleanupStack::PopAndDestroy(platform);
1831 }
1832 }
1833
1834 CleanupStack::PopAndDestroy(); // reader
1835
1836 if (!aPlatformName)
1837 {
1838 aPlatformName = iEnv->AllocReadResourceL(R_STR_DEFAULT_PLATFORM_NAME);
1839 }
1840
1841 FlashEngineRscHandler::DeleteEngineResourceFile(iEnv, resoffset);
1842}
1843
1844/*void CPlatformFlashEngine::LoadResourceFileL()
1845{
1846 TFileName dllName;
1847 TFileName rscfn;
1848 Dll::FileName(dllName);
1849 TBuf<2> drive = dllName.Left(2);
1850 rscfn.Copy(drive); // get the drive letter
1851 rscfn.Append(KFlash2EngineResourceFile);
1852
1853 BaflUtils::NearestLanguageFile(iFs, rscfn);
1854
1855 TBool fileExists( BaflUtils::FileExists(iFs, rscfn) );
1856 if ( fileExists )
1857 {
1858 iResourceOffset = iEnv->AddResourceFileL(rscfn);
1859 }
1860 else
1861 {
1862 User::Leave(KErrNotFound);
1863 }
1864
1865 if (iResourceOffset < 0)
1866 {
1867 User::Leave(iResourceOffset);
1868 }
1869
1870}*/
1871
1872
1873TInt16 CPlatformFlashEngine::GetDeviceName(TUint8* aCharBuffer, const TInt /*aMaxLen*/)
1874{
1875 //CPhoneInfo* phoneInfo = GetPhoneInfo();
1876 if(iPhoneInfo)
1877 {
1878 CreateFlashString((char*)aCharBuffer,iPhoneInfo->GetDeviceName());
1879
1880 return 1;
1881 }
1882
1883 return -1;
1884}
1885
1886TInt16 CPlatformFlashEngine::GetDeviceID(TUint8* aCharBuffer, const TInt /*aMaxLen*/)
1887{
1888 CPhoneInfo* phoneInfo = GetPhoneInfo();
1889
1890 if(phoneInfo)
1891 {
1892 CreateFlashString((char*)aCharBuffer,phoneInfo->GetDeviceID());
1893
1894 return 1;
1895 }
1896
1897 return -1;
1898}
1899
1900TUint CPlatformFlashEngine::GetBatteryLevelL()
1901{
1902 /*if(!iBatteryInfo)
1903 { //ok ,object not created , delayed creation will be done now
1904 if(!NoETelSuppport())
1905 { //let us create object now
1906 iBatteryInfo = CPhoneBatteryInfo::NewL();
1907 }
1908 }*/
1909
1910 CPhoneBatteryInfo* batteryInfo = GetBatteryInfoL();
1911
1912 if(batteryInfo)
1913 {
1914 return batteryInfo->GetBatteryChargeLevel();
1915 }
1916
1917 return 0;
1918}
1919
1920TUint CPlatformFlashEngine::GetCallerInfoL(FI_ReturnString* aName,FI_ReturnString* aNumber)
1921{
1922 CPhoneMonitor* phoneMonitor = GetPhoneMonitorL();
1923
1924 if(phoneMonitor)
1925 {
1926 TUint retValue = phoneMonitor->GetCallerInfoL(aName,aNumber);
1927 return retValue;
1928 }
1929 return 4;//Default Value Indicating No Call is in Progress
1930}
1931
1932TBool CPlatformFlashEngine::GetBatterychargeStatusL()
1933{
1934 /*if(!iChargingInfo)
1935 { //ok ,object not created , delayed creation will be done now
1936 if(!NoETelSuppport())
1937 { //let us create object now
1938 iChargingInfo = CPhoneChargingInfo::NewL();
1939 }
1940 }*/
1941
1942 CPhoneChargingInfo* chargingInfo = GetPhoneChargingInfoL();;
1943
1944 if(chargingInfo)
1945 {
1946 return chargingInfo->GetDeviceChargingInfo();
1947 }
1948
1949 return EFalse;
1950}
1951
1952
1953TInt CPlatformFlashEngine::GetSignalStrengthL()
1954{
1955 /*if(!iSignalInfo)
1956 { //ok ,object not created , delayed creation will be done now
1957 if(!NoETelSuppport())
1958 { //let us create object now
1959 iSignalInfo = CPhoneSignalInfo::NewL();
1960 }
1961 }*/
1962
1963 CPhoneSignalInfo* signalInfo = GetPhoneSignalInfoL();
1964 if(signalInfo)
1965 {
1966 return signalInfo->GetSignalBarValue();
1967 }
1968
1969 return 0;
1970}
1971
1972
1973TInt16 CPlatformFlashEngine::GetPlatformName(TUint8* aCharBuffer, const TInt aMaxLen)
1974{
1975 TPtr8 ptrBuffer(aCharBuffer, aMaxLen);
1976// if (iCharacterConverter->ConvertFromUnicode(ptrBuffer, *iPlatformName) < 0)
1977
1978 CPlatformInfo* platformInfo = GetPlatformInfo();
1979
1980 if (platformInfo)
1981 {
1982 TRAP_IGNORE(platformInfo->GetOSInfoL());//create plat info
1983 if (iCharacterConverter->ConvertFromUnicode(ptrBuffer,
1984 platformInfo->GetOSInfo()) < 0)
1985
1986 {
1987 return 0;
1988 }
1989 }
1990 ptrBuffer.ZeroTerminate();
1991 return 1;
1992}
1993
1994void CPlatformFlashEngine::SetForeground(TBool aForeground)
1995{
1996 if(aForeground)
1997 {
1998 iRedraw = ETrue;
1999 }
2000 iForeground = aForeground;
2001}
2002
2003#ifdef FEATURE_SUPPORT_ALR_SNAP
2004TBool CPlatformFlashEngine::ConnectionPromptNeeded()
2005{
2006 //if (/*iControl == NULL ||*/ iFlashUI != NULL) //show the prompt ONLY in viewer mode
2007 if(eStandAlone==iExecutionMode) //show the prompt ONLY in viewer mode
2008 {
2009 return ETrue;
2010 }
2011 else
2012 {
2013 return EFalse;
2014 }
2015}
2016#endif
2017
2018void CPlatformFlashEngine::InitializeL(const TRect& aRect, TBool aResize, TBool aLandscape)
2019{
2020 DEBUGPRINT("CPlatformFlashEngine::InitializeL: aRect(%d %d %d %d) aResize: %d", aRect.iTl.iX,
2021 aRect.iTl.iY, aRect.iBr.iX, aRect.iBr.iY, aResize);
2022#ifdef FEATURE_OPENVG
2023 /* In case of viewer we are always within the limits, hence checking is not required.
2024 * This is called from PlayerView ConstructL, hence RWindow can not be obtained in ChooseEglConfigL
2025 */
2026 if (eStandAlone != iExecutionMode)
2027 {
2028 /* Initializing EGL ahead to know the max supported EGL width & heigth */
2029 if (iOpenVgMode && !iEGLInitialized)
2030 {
2031 InitializeEglL();
2032 }
2033
2034 /* EGL does not support frame size more than 2048. Even in SW rendering mode
2035 * Graphics layer internally uses EGL for blitting bitmap. Currently we do not have
2036 * any mechanism to propagate error from Graphics/ALF module, hence checking for max
2037 * frame size & returning with KErrNoMemory. For this same reason this code is kept common
2038 */
2039 if (aRect.Width() > iEGLMaxSupportedWidth || aRect.Height() > iEGLMaxSupportedHeight)
2040 {
2041 DEBUGPRINT("CPlatformFlashEngine::InitializeL: aRect.Width: %d aRect.Height: %d returning KErrNoMemory",
2042 aRect.Width(),aRect.Height());
2043 User::Leave(KErrNoMemory);
2044 }
2045 }
2046#endif
2047
2048 if(iInDoPlay)
2049 {
2050 iFrameBufferResized = ETrue;
2051 iInitInfo.iRect = aRect;
2052 iInitInfo.iResize = aResize;
2053 iInitInfo.iLandscape = aLandscape;
2054 return;
2055 }
2056
2057 iLandscapeScreen = aLandscape;
2058 iIsInitialized = EFalse;
2059
2060 if (iPlayerStaticHeap == NULL)
2061 {
2062 iPlayerStaticHeap = (TAny*)User::AllocL(iPlayerStaticHeapSize);
2063 User::LeaveIfNull(iPlayerStaticHeap);
2064 }
2065
2066 iRect.xmin = 0;
2067 iRect.ymin = 0;
2068 iRect.xmax = aRect.Width();
2069 iRect.ymax = aRect.Height();
2070
2071 iFrameBufferSize = aRect.Size();
2072
2073 if (aResize && iWindowMode == EWindow)
2074 {
2075 TRAPD(errd,ResizeBitmapsL(iFrameBufferSize));
2076
2077 if(errd != KErrNone)
2078 {
2079 StopPlaying();
2080 User::Leave(errd);
2081 }
2082
2083#ifdef FEATURE_OPENVG
2084 if(iOpenVgMode)
2085 {
2086 TSize currentWindowSize = GetWindow()->Size();
2087 if(iCurrentWindowSize != currentWindowSize)
2088 {
2089 TRAPD(err, RecreateSurfaceL(GetWindow()));
2090 if(err != KErrNone)
2091 {
2092 SwitchToSoftwareRendering();
2093 }
2094 }
2095 }
2096#endif
2097
2098 iRedraw = ETrue;
2099
2100 if( !iFlvDecoderArray.Count() && !iVideoRect.iRect.IsEmpty() && iVideoEngine && iVideoRect.iVideoType == EDeviceVideo )
2101 {
2102 iVideoEngine->NotifySizeChangedL();
2103 }
2104 else if( iFlvDecoderArray.Count() )
2105 {
2106 // Resizing the display rect
2107 SetScreenMode();
2108 }
2109 }
2110 else
2111 {
2112 if (iWindowMode == EWindow)
2113 {
2114 RecreateBitmapsL(iFrameBufferSize);
2115 }
2116#ifdef FEATURE_WINDOWLESS
2117 else if(iWlessSurface)
2118 {
2119 if(iWlessGc)
2120 {
2121 delete iWlessGc;
2122 iWlessGc = NULL;
2123 }
2124
2125 if(iWlessDevice)
2126 {
2127 if (iDefaultFont && iDefaultFontBitmapDevice == iWlessDevice)
2128 {
2129 iWlessDevice->ReleaseFont( iDefaultFont );
2130 iDefaultFont = NULL;
2131 }
2132
2133 if(iFontMapTable)
2134 iFontMapTable->ReleaseAllFonts(iWlessDevice);
2135
2136 delete iWlessDevice;
2137 iWlessDevice = NULL;
2138 }
2139
2140 iWlessDevice = CFbsBitmapDevice::NewL(iWlessSurface);
2141 }
2142#endif
2143 }
2144
2145 if (iMMObject)
2146 {
2147 FI_Rect fiRect;
2148 fiRect.xmin = (short)iRect.xmin;
2149 fiRect.ymin = (short)iRect.ymin;
2150 fiRect.xmax = (short)iRect.xmax;
2151 fiRect.ymax = (short)iRect.ymax;
2152
2153 if(iFiObject.FI_SetFrameBuffer( NULL, (TUint16)iFrameBufferSize.iWidth, (TUint16)iFrameBufferSize.iHeight, FrameBufferPitch(), FrameBufferDisplayFormat()) == -1)
2154 {
2155 if (iFlashClientIf)
2156 {
2157 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
2158 if (userNotifierIf)
2159 userNotifierIf->NotifyClientError(EInvalidConfigError,
2160 ETrue, ETrue);
2161 }
2162 }
2163
2164 if(iFiObject.FI_SetDisplayRect(&fiRect) == -1)
2165 {
2166 if (iFlashClientIf)
2167 {
2168 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
2169 if (userNotifierIf)
2170 userNotifierIf->NotifyClientError(EInvalidConfigError,
2171 ETrue, ETrue);
2172 }
2173 }
2174
2175 iFiObject.FI_SetDirtyRect(&fiRect, 1); //dont care return value.
2176 }
2177
2178 iIsInitialized = ETrue;
2179
2180 StartTimer();
2181}
2182
2183/*void CPlatformFlashEngine::InitializeStandaloneL(const TRect& aRect, TBool aResize, TBool aLandscape)
2184{
2185 InitializeL(aRect, aResize, aLandscape);
2186 // do standalone player specific stuff here
2187}*/
2188//Not used
2189/*
2190 void CPlatformFlashEngine::AddMp3StateObserver(MMp3StateObserver* aObserver)
2191 {
2192 iMp3PlayStateObserver = aObserver;
2193 }
2194 */
2195/*
2196void CPlatformFlashEngine::InitializePluginL(MFlashPlugin* aControl,
2197 const TRect& aRect, TBool aResize, TBool aLandscape)
2198{
2199 iControl = aControl;
2200 iBrowserPluginActive = ETrue;
2201 iFrameBufferResized = EFalse;
2202
2203 if(!iInDoPlay)
2204 {
2205 InitializeL(aRect, aResize, aLandscape);
2206 }
2207 else
2208 {
2209 iFrameBufferResized = ETrue;
2210 iInitInfo.iRect = aRect;
2211 iInitInfo.iResize = aResize;
2212 iInitInfo.iLandscape = aLandscape;
2213 }
2214}*/
2215
2216
2217TBool CPlatformFlashEngine::FrameBufferBitsValid()
2218{
2219 if(iBitmap
2220#ifdef FEATURE_WINDOWLESS
2221 || iWlessSurface
2222#endif //FEATURE_WINDOWLESS
2223 )
2224 return ETrue;
2225 else
2226 return EFalse;
2227}
2228
2229void* CPlatformFlashEngine::LockFrameBufferBits()
2230{
2231 ASSERT(iRenderToBitmap);
2232
2233 if (FrameBufferBitsValid())
2234 {
2235 if ( !iIsBitmapLocked )
2236 {
2237 if(iWindowMode == EWindow)
2238 {
2239 iBitmap->BeginDataAccess();
2240 }
2241 else
2242 {
2243 #ifdef FEATURE_WINDOWLESS
2244 iWlessSurface->BeginDataAccess();
2245 #endif
2246 }
2247 iIsBitmapLocked = ETrue;
2248 }
2249
2250 if(iWindowMode == EWindow)
2251 {
2252 return iBitmap->DataAddress();
2253 }
2254 else
2255 {
2256 #ifdef FEATURE_WINDOWLESS
2257 return iWlessSurface->DataAddress();
2258 #endif
2259 }
2260 }
2261
2262 return NULL;
2263}
2264
2265void CPlatformFlashEngine::UnlockFrameBufferBits( TAny* /*aBitmap*/ )
2266{
2267 ASSERT(iRenderToBitmap);
2268
2269 if ( iIsBitmapLocked )
2270 {
2271 if(iWindowMode == EWindow)
2272 {
2273 iBitmap->EndDataAccess();
2274 }
2275 else
2276 {
2277 #ifdef FEATURE_WINDOWLESS
2278 iWlessSurface->EndDataAccess();
2279 #endif
2280 }
2281
2282 iIsBitmapLocked = EFalse;
2283 }
2284}
2285
2286void CPlatformFlashEngine::FreeFrameBufferBits()
2287{
2288 if(!iRenderToBitmap)
2289 return;
2290
2291 UnlockFrameBufferBits();
2292
2293 if ( iWindowGc )
2294 {
2295 iWindowGc->Deactivate();
2296 delete iWindowGc;
2297 iWindowGc = NULL;
2298 }
2299
2300 if ( iBitmapGc )
2301 {
2302 delete iBitmapGc;
2303 iBitmapGc = NULL;
2304 }
2305
2306 if ( iBitmapDevice )
2307 {
2308 if (iDefaultFont && iDefaultFontBitmapDevice == iBitmapDevice)
2309 {
2310 iBitmapDevice->ReleaseFont( iDefaultFont );
2311 iDefaultFont = NULL;
2312 }
2313
2314 if(iFontMapTable)
2315 iFontMapTable->ReleaseAllFonts(iBitmapDevice);
2316
2317 delete iBitmapDevice;
2318 iBitmapDevice = NULL;
2319 }
2320
2321 if ( iBitmap )
2322 {
2323 iBitmap->Reset();
2324 delete iBitmap;
2325 iBitmap = NULL;
2326 }
2327}
2328
2329
2330TBool CPlatformFlashEngine::CreateFrameBufferBitsL(TSize aSize)
2331{
2332 if(!iRenderToBitmap)
2333 return ETrue;
2334
2335 if (FrameBufferBitsValid())
2336 {
2337 return ETrue;
2338 }
2339
2340 FreeFrameBufferBits();
2341
2342 iBitmapSize.x = aSize.iWidth;
2343 iBitmapSize.y = aSize.iHeight;
2344
2345 iIsBitmapLocked = EFalse;
2346
2347 if ((iBitmap = new CWsBitmap(iEnv->WsSession())) == NULL ||
2348 (iBitmap->Create(TSize(iBitmapSize.x, iBitmapSize.y), iDisplayFormat) != KErrNone) ||
2349 (iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap)) == NULL)
2350 {
2351 // note: the bitmap will be deallocated automatically by the destructor
2352 FreeFrameBufferBits();
2353 return EFalse;
2354 }
2355
2356 return ETrue;
2357}
2358
2359void CPlatformFlashEngine::ClearBitmap()
2360{
2361 if(iWindowMode != EWindow)
2362 return;
2363
2364 CFbsBitGc* pGc = GetBitmapContext();
2365 if ( !pGc )
2366 {
2367 return;
2368 }
2369
2370 TRect rect( 0, 0, iBitmapSize.x, iBitmapSize.y );
2371 TRgb white( 0xFF, 0xFF, 0xFF );
2372 pGc->SetPenStyle( CFbsBitGc::ESolidPen );
2373 pGc->SetPenColor( white );
2374 pGc->SetBrushStyle( CFbsBitGc::ESolidBrush );
2375 pGc->SetBrushColor( white );
2376 pGc->DrawRect( rect );
2377}
2378
2379
2380void CPlatformFlashEngine::FreeBits()
2381{
2382 if(iWindowMode == EWindow)
2383 {
2384 FreeFrameBufferBits();
2385#ifdef FEATURE_OPENVG
2386 FreeAuxTextBits();
2387#endif
2388 }
2389#ifdef FEATURE_WINDOWLESS
2390 else
2391 {
2392 if(iWlessGc)
2393 {
2394 delete iWlessGc;
2395 iWlessGc = NULL;
2396 }
2397
2398 if(iWlessDevice)
2399 {
2400 if(iDefaultFont && iDefaultFontBitmapDevice == iWlessDevice)
2401 {
2402 iWlessDevice->ReleaseFont(iDefaultFont);
2403 iDefaultFont = NULL;
2404 }
2405
2406 delete iWlessDevice;
2407 iWlessDevice = NULL;
2408 }
2409
2410 iWlessSurface = NULL;
2411 }
2412#endif
2413}
2414
2415#ifdef FEATURE_OPENVG
2416TBool CPlatformFlashEngine::CreateAuxTextBitsL(TSize aSize)
2417{
2418 if(!iOpenVgMode)
2419 return EFalse;
2420
2421 ASSERT(iHwConfig.configFlags & FI_HardwareConfig_UseAuxTextBufferForHWRendering);
2422
2423 if (AuxTextBitsValid())
2424 {
2425 return ETrue;
2426 }
2427
2428 FreeAuxTextBits();
2429
2430 iAuxTextBitmapSize.x = aSize.iWidth;
2431 iAuxTextBitmapSize.y = aSize.iHeight;
2432
2433 if ((iAuxTextBitmap = new CFbsBitmap()) == NULL ||
2434 (iAuxTextBitmap->Create(TSize(iAuxTextBitmapSize.x, iAuxTextBitmapSize.y), EColor256 /*iDisplayMode*/) != KErrNone) ||
2435 (iAuxTextBitmapDevice = CFbsBitmapDevice::NewL(iAuxTextBitmap)) == NULL)
2436 {
2437 // note: the bitmap will be deallocated automatically by the destructor
2438 FreeAuxTextBits();
2439 return EFalse;
2440 }
2441
2442 NPPDebug(LOG_ERROR, EFalse, _L("CreateAuxTextBits %d"),iAuxTextBitmap->DisplayMode());
2443 return ETrue;
2444}
2445
2446void CPlatformFlashEngine::FreeAuxTextBits()
2447{
2448 if(!iOpenVgMode)
2449 return;
2450
2451 ASSERT(iHwConfig.configFlags & FI_HardwareConfig_UseAuxTextBufferForHWRendering);
2452
2453 UnlockAuxTextBits();
2454
2455 if (iAuxTextBitmapGc)
2456 {
2457 delete iAuxTextBitmapGc;
2458 iAuxTextBitmapGc = NULL;
2459 }
2460
2461 if (iAuxTextBitmapDevice)
2462 {
2463 if (iDefaultFont && iDefaultFontBitmapDevice == iAuxTextBitmapDevice)
2464 {
2465 iAuxTextBitmapDevice->ReleaseFont(iDefaultFont);
2466 iDefaultFont = NULL;
2467 }
2468
2469 if(iFontMapTable)
2470 iFontMapTable->ReleaseAllFonts(iAuxTextBitmapDevice);
2471
2472 delete iAuxTextBitmapDevice;
2473 iAuxTextBitmapDevice = NULL;
2474 }
2475
2476 if (iAuxTextBitmap)
2477 {
2478 iAuxTextBitmap->Reset();
2479 delete iAuxTextBitmap;
2480 iAuxTextBitmap = NULL;
2481 }
2482}
2483
2484TBool CPlatformFlashEngine::AuxTextBitsValid()
2485{
2486 return iAuxTextBitmap != NULL;
2487}
2488
2489void* CPlatformFlashEngine::LockAuxTextBits(unsigned int* width, unsigned int* height, unsigned int* pitch, unsigned int* depth)
2490{
2491 ASSERT(iHwConfig.configFlags & FI_HardwareConfig_UseAuxTextBufferForHWRendering);
2492
2493 if (AuxTextBitsValid())
2494 {
2495 if (!iIsAuxTextBitmapLocked)
2496 {
2497 iAuxTextBitmap->BeginDataAccess();
2498 iIsAuxTextBitmapLocked = ETrue;
2499 }
2500
2501 *width = iAuxTextBitmapSize.x;
2502 *height = iAuxTextBitmapSize.y;
2503 *pitch = iAuxTextBitmap->DataStride();
2504 *depth = TDisplayModeUtils::NumDisplayModeBitsPerPixel(iAuxTextBitmap->DisplayMode());
2505 return iAuxTextBitmap->DataAddress();
2506 }
2507
2508 return NULL;
2509}
2510
2511void CPlatformFlashEngine::UnlockAuxTextBits(TAny* /*aBitmap*/)
2512{
2513 ASSERT(iHwConfig.configFlags & FI_HardwareConfig_UseAuxTextBufferForHWRendering);
2514
2515 if (iIsAuxTextBitmapLocked)
2516 {
2517 iAuxTextBitmap->EndDataAccess();
2518 iIsAuxTextBitmapLocked = EFalse;
2519 }
2520}
2521#endif
2522
2523
2524void CPlatformFlashEngine::UpdateFrameInterval(TUint32 aNewFrameInterval)
2525{
2526 if (iFrameInterval != aNewFrameInterval)
2527 {
2528 iFrameInterval = aNewFrameInterval;
2529 if(iIsRunning)
2530 {
2531 StartTimer();
2532 }
2533 }
2534}
2535
2536void CPlatformFlashEngine::StartTimer()
2537{
2538 if (iPlayerState != EPlayerOK || !iTimer )
2539 {
2540 return;
2541 }
2542
2543 StopTimer();
2544
2545 CalculateInterval();
2546
2547 // Set the initial delay to 1, since we want the initial frame to play immediately
2548 if( !iTimer->IsActive() )
2549 {
2550 iTimer->After(1);
2551 }
2552}
2553
2554void CPlatformFlashEngine::CalculateInterval()
2555{
2556 if (! iSvgMode)
2557 {
2558 iDelay = iFrameInterval;
2559 if ( iDelay <= 0 )
2560 {
2561 iDelay = 1;
2562 }
2563 }
2564 else
2565 {
2566 iDelay = 10;
2567 }
2568
2569 // ** NB : StartTimer takes intervals in milliseconds. EPOC timers run on
2570 // microseconds. So multiply by 1000 before passing them in.
2571 iDelay*=KMicrosecondsInMillisecond;
2572}
2573
2574void CPlatformFlashEngine::StopTimer()
2575{
2576 iTimer->Cancel();
2577}
2578
2579#ifdef __FEATURE_OSK__
2580void CPlatformFlashEngine::SetCompatibilityMode(TBool aOnoROff)
2581{
2582 //enable or disable the compatibility mode onscreen keypad
2583 //iFlashUI->SetOSKIsActive(aOnoROff);
2584 iFlashClientIf->GetDisplay()->SetOSKIsActive(aOnoROff);
2585}
2586#endif // __FEATURE_OSK__
2587
2588void CPlatformFlashEngine::ChangeScreen(TInt aFormat)
2589{
2590 if (!iAllowFullscreen)
2591 {
2592 return;
2593 }
2594
2595 if ( aFormat == EChangeScreenFullScreen || aFormat == EChangeScreenAppScreen )
2596 {
2597 iChangeScreenSizeRequest = aFormat;
2598 }
2599
2600 TriggerAsyncEvent();
2601}
2602
2603void ResetSoftkeysAndScreenL( MDisplay* pScreenIf )
2604{
2605 if(pScreenIf)
2606 {
2607 pScreenIf->ResetSoftkeysL();
2608 pScreenIf->SetAppScreenL();
2609 }
2610}
2611
2612void CPlatformFlashEngine::HandleAsyncEventsL()
2613{
2614 //if(iFitVideoToScreen && !iBrowserPluginActive && (eStandAlone==iExecutionMode))
2615 if(iFitVideoToScreen)// && (eStandAlone==iExecutionMode)) //No need to check for !iBrowserPluginActive
2616 //to find out viewer mode
2617 {
2618 iFitVideoToScreen = EFalse;
2619 //iFlashUI->ZoomShowAll();
2620 iFlashClientIf->GetDisplay()->ZoomShowAll();
2621 }
2622
2623 if (iGetInputTextRequest)
2624 {
2625 if (iFlashClientIf)
2626 {
2627 MInputTxtIf* inputTxtIf = iFlashClientIf->GetInputTextIf();
2628 if (inputTxtIf)
2629 {
2630 inputTxtIf->GetInputTextL(*iGetInputTextRequest);
2631 }
2632 }
2633 /*
2634 if( iFlashUI )
2635 {
2636 iFlashUI->GetInputText(*iGetInputTextRequest);
2637 }
2638 else
2639 {
2640 iControl->GetInputTextL(*iGetInputTextRequest);
2641 }
2642 */
2643 delete iGetInputTextRequest->iInitialString;
2644 delete iGetInputTextRequest;
2645 iGetInputTextRequest = NULL;
2646 }
2647
2648 // changing the order.. it was at the bottom initially
2649 // IME Control
2650 // We have got an SI_EnableIME call. So lets enable IME
2651 if (iIMEControlState == EIMEEnable)
2652 {
2653 if(iFlashClientIf)
2654 {
2655 MInputTxtIf* inputTxtIf = iFlashClientIf->GetInputTextIf();
2656 if(inputTxtIf)
2657 inputTxtIf->EnableIMEL();
2658 }
2659
2660 iIMEControlState = EIMEEnabled; // we have enabled it
2661
2662 /*
2663 if (iFlashUI && !iBrowserPluginActive)
2664 {
2665 iFlashUI->EnableIMEL();
2666 iIMEControlState = EIMEEnabled; // we have enabled it
2667 }
2668 else if (iControl && iBrowserPluginActive)
2669 {
2670 iControl->EnableIMEL();
2671 iIMEControlState = EIMEEnabled; // we have enabled it
2672 }
2673 */
2674 }
2675
2676 if (iPauseFlags==ENotPaused && iSoundHandler)
2677 {
2678 iSoundHandler->DoSoundL();
2679 }
2680
2681 if(!iInDoPlay && ((iChangeScreenSizeRequest == EChangeScreenFullScreen)
2682 ||(iChangeScreenSizeRequest == EChangeScreenAppScreen)))
2683 {
2684 if(iFlashClientIf)
2685 {
2686 MDisplay* display = iFlashClientIf->GetDisplay();
2687 if(display)
2688 {
2689 if(iChangeScreenSizeRequest == EChangeScreenFullScreen)
2690 {
2691 display->SetScreenL(eFullScreen);
2692 }
2693 else
2694 {
2695 display->SetScreenL(eAppScreen);
2696 }
2697 iChangeScreenSizeRequest = EChangeScreenNull;
2698 }
2699 }
2700 }
2701 else
2702 {
2703 if(iChangeScreenSizeRequest != EChangeScreenNull)
2704 iRequestedScreenChange=ETrue;
2705 }
2706
2707 if((iChangeKeysRequest == EChangeScreenSetSoftkeys ) || (iChangeKeysRequest == EChangeScreenResetSoftkeys))
2708 {
2709 if(iFlashClientIf)
2710 {
2711 MDisplay* display = iFlashClientIf->GetDisplay();
2712 if(display)
2713 {
2714 if(iChangeKeysRequest == EChangeScreenSetSoftkeys )
2715 {
2716 display->SetSoftkeysL(iSoftkeyArray, iSoftkeyArraySize);
2717 }
2718 else
2719 {
2720 display->ResetSoftkeysL();
2721 }
2722 iChangeKeysRequest = EChangeScreenNull;
2723 }
2724 }
2725 }
2726
2727 if (iNewFile)
2728 {
2729 if ((iPauseFlags==ENotPaused) )
2730 {
2731 iAsyncEventHandler->SetLeaveIsCritical(ETrue);
2732 OpenFileAndStartMovieL(*iNewFile, ETrue, ETrue);
2733 iAsyncEventHandler->SetLeaveIsCritical(EFalse);
2734 delete iNewFile;
2735 iNewFile = NULL;
2736 }
2737 //return;
2738 }
2739
2740}
2741
2742void CPlatformFlashEngine::PlatformTimerTick()
2743{
2744 //Backlight handling moved to ExtendBacklightForVideoPlayback
2745
2746 if (iPauseFlags==ENotPaused && (iIsStopped == EFalse))
2747 {
2748 PlayStep(EFalse);
2749 }
2750
2751}
2752
2753
2754void CPlatformFlashEngine::DrawVideoRect()
2755{
2756 DrawDirtyRegion(iVideoRect.iRect);
2757}
2758
2759void CPlatformFlashEngine::Draw(const TRect& aDirtyRect, CWindowGc& aWGc)
2760{
2761 if(!iRenderToBitmap) {
2762 aWGc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
2763 aWGc.SetBrushColor(TRgb(0,0,0,0));
2764 aWGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
2765 aWGc.DrawRect(aDirtyRect);
2766 return;
2767 }
2768
2769 if (iPlayerState == EPlayerOK && iIsInitialized )
2770 {
2771#ifdef FEATURE_VIDEO_OVERLAY_RECTS
2772 CWsScreenDevice* screenDevice = iEnv->ScreenDevice();
2773
2774 if( screenDevice && (screenDevice->DisplayMode() == EColor16MA || screenDevice->DisplayMode() == EColor16MAP) )
2775 {
2776 aWGc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
2777 }
2778
2779 // NOTE : There is no overlay on top of Device video.
2780
2781 if( !iVideoRect.iRect.IsEmpty() && iVideoRect.iVideoType == EDeviceVideo )
2782 {
2783 BitBltExcludingVideoRect(aWGc, aDirtyRect);
2784 }
2785 else if( !iVideoRect.iRect.IsEmpty() && iVideoRect.iVideoType == ENativeVideo &&
2786 screenDevice && screenDevice->DisplayMode() == EColor16MU &&
2787 iFlvDecoderArray.Count() )
2788 {
2789 TBool playbackComplete = EFalse;
2790 for(TInt idx=0; idx<iFlvDecoderArray.Count(); idx++)
2791 {
2792 if(iFlvDecoderArray[idx]->IsComplete()) {
2793 playbackComplete = ETrue;
2794 }
2795 else {
2796 playbackComplete = EFalse;
2797 iContentOverVideo = EFalse;
2798 break;
2799 }
2800 }
2801
2802 if(!playbackComplete) {
2803 //Dont draw anything over video yet. Playback is not done yet.
2804 BitBltExcludingVideoRect(aWGc, aDirtyRect);
2805 }
2806 else {
2807 if(!iContentOverVideo && aDirtyRect.Intersects(iVideoRect.iRect)) {
2808 //There is some content on top of video. Since playback is done, we can now draw on top of video area
2809 iContentOverVideo = ETrue;
2810 }
2811
2812 if(iContentOverVideo) {
2813 aWGc.BitBlt(aDirtyRect.iTl, iBitmap, aDirtyRect);
2814 aWGc.BitBlt(iVideoRect.iRect.iTl, iBitmap, iVideoRect.iRect);
2815 }
2816 else {
2817 BitBltExcludingVideoRect(aWGc, aDirtyRect);
2818 }
2819 }
2820 }
2821 else
2822 {
2823 if(iWindowMode == EWindow)
2824 {
2825 aWGc.BitBlt(aDirtyRect.iTl, iBitmap, aDirtyRect);
2826 }
2827#ifdef FEATURE_WINDOWLESS
2828 else
2829 {
2830 GetBitmapContext();
2831 if(iWlessGc && iWlessSurface)
2832 this->iWlessGc->BitBlt(aDirtyRect.iTl, this->iWlessSurface, aDirtyRect);
2833 }
2834#endif //FEATURE_WINDOWLESS
2835
2836 #ifdef DUMP_DIRTY_RECTS
2837 iBitmapToBeDumped = iBitmap;
2838 DumpDirtyRects(aDirtyRect);
2839 #endif
2840 }
2841
2842 #ifdef SHOW_REDRAW_REGIONS
2843 ShowRedrawRegions(aDirtyRect,aWGc);
2844 #endif
2845
2846#else
2847 aWGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
2848 BitBltExcludingVideoRect(aWGc, aDirtyRect);
2849#endif // FEATURE_VIDEO_OVERLAY_RECTS
2850 }
2851 else
2852 {
2853 aWGc.Clear();
2854 }
2855}
2856
2857void CPlatformFlashEngine::RefreshScreen()
2858{
2859 iRedraw = ETrue;
2860 HandleRedraw();
2861}
2862
2863void CPlatformFlashEngine::DrawBitBuffer()
2864{
2865
2866#ifdef FEATURE_COLLECT_BITMAP
2867 /* Ignore DrawBitBuffer calls during scrolling, Playstep calls DrawBitBuffer if framerate is lagging than expected
2868 * But since SWF is paused during scrolling we can ignore these calls.
2869 * If this call is allowed it will add additional flickers in webpage with multiple flash contents (iltalehti.fi)
2870 * Reset this flag once scrolling Stops/ SWF play back resumes
2871 */
2872 if(iIgnoreDrawBitBuffer)
2873 {
2874 return;
2875 }
2876#endif
2877
2878#ifdef FEATURE_OPENVG
2879 if(iOpenVgMode)
2880 {
2881 vgFlush();
2882#ifdef DUMP_DIRTY_RECTS
2883 if(iSurfaceData && iSurfaceData->SizeInPixels() != iCurrentWindowSize )
2884 {
2885 delete iSurfaceData;
2886 iSurfaceData = NULL;
2887 }
2888 if(iSurfaceData == NULL)
2889 {
2890 iSurfaceData = new CFbsBitmap();
2891 iSurfaceData->Create(iCurrentWindowSize,iDisplayFormat);
2892 }
2893
2894 MDisplay* disp = GetDisplay();
2895 TRect rect = disp->GetWindow()->GetDrawRect();
2896 eglCopyBuffers(iEGLDisplay, (EGLSurface)iEGLSurface.surface, iSurfaceData);
2897 iBitmapToBeDumped = iSurfaceData;
2898 DumpDirtyRects(TRect(iCurrentWindowSize));
2899#endif
2900 if( eglSwapBuffers(iEGLDisplay, (EGLSurface)iEGLSurface.surface) == EGL_BAD_ALLOC)
2901 {
2902 SwitchToSoftwareRendering();
2903 }
2904 }
2905 else
2906#endif
2907 {
2908 if (iRedraw)
2909 {
2910 HandleRedraw();
2911 }
2912 else
2913 {
2914 /*//We have to either draw only sub-dirty rects, or their union. Not both.
2915 TInt numberOfDirtyRect = GetNumberOfSubDirtyRects();
2916
2917 for(TInt i=0; i < numberOfDirtyRect; ++i )
2918 {
2919 DrawDirtyRegion( GetSubDirtyRect(i) );
2920 }*/
2921
2922 DrawDirtyRegion( GetDirtyRect() );
2923
2924 // Draw the inline text indicator
2925 // TODO : Check whether this can be moved to Viewer and BP controls.
2926 // Ideally, this is not the right place to do this stuff.
2927
2928 #ifdef FEATURE_INLINE_TEXT_ENTRY
2929 if( !(iTIIndicatorDirtyRect.IsEmpty()) )
2930 {
2931 DrawDirtyRegion( iTIIndicatorDirtyRect );
2932 }
2933 #endif
2934 }
2935
2936#ifdef ENABLE_CURSOR
2937 //if( iBrowserPluginActive )
2938 if(iExecutionMode == ePlugin)
2939 {
2940 HandleCursorDraw();
2941 }
2942#endif
2943 }
2944}
2945
2946void CPlatformFlashEngine::HandleRedraw()
2947{
2948 if( !iRedraw )
2949 {
2950 return;
2951 }
2952
2953 TRect trect(0, 0, iFrameBufferSize.iWidth, iFrameBufferSize.iHeight);
2954
2955 if(iRenderToBitmap)
2956 {
2957 DrawDirtyRegion(trect);
2958 }
2959#ifdef FEATURE_OPENVG
2960 else if(iOpenVgMode)
2961 {
2962 FI_Rect dirtyRect;
2963 dirtyRect.xmin = 0;
2964 dirtyRect.ymin = 0;
2965 dirtyRect.xmax = iFrameBufferSize.iWidth;
2966 dirtyRect.ymax = iFrameBufferSize.iHeight;
2967
2968 iFiObject.FI_SetDirtyRect(&dirtyRect, 1); //dont care return value.
2969 }
2970#endif
2971
2972 UpdateVideoScreen();
2973
2974 iRedraw = EFalse;
2975}
2976
2977TRect CPlatformFlashEngine::GetSubDirtyRect(unsigned int index)
2978{
2979 FI_Rect dirtyRect;
2980 iFiObject.FI_GetSubDirtyRect(index,&dirtyRect);
2981
2982 TRect trect;
2983
2984 trect.iTl.iX = dirtyRect.xmin;
2985 trect.iTl.iY = dirtyRect.ymin;
2986 trect.iBr.iX = dirtyRect.xmax;
2987 trect.iBr.iY = dirtyRect.ymax;
2988
2989 return trect;
2990}
2991
2992unsigned short CPlatformFlashEngine::GetNumberOfSubDirtyRects()
2993{
2994 return iFiObject.FI_GetNumberOfSubDirtyRects();
2995}
2996
2997TRect CPlatformFlashEngine::GetDirtyRect()
2998{
2999 FI_Rect dirtyRect;
3000 iFiObject.FI_GetDirtyRect(&dirtyRect);
3001
3002 TRect trect;
3003
3004 trect.iTl.iX = dirtyRect.xmin;
3005 trect.iTl.iY = dirtyRect.ymin;
3006 trect.iBr.iX = dirtyRect.xmax;
3007 trect.iBr.iY = dirtyRect.ymax;
3008
3009 return trect;
3010}
3011
3012void CPlatformFlashEngine::DrawDirtyRegion(const TRect& aRect)
3013{
3014 if(iFlashClientIf)
3015 iFlashClientIf->DrawDirtyRect(aRect);
3016}
3017/*
3018 if( iControl && iBrowserPluginActive )
3019 {
3020 #ifdef FEATURE_BG_TRANSPARENCY
3021 HandleBGTBitBlt(aRect);
3022 #endif
3023
3024 iControl->DrawDirtyRect(aRect);
3025 }
3026 else if( iFlashUI )
3027 {
3028 iFlashUI->DrawDirtyRect(aRect);
3029 }
3030*/
3031//}
3032
3033void CPlatformFlashEngine::BitBltExcludingVideoRect(CWindowGc& aWGc, const TRect& aDirtyRect)
3034{
3035 ASSERT(iRenderToBitmap);
3036
3037 TRect videoRect = iVideoRect.iRect;
3038 if (videoRect.IsEmpty() || !videoRect.Intersects(aDirtyRect))
3039 {
3040 // if video rect and dirty rect do NOT intersect, just blit as usual
3041 aWGc.BitBlt(aDirtyRect.iTl, iBitmap, aDirtyRect);
3042 return;
3043 }
3044
3045 // if video rect and dirty rect intersect, divide dirty rect into sections that don't overlap
3046 // rectA covers the area above the video rect
3047
3048 if (aDirtyRect.iTl.iY < videoRect.iTl.iY)
3049 {
3050 TRect rectA;
3051 rectA.iTl.iX = aDirtyRect.iTl.iX;
3052 rectA.iTl.iY = aDirtyRect.iTl.iY;
3053 rectA.iBr.iX = aDirtyRect.iBr.iX;
3054 rectA.iBr.iY = videoRect.iTl.iY;
3055
3056 if (!rectA.IsEmpty())
3057 {
3058 aWGc.BitBlt(rectA.iTl, iBitmap, rectA);
3059 }
3060 }
3061
3062 // rectB covers the area to the left of the video rect
3063 if (aDirtyRect.iTl.iX < videoRect.iTl.iX)
3064 {
3065 TRect rectB;
3066 rectB.iTl.iX = aDirtyRect.iTl.iX;
3067 rectB.iTl.iY = videoRect.iTl.iY;
3068 rectB.iBr.iX = videoRect.iTl.iX;
3069 rectB.iBr.iY = videoRect.iBr.iY;
3070
3071 if (!rectB.IsEmpty())
3072 {
3073 aWGc.BitBlt(rectB.iTl, iBitmap, rectB);
3074 }
3075 }
3076
3077 // rectC covers the area to the right of the video rect
3078 if (aDirtyRect.iBr.iX > videoRect.iBr.iX)
3079 {
3080 TRect rectC;
3081 rectC.iTl.iX = videoRect.iBr.iX;
3082 rectC.iTl.iY = videoRect.iTl.iY;
3083 rectC.iBr.iX = aDirtyRect.iBr.iX;
3084 rectC.iBr.iY = videoRect.iBr.iY;
3085
3086 if (!rectC.IsEmpty())
3087 {
3088 aWGc.BitBlt(rectC.iTl, iBitmap, rectC);
3089 }
3090 }
3091
3092 // rectD covers the area below the video rect.
3093 if (aDirtyRect.iBr.iY > videoRect.iBr.iY)
3094 {
3095 TRect rectD;
3096 rectD.iTl.iX = aDirtyRect.iTl.iX;
3097 rectD.iTl.iY = videoRect.iBr.iY;
3098 rectD.iBr.iX = aDirtyRect.iBr.iX;
3099 rectD.iBr.iY = aDirtyRect.iBr.iY;
3100
3101 if (!rectD.IsEmpty())
3102 {
3103 aWGc.BitBlt(rectD.iTl, iBitmap, rectD);
3104 }
3105 }
3106}
3107
3108
3109#ifdef ENABLE_CURSOR
3110
3111MFlashCursor* CPlatformFlashEngine::Cursor()
3112{
3113 //if( !iControl )
3114 // return NULL;
3115
3116 //MFlashCursor* cursor = NULL;
3117
3118 //cursor = iControl->Cursor();
3119
3120 // return iCursor;
3121 if(iFlashClientIf)
3122 return iFlashClientIf->GetCursor();
3123
3124 return NULL;
3125}
3126
3127void CPlatformFlashEngine::DrawCursor()
3128{
3129 CWindowGc* pGc = GetWindowContext();
3130 if (!pGc)
3131 {
3132 return;
3133 }
3134
3135 MFlashCursor* cursor = Cursor();
3136
3137 if(!cursor)
3138 {
3139 return;
3140 }
3141
3142 TPoint startPoint = cursor->Position();
3143 TRect cursorRect = cursor->GetRect();
3144
3145 /* Disabling, since sprites are used for cursor.
3146
3147 DEBUGPRINT("CPlatformFlashEngine::DrawCursor");
3148
3149 if (iPlayerState == EPlayerOK && iIsInitialized)
3150 {
3151 DEBUGPRINT("drawing cursor %d %d %d %d",cursorRect.iTl.iX, cursorRect.iTl.iY, cursorRect.iBr.iX, cursorRect.iBr.iY);
3152 pGc->BitBlt(startPoint, iBitmap, cursorRect);
3153 }
3154 else
3155 {
3156 pGc->Clear();
3157 }
3158 */
3159}
3160
3161void CPlatformFlashEngine::ClearCursor(const TRect& aRect)
3162{
3163 // Set the dirty rect and force the render
3164
3165 struct FI_Rect dirtyRect;
3166
3167 dirtyRect.xmin = aRect.iTl.iX;
3168 dirtyRect.xmax = aRect.iBr.iX;
3169 dirtyRect.ymin = aRect.iTl.iY;
3170 dirtyRect.ymax = aRect.iBr.iY;
3171
3172 TInt ret = iFiObject.FI_SetDirtyRect(&dirtyRect, 1);
3173
3174 iRedraw = EFalse;
3175
3176 if (IsPaused())
3177 {
3178 FI_Rect fiRect;
3179 fiRect.xmin = iRect.xmin;
3180 fiRect.ymin = iRect.ymin;
3181 fiRect.xmax = iRect.xmax;
3182 fiRect.ymax = iRect.ymax;
3183
3184 iFiObject.FI_SetDisplayRect(&fiRect);
3185 }
3186
3187 PlayStep(ETrue);
3188}
3189
3190void CPlatformFlashEngine::HandleCursorDraw()
3191{
3192 MFlashCursor* cursor = Cursor();
3193 if(cursor)
3194 {
3195 TFlashCursorState curState = cursor->State();
3196
3197 if( curState == EFlashCursorDisplaying )
3198 {
3199 cursor->UpdateCursor();
3200 }
3201 }
3202}
3203#endif
3204
3205
3206//Not used
3207/*
3208void CPlatformFlashEngine::Exit()
3209{
3210 iMustExit = ETrue;
3211}*/
3212
3213void CPlatformFlashEngine::Stop()
3214{
3215 StopTimer();
3216 //Order of call was: Earlier FI_Pause() ->FI_Stop()
3217 // Now FI_Stop() ->FI_Pause()
3218 iFiObject.FI_Stop();
3219 iFiObject.FI_Pause();
3220
3221 iIsRunning = EFalse;
3222 iIsStopped = ETrue;
3223 iPauseFlags = EReasonUser;
3224
3225 if( iSoundHandler )
3226 {
3227 iSoundHandler->StopSound();
3228 iSoundHandler->CleanupCachedFiles(iFs);
3229 }
3230
3231 // Pause the audio- video if those objects are present
3232 THXVDCmdArg arg;
3233 EngineDispatchHXCommand(EHXVDCmdPause, arg);
3234}
3235
3236void CPlatformFlashEngine::EngineDispatchHXCommand(const THXVideoDecCommand& aCommand,THXVDCmdArg& aArgInfo)
3237{
3238 if( !iConfig.iHelixFlvMode )
3239 {
3240 return;
3241 }
3242
3243 CFLPlatformDecoderInterface* decoderInstance;
3244 TInt argOriginalVolume = aArgInfo.iVolume;
3245
3246 for(TInt n=0; n < iFlvDecoderArray.Count(); n++)
3247 {
3248 decoderInstance = iFlvDecoderArray[n];
3249
3250 if( !decoderInstance ) continue;
3251
3252 if( aCommand == EHXVDCmdSetVolume && aArgInfo.iVolume )
3253 {
3254 TInt max = decoderInstance->MaxVolume();
3255 TInt swfvol = decoderInstance->GetSwfVolume();
3256 TInt vol = (swfvol * max / KMaxVolumeFromFL)* aArgInfo.iVolume / KMaxUserVolume;
3257 aArgInfo.iVolume = vol;
3258 DEBUGPRINT("CPlatformFlashEngine::EngineDispatchHXCommand aArgInfo.iVolume[%d]",aArgInfo.iVolume );
3259 }
3260 if( (aCommand == EHXVDCmdPlay || aCommand == EHXVDCmdPause) && decoderInstance->IsComplete() )
3261 {
3262 return;
3263 }
3264
3265 decoderInstance->DispatchHXCommand(aCommand, aArgInfo);
3266 aArgInfo.iVolume = argOriginalVolume;
3267 }
3268}
3269
3270void CPlatformFlashEngine::PauseForNetworkPrompt()
3271{
3272 //if(iFlashUI)
3273 if(eStandAlone==iExecutionMode)
3274 {
3275 // this is valid only in the viewer mode
3276 if(iIAPTimer == NULL)
3277 {
3278 TRAPD(error,iIAPTimer = CFlhTimerObject::NewL(CActive::EPriorityStandard,*this));
3279 if(error)
3280 return;
3281 }
3282 if(iNetworkPromptPausedCount == 0)
3283 {
3284 // This is the first pause.. hence we notify the viewer
3285 Pause(EReasonNetworkPrompt);
3286 //iFlashUI->NotifyEngineState(EEnginePaused);
3287 iFlashClientIf->NotifyEngineState(EEnginePaused);
3288 }
3289
3290 if(iIAPTimer->IsActive())
3291 {
3292 // restart the timer
3293 iIAPTimer->Cancel();
3294 }
3295
3296 iIAPTimer->After(KNetworkPromptTimeOut);
3297 iNetworkPromptPausedCount++;
3298 }
3299}
3300
3301#ifdef FEATURE_AMCEXTENSIONS
3302void CPlatformFlashEngine::RegisterExtensionCallback(MAMCEXtensionCallback *aAMCClient)
3303{
3304 if (iExtensionCallback.Find(aAMCClient) == KErrNotFound)
3305 iExtensionCallback.Append(aAMCClient);
3306}
3307void CPlatformFlashEngine::DeregisterExtensionCallback(MAMCEXtensionCallback *aAMCClient)
3308{
3309 int pos = KErrNotFound;
3310 if ((pos = iExtensionCallback.Find(aAMCClient)) != KErrNotFound)
3311 iExtensionCallback.Remove(pos);
3312}
3313
3314void CPlatformFlashEngine::NotifyExt(TPlayerState2 aPlayerState)
3315{
3316 int index;
3317 for(index=0; index<iExtensionCallback.Count(); ++index){
3318 iExtensionCallback[index]->PlayerStateChanged(aPlayerState);
3319 }
3320}
3321
3322TBool CPlatformFlashEngine::AllowAMCExtension()
3323{
3324 return iFlashClientIf->AllowAMCExtension();
3325}
3326
3327#endif // FEATURE_AMCEXTENSIONS
3328
3329void CPlatformFlashEngine::Pause(TInt aReason)
3330{
3331 if (iPauseFlags==ENotPaused || iFiObject.FI_IsPlaying())
3332 {
3333 if (iMMObject)
3334 {
3335 iFiObject.FI_Pause();
3336 }
3337
3338 // notify MMI that the player is now paused. Reason why is not propagated to MMI plugins at this point
3339 // so only tell on a new pause happening, and on resume happening - not when the reason changes.
3340 NotifyExtsOfPauseStateChange(aReason);
3341#ifdef FEATURE_AMCEXTENSIONS
3342 NotifyExt(ePlayerPause);
3343#endif
3344
3345 // Pause the audio- video if those objects are present
3346 THXVDCmdArg arg;
3347 EngineDispatchHXCommand(EHXVDCmdPause, arg);
3348
3349 if( iSoundHandler )
3350 {
3351 iSoundHandler->PauseSound();
3352 }
3353
3354 StopTimer();
3355 }
3356
3357 if(!iFiObject.FI_IsPlaying())
3358 {
3359 StopTimer();
3360 }
3361
3362 iPauseFlags|=aReason;
3363}
3364
3365
3366void CPlatformFlashEngine::NotifyExtsOfPauseStateChange(TInt aReason)
3367{
3368 CArrayPtr<CFlashExtension>* exts=iFiObject.Extensions();
3369 if(exts)
3370 {
3371 const TInt count=exts->Count();
3372
3373 for(TInt i=0;i<count;i++)
3374 {
3375 (*exts)[i]->NotifyPauseState(aReason);
3376 }
3377 }
3378}
3379
3380void CPlatformFlashEngine::NotifyExtsOfIncomingCallStateChange(TBool aStatus)
3381{
3382 CArrayPtr<CFlashExtension>* exts=iFiObject.Extensions();
3383 if(exts)
3384 {
3385 const TInt count=exts->Count();
3386
3387 for(TInt i=0;i<count;i++)
3388 {
3389 (*exts)[i]->NotifyIncomingCall(aStatus);
3390 }
3391 }
3392}
3393
3394void CPlatformFlashEngine::ResumeOnNetworkPrompt()
3395{
3396 //if(iFlashUI && iNetworkPromptPausedCount > 0 && iIAPTimer)
3397 if((eStandAlone==iExecutionMode) && iNetworkPromptPausedCount > 0 && iIAPTimer)
3398 {
3399
3400 iNetworkPromptPausedCount--;
3401
3402 if(!iIAPTimer->IsActive()) // this means that we timed out. So, resume.
3403 iNetworkPromptPausedCount = 0;
3404
3405 if(iNetworkPromptPausedCount == 0 )
3406 {
3407 TRAPD(err, ResumeL(EReasonNetworkPrompt,EFalse));
3408 if(err != KErrNone ) // for some reason we could not resume
3409 return; // do not notify the UI
3410
3411 //iFlashUI->NotifyEngineState(EEngineResumed);
3412 iFlashClientIf->NotifyEngineState(EEngineResumed);
3413 if(iIAPTimer)
3414 {
3415 iIAPTimer->Cancel();
3416 }
3417 }
3418 }
3419}
3420
3421void CPlatformFlashEngine::ResumeL(TInt aReason, TBool aIgnoreActiveView)
3422{
3423
3424#ifdef FEATURE_COLLECT_BITMAP
3425 iIgnoreDrawBitBuffer = EFalse;
3426#endif
3427
3428 // because the user resume can unset all the flags, we may not always be paused when resume
3429 // is called. Check that first, and return if we are already playing.
3430 if(iPauseFlags==ENotPaused)
3431 {
3432 return;
3433 }
3434
3435 //if the user instructs resume, ignore any other flags
3436 if(aReason==EReasonUser || aReason==EReasonFocus)
3437 {
3438 iPauseFlags=ENotPaused;
3439 }
3440 else
3441 {
3442 // unset the appropriate flag
3443 iPauseFlags&=(~aReason);
3444 }
3445
3446 // player view must be active or we must be explicitly told to ignore that...
3447 //if(!iBrowserPluginActive)
3448 //{
3449 //if (iFlashUI && iPauseFlags==ENotPaused && (aIgnoreActiveView || iFlashUI->IsPlayerViewActive()) && !(iIsStopped))
3450 if ((eStandAlone==iExecutionMode) && iPauseFlags==ENotPaused && (aIgnoreActiveView ) && !(iIsStopped))
3451 {
3452 if (iMMObject)
3453 {
3454 iFiObject.FI_Resume();
3455 // notify MMI that the player is now paused. Reason why is not propagated to MMI plugins at this point
3456 // so only tell on a new pause happening, and on resume happening - not when the reason changes.
3457 NotifyExtsOfPauseStateChange(ENotPaused);
3458#ifdef FEATURE_AMCEXTENSIONS
3459 NotifyExt(ePlayerResume);
3460#endif
3461 }
3462
3463 if(iSoftkeyLocation&KPendingUpdateFlag)
3464 {
3465 iSoftkeyLocation=(short)(iSoftkeyLocation&(~KPendingUpdateFlag));
3466 NotifyCorePlayerOfSoftkeyLocationChangeL();
3467 }
3468
3469 if (iSoundHandler && iConfig.iHelixFlvMode )
3470 {
3471 iSoundHandler->ResumeSound();
3472 }
3473
3474 THXVDCmdArg arg;
3475 EngineDispatchHXCommand(EHXVDCmdResume, arg);
3476
3477 // make sure that timer is restarted if necessary.
3478 if (!iTimer->IsActive())
3479 {
3480 StartTimer();
3481 }
3482 }
3483 //}
3484 else
3485 {
3486 // commented aIgnoreActiveView condition for Flash methods stop and play function
3487 if (iPauseFlags==ENotPaused ) /* && (aIgnoreActiveView))*/
3488 {
3489 if (iMMObject)
3490 {
3491 iFiObject.FI_Resume();
3492
3493 //changes done for iSource [#12892]: Start
3494#ifdef FEATURE_AMCEXTENSIONS
3495 NotifyExt(ePlayerResume);
3496#endif
3497 //changes done for iSource [#12892]: End
3498 }
3499
3500 if (iSoundHandler)
3501 {
3502 iSoundHandler->ResumeSound();
3503 }
3504
3505 // Pause the audio- video if those objects are present
3506 THXVDCmdArg arg;
3507 EngineDispatchHXCommand(EHXVDCmdResume, arg);
3508
3509 // make sure that timer is restarted if necessary.
3510 if (!iTimer->IsActive())
3511 {
3512 StartTimer();
3513 }
3514 }
3515 }
3516
3517 // Run once to update the buffer
3518 if(aReason != EReasonPhone)
3519 {
3520 PlayStep(EFalse);
3521 }
3522}
3523
3524
3525TBool CPlatformFlashEngine::CanRewind()
3526{
3527 return (iFiObject.FI_NumberOfFrames() > 1);
3528}
3529
3530TInt CPlatformFlashEngine::GetCurrentFrameNumber()
3531{
3532 return iFiObject.FI_FrameNumber();
3533}
3534
3535TInt CPlatformFlashEngine::GetTotalFrameNumber()
3536{
3537 return iFiObject.FI_NumberOfFrames();
3538}
3539
3540void CPlatformFlashEngine::RewindL()
3541{
3542 // Force a refresh, because some platforms don't repaint
3543 // the screen after rewind.
3544 // rewind causes player to resume playback, so turn off the paused flag.
3545 if(!iIsStopped)
3546 {
3547 iFiObject.FI_Stop();
3548 }
3549
3550 iIsStopped = EFalse;
3551 iIsRunning = ETrue;
3552 iNotifyEndOfMovie = ETrue;
3553 if (iPauseFlags!=ENotPaused)
3554 {
3555 // user initiated
3556 ResumeL(EReasonUser, EFalse);
3557 }
3558
3559 RefreshScreen();
3560}
3561
3562void CPlatformFlashEngine::SetQuality(TInt aQuality)
3563{
3564 iFiObject.FI_SetQuality(static_cast<TInt16>(aQuality));
3565 iQuality = aQuality;
3566}
3567
3568TInt CPlatformFlashEngine::GetQuality()
3569{
3570 return iFiObject.FI_GetQuality();
3571}
3572
3573
3574// this overload is called by the view and is therefore a brand new user selected SWF
3575// it should capture the background bitmap and reset the IAP access flags
3576void CPlatformFlashEngine::OpenFileAndStartMovieL(const TDesC& aFilename, TBool aResetBaseURL, const TBool& aFirstMovie, CContent* aContent )
3577{
3578 OpenFileAndStartMovieL(aFilename,aResetBaseURL,ETrue,aFirstMovie, aContent);
3579}
3580
3581void CPlatformFlashEngine::OpenFileAndStartMovieL(const TDesC& aFilename,
3582 TBool aResetBaseURL,
3583 TBool aResetIAPAccess,
3584 const TBool& aFirstMovie,
3585 CContent* aContent )
3586
3587{
3588 RFile file;
3589
3590#ifdef FEATURE_ATS_AUTOMATION
3591
3592 RFile atsfile;
3593 iXMLFlag = EFalse;
3594
3595 if(iConfig.iMode & KPlayerInATSMode)
3596 {
3597 if(KErrNotFound != aFilename.Find(_L("ATSAutomation.swf")))
3598 {
3599 iXMLFlag = ETrue;
3600 }
3601 else if (KErrNotFound != aFilename.Find(_L("results.swf")))
3602 {
3603 iXMLFlag = true;
3604 atsfile.Create(iFs,_L("C:\\data\\others\\ats\\resultswf.txt"),EFileShareAny);
3605 atsfile.Close();
3606 }
3607 else
3608 {
3609 TFileName atsfileName;
3610 atsfileName = aFilename;
3611 TInt cchText = aFilename.Length();
3612
3613 for (TInt idx = 0; idx < cchText; ++idx)
3614 {
3615 if( KErrNotFound != atsfileName.Locate('/') )
3616 {
3617 atsfileName[idx] = '\\';
3618 }
3619 }
3620
3621 // Here we presume that the test XML file is in the same directory as the SWF.
3622 // If we don't find it, we don't open the ATS Test library
3623
3624 atsfileName.Delete((aFilename.Length() -3), 3);
3625 _LIT(XML, "xml");
3626 atsfileName.Append(XML);
3627
3628 if(BaflUtils::FileExists(CEikonEnv::Static()->FsSession(),atsfileName))
3629 iXMLFlag = ETrue;
3630 atsfile.Close();
3631 }
3632 }
3633#endif //FEATURE_ATS_AUTOMATION
3634 // Is engine ready?
3635 if (!iIsInitialized)
3636 {
3637 User::Leave(KErrNotReady);
3638 }
3639
3640 //Preparing File Handle from File name
3641 TInt err = file.Open(iFs, aFilename, EFileRead | EFileShareReadersOnly | EFileStream);
3642 CleanupClosePushL(file);
3643 if (err == KErrNone)
3644 {
3645 // Make sure not to reset baseURL if loading the openNet temp file.
3646 if (aResetBaseURL && (aFilename != iTempOpenNetFileName))
3647 {
3648 if (iBaseURL)
3649 {
3650 delete iBaseURL;
3651 iBaseURL=NULL;
3652 }
3653 iBaseURL = CreateBaseUrlFromFilenameL(aFilename);
3654 }
3655
3656 iFLVPlayStat = EFalse;//start playing fresh file make it false;
3657 OpenFileHandleAndStartMovieL(file, EFalse,aResetIAPAccess, aFirstMovie, aContent);
3658
3659 }
3660 CleanupStack::PopAndDestroy(&file);
3661}
3662
3663unsigned short CPlatformFlashEngine::SendtoBrowserPluginL( unsigned short streamId,
3664 const char* url,
3665 unsigned int aUrllen,
3666 const char* aPostDataContentType,
3667 unsigned int aPostDataContentLen,
3668 const unsigned char* postData,
3669 unsigned int aPostDataLen)
3670 {
3671 unsigned short result = 0;
3672 HBufC* hUrl = CreateEpocStringL(url, aUrllen);
3673 CleanupStack::PushL(hUrl);
3674 if (postData)
3675 {
3676 TInt lPdContentTypeStrlen = (aPostDataContentType ? strlen(aPostDataContentType) : 0);
3677
3678 HBufC* hContentType = CreateEpocStringL((const char*)aPostDataContentType, lPdContentTypeStrlen);
3679
3680 CleanupStack::PushL(hContentType);
3681 MPluginStreamIf* streamIf = iFlashClientIf->GetStreamIf();
3682
3683 TPtrC8 ptr;
3684 ptr.Set((TUint8*)postData,aPostDataLen);
3685
3686 HBufC* binaryPostdata = HBufC::NewLC(ptr.Length());
3687 binaryPostdata->Des().Copy(ptr);
3688
3689 TInt ret = hContentType->Find(KTermiChar);
3690
3691 if(ret != KErrNotFound)
3692 {
3693 //ignore \r\n and pass the rest of the string.Eg: RTMPT/S streams
3694 TPtrC ptrc( hContentType->Mid(0,ret));
3695 hContentType->Des().Copy(ptrc);
3696 }
3697 if(streamIf)
3698
3699 //Pass the binary postdata AS IT IS to browser without any unicode conversion.
3700 result = streamIf->OpenStreamL(streamId, *hUrl, *hContentType, aPostDataContentLen, *binaryPostdata);
3701
3702 CleanupStack::PopAndDestroy(binaryPostdata);
3703 CleanupStack::PopAndDestroy(hContentType);
3704
3705 }
3706 else
3707 {
3708 TPtrC nullDes;
3709 MPluginStreamIf* streamIf = iFlashClientIf->GetStreamIf();
3710 if(streamIf)
3711 result = streamIf->OpenStreamL(streamId, *hUrl, nullDes, 0, nullDes);
3712 }
3713 CleanupStack::PopAndDestroy(hUrl);
3714 return result;
3715}
3716
3717unsigned short CPlatformFlashEngine::CreateBrowserStreamL(unsigned short streamId,
3718 struct FI_URLStreamInfo* pStreamInfo)
3719{
3720 unsigned short result = 0;
3721
3722 TPtrC8 protocolSchema;
3723
3724 if( pStreamInfo->protocolSchema )
3725 {
3726 protocolSchema.Set( (TUint8*)pStreamInfo->protocolSchema );
3727 }
3728
3729 TInt protocolSize = protocolSchema.Length();
3730
3731 TPtrC8 host;
3732
3733 if( pStreamInfo->hostName )
3734 {
3735 host.Set( (TUint8*)pStreamInfo->hostName );
3736 }
3737
3738 TInt hostSize = host.Length();
3739
3740
3741 TPtrC8 documentPath;
3742 if( pStreamInfo->documentPath )
3743 {
3744 documentPath.Set((TUint8*)pStreamInfo->documentPath);
3745 }
3746
3747 TInt documentPathSize = documentPath.Length();
3748
3749 const TInt KLengthColonChar = 1;
3750 const TInt KLengthZeroTerminateChar = 1;
3751
3752 TInt sizeToBeAllocated = protocolSize + hostSize + documentPathSize + KPortNumLength + KLengthColonChar + KLengthZeroTerminateChar; // 1 for KColonChar
3753
3754 HBufC8* buf = HBufC8::NewLC(sizeToBeAllocated);
3755 TPtr8 url = buf->Des();
3756
3757 url.Copy(protocolSchema);
3758 url.Append(host);
3759
3760 if( pStreamInfo->port && pStreamInfo->port != KHttpDefaultPort )
3761 {
3762 url.Append(KColonChar);
3763 url.AppendNum(pStreamInfo->port);
3764 }
3765 url.Append(documentPath);
3766 url.ZeroTerminate();
3767
3768 result = SendtoBrowserPluginL(streamId,
3769 (const char*)url.Ptr(),
3770 url.Length(),
3771 pStreamInfo->additionalHeaders,
3772 pStreamInfo->contentLength,
3773 pStreamInfo->postData,
3774 pStreamInfo->contentLength);
3775
3776 CleanupStack::PopAndDestroy(buf);
3777
3778 return result;
3779}
3780
3781_LIT( KContentLength,"Content-Length" );
3782_LIT( KContentType,"Content-Type" );
3783const TInt KMaxTIntLength = 64;
3784//AddContentLengthToHeaderL
3785void CPlatformFlashEngine::AddToHeaderInfoL(FI_URLStreamHeaderInfo& aHeaderInfo, TInt aContentLength, TDesC8& aContentType)
3786 {
3787 if(aContentLength>=0)
3788 {
3789 aHeaderInfo.headerNames = new(ELeave) char*[2];
3790
3791 aHeaderInfo.headerValues = new(ELeave) char*[2];
3792
3793 aHeaderInfo.numHeaders = 2;
3794
3795 aHeaderInfo.headerNames[0] = CreateFlashString(KContentLength);
3796
3797 aHeaderInfo.headerValues[0] = new(ELeave) char[KMaxTIntLength];
3798
3799 TPtr8 ptrContentLength ((TUint8*)aHeaderInfo.headerValues[0], KMaxTIntLength);
3800
3801 ptrContentLength.AppendNum(aContentLength);
3802 ptrContentLength.ZeroTerminate();
3803
3804 aHeaderInfo.headerNames[1] = CreateFlashString(KContentType);
3805
3806 aHeaderInfo.headerValues[1] = new(ELeave) char[KMaxTIntLength];
3807
3808 TPtr8 ptrContentType ((TUint8*)aHeaderInfo.headerValues[1], KMaxTIntLength);
3809
3810 ptrContentType.Append(aContentType);
3811 ptrContentType.ZeroTerminate();
3812 }
3813 else
3814 {
3815 aHeaderInfo.headerNames = new(ELeave) char*[1];
3816
3817 aHeaderInfo.headerValues = new(ELeave) char*[1];
3818
3819 aHeaderInfo.numHeaders = 1;
3820
3821 aHeaderInfo.headerNames[0] = CreateFlashString(KContentType);
3822
3823 aHeaderInfo.headerValues[0] = new(ELeave) char[KMaxTIntLength];
3824
3825 TPtr8 ptrContentType ((TUint8*)aHeaderInfo.headerValues[0], KMaxTIntLength);
3826
3827 ptrContentType.Append(aContentType);
3828 ptrContentType.ZeroTerminate();
3829 }
3830 }
3831
3832
3833#ifdef FEATURE_FLV_MMC
3834void CPlatformFlashEngine::NewURLStreamL(const char* aFinalURL, TUint aStreamId, TInt aContentLength, TDesC8& aContentType)
3835 {
3836 //FI_URLStreamHeaderInfo headerInfo;
3837
3838 //AddContentLengthToHeaderL(headerInfo, aContentLength);
3839
3840 CBrowserURLRequestInfo* browserURLRequestInfo = CBrowserURLRequestInfo::NewLC(this, aStreamId
3841 , aFinalURL, aContentLength, aContentType);
3842
3843 iNetBufArray.Append(browserURLRequestInfo);
3844
3845 MPluginStreamIf* streamIf = iFlashClientIf->GetStreamIf();
3846 if(streamIf)
3847 streamIf->SetStreamBufferSizeL(aStreamId, browserURLRequestInfo->GetMaxSize());
3848 CleanupStack::Pop(browserURLRequestInfo);
3849 }
3850
3851#else //!FEATURE_FLV_MMC
3852void CPlatformFlashEngine::NewURLStreamL(const char* aFinalURL, TUint aStreamId, TInt aContentLength)
3853{
3854 FI_NetworkBufferInfo* retBuf;// field dataSize need to be filled by Host application, which data stream data size
3855 TInt16 errorCode;
3856 FI_URLStreamHeaderInfo headerInfo;
3857 AddContentLengthToHeaderL(headerInfo, aContentLength);
3858 retBuf = iFiObject.FI_URLStreamOpened(aStreamId, &headerInfo, &errorCode);
3859
3860 if (errorCode <= 0)
3861 {
3862 //Some error has occured.
3863 // Need to check whether here to call FI_CloseURLStreamClosed() or not??
3864 CloseStream(aStreamId, errorCode);
3865 }
3866 else if(retBuf == NULL)
3867 {
3868 //error has not occured, but return buffer is NULL
3869 //in this case need to wait for SI_LoadStreamBuffer function from MM Core Player,
3870 //which provides the address to store headers/data
3871 }
3872 else
3873 {
3874 //no error and have got valid buffer pointer to store
3875 retBuf->streamId = aStreamId;
3876 iNetBufArray.Append(retBuf);
3877
3878 iStreamIf->SetStreamBufferSizeL(aStreamId, retBuf->maxBufSize);
3879 }
3880 iFiObject.FI_URLStreamSetFinalURL( aStreamId, aFinalURL, FI_UseDefault);
3881}
3882#endif //FEATURE_FLV_MMC
3883#ifdef FEATURE_FLV_MMC
3884void CPlatformFlashEngine::SetNetworkBufferL(unsigned short aStreamId, struct FI_NetworkBufferInfo* aNetBuf)
3885 {
3886 int index = 0;
3887 //find the browserurlrequest object
3888 //corresponding to the streamID
3889 CBrowserURLRequestInfo* browserURLRequestInfo = NULL;
3890 for( ; index < iNetBufArray.Count(); index++ )
3891 {
3892 browserURLRequestInfo = iNetBufArray[index];
3893 if( browserURLRequestInfo && browserURLRequestInfo->GetStreamID() == aStreamId )
3894 {
3895 browserURLRequestInfo->SetNetworkBuffer(aNetBuf);
3896 break;
3897 }
3898 }
3899 }
3900
3901#else //!FEATURE_FLV_MMC
3902void CPlatformFlashEngine::SetNetworkBufferL(unsigned short aStreamId, struct FI_NetworkBufferInfo* aNetBuf)
3903 {
3904
3905 if( aNetBuf )
3906 {
3907 aNetBuf->streamId = aStreamId;
3908 }
3909
3910 int index = 0;
3911 for( ; index < iNetBufArray.Count(); index++ )
3912 {
3913 FI_NetworkBufferInfo* netBuf = iNetBufArray[index];
3914 if( netBuf && netBuf->streamId == aStreamId )
3915 {
3916 iNetBufArray.Remove(index);
3917 iNetBufArray.InsertL(aNetBuf, index);
3918 break;
3919 }
3920 }
3921
3922 if( index == iNetBufArray.Count() )
3923 {
3924 iNetBufArray.Append(aNetBuf);
3925 }
3926
3927 if( aNetBuf )
3928 {
3929 iStreamIf->SetStreamBufferSizeL(aStreamId, aNetBuf->maxBufSize);
3930 }
3931 }
3932#endif //FEATURE_FLV_MMC
3933
3934#ifdef FEATURE_FLV_MMC
3935void CPlatformFlashEngine::CancelURLStream(unsigned short aStreamId)
3936{
3937 //NPPDebug(LOG_INFO,iBrowserPluginActive,_L("CPlatformFlashEngine::CancelURLStream:%d ++"),aStreamId);
3938
3939 //if(!iBrowserPluginActive) //if non plug-in mode
3940 if(iExecutionMode == eStandAlone)
3941 {
3942 CFileEngine* fileEngine = GetFileEngine();
3943 CHttpEngine* httpEngine = GetHttpEngine();
3944 if( fileEngine && fileEngine->GetRequestObjectOrNull(aStreamId))
3945 {
3946 fileEngine->CancelRequestObject(aStreamId);
3947 }
3948 else if (httpEngine)
3949 {
3950 // Tell HttpEventHandler to stop current stream
3951 httpEngine->CancelHttpRequest(GetMMObject(), aStreamId);
3952 }
3953 }
3954 else
3955 {
3956 CBrowserURLRequestInfo* browserURLRequestInfo = NULL;
3957 TInt index=0;
3958// RemoveCompletedRequest(aStreamId);
3959// FireNextRequestL();
3960 MPluginStreamIf* streamIf = iFlashClientIf->GetStreamIf();
3961
3962
3963 for( ; index < iNetBufArray.Count(); index++ )
3964 {
3965 browserURLRequestInfo = iNetBufArray[index];
3966 if( browserURLRequestInfo && browserURLRequestInfo->GetStreamID() == aStreamId )
3967 {
3968 iNetBufArray.Remove(index);
3969 browserURLRequestInfo->DoCancelStream();
3970 if(streamIf)
3971 {//now tell the plug-in that stream needs to be cancelled
3972 // means dont send data to engine
3973 streamIf->CancelStream(aStreamId);
3974 }
3975 if(browserURLRequestInfo)
3976 {
3977 delete browserURLRequestInfo;
3978 browserURLRequestInfo = NULL;
3979 }
3980 break;
3981 }
3982 }
3983 }
3984
3985 //NPPDebug(LOG_DEBUG,iBrowserPluginActive,_L("CPlatformFlashEngine::CancelURLStream:--"));
3986
3987}
3988#else
3989void CPlatformFlashEngine::CancelURLStream(unsigned short aStreamId)
3990{
3991 if(!iBrowserPluginActive)
3992 {
3993 CFileEngine* fileEngine = GetFileEngine();
3994 CHttpEngine* httpEngine = GetHttpEngine();
3995
3996 if( fileEngine && fileEngine->GetRequestObjectOrNull(aStreamId))
3997 {
3998 fileEngine->CancelRequestObject(aStreamId);
3999 }
4000 else if (httpEngine)
4001 {
4002 // Tell HttpEventHandler to stop current stream
4003 httpEngine->CancelHttpRequest(GetMMObject(), aStreamId);
4004 }
4005 }
4006 else
4007 {
4008
4009 int index = 0;
4010 for( ; index < iNetBufArray.Count(); index++ )
4011 {
4012 FI_NetworkBufferInfo* netBuf = iNetBufArray[index];
4013 if( netBuf && netBuf->streamId == aStreamId )
4014 {
4015 iNetBufArray.Remove(index);
4016 //TODO:do we need to delete netBuf;
4017 break;
4018 }
4019 }
4020 }
4021
4022 NPPDebug(iBrowserPluginActive,_L("CPlatformFlashEngine::CancelURLStream: --"));
4023}
4024
4025#endif
4026_LIT8(KLitFile,"file://");
4027_LIT8(KLitLocalhostName, "localhost");
4028_LIT8(KLitLocalhostNumber, "127.0.0.1");
4029short CPlatformFlashEngine::OpenURLStreamL(unsigned short streamId
4030 ,struct FI_URLStreamInfo* pStreamInfo
4031 ,struct MM_Object* aMMObj)
4032{
4033 //NPPDebug(LOG_INFO,iBrowserPluginActive,_L("CPlatformFlashEngine::OpenURLStreamL:%d ++"),streamId);
4034 unsigned short result = SI_GenericError;
4035
4036
4037 if(IsBrowserPluginActive())
4038 {
4039 result = CreateBrowserStreamL(streamId, pStreamInfo);
4040
4041 }
4042 else
4043 {
4044 TPtrC8 wrapper;
4045
4046 if (pStreamInfo->protocolSchema)
4047 {
4048 wrapper.Set((TUint8*)pStreamInfo->protocolSchema);
4049 }
4050
4051 if ( 0==wrapper.Compare(KLitFile))
4052 {
4053 CFileEngine* fileEngine = GetFileEngine();
4054 if (fileEngine)
4055 {
4056 CFileEngineRequest* feReq=CFileEngineRequest::NewL(aMMObj, pStreamInfo, streamId);
4057 result = fileEngine->StartFileRequest(feReq);
4058
4059 }
4060 }
4061 else
4062 {
4063 TPtrC8 host;
4064
4065 if (pStreamInfo->hostName)
4066 {
4067 host.Set((TUint8*)pStreamInfo->hostName);
4068 }
4069
4070 CLocalHttpEngine* localHttpEngine = GetLocalHttpEngine();
4071 CHttpEngine* httpEngine = GetHttpEngine();
4072
4073 if ((localHttpEngine) && (( 0==host.Compare(KLitLocalhostName)) || (0==host.Compare(KLitLocalhostNumber))))
4074 {
4075 CUrlRequestInfo* info=CLocalUrlRequestInfo::NewL(GetMMObject(), aMMObj,pStreamInfo,streamId);
4076 result = localHttpEngine->StartLocalRequestL(info);
4077
4078 }
4079 else if (httpEngine)
4080 {
4081 CUrlRequestInfo* info=CUrlRequestInfo::NewL(GetMMObject(), aMMObj,pStreamInfo,streamId);
4082 result = httpEngine->StartHttpRequestL(info);
4083
4084 }
4085 }
4086 }
4087
4088 //NPPDebug(LOG_DEBUG,iBrowserPluginActive,_L("CPlatformFlashEngine::OpenURLStreamL: --"));
4089
4090 return result;
4091}
4092
4093void CPlatformFlashEngine::LoadURLStreamBufferL( unsigned short streamId
4094 , struct FI_NetworkBufferInfo* pNetBuf)
4095{
4096 // see if its a file object...
4097 if(IsBrowserPluginActive())
4098 {
4099 //need to use the struct given by this func argument, to wrtie the stream data for MM Core Player
4100 return SetNetworkBufferL(streamId, pNetBuf);
4101
4102 }
4103 else
4104 {
4105 CFileEngine* fileEngine = GetFileEngine();
4106
4107 CFileEngineRequest* info = (fileEngine )? fileEngine->GetRequestObjectOrNull(streamId) : NULL;
4108
4109 if (info)
4110 {
4111 info->SetNetBuf(pNetBuf);
4112 }
4113 else
4114 {
4115 CHttpEngine* httpEngine = GetHttpEngine();
4116
4117 CUrlRequestInfo* urlInfo=(CUrlRequestInfo*) (httpEngine ? httpEngine->GetRequestObject(GetMMObject(),streamId) : NULL);
4118
4119 if(urlInfo)
4120 {
4121 urlInfo->SetNetworkBuffer(pNetBuf);
4122 }
4123 }
4124 }
4125
4126}
4127
4128void CPlatformFlashEngine::StreamClosed(TUint16 aStreamId, TInt16 aClosedStatusCode)
4129{
4130 DEBUGPRINT("CPlatformFlashEngine::StreamClosed()++, aClosedStatusCode: %d", aClosedStatusCode);
4131 if( aClosedStatusCode == 0)
4132 {
4133 aClosedStatusCode = FI_ResultOK;
4134 }
4135 else
4136 {
4137 aClosedStatusCode = FI_ResultError;
4138 }
4139 //as broswer donesn't support http status ocde to be propogated to flash plugin, hence we are
4140 // sending "200" for success transaction and '0' for all other cases.
4141 iFiObject.FI_URLStreamClosed(aStreamId, aClosedStatusCode, 0);
4142}
4143
4144#ifdef FEATURE_FLV_MMC
4145
4146TInt CPlatformFlashEngine::WriteStreamDataL(unsigned long streamId, const char* data, unsigned long dataLength)
4147 {
4148 CBrowserURLRequestInfo* browserURLRequestInfo = NULL;
4149
4150 int index = 0;
4151 TBool status = EFalse;
4152
4153 //find the browserurlrequest object
4154 //corresponding to the streamID
4155
4156 for( ; index < iNetBufArray.Count(); index++ )
4157 {
4158 browserURLRequestInfo = iNetBufArray[index];
4159 if( browserURLRequestInfo && browserURLRequestInfo->GetStreamID() == streamId )
4160 {
4161 status = ETrue;
4162 break;
4163 }
4164 }
4165
4166 if( status )
4167 {
4168 TPtrC8 dataPtr ((const TUint8*)data, dataLength);
4169 browserURLRequestInfo->WriteStreamDataL( dataPtr, dataLength);
4170
4171 MPluginStreamIf* streamIf = iFlashClientIf->GetStreamIf();
4172 if(streamIf)
4173 streamIf->SetStreamBufferSizeL(streamId, browserURLRequestInfo->GetMaxSize());
4174 }
4175
4176
4177 // NOTE: If we perform one step of player (Playstep) as soon as data is written, then it is quite faster.
4178
4179 if( iTimer )
4180 {
4181 // StartTimer();
4182 }
4183
4184 return status;
4185 }
4186
4187#else //!FEATURE_FLV_MMC
4188
4189TInt CPlatformFlashEngine::WriteStreamDataL(unsigned long streamId, const char* data, unsigned long dataLength)
4190
4191 {
4192
4193 if (iMMObject)
4194
4195 {
4196
4197 FI_NetworkBufferInfo* netBuf = NULL;
4198
4199 int index = 0;
4200
4201 for( ; index < iNetBufArray.Count(); index++ )
4202
4203 {
4204
4205 netBuf = iNetBufArray[index];
4206
4207 if( netBuf && netBuf->streamId == streamId )
4208
4209 {
4210
4211 break;
4212
4213 }
4214
4215 }
4216
4217
4218 if( !netBuf || index == iNetBufArray.Count() || !data || !netBuf->pBuffer )
4219
4220 return EFalse;
4221
4222 unsigned char * buffer = netBuf->pBuffer;
4223
4224 const char* dataToWrite = data;
4225
4226 TInt bytesToWrite = dataLength;
4227
4228 while (bytesToWrite > 0)
4229
4230 {
4231
4232 if(!netBuf || !netBuf->pBuffer)
4233
4234 {
4235
4236 break;
4237
4238 }
4239
4240 netBuf->dataSize = (bytesToWrite > netBuf->maxBufSize) ? netBuf->maxBufSize : bytesToWrite;
4241
4242 FlashMemCpy(netBuf->pBuffer, dataToWrite, netBuf->dataSize);
4243
4244
4245 // need to advance the dataToWrite pointer;
4246
4247 if (bytesToWrite > netBuf->maxBufSize)
4248
4249 {
4250
4251 dataToWrite = dataToWrite + netBuf->maxBufSize;
4252
4253 bytesToWrite -= netBuf->maxBufSize;
4254
4255 }
4256
4257 else
4258
4259 {
4260
4261 dataToWrite = NULL;
4262
4263 bytesToWrite = 0;
4264
4265 }
4266
4267 netBuf = iFiObject.FI_URLStreamDataLoaded(netBuf->streamId, netBuf );
4268
4269
4270 }
4271
4272 if( netBuf )
4273
4274 {
4275
4276 iStreamIf->SetStreamBufferSizeL(streamId, netBuf->maxBufSize);
4277
4278 }
4279 return ETrue;
4280 }
4281
4282 return EFalse;
4283 }
4284#endif //FEATURE_FLV_MMC
4285#ifdef FEATURE_FLV_MMC
4286
4287void CPlatformFlashEngine::CloseStream(TUint16 aStreamId
4288 , TInt16 aClosedStatusCode
4289 , EMediaStreamType /*aMediaStreamType*/ )
4290 {
4291 if( aClosedStatusCode == HTTPStatus::EOk)
4292 {
4293 aClosedStatusCode = FI_ResultOK;
4294 }
4295 else
4296 {
4297 aClosedStatusCode = FI_ResultError;
4298 }
4299
4300
4301
4302 for(int index = 0; index < iNetBufArray.Count(); index++ )
4303 {
4304 CBrowserURLRequestInfo* browserURLRequestInfo = iNetBufArray[index];
4305 if( browserURLRequestInfo && browserURLRequestInfo->GetStreamID() == aStreamId )
4306 {
4307 //iFiObject.FI_URLStreamClosed(aStreamId, aClosedStatusCode,201);
4308 // iNetBufArray.Remove(index);
4309 //to do reset to be called
4310 // delete browserURLRequestInfo;
4311 browserURLRequestInfo->WriteComplete(FI_Result(aClosedStatusCode));
4312 break;
4313 }
4314 }
4315
4316// RemoveCompletedRequest(aStreamId);
4317// FireNextRequestL();
4318 }
4319
4320
4321
4322#else //!FEATURE_FLV_MMC
4323void CPlatformFlashEngine::CloseStream(TUint16 aStreamId
4324 , TInt16 aClosedStatusCode
4325 ,EMediaStreamType aMediaStreamType)
4326 {
4327 if( aClosedStatusCode == HTTPStatus::EOk)
4328 {
4329 aClosedStatusCode = FI_ResultOK;
4330 }
4331 else
4332 {
4333 aClosedStatusCode = FI_ResultError;
4334 }
4335
4336 iFiObject.FI_URLStreamClosed(aStreamId, aClosedStatusCode,200);
4337
4338
4339 for(int index = 0; index < iNetBufArray.Count(); index++ )
4340 {
4341 FI_NetworkBufferInfo* netBuf = iNetBufArray[index];
4342 if( netBuf && netBuf->streamId == aStreamId )
4343 {
4344 iNetBufArray.Remove(index);
4345 break;
4346 }
4347 }
4348
4349// RemoveCompletedRequest(aStreamId);
4350// FireNextRequestL();
4351 if(aMediaStreamType == EVideoStream)
4352 { //if flv stream is closed then we need to handle backlight here
4353 //extend max 20 secs
4354 // ExtendBacklight(20);
4355 }
4356
4357 }
4358#endif //FEATURE_FLV_MMC
4359
4360#ifdef FEATURE_FLV_MMC
4361
4362TBool CPlatformFlashEngine::SeekURLStreamFLV( unsigned short streamId,
4363 unsigned int seekTime,
4364 struct FI_NetworkBufferInfo* pNetBuf)
4365 {
4366 for(int index = 0; index < iNetBufArray.Count(); index++ )
4367 {
4368 CBrowserURLRequestInfo* browserURLRequestInfo = iNetBufArray[index];
4369 if( browserURLRequestInfo && browserURLRequestInfo->GetStreamID() == streamId )
4370 {
4371 return browserURLRequestInfo->Seek(seekTime, pNetBuf);
4372 }
4373 }
4374 return EFalse;
4375 }
4376
4377
4378unsigned int CPlatformFlashEngine::GetBytesLoaded(unsigned short streamId)
4379{
4380
4381 unsigned int byteval = 0;
4382 for(int index = 0; index < iNetBufArray.Count(); index++ )
4383 {
4384 CBrowserURLRequestInfo* browserURLRequestInfo = iNetBufArray[index];
4385 if( browserURLRequestInfo && browserURLRequestInfo->GetStreamID() == streamId )
4386 {
4387 byteval = browserURLRequestInfo->GetBytes();
4388 }
4389 }
4390 return byteval;
4391}
4392
4393unsigned int CPlatformFlashEngine::GetTotalBytes(unsigned short streamId)
4394{
4395
4396 unsigned int byteval = 0;
4397 for(int index = 0; index < iNetBufArray.Count(); index++ )
4398 {
4399 CBrowserURLRequestInfo* browserURLRequestInfo = iNetBufArray[index];
4400 if( browserURLRequestInfo && browserURLRequestInfo->GetStreamID() == streamId )
4401 {
4402 byteval = browserURLRequestInfo->GetTotalBytes();
4403 }
4404 }
4405 return byteval;
4406}
4407
4408#endif //FEATURE_FLV_MMC
4409
4410/*
4411Function compares Swfs Content's dimension with Screen size and
4412returns mode to be set by the viewer.
4413*/
4414TBool CPlatformFlashEngine::IsLandScapeMode()
4415{
4416 unsigned short swfHeight;
4417 unsigned short swfWidth;
4418 //check the dimension of file to be played
4419 iFiObject.FI_GetSWFDimensions(&swfHeight,&swfWidth);
4420 TSize aDeviceScreenSize = CCoeEnv::Static()->ScreenDevice()->SizeInPixels();
4421
4422 if(aDeviceScreenSize.iWidth < swfWidth)
4423 return ETrue; // Landscape mode
4424 else
4425 return EFalse; //Portrait Mode
4426
4427}
4428
4429
4430TRect CPlatformFlashEngine::GetViewRectangle()
4431 {
4432 TRect viewRect(0,0,0,0);
4433
4434 //TODO : Check this..
4435 /*
4436 if(iBrowserPluginActive && iControl)
4437 return (iControl->GetRect());
4438 */
4439 MDisplay* display = iFlashClientIf->GetDisplay();
4440 if(display)
4441 viewRect = display->ClientRect();
4442
4443 return viewRect;
4444 }
4445
4446
4447TInt CPlatformFlashEngine::ValidSwfContentVersion(const TUint8 *aSwfBuffer, TInt aBufferLength)
4448 {
4449 TInt result = 1;
4450 if(aBufferLength > 3)
4451 {
4452 TPtrC8 content(aSwfBuffer, aBufferLength);
4453 TBool couldbeSwf = EFalse;
4454
4455 if (content.Left(KSWFFileFirstFewBytes.iTypeLength).CompareF(KSWFFileFirstFewBytes) == 0)
4456 {
4457 couldbeSwf = ETrue;
4458 }
4459 else if (content.Left(KSWCFileFirstFewBytes.iTypeLength).CompareF(KSWCFileFirstFewBytes) == 0)
4460 {
4461 couldbeSwf = ETrue;
4462 }
4463
4464 if(couldbeSwf)
4465 {
4466 iSWFContentVersion = aSwfBuffer[3];
4467 if( iSWFContentVersion > PLAYER_MAJOR_VERSION || iSWFContentVersion == 0 )
4468 {
4469 result = 0;
4470 //if(iFlashUI)
4471 if(eStandAlone==iExecutionMode)
4472 {
4473 ErrorInfo errorInfo;
4474 errorInfo.iInfo = (TInt)iSWFContentVersion;
4475 ClearBitmap();
4476 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
4477 if(userNotifierIf)
4478 userNotifierIf->NotifyFlashError(EInvalidFileVersionError,ETrue,ETrue,&errorInfo);
4479 }
4480 //else if (iControl)
4481 else if(ePlugin==iExecutionMode)
4482 {
4483 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
4484 if(userNotifierIf)
4485 userNotifierIf->NotifyClientError(EInvalidFileVersionError, ETrue, ETrue);
4486 }
4487 }
4488 }
4489 }
4490 return result;
4491 }
4492
4493
4494void CPlatformFlashEngine::OpenFileHandleAndStartMovieL(RFile& aFile, TBool aResetBaseURL, TBool aResetIAPAccess,
4495 const TBool& aFirstMovie, CContent* aContent )
4496{
4497 if(!iIsStopped)
4498 {
4499 iZoomFactor = 0;
4500 }
4501 else
4502 {
4503 iReplayFlag = ETrue;
4504 }
4505
4506 if (!iIsInitialized)
4507 {
4508 User::Leave(KErrNotReady);
4509 }
4510
4511 iIsStopped = EFalse;
4512 TInt length = 0;
4513 HBufC8* swfbuf = 0;
4514 TPtr8 bufptr(NULL,0);
4515
4516 if (!iIsInitialized)
4517 {
4518 User::Leave(KErrNotReady);
4519 }
4520
4521 // Get file path from RFile
4522 TPath* filepath = new(ELeave) TPath;
4523 aFile.FullName(*filepath);
4524 CleanupStack::PushL(filepath);
4525
4526 // make sure not to reset baseURL if loading the openNet temp file.
4527 if (aResetBaseURL && (*filepath != iTempOpenNetFileName))
4528 {
4529 if (iBaseURL)
4530 {
4531 delete iBaseURL;
4532 iBaseURL = NULL;
4533 }
4534
4535 if( (eStandAlone==iExecutionMode) && (iFlashClientIf->IsUrlDescSet()) )
4536 {
4537 //iBaseURL = iFlashUI->GetUrlDesc().AllocL();
4538 iBaseURL = iFlashClientIf->GetUrlDesc().AllocL();
4539
4540 }
4541 else
4542 {
4543 iBaseURL = CreateBaseUrlFromFilenameL(*filepath);
4544 }
4545 }
4546
4547 if(iBaseURL)
4548 {
4549 delete iSwfPath;
4550 iSwfPath = NULL;
4551 iSwfPath = iBaseURL->AllocL();
4552 }
4553
4554 CContent* content = NULL;
4555 if( !aContent )
4556 {
4557 content = CContent::NewLC(aFile);
4558 }
4559 else
4560 {
4561 content = aContent;
4562 }
4563
4564 CData* data = content->OpenContentLC( ContentAccess::EExecute );
4565
4566 data->DataSizeL( length ) ;
4567
4568 data->ExecuteIntent(ContentAccess::EExecute);
4569
4570 //Initially read 8 bytes of header only, if SWF content version is Ok then only read
4571 //whole file.
4572 TInt swfHeaderLength = 8;
4573 HBufC8* swfHeaderBuf;
4574 swfHeaderBuf = HBufC8::NewLC(swfHeaderLength + 1);
4575 TPtr8 swfHeaderPtr(NULL,0);
4576
4577 swfHeaderPtr.Set(swfHeaderBuf->Des());
4578 data->Read(swfHeaderPtr,swfHeaderLength);
4579
4580 if (!ValidSwfContentVersion(swfHeaderPtr.PtrZ(),length ))
4581 {
4582 CleanupStack::PopAndDestroy(swfHeaderBuf);
4583 CleanupStack::PopAndDestroy(data);
4584 if( !aContent )
4585 {
4586 CleanupStack::PopAndDestroy(content);
4587 }
4588 CleanupStack::PopAndDestroy(filepath);
4589 return;
4590 }
4591
4592 swfHeaderLength *= -1;
4593 data->Seek(ESeekCurrent, swfHeaderLength);
4594 // Length + 1 because the buffer needs to be null terminated
4595 swfbuf = HBufC8::NewLC(length + 1);
4596 bufptr.Set(swfbuf->Des());
4597 data->Read(bufptr);
4598
4599 char* swfURL = NULL;
4600
4601 swfURL = CreateFlashStringL(iBaseURL->Des());
4602 char* s = swfURL;
4603
4604 while (*s)
4605 {
4606 if (*s == KCharBackslash)
4607 {
4608 *s = KCharForwardSlash;
4609 }
4610 s++;
4611 }
4612
4613 StartMovieL( swfURL, bufptr.PtrZ(), length,aResetIAPAccess,aFirstMovie);
4614 //if(!IsBrowserPluginActive())
4615 //iFlashUI->SetLandScapeModeL(IsLandScapeMode()); //Decide on the landascape/portait mode comparing screen dimensions and swf file dimensions
4616
4617 //CleanupStack::PopAndDestroy(swfURLBuf);
4618 CleanupStack::PopAndDestroy(swfbuf);
4619 CleanupStack::PopAndDestroy(swfHeaderBuf);
4620 CleanupStack::PopAndDestroy(data);
4621 if( !aContent )
4622 {
4623 CleanupStack::PopAndDestroy(content);
4624 }
4625 CleanupStack::PopAndDestroy(filepath);
4626
4627
4628}
4629
4630void CPlatformFlashEngine::OpenBrowserFileAndStartMovieL( const TDesC& aFilename,
4631 TBool aResetBaseURL,
4632 const TDesC* aBaseUrl,
4633 const TBool& aFirstMovie,
4634 CContent* aContent )
4635{
4636 // make sure not to reset baseURL if loading the openNet temp file.
4637 if (aResetBaseURL && (aFilename != iTempOpenNetFileName))
4638 {
4639 if (iBaseURL)
4640 {
4641 delete iBaseURL;
4642 iBaseURL=NULL;
4643 }
4644 if (aBaseUrl)
4645 {
4646 iBaseURL = aBaseUrl->AllocL();
4647 }
4648
4649 else
4650 {
4651 iBaseURL = CreateBaseUrlFromFilenameL(aFilename);
4652 }
4653 }
4654 OpenFileAndStartMovieL(aFilename,EFalse,ETrue, aFirstMovie, aContent);
4655}
4656
4657void CPlatformFlashEngine::SetBaseUrlL(const TDesC8* aBaseUrl)
4658{
4659 if(!aBaseUrl)
4660 {
4661 return;
4662 }
4663
4664 //Part of eroom761++:
4665 if(iHTMLBaseURL)
4666 {
4667 delete iHTMLBaseURL;
4668 iHTMLBaseURL = NULL;
4669 }
4670 iHTMLBaseURL = HBufC8::NewL(aBaseUrl->Length() + 2);
4671 TPtr8 urlPtr = iHTMLBaseURL->Des();
4672 urlPtr.Copy(*aBaseUrl);
4673 urlPtr.ZeroTerminate();
4674 //eroom761--
4675
4676
4677 //TPtr8 urlPtr = ((HBufC8*)aBaseUrl)->Des();
4678
4679 //const char* url = (const char *) urlPtr.Ptr();
4680
4681 //iFiObject.FI_SetBaseURL(url);
4682
4683 if( iBaseURL )
4684 {
4685 delete iBaseURL;
4686 iBaseURL = 0;
4687 }
4688}
4689void CPlatformFlashEngine::SetSecurityContextUrl(const TDesC8* iSecurityContextUrl)
4690{
4691
4692 if(!iSecurityContextUrl)
4693 {
4694 return;
4695 }
4696 if(iEngineSecurityContextUrl)
4697 {
4698 delete iEngineSecurityContextUrl;
4699 iEngineSecurityContextUrl = NULL;
4700 }
4701 iEngineSecurityContextUrl = HBufC8::NewL(iSecurityContextUrl->Length() + 2);
4702 TPtr8 urlPtr = iEngineSecurityContextUrl->Des();
4703 urlPtr.Copy(*iSecurityContextUrl);
4704 urlPtr.ZeroTerminate();
4705}
4706
4707
4708void CPlatformFlashEngine::ProcessParamBGcolor(const TDesC& aBGColor)
4709{
4710 iRed = KDefaultBackgroundRed;
4711 iGreen = KDefaultBackgroundGreen;
4712 iBlue = KDefaultBackgroundBlue;
4713 iTransparency = KDefaultBackgroundTransparency;
4714
4715 if(aBGColor.Length() == 0)
4716 return;
4717
4718 const TInt KColorCodeLength = 6;
4719
4720 if ( aBGColor.Locate(TChar('#')) == 0 && (aBGColor.Length() == (KColorCodeLength + 1)) ) //if we don't find # in the first position then ignore the color changes
4721 {
4722 iBackgroundColorPresent = ETrue;
4723 TPtrC16 lPtr(aBGColor);
4724
4725 const TInt KSingleColorLength = 2; //we have 2 Hex digits for every color
4726 const TInt KHashCharLength = 1; //lenght of '#' char
4727
4728 for (TInt i(0); i < KColorCodeLength ; i = i+ KSingleColorLength)
4729 {
4730 TUint lColorValue;
4731 TLex lParser(lPtr.Mid(i + KHashCharLength ,KSingleColorLength ));
4732 TInt error = lParser.Val(lColorValue, EHex);
4733
4734 if(error)
4735 return; //return if we get any error parsing color , it is better not to give backround color info
4736 //than processing wrong one.hence skipping other color value to be processed
4737 else{
4738 switch (i)
4739 {
4740 case 0:
4741 iRed = lColorValue;
4742 break;
4743 case 2:
4744 iGreen = lColorValue;
4745 break;
4746 case 4:
4747 iBlue = lColorValue;
4748 break;
4749
4750 }
4751 }
4752 }//for loop
4753 }
4754}
4755//Return the background clour if it is present else return white
4756TRgb CPlatformFlashEngine::GetBgcolour()
4757{
4758 if(iBackgroundColorPresent)
4759 {
4760 return TRgb(iRed,iGreen,iBlue);
4761 }
4762 else
4763 {
4764 return TRgb(KRgbWhite);
4765 }
4766}
4767
4768#ifdef FEATURE_BG_TRANSPARENCY
4769void CPlatformFlashEngine::ProcessParamWMode(const TDesC& awMode)
4770{
4771
4772 if (0 == awMode.CompareF(KWModeTransparent))
4773 {
4774 iConfig.iBackgroundAlpha = 0;
4775 iConfig.iPlayerBlendsBackground = ETrue;
4776 }
4777}
4778
4779short CPlatformFlashEngine::RedrawBackground(struct FI_Rect* aRects, unsigned short /*aNumRects*/)
4780{
4781 if( !aRects )
4782 return 0;
4783
4784 return 1;
4785}
4786
4787#endif //#ifdef FEATURE_BG_TRANSPARENCY
4788
4789void CPlatformFlashEngine::ProcessParamQuality(const TDesC& aQuality)
4790{
4791 if (0 == aQuality.CompareF(KLow))
4792 {
4793 iSwfQuality = KQualityLow;
4794 }
4795 else if (0 == aQuality.CompareF(KMedium))
4796 {
4797 iSwfQuality = KQualityMedium;
4798 }
4799 else if (0 == aQuality.CompareF(KHigh))
4800 {
4801 iSwfQuality = KQualityHigh;
4802 }
4803 else
4804 {
4805 iSwfQuality = KDefaultQuality;
4806 }
4807
4808}
4809
4810void CPlatformFlashEngine::ProcessParamLoop(const TDesC& aLoop)
4811{
4812 if ((0 == aLoop.CompareF(KOn))||
4813 (0 == aLoop.CompareF(KTrue)) ||
4814 (0 == aLoop.CompareF(KYes)) )
4815 {
4816 iLoop = KLoopOn;
4817 }
4818 else if ((0 == aLoop.CompareF(KOff))||
4819 (0 == aLoop.CompareF(KFalse)) ||
4820 (0 == aLoop.CompareF(KNo)))
4821 {
4822 iLoop = KLoopOff;
4823 }
4824
4825}
4826
4827void CPlatformFlashEngine::ProcessParamBaseURL(const TDesC& /*aBaseURL*/)
4828{
4829
4830}
4831
4832void CPlatformFlashEngine::ProcessParamFlashVars(const TDesC& aFlashVars)
4833{
4834 iFlashVarsPresent = ETrue;
4835
4836 if(iFlashVarVal)
4837 {
4838 delete iFlashVarVal;
4839 iFlashVarVal= NULL;
4840 }
4841
4842 TRAP_IGNORE(iFlashVarVal = EscapeUtils::ConvertFromUnicodeToUtf8L(aFlashVars));
4843
4844}
4845
4846
4847
4848
4849void CPlatformFlashEngine::ProcessParameters(CDesCArray* argnames, CDesCArray* argvalues)
4850{
4851
4852 iLoop = KDefaultLoop;
4853 iSwfQuality = KDefaultQuality;
4854 iBackgroundColorPresent = EFalse;
4855 iFlashVarsPresent = EFalse;
4856 iScaleValue = -1;
4857 iAlignValue = -1;
4858
4859 for ( int i = 0; i != argnames->Count ( ); i++ )
4860 {
4861
4862 TPtrC argname = (*argnames)[i];
4863 TPtrC argvalue = (*argvalues)[i];
4864 if (0 == argname.CompareF(KFlashVars) )
4865 {
4866 ProcessParamFlashVars(argvalue);
4867 }
4868 else
4869 if (0 == argname.CompareF(KLoop) )
4870 {
4871 ProcessParamLoop(argvalue);
4872 }
4873 else if ( 0 == argname.CompareF(KQuality) )
4874 {
4875 ProcessParamQuality(argvalue);
4876 }
4877 else if (0 == argname.CompareF(KAllowFullscreen)) // allowfullscreen
4878 {
4879 if (0 == argvalue.CompareF(KFalse))
4880 {
4881 iAllowFullscreen = EFalse;
4882 }
4883 else
4884 {
4885 iAllowFullscreen = ETrue;
4886 }
4887 }
4888 else if (0 == argname.CompareF(KAllowNetworking))
4889 {
4890 if (0 == argvalue.CompareF(KAllowNetInternal))
4891 {
4892 iAllowNetworking = kAllowNetworkingInternal;
4893 }
4894 else if (0 == argvalue.CompareF(KAllowNetAll))
4895 {
4896 iAllowNetworking = kAllowNetworkingAll;
4897 }
4898 else if (0 == argvalue.CompareF(KAllowNetNone))
4899 {
4900 iAllowNetworking = kAllowNetworkingNone;
4901 }
4902 else if (0 == argvalue.CompareF(KAllowNetMax))
4903 {
4904 iAllowNetworking = kAllowNetworkingMax;
4905 }
4906 }
4907 else if ( (0 == argname.CompareF(KBackgroundcolor))||(0==argname.CompareF(KBgcolor)) )
4908 {
4909 ProcessParamBGcolor(argvalue);
4910 }
4911
4912#ifdef FEATURE_BG_TRANSPARENCY
4913 _LIT(Kblendbg, "blendbg");
4914
4915 if(0 == argname.CompareF(KWMode))
4916 {
4917 ProcessParamWMode(argvalue) ;
4918 }
4919 else if(0 == argname.CompareF(Kblendbg))
4920 {
4921 iConfig.iBackgroundAlpha = GetIntFromDesc(argvalue);
4922 }
4923#endif // FEATURE_BG_TRANSPARENCY
4924
4925 else if( 0 == argname.CompareF(KFlashSwfSrc) ||0 == argname.CompareF(KFlashSwfMovie) )
4926 {
4927 iSwfSrcPath.Set(argvalue);
4928 }
4929#ifdef FEATURE_WEB_BROWSABILITY
4930 else if( (0 == argname.CompareF( KFlashName )) ||
4931 (0 == argname.CompareF( KFlashId )) )//or id
4932 {
4933 if( iName )
4934 {
4935 delete iName;
4936 iName = NULL;
4937 }
4938
4939 TRAP_IGNORE(iName = HBufC8::NewL( argvalue.Length() +1 ));
4940 TPtr8 namevar = iName->Des();
4941 namevar.Copy( argvalue );
4942 namevar.ZeroTerminate();
4943
4944 }
4945
4946 else if(0 == argname.Compare(KScale ))
4947 {
4948 if (0 == argvalue.CompareF(KShowAll))
4949 iScaleValue = EScaleShowAll;
4950 else if (0 == argvalue.CompareF(KNoBorder))
4951 iScaleValue = EScaleNoBorder;
4952 else if (0 == argvalue.CompareF(KExactFit))
4953 iScaleValue = EScaleExactFit;
4954 else if (0 == argvalue.CompareF(KNoScale))
4955 iScaleValue = ENoScale;
4956 }
4957 // Commented on 10 march.Align param is handled by the browser, which is the alignment of the swf in the html page.
4958 /*else if(0 == argname.Compare(KAlign ))
4959 {
4960 if (0 == argvalue.CompareF(KLeft))
4961 iAlignValue = EAlignLeft;
4962 else if (0 == argvalue.CompareF(KRight))
4963 iAlignValue = EAlignRight;
4964 else if (0 == argvalue.CompareF(KTop))
4965 iAlignValue = EAlignTop;
4966 else if (0 == argvalue.CompareF(KBottom))
4967 iAlignValue = EAlignBottom;
4968 }*/
4969 // SAlign is the alignment of the Flash object in the swf.
4970 else if(0 == argname.Compare(KSAlign ))
4971 {
4972 if ((0 == argvalue.CompareF(KTopLeft)) || (0 == argvalue.CompareF(KLeftTop)))
4973 iAlignValue = (EAlignTop | EAlignLeft);
4974 else if ((0 == argvalue.CompareF(KTopRight)) || (0 == argvalue.CompareF(KRightTop)))
4975 iAlignValue = (EAlignTop | EAlignRight);
4976 else if ((0 == argvalue.CompareF(KBottomLeft)) || (0 == argvalue.CompareF(KLeftBottom)))
4977 iAlignValue = (EAlignBottom | EAlignLeft);
4978 else if ((0 == argvalue.CompareF(KBottomRight)) || (0 == argvalue.CompareF(KRightBottom)))
4979 iAlignValue = (EAlignBottom | EAlignRight);
4980 else if ((0 == argvalue.CompareF(KSLeft)) || (0 == argvalue.CompareF(KLeft)))
4981 iAlignValue = EAlignLeft;
4982 else if ((0 == argvalue.CompareF(KSRight)) || (0 == argvalue.CompareF(KRight)))
4983 iAlignValue = EAlignRight;
4984 else if ((0 == argvalue.CompareF(KSTop)) || (0 == argvalue.CompareF(KTop)))
4985 iAlignValue = EAlignTop;
4986 else if ((0 == argvalue.CompareF(KSBottom)) || (0 == argvalue.CompareF(KSBottom)))
4987 iAlignValue = EAlignBottom;
4988 }
4989 else if(0 == argname.CompareF(KCanHandleException) && 0 == argvalue.CompareF(KTrue))
4990 {
4991 iPassOnException = ETrue;
4992 }
4993#endif //FEATURE_WEB_BROWSABILITY
4994 }
4995}
4996TInt CPlatformFlashEngine::GetIntFromDesc(const TDesC& aDesc)
4997{
4998 const TInt len = aDesc.Length();
4999 TInt ret=0;
5000 TInt j;
5001 TInt digit;
5002
5003 for(TInt i=0; i<len; i++)
5004 {
5005 digit=(aDesc[i]);
5006 digit-=KAsciiZero;
5007 for(j=0;j<(len-i-1);j++)
5008 {
5009 digit*=10;
5010 }
5011 ret+=digit;
5012 }
5013 return ret;
5014}
5015void CPlatformFlashEngine::RecreateBitmapL(const TRect& aRect)
5016{
5017 iIsInitialized = EFalse;
5018
5019 iRect.xmin = 0; //aRect.iTl.iX;
5020 iRect.ymin = 0; //aRect.iTl.iY;
5021 iRect.xmax = aRect.Width(); // .iBr.iX;
5022 iRect.ymax = aRect.Height(); //iBr.iY - aRect.iTl.iY;
5023
5024 iFrameBufferSize = aRect.Size();
5025
5026 if(iWindowMode == EWindow)
5027 {
5028 RecreateBitmapsL(iFrameBufferSize);
5029 }
5030
5031 if (iMMObject)
5032 {
5033 FI_Rect fiRect;
5034 fiRect.xmin = iRect.xmin;
5035 fiRect.ymin = iRect.ymin;
5036 fiRect.xmax = iRect.xmax;
5037 fiRect.ymax = iRect.ymax;
5038
5039
5040 // must do these two commands in appropriate order based on increasing
5041 // or decreasing display rect size, otherwise error checks fail.
5042 if(iFiObject.FI_SetFrameBuffer( NULL, (TUint16)iFrameBufferSize.iWidth, (TUint16)iFrameBufferSize.iHeight, FrameBufferPitch(), FrameBufferDisplayFormat()) == -1)
5043 {
5044 //invalid frame buffer
5045 /*
5046 if(iFlashUI)
5047 {
5048 iFlashUI->NotifyClientError(EInvalidConfigError, ETrue, ETrue);
5049 }
5050 */
5051 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
5052 if(userNotifierIf)
5053 userNotifierIf->NotifyClientError(EInvalidConfigError, ETrue, ETrue);
5054 }
5055
5056 if(iFiObject.FI_SetDisplayRect(&fiRect) == -1)
5057 {
5058 //invalid frame buffer
5059 /*
5060 if(iFlashUI)
5061 {
5062 iFlashUI->NotifyClientError(EInvalidConfigError, ETrue, ETrue);
5063 }
5064 */
5065 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
5066 if(userNotifierIf)
5067 userNotifierIf->NotifyClientError(EInvalidConfigError, ETrue, ETrue);
5068 }
5069 }
5070
5071 iIsInitialized = ETrue;
5072}
5073
5074
5075#ifndef USE_SYNC_MSO
5076void CPlatformFlashEngine::NotifyNumberOfItemsInQueue(TInt aNumItemsInQueue)
5077{
5078/*
5079 * In case of Shared Object, and when Browser wants to store COOKIES, need to add if(iBrowserPluginActive)
5080 */
5081 //if(!iBrowserPluginActive)
5082 if(eStandAlone==iExecutionMode)
5083 {
5084 iFlashClientIf->NotifyShutdownCountdown(aNumItemsInQueue);
5085 }
5086}
5087
5088#endif // USE_SYNC_MSO
5089
5090void CPlatformFlashEngine::DestroyPlayer()
5091{
5092 // iHttpEngine & iLocalHttpEngine & iFileEngine call HandleRequestFailed()
5093 // to notify the core player
5094 // that the outstanding requests (if any) have been cancelled.
5095 // Hence we need this before the core player is destroyed.
5096 // -> No FI Calls incase of RTMPT close
5097 iSwfInDestruction = ETrue;
5098 if(iHttpEngine)
5099 {
5100 iHttpEngine->PrepareToExit();
5101 iHttpEngine->CloseAllTransactions();
5102 }
5103
5104 if (iLocalHttpEngine) // used for local IP connection ("localhost" & 127.0.0.1)
5105 {
5106 iLocalHttpEngine->PrepareToExit();
5107 iLocalHttpEngine->CloseAllTransactions();
5108 }
5109
5110 if(iFileEngine)
5111 {
5112 iFileEngine->CancelAllRequests();
5113 }
5114
5115 /*****************************************************************************
5116 NOTE:December 08, 2007: This should never be called
5117 short* aErr = iFiObject.FI_GetInterruptVariable();
5118 if(aErr !=NULL)
5119 {
5120
5121 //when flash player is in play state and browser page is getting
5122 //closed then possible that player in some state which will
5123 //cause crash, so before calling destroyplayer
5124 //set interrupt variable
5125 //eroom note:
5126 //------------
5127
5128 //Player shutdown should be a controlled process. Basically,
5129 //FI_DestroyPlayer shouldn't be called while a thread is running inside DoPlay function of the player.
5130 //The host must wait for the DoPlay to finish,
5131 //control returns to the host, before calling FI_DestroyPlayer.
5132 //You can speedup DoPlay return, by calling FI_GetInterruptVariable,
5133 // (which returns a pointer to the interrupt variable) then set the value of the
5134 // variable to none zero. It is basically a watch dog variable.
5135 //Do you have DoPlay() running on a timer or a while loop?
5136 //Itis good to shutdown the timer, and breakout of the loop, That will
5137 //prevent the code from re-entering DoPlay() in the next round.
5138 //It should be safe to call FI_DestroyPlayer() after the above steps.
5139 //---------------------
5140
5141 *aErr= 3;
5142
5143 //iFiObject.FI_SetInterruptVariable(aErr);
5144 }
5145 *****************************************************************************/
5146
5147
5148 THXVDCmdArg arg;
5149 EngineDispatchHXCommand(EHXVDCmdStop, arg);
5150
5151 if( iMMObject )
5152 {
5153 iFiObject.FI_DestroyPlayer();
5154 iMMObject = NULL;
5155 // once we are out of FI_DestroyPlayer(), the player would have issued all the
5156 // RTMTP "/close" requests and the ACK would have been received.
5157 }
5158 //Fix for HIIN-857FWY:Remove Information of all Streams Associated with previous CorePlayer Instance
5159 //as the CorePlayer has been destroyed at this point.
5160 DestroyStreamBuffers();
5161
5162
5163 if (iHttpEngine) // used for remote IP connections
5164 {
5165 iHttpEngine->ResetEngine();
5166 }
5167
5168 if(iLocalHttpEngine)
5169 {
5170 iLocalHttpEngine->ResetEngine();
5171 }
5172
5173#ifdef FEATURE_XML_SOCKET
5174 if(iSocketEngine) //safe to access directly..
5175 {
5176 iSocketEngine->ResetEngine();
5177 }
5178#endif //FEATURE_XML_SOCKET
5179
5180 if(iImageConverter)
5181 {
5182 iImageConverter->Reset();
5183 }
5184
5185 // Notify the Shared Objects after the player is destroyed
5186 // in case FI_DestroyPlayer triggers another SharedObject request.
5187
5188#ifndef USE_SYNC_MSO
5189 if(iShObjEngine)
5190 {
5191 iShObjEngine->MovieClosed();
5192 }
5193#endif //USE_SYNC_MSO
5194
5195 CQueuedSILaunch* siLaunch;
5196
5197 // flush the launch queue
5198 while(!(iLaunchQueue.IsEmpty()))
5199 {
5200 siLaunch=iLaunchQueue.First();
5201 iLaunchQueue.Remove(*siLaunch);
5202 delete siLaunch;
5203 }
5204
5205 //unload ATS Library
5206#ifdef FEATURE_ATS_AUTOMATION
5207 if((iConfig.iMode & KPlayerInATSMode) && iXMLFlag)
5208 {
5209 if(iATSHandler)
5210 {
5211 iATSHandler->UnLoadATSLibrary();
5212 }
5213 }
5214#endif
5215
5216 //fix for phone freeze on options->exit in sms
5217 // UnlockBits(NULL);
5218
5219}
5220
5221void CPlatformFlashEngine::DestroyStreamBuffers()
5222 {
5223#ifdef FEATURE_FLV_MMC
5224 CBrowserURLRequestInfo* browserURLRequestInfo = NULL;
5225 for( TInt index =0 ; index < iNetBufArray.Count(); index++ )
5226 {
5227 browserURLRequestInfo = iNetBufArray[index];
5228 if( browserURLRequestInfo )
5229 {
5230 delete browserURLRequestInfo;
5231 browserURLRequestInfo = NULL;
5232 }
5233 }
5234
5235 iNetBufArray.Reset();
5236 iNetBufArray.Close();
5237#else
5238 iNetBufArray.Reset();
5239 iNetBufArray.Close();
5240#endif //FEATURE_FLV_MMC
5241 }
5242
5243#ifdef FF_FLASHLITE_SCREENSAVER
5244TInt CPlatformFlashEngine::CheckFileValidityL(const TDesC& aFilename)
5245{
5246 CData* data = NULL;
5247 HBufC8* swfbuf = 0;
5248 TPtr8 bufptr(NULL,0);
5249 TInt length(0);
5250 RFile fileHandle;
5251 TInt err = fileHandle.Open(iFs, aFilename, EFileRead | EFileShareReadersOrWriters);
5252
5253
5254 if(err == KErrNone)
5255 {
5256 CleanupClosePushL(fileHandle);
5257 CContent* content = CContent::NewLC(fileHandle);
5258 TRAP(err, data = content->OpenContentL( ContentAccess::EExecute ));
5259 if ( err == KErrNone )
5260 {
5261 CleanupStack::PushL( data );
5262 TRAPD( sizeError, data->DataSizeL( length ) );
5263 if ( sizeError != KErrNone )
5264 {
5265 CleanupStack::PopAndDestroy( data );
5266 CleanupStack::PopAndDestroy( content ); // content
5267 CleanupStack::PopAndDestroy( &fileHandle );
5268 return sizeError;
5269 }
5270 swfbuf = HBufC8::NewLC(length + 1);
5271 bufptr.Set(swfbuf->Des());
5272 data->Read(bufptr);
5273
5274 if (iPlayerStaticHeap == NULL)
5275 {
5276 iPlayerStaticHeap = (TAny*)User::AllocL(iConfig.iStaticHeapSize);
5277 User::LeaveIfNull(iPlayerStaticHeap);
5278 }
5279 TInt isValid;
5280 if(length > (iConfig.iStaticHeapSize + iPlayerDynamicHeapMaxSize))
5281 {
5282 err = KErrNoMemory;
5283 }
5284 if( err == KErrNone )
5285 {
5286 //This is a hack and will be removed when the prototype of FI_CheckSWFDataBufferValidity is changed by Adobe
5287 //to FI_CheckSWFDataBufferValidity (const unsigned char* swfBuffer, unsigned long bufferLength,void* memoryPool,unsigned long poolSize);
5288 unsigned short poolSize ;
5289 if(iPlayerStaticHeapSize > 0xffff)
5290 {
5291 poolSize = 0xffff;
5292 }
5293 else
5294 {
5295 poolSize = iPlayerStaticHeapSize;
5296 }
5297 isValid = iFiObject.FI_CheckSWFDataBufferValidity(bufptr.PtrZ(),length,
5298 iPlayerStaticHeap, /*iConfig.iStaticHeapSize*/poolSize);
5299 if(isValid == 1)
5300 {
5301 err = KErrNone;
5302 }
5303 else if( isValid == -1 )
5304 {
5305 err = KErrNoMemory;
5306 }
5307 else
5308 {
5309 err = KErrCorrupt;
5310 }
5311 }
5312 CleanupStack::PopAndDestroy( swfbuf);
5313 CleanupStack::PopAndDestroy( data );
5314 }
5315 CleanupStack::PopAndDestroy( content );
5316 CleanupStack::PopAndDestroy( &fileHandle );
5317 }
5318 return err;
5319}
5320#endif //FF_FLASHLITE_SCREENSAVER
5321
5322void CPlatformFlashEngine::CreateCharacterConverterL()
5323{
5324 if ( iCharacterConverter )
5325 {
5326 return;
5327 }
5328
5329 CCnvCharacterSetConverter* characterConverter = CCnvCharacterSetConverter::NewL();
5330 CleanupStack::PushL(characterConverter);
5331
5332 if ( characterConverter->PrepareToConvertToOrFromL( KCharacterSetIdentifierCodePage1252, iFs )
5333 != CCnvCharacterSetConverter::EAvailable )
5334 {
5335 User::Leave ( KErrNotSupported );
5336 }
5337 CleanupStack::Pop(characterConverter);
5338 iCharacterConverter = characterConverter;
5339 iCurrentCodePage = KCharacterSetIdentifierCodePage1252;
5340}
5341
5342void CPlatformFlashEngine::ChangeCodePageL(TUint aCodePage)
5343{
5344 if (iCharacterConverter && (iCurrentCodePage != aCodePage))
5345 {
5346 iCharacterConverter->PrepareToConvertToOrFromL(aCodePage, iFs);
5347 iCurrentCodePage = aCodePage;
5348 }
5349}
5350
5351HBufC* CPlatformFlashEngine::CreateEpocStringLC( const char* aStr, int aLength )
5352{
5353 HBufC* pBuf= CreateEpocStringL(aStr,aLength);
5354
5355 CleanupStack::PushL(pBuf);
5356
5357 return pBuf;
5358}
5359
5360HBufC* CPlatformFlashEngine::CreateEpocStringL( const char* aStr, int aLength )
5361{
5362 HBufC* pBuf=CreateEpocString(aStr, aLength);
5363
5364 User::LeaveIfNull(pBuf);
5365
5366 return pBuf;
5367}
5368
5369HBufC* CPlatformFlashEngine::CreateEpocString( const char* aStr, int aLength )
5370{
5371 HBufC* pResult=NULL;
5372
5373 if( iCharacterConverter )
5374 {
5375
5376 TPtrC8 ptr( (TUint8*)aStr, aLength );
5377
5378 pResult = HBufC::New( aLength );
5379
5380 if(pResult)
5381 {
5382
5383 TPtr ptrResult( pResult->Des() );
5384
5385 TInt state = CCnvCharacterSetConverter::KStateDefault;
5386 TInt err=iCharacterConverter->ConvertToUnicode( ptrResult, ptr, state );
5387 if(err)
5388 {
5389 delete pResult;
5390 pResult=NULL;
5391 }
5392 }
5393 }
5394
5395 return pResult;
5396}
5397
5398void CPlatformFlashEngine::CreateFlashStringL( char* buf,const TDesC& aStr )
5399{
5400 User::LeaveIfNull( iCharacterConverter );
5401 TInt maxlen = aStr.Length() << 1;
5402
5403 TPtr8 ptrResult( (TUint8*)buf, maxlen );
5404
5405 User::LeaveIfError( iCharacterConverter->ConvertFromUnicode ( ptrResult, aStr ) );
5406
5407 //pResult[buf.Length()] = 0;
5408
5409 buf[aStr.Length()] = 0;
5410
5411 return ;
5412
5413}
5414
5415void CPlatformFlashEngine::CreateFlashString(char* buf, const TDesC& aStr )
5416{
5417 TRAP_IGNORE(CreateFlashStringL(buf,aStr ) );
5418
5419}
5420
5421char* CPlatformFlashEngine::CreateFlashStringLC( const TDesC& aStr )
5422{
5423 User::LeaveIfNull( iCharacterConverter );
5424
5425 TInt maxlen = aStr.Length() << 1;
5426 char* pResult = new(ELeave) char[maxlen + 1];
5427 CleanupStack::PushL ( pResult );
5428
5429 TPtr8 ptrResult( (TUint8*)pResult, maxlen );
5430
5431 User::LeaveIfError( iCharacterConverter->ConvertFromUnicode ( ptrResult, aStr ) );
5432
5433 pResult[ptrResult.Length()] = 0;
5434
5435 return pResult;
5436}
5437
5438
5439char* CPlatformFlashEngine::CreateFlashStringL( const TDesC& aStr )
5440{
5441 char* pResult = CreateFlashStringLC(aStr);
5442
5443 CleanupStack::Pop(pResult);
5444
5445 return pResult;
5446}
5447
5448char* CPlatformFlashEngine::CreateFlashString( const TDesC& aStr )
5449{
5450 char* pResult = NULL;
5451 TRAP_IGNORE( pResult = CreateFlashStringL( aStr ) );
5452 return pResult;
5453}
5454
5455void CPlatformFlashEngine::GetLanguageInfo(TInt &aSymbianCodepage, FI_CodePage &aFlashCodepage)
5456{
5457 aSymbianCodepage = KCharacterSetIdentifierCodePage1252;
5458 aFlashCodepage = FI_Latin1_CodePage;
5459
5460#ifdef QA_OVERRIDE_PHONE_LANGUAGE
5461 TLanguage lang = ELangRussian;
5462 //TLanguage lang = ELangEstonian;
5463 //TLanguage lang = ELangGreek;
5464 //TLanguage lang = ELangTurkish;
5465#else
5466 TLanguage lang = User::Language();
5467#endif
5468 switch (lang)
5469 {
5470 case ELangAfrikaans:
5471 case ELangAlbanian:
5472 case ELangAmerican:
5473 case ELangApacEnglish:
5474 case ELangApacIndonesian:
5475 case ELangApacMalay:
5476 case ELangAustralian:
5477 case ELangAustrian:
5478 case ELangBasque:
5479 case ELangBelgianFlemish:
5480 case ELangBelgianFrench:
5481 case ELangBrazilianPortuguese:
5482 case ELangCanadianEnglish:
5483 case ELangCanadianFrench:
5484 case ELangCatalan:
5485 case ELangDanish:
5486 case ELangDutch:
5487 case ELangEnglish:
5488 case ELangFinlandSwedish:
5489 case ELangFinnish:
5490 case ELangFrench:
5491 case ELangGalician:
5492 case ELangGerman:
5493 case ELangIcelandic:
5494 case ELangIndonesian:
5495 case ELangInternationalEnglish:
5496 case ELangInternationalFrench:
5497 case ELangInternationalSpanish:
5498 case ELangIrish:
5499 case ELangItalian:
5500 case ELangLatinAmericanSpanish:
5501 case ELangMalay:
5502 case ELangNewZealand:
5503 case ELangNorwegian:
5504 case ELangPortuguese:
5505 case ELangSouthAfricanEnglish:
5506 case ELangSpanish:
5507 case ELangSwahili:
5508 case ELangSwedish:
5509 case ELangSwissFrench:
5510 case ELangSwissGerman:
5511 case ELangSwissItalian:
5512 case ELangTagalog:
5513 case ELangWelsh:
5514 aSymbianCodepage = KCharacterSetIdentifierCodePage1252;
5515 aFlashCodepage = FI_Latin1_CodePage;
5516 break;
5517
5518 case ELangTurkish:
5519 case ELangCyprusTurkish:
5520 aSymbianCodepage = /*KCharacterSetIdentifierIso88599*/0x100059D9;
5521 aFlashCodepage = FI_Turkish_CodePage;
5522 break;
5523
5524 case ELangEstonian:
5525 case ELangLatvian:
5526 case ELangLithuanian:
5527 aSymbianCodepage = /*KCharacterSetIdentifierIso88594*/0x100059DA;
5528 aFlashCodepage = FI_Latin4_CodePage;
5529 break;
5530
5531 case ELangBelarussian:
5532 case ELangBulgarian:
5533 case ELangMacedonian:
5534 case ELangRussian:
5535 case ELangUkrainian:
5536 aSymbianCodepage = /*KCharacterSetIdentifierIso88595*/0x100059D7;
5537 aFlashCodepage = FI_Cyrillic_CodePage;
5538 break;
5539
5540 case ELangCroatian:
5541 case ELangCzech:
5542 case ELangHungarian:
5543 case ELangPolish:
5544 case ELangRomanian:
5545 case ELangSerbian:
5546 case ELangSlovak:
5547 case ELangSlovenian:
5548 aSymbianCodepage = /*KCharacterSetIdentifierIso88592*/0x100059D6;
5549 aFlashCodepage = FI_Latin2_CodePage;
5550 break;
5551
5552 case ELangHongKongChinese:
5553 case ELangHongKongEnglish:
5554 case ELangTaiwanChinese:
5555 case ELangTaiwanEnglish:
5556 // Some Series60 APAC variants report special IDs for
5557 // English. In these cases, we'll set the code page to Big5 so that
5558 // both English and Chinese content displays properly.
5559 aSymbianCodepage = KCharacterSetIdentifierBig5;
5560 aFlashCodepage = FI_TraditionalChinese_Big5_CodePage;
5561 break;
5562
5563 case ELangPrcChinese:
5564 case ELangPrcEnglish:
5565 aSymbianCodepage = KCharacterSetIdentifierGbk;
5566 aFlashCodepage = FI_SimplifiedChinese_GBK_CodePage;
5567 break;
5568
5569 case ELangJapanese:
5570 case ELangJapaneseEnglish:
5571 aSymbianCodepage = KCharacterSetIdentifierShiftJis;
5572 aFlashCodepage = FI_Japanese_ShiftJIS_CodePage;
5573 break;
5574
5575 case ELangGreek:
5576 case ELangCyprusGreek:
5577 aSymbianCodepage = /*KCharacterSetIdentifierIso88597*/0x100059D8;
5578 aFlashCodepage = FI_Greek_CodePage;
5579 break;
5580
5581 case ELangKorean:
5582 aSymbianCodepage = KCharacterSetIdentifierEUCKR;
5583 aFlashCodepage = FI_Korean_UHC_CodePage;
5584 break;
5585
5586 case ELangUrdu:
5587 case ELangArabic:
5588 aSymbianCodepage = 0x101F8548;
5589 aFlashCodepage = FI_Arabic_CodePage;
5590 break;
5591
5592 case ELangHebrew:
5593 aSymbianCodepage = 0x101F8547;
5594 aFlashCodepage = FI_Hebrew_CodePage;
5595 break;
5596
5597 case ELangThai:
5598 case ELangThaiEnglish:
5599 aSymbianCodepage = KCharacterSetIdentifierTis620;
5600 aFlashCodepage = FI_Thai_CodePage;
5601 break;
5602
5603 case ELangAmharic:
5604 case ELangArmenian:
5605 case ELangBengali:
5606 case ELangBurmese:
5607 case ELangFarsi:
5608 case ELangGeorgian:
5609 case ELangGujarati:
5610 case ELangHindi:
5611 case ELangKannada:
5612 case ELangKazakh:
5613 case ELangKhmer:
5614 case ELangLao:
5615 case ELangMalayalam:
5616 case ELangMarathi:
5617 case ELangMoldavian:
5618 case ELangMongolian:
5619 case ELangNorwegianNynorsk:
5620 case ELangPunjabi:
5621 case ELangScotsGaelic:
5622 case ELangSinhalese:
5623 case ELangSomali:
5624 case ELangTamil:
5625 case ELangTelugu:
5626 case ELangTibetan:
5627 case ELangTigrinya:
5628 case ELangTurkmen:
5629 case ELangVietnamese:
5630 case ELangZulu:
5631 aSymbianCodepage = KCharacterSetIdentifierCodePage1252;
5632 aFlashCodepage = FI_Latin1_CodePage;
5633 break;
5634
5635 default:
5636 aSymbianCodepage = KCharacterSetIdentifierCodePage1252;
5637 aFlashCodepage = FI_Latin1_CodePage;
5638 break;
5639 }
5640
5641}
5642
5643TBool CPlatformFlashEngine::CreatePlayerL()
5644{
5645 SI_Fncs siFunctions;
5646
5647 FlashMemSet(&siFunctions, 0, sizeof(siFunctions));
5648
5649 siFunctions.sizeof_SI_Fncs = sizeof(SI_Fncs);
5650
5651 siFunctions.SIVersion = 1;
5652
5653 SI_FlashPlayerControlFncs siFlashPlayerControl;
5654 FlashMemSet(&siFlashPlayerControl, 0, sizeof(siFlashPlayerControl));
5655 siFunctions.pSIFlashPlayerControl = &siFlashPlayerControl;
5656
5657 siFlashPlayerControl.pFncSI_Malloc = SI_Interface::SI_Malloc;
5658 siFlashPlayerControl.pFncSI_Free = SI_Interface::SI_Free;
5659 siFlashPlayerControl.pFncSI_UpdateFrameInterval = SI_Interface::SI_UpdateFrameInterval;
5660 siFlashPlayerControl.pFncSI_GetMaxAvailablePlayerMemory = SI_Interface::SI_GetMaxAvailablePlayerMemory;
5661#ifdef FEATURE_BG_TRANSPARENCY
5662 siFlashPlayerControl.pFncSI_UpdateBackgroundRegion = SI_Interface::SI_UpdateBackgroundRegion;
5663#endif //FEATURE_BG_TRANSPARENCY
5664
5665#ifdef FEATURE_COMPUTE_STACK // provide stack base address compute implementation
5666 siFlashPlayerControl.pFncSI_ComputeStackBase = SI_Interface::SI_ComputeStackBase;
5667#endif
5668
5669 // frame buffer locking/access
5670 SI_FrameBufferFncs siFrameBufferFncs;
5671 FlashMemSet(&siFrameBufferFncs, 0, sizeof(siFrameBufferFncs));
5672 siFunctions.pSIFrameBufferFncs = &siFrameBufferFncs;
5673
5674 siFrameBufferFncs.pFncSI_GetLockedFrameBuffer = SI_Interface::SI_GetLockedFrameBuffer;
5675 siFrameBufferFncs.pFncSI_UnlockFrameBuffer = SI_Interface::SI_UnlockFrameBuffer;
5676
5677#ifdef FEATURE_OPENVG
5678 //if(iOpenVgMode)
5679
5680#ifdef ACHW
5681 siFrameBufferFncs.pFncSI_GetHardwareInterfaces = SI_Interface::SI_GetHardwareInterfaces;
5682 siFrameBufferFncs.pFncSI_eglGetDisplay = SI_Interface::SI_eglGetDisplay;
5683 siFrameBufferFncs.pFncSI_eglInitialize = SI_Interface::SI_eglInitialize;
5684 siFrameBufferFncs.pFncSI_eglTerminate = SI_Interface::SI_eglTerminate;
5685 siFrameBufferFncs.pFncSI_eglCreateContext = SI_Interface::SI_eglCreateContext;
5686 siFrameBufferFncs.pFncSI_eglChooseConfig = SI_Interface::SI_eglChooseConfig;
5687 siFrameBufferFncs.pFncSI_eglCreatePbufferSurface = SI_Interface::SI_eglCreatePbufferSurface;
5688 siFrameBufferFncs.pFncSI_eglCreateNativePixmapSurface = SI_Interface::SI_eglCreateNativePixmapSurface;
5689 siFrameBufferFncs.pFncSI_eglCreatePbufferFromClientBuffer = SI_Interface::SI_eglCreatePbufferFromClientBuffer;
5690 siFrameBufferFncs.pFncSI_eglMakeCurrent = SI_Interface::SI_eglMakeCurrent;
5691 siFrameBufferFncs.pFncSI_eglDestroyContext = SI_Interface::SI_eglDestroyContext;
5692 siFrameBufferFncs.pFncSI_eglDestroySurface = SI_Interface::SI_eglDestroySurface;
5693 siFrameBufferFncs.pFncSI_eglGetConfigAttrib = SI_Interface::SI_eglGetConfigAttrib;
5694 siFrameBufferFncs.pFncSI_eglCopySurfaceToFrameBuffer = SI_Interface::SI_eglCopySurfaceToFrameBuffer;
5695#endif
5696
5697 //OpenVG functions
5698 SI_OpenVGFncs siOVGFncs;
5699 FlashMemSet(&siOVGFncs, 0, sizeof(siOVGFncs));
5700 siFunctions.pSIOpenVGFncs = &siOVGFncs;
5701
5702 siOVGFncs.pFncSI_vgAppendPath = SI_Interface::SI_ovgAppendPath;
5703 siOVGFncs.pFncSI_vgAppendPathData = SI_Interface::SI_ovgAppendPathData;
5704 siOVGFncs.pFncSI_vgSeti = SI_Interface::SI_ovgSeti;
5705 siOVGFncs.pFncSI_vgClear = SI_Interface::SI_ovgClear;
5706 siOVGFncs.pFncSI_vgClearImage = SI_Interface::SI_ovgClearImage;
5707 siOVGFncs.pFncSI_vgClearPath = SI_Interface::SI_ovgClearPath;
5708 siOVGFncs.pFncSI_vgCreateImage = SI_Interface::SI_ovgCreateImage;
5709 siOVGFncs.pFncSI_vgCreateMaskLayer = SI_Interface::SI_ovgCreateMaskLayer;
5710 siOVGFncs.pFncSI_vgCreatePaint = SI_Interface::SI_ovgCreatePaint;
5711 siOVGFncs.pFncSI_vgCreatePath = SI_Interface::SI_ovgCreatePath;
5712 siOVGFncs.pFncSI_vgCopyMask = SI_Interface::SI_ovgCopyMask;
5713 siOVGFncs.pFncSI_vgDestroyImage = SI_Interface::SI_ovgDestroyImage;
5714 siOVGFncs.pFncSI_vgDestroyMaskLayer = SI_Interface::SI_ovgDestroyMaskLayer;
5715 siOVGFncs.pFncSI_vgDestroyPaint = SI_Interface::SI_ovgDestroyPaint;
5716 siOVGFncs.pFncSI_vgDestroyPath = SI_Interface::SI_ovgDestroyPath;
5717 siOVGFncs.pFncSI_vgDrawImage = SI_Interface::SI_ovgDrawImage;
5718 siOVGFncs.pFncSI_vgDrawPath = SI_Interface::SI_ovgDrawPath;
5719 siOVGFncs.pFncSI_vgFinish = SI_Interface::SI_ovgFinish;
5720 siOVGFncs.pFncSI_vgFlush = SI_Interface::SI_ovgFlush;
5721 siOVGFncs.pFncSI_vgGetError = SI_Interface::SI_ovgGetError;
5722 siOVGFncs.pFncSI_vgGetMatrix = SI_Interface::SI_ovgGetMatrix;
5723 siOVGFncs.pFncSI_vgGetParameteri = SI_Interface::SI_ovgGetParameteri;
5724 siOVGFncs.pFncSI_vgGeti = SI_Interface::SI_ovgGeti;
5725 siOVGFncs.pFncSI_vgImageSubData = SI_Interface::SI_ovgImageSubData;
5726 siOVGFncs.pFncSI_vgInterpolatePath = SI_Interface::SI_ovgInterpolatePath;
5727 siOVGFncs.pFncSI_vgLoadIdentity = SI_Interface::SI_ovgLoadIdentity;
5728 siOVGFncs.pFncSI_vgLoadMatrix = SI_Interface::SI_ovgLoadMatrix;
5729 siOVGFncs.pFncSI_vgMask = SI_Interface::SI_ovgMask;
5730 siOVGFncs.pFncSI_vgModifyPathCoords = SI_Interface::SI_ovgModifyPathCoords;
5731 siOVGFncs.pFncSI_vgMultMatrix = SI_Interface::SI_ovgMultMatrix;
5732 siOVGFncs.pFncSI_vgPaintPattern = SI_Interface::SI_ovgPaintPattern;
5733 siOVGFncs.pFncSI_vgPathBounds = SI_Interface::SI_ovgPathBounds;
5734 siOVGFncs.pFncSI_vgRenderToMask = SI_Interface::SI_ovgRenderToMask;
5735 siOVGFncs.pFncSI_vgScale = SI_Interface::SI_ovgScale;
5736 siOVGFncs.pFncSI_vgSetColor = SI_Interface::SI_ovgSetColor;
5737 siOVGFncs.pFncSI_vgSetPaint = SI_Interface::SI_ovgSetPaint;
5738 siOVGFncs.pFncSI_vgSetParameterfv = SI_Interface::SI_ovgSetParameterfv;
5739 siOVGFncs.pFncSI_vgSetParameteri = SI_Interface::SI_ovgSetParameteri;
5740 siOVGFncs.pFncSI_vgSetf = SI_Interface::SI_ovgSetf;
5741 siOVGFncs.pFncSI_vgSetfv = SI_Interface::SI_ovgSetfv;
5742 siOVGFncs.pFncSI_vgSetiv = SI_Interface::SI_ovgSetiv;
5743 siOVGFncs.pFncSI_vgTransformPath = SI_Interface::SI_ovgTransformPath;
5744 siOVGFncs.pFncSI_vgTranslate = SI_Interface::SI_ovgTranslate;
5745 siOVGFncs.pFncSI_vgChildImage = SI_Interface::SI_ovgChildImage;
5746
5747#endif // FEATURE_OPENVG
5748
5749 // device text rendering support functions
5750 SI_TextRenderingFncs siTextRenderingFncs;
5751 FlashMemSet(&siTextRenderingFncs, 0, sizeof(siTextRenderingFncs));
5752 siFunctions.pSITextRenderingFncs = &siTextRenderingFncs;
5753
5754 siTextRenderingFncs.pFncSI_BeginTextDraw = SI_Interface::SI_BeginTextDraw;
5755 siTextRenderingFncs.pFncSI_DeviceTextOut = SI_Interface::SI_DeviceTextOut;
5756 siTextRenderingFncs.pFncSI_ComplexLineBreak = SI_Interface::SI_ComplexLineBreak;
5757 siTextRenderingFncs.pFncSI_EndTextDraw = SI_Interface::SI_EndTextDraw;
5758 siTextRenderingFncs.pFncSI_GetBitmapInfo = SI_Interface::SI_GetBitmapInfo;
5759 siTextRenderingFncs.pFncSI_GetCharacterInfo = SI_Interface::SI_GetCharacterInfo;
5760 siTextRenderingFncs.pFncSI_GetFontMetrics = SI_Interface::SI_GetFontMetrics;
5761 siTextRenderingFncs.pFncSI_GetTextWidth = SI_Interface::SI_GetTextWidth;
5762 siTextRenderingFncs.pFncSI_CreateFont = SI_Interface::SI_CreateFont;
5763 siTextRenderingFncs.pFncSI_DestroyFont = SI_Interface::SI_DestroyFont;
5764 siTextRenderingFncs.pFncSI_SelectFont = SI_Interface::SI_SelectFont;
5765
5766 // Font Source functions
5767 SI_FontSourceFncs fontSourceFns;
5768 FlashMemSet(&fontSourceFns, 0, sizeof(fontSourceFns));
5769 fontSourceFns.pFncSI_NewFontSource = SI_Interface::SI_NewFontSource;
5770 fontSourceFns.pFncSI_FreeFontSource = SI_Interface::SI_FreeFontSource;
5771 siFunctions.pSIFontSourceFncs = &fontSourceFns;
5772
5773
5774#ifdef FEATURE_OPENVG
5775 siTextRenderingFncs.pFncSI_GetLockedTextBuffer = SI_Interface::SI_GetLockedTextBuffer;
5776 siTextRenderingFncs.pFncSI_UnlockTextBuffer = SI_Interface::SI_UnlockTextBuffer;
5777#endif
5778
5779
5780//#ifdef FEATURE_MULTITOUCH
5781 SI_MultitouchFncs mtFuncs;
5782
5783 mtFuncs.pFncSI_InitMultitouch = NULL;
5784 mtFuncs.pFncSI_GetSupportedGestures = SI_Interface::SI_GetSupportedGestures;
5785 mtFuncs.pFncSI_SetMultitouchInputMode = NULL;
5786 siFunctions.pSIMultitouchFncs = &mtFuncs;
5787//#endif
5788
5789 // character encoding support functions
5790 SI_CharacterEncodingFncs siCharacterEncodingFncs;
5791 FlashMemSet(&siCharacterEncodingFncs, 0, sizeof(siCharacterEncodingFncs));
5792 siFunctions.pSICharacterEncodingFncs = &siCharacterEncodingFncs;
5793
5794 siCharacterEncodingFncs.pFncSI_ConvertCStringToUTF16String = SI_Interface::SI_ConvertCStringToUTF16String;
5795 siCharacterEncodingFncs.pFncSI_ConvertUTF16StringToCString = SI_Interface::SI_ConvertUTF16StringToCString;
5796
5797 // Inline text entry
5798 SI_InlineTextEntryFncs siInlineTextEntryFncs;
5799 FlashMemSet(&siInlineTextEntryFncs, 0, sizeof(siInlineTextEntryFncs));
5800 siFunctions.pSIInlineTextEntryFncs = &siInlineTextEntryFncs;
5801
5802#ifdef FEATURE_INLINE_TEXT_ENTRY
5803 siInlineTextEntryFncs.pFncSI_EnableIME = SI_Interface::SI_EnableIME;
5804 siInlineTextEntryFncs.pFncSI_DisableIME = SI_Interface::SI_DisableIME;
5805 siInlineTextEntryFncs.pFncSI_DrawFullScreenInputModeIndicator = SI_Interface::SI_DrawFullScreenInputModeIndicator;
5806#endif // FEATURE_INLINE_TEXT_ENTRY
5807
5808 SI_ErrorNotifyFncs siFlashLiteErrorNotifyFncs;
5809 FlashMemSet(&siFlashLiteErrorNotifyFncs, 0, sizeof(siFlashLiteErrorNotifyFncs));
5810 siFunctions.pSIFlashLiteErrorNotifyFncs = &siFlashLiteErrorNotifyFncs;
5811
5812 siFlashLiteErrorNotifyFncs.pFncSI_NotifyFlashLiteError = SI_Interface::SI_NotifyError;
5813 SI_SecurityFncs siSecurityFncs;
5814 FlashMemSet(&siSecurityFncs,0,sizeof(siSecurityFncs));
5815 siFunctions.pSISecurityFncs = &siSecurityFncs;
5816 siSecurityFncs.pFncSI_showLocalSecurityDialog = SI_Interface::SI_ShowLocalSecurityDialog;
5817
5818 SI_SoundControlFncs siSoundControlFncs;
5819 FlashMemSet(&siSoundControlFncs, 0, sizeof(siSoundControlFncs));
5820
5821 if (iConfig.iMode & KSupportSound)
5822 {
5823 siFunctions.pSISoundControlFncs = &siSoundControlFncs;
5824 // event sound functions
5825 siSoundControlFncs.pFncSI_CacheSound = SI_Interface::SI_CacheSound;
5826 siSoundControlFncs.pFncSI_PlayCachedSound = SI_Interface::SI_PlayCachedSound;
5827 siSoundControlFncs.pFncSI_FreeCachedSound = SI_Interface::SI_FreeCachedSound;
5828 siSoundControlFncs.pFncSI_PlaySound = SI_Interface::SI_PlaySound;
5829 siSoundControlFncs.pFncSI_StopSound = SI_Interface::SI_StopSound;
5830 siSoundControlFncs.pFncSI_PauseSound = SI_Interface::SI_PauseSound;
5831 siSoundControlFncs.pFncSI_ResumeSound = SI_Interface::SI_ResumeSound;
5832
5833 // streaming sound functions
5834 siSoundControlFncs.pFncSI_CloseStreamSoundDevice = SI_Interface::SI_CloseStreamSoundDevice;
5835 siSoundControlFncs.pFncSI_CreateSoundDecompressor = SI_Interface::SI_CreateSoundDecompressor;
5836 siSoundControlFncs.pFncSI_DecompressSound = SI_Interface::SI_DecompressSound;
5837 siSoundControlFncs.pFncSI_DestroySoundDecompressor = SI_Interface::SI_DestroySoundDecompressor;
5838 siSoundControlFncs.pFncSI_OpenStreamSoundDevice = SI_Interface::SI_OpenStreamSoundDevice;
5839 siSoundControlFncs.pFncSI_PlayStreamSoundBuffer = SI_Interface::SI_PlayStreamSoundBuffer;
5840 siSoundControlFncs.pFncSI_SetupSoundDecompressor = SI_Interface::SI_SetupSoundDecompressor;
5841 }
5842 else
5843 {
5844 siFunctions.pSISoundControlFncs = NULL;
5845 }
5846
5847 SI_VideoFncs siVideoFncs;
5848 FlashMemSet( &siVideoFncs, 0, sizeof(siVideoFncs) );
5849
5850#ifdef FEATURE_VIDEO
5851 SI_FLVFncs siFLVFncs;
5852 FlashMemSet( &siFLVFncs, 0, sizeof(siFLVFncs) );
5853#endif
5854
5855#ifdef FEATURE_VIDEO_DLL
5856 SI_NativeVideoFncs siNativeVideoFncs;
5857 memset( &siNativeVideoFncs, 0, sizeof(siNativeVideoFncs) );
5858#endif //FEATURE_VIDEO_DLL
5859 if (iConfig.iMode & KSupportVideo)
5860 {
5861 siFunctions.pSIVideoFncs = &siVideoFncs;
5862 siVideoFncs.pFncSI_CreateVideo = SI_Interface::SI_CreateVideo;
5863 siVideoFncs.pFncSI_PlayVideo = SI_Interface::SI_PlayVideo;
5864 siVideoFncs.pFncSI_CloseVideo = SI_Interface::SI_CloseVideo;
5865 siVideoFncs.pFncSI_StopVideo = SI_Interface::SI_StopVideo;
5866 siVideoFncs.pFncSI_PauseVideo = SI_Interface::SI_PauseVideo;
5867 siVideoFncs.pFncSI_ResumeVideo = SI_Interface::SI_ResumeVideo;
5868 siVideoFncs.pFncSI_GetVideoMethods = SI_Interface::SI_GetVideoMethods;
5869 siVideoFncs.pFncSI_ProcessVideoMethod = SI_Interface::SI_ProcessVideoMethod;
5870 siVideoFncs.pFncSI_DestroyVideo = SI_Interface::SI_DestroyVideo;
5871 siVideoFncs.pFncSI_SetVideoRect = SI_Interface::SI_SetVideoRect;
5872
5873 //For device video overlay
5874 siVideoFncs.pFncSI_GetVideoSize = SI_Interface::SI_GetVideoSize;
5875 //siVideoFncs.pFncSI_GetVideoBits = SI_Interface::SI_GetVideoBits;
5876
5877#ifdef FEATURE_VIDEO_DLL
5878 siFunctions.pSINativeVideoFncs = &siNativeVideoFncs;
5879 siNativeVideoFncs.pFncSI_CreateDecompressor = SI_Interface::SI_NativeVideoCreateDecompressor;
5880 siNativeVideoFncs.pFncSI_DestroyDecompressor = SI_Interface::SI_NativeVideoDestroyDecompressor;
5881#endif //FEATURE_VIDEO_DLL
5882
5883#ifdef FEATURE_VIDEO
5884 siFunctions.pSIFLVFncs = &siFLVFncs;
5885 siFLVFncs.pFncSI_FLVStatus = SI_Interface::SI_FLVStatus;
5886#endif //FEATURE_VIDEO
5887 }
5888 else
5889 {
5890 siFunctions.pSIVideoFncs = NULL;
5891 }
5892
5893 // misc functions
5894 SI_KeyInputFncs siKeyInputFncs;
5895 FlashMemSet(&siKeyInputFncs, 0, sizeof(siKeyInputFncs));
5896 siFunctions.pSIKeyInputFncs = &siKeyInputFncs;
5897 siKeyInputFncs.pFncSI_GetInputText = SI_Interface::SI_GetInputText;
5898
5899 SI_DataAccessFncs siDataAccessFncs;
5900 FlashMemSet(&siDataAccessFncs, 0, sizeof(siDataAccessFncs));
5901 siFunctions.pSIDataAccessFncs = &siDataAccessFncs;
5902
5903 if (iConfig.iMode & KSupportSharedObject)
5904 {
5905#ifndef USE_SYNC_MSO
5906 siDataAccessFncs.pFncSI_SetPersistentData = SI_Interface::SI_SetPersistentData;
5907 siDataAccessFncs.pFncSI_GetPersistentData = SI_Interface::SI_GetPersistentData;
5908 siDataAccessFncs.pFncSI_GetMaxPersistentStorage = SI_Interface::SI_GetMaxPersistentStorage;
5909
5910 siDataAccessFncs.pFncSI_GetPersistentDataSize = SI_Interface::SI_GetPersistentDataSize;
5911 siDataAccessFncs.pFncSI_CancelSharedObjectRequest = SI_Interface::SI_CancelSharedObjectRequest;
5912#else
5913 siDataAccessFncs.pFncSI_GetMaxPersistentStorage = SI_Interface::SI_GetMaxPersistentStorage;
5914
5915 siDataAccessFncs.pFncSI_GetPersistentDataSync = SI_Interface::SI_GetPersistentDataSync;
5916 siDataAccessFncs.pFncSI_GetPersistentDataSizeSync = SI_Interface::SI_GetPersistentDataSizeSync;
5917 siDataAccessFncs.pFncSI_SetPersistentDataSync = SI_Interface::SI_SetPersistentDataSync;
5918#endif //USE_SYNC_MSO
5919
5920#ifdef FEATURE_LOCAL_CONNECTION
5921 siDataAccessFncs.pFncSI_CreateSharedMemory = SI_Interface::SI_CreateSharedMemory;
5922 siDataAccessFncs.pFncSI_DestroySharedMemory = SI_Interface::SI_DestroySharedMemory;
5923 siDataAccessFncs.pFncSI_LockSharedMemory = SI_Interface::SI_LockSharedMemory;
5924 siDataAccessFncs.pFncSI_UnlockSharedMemory = SI_Interface::SI_UnLockSharedMemory;
5925#endif // FEATURE_LOCAL_CONNECTION
5926
5927 }
5928
5929 SI_URLAccessFncs siURLAccessFncs;
5930 FlashMemSet(&siURLAccessFncs, 0, sizeof(siURLAccessFncs));
5931 siFunctions.pSIURLAccessFncs = &siURLAccessFncs;
5932
5933 siURLAccessFncs.pFncSI_GetURL = SI_Interface::SI_GetURL;
5934
5935 if (iConfig.iMode & KSupportNetwork || iConfig.iMode & KSupportLocalFile)
5936 {
5937 siURLAccessFncs.pFncSI_OpenURLStream = SI_Interface::SI_OpenURLStream;
5938 siURLAccessFncs.pFncSI_LoadURLStreamBuffer = SI_Interface::SI_LoadURLStreamBuffer;
5939 siURLAccessFncs.pFncSI_CancelURLStream = SI_Interface::SI_CancelURLStream;
5940#ifdef FEATURE_FLV_MMC
5941 siURLAccessFncs.pFncSI_SeekURLStreamFLV = SI_Interface::SI_SeekURLStreamFLV;
5942#ifdef FEATURE_HOST_SEEK_FLV
5943 siURLAccessFncs.pFncSI_FLVGetBytesLoaded = SI_Interface::SI_FLVGetBytesLoaded;
5944#endif //FEATURE_HOST_SEEK_FLV - Sathya
5945 siURLAccessFncs.pFncSI_FLVGetTotalBytes = SI_Interface::SI_FLVGetTotalBytes;
5946#endif //FEATURE_FLV_MMC
5947 }
5948
5949 // fscommand support functions
5950 SI_DeviceControlFncs siDeviceControlFncs;
5951 FlashMemSet(&siDeviceControlFncs, 0, sizeof(siDeviceControlFncs));
5952 siFunctions.pSIDeviceControlFncs = &siDeviceControlFncs;
5953
5954 siDeviceControlFncs.pFncSI_DoFsCommand = SI_Interface::SI_DoFsCommand;
5955 siDeviceControlFncs.pFncSI_GetBatteryLevel = SI_Interface::SI_GetBatteryLevel;
5956 siDeviceControlFncs.pFncSI_GetDevice = SI_Interface::SI_GetDevice;
5957 siDeviceControlFncs.pFncSI_GetDeviceCapabilities = SI_Interface::SI_GetDeviceCapabilities;
5958 siDeviceControlFncs.pFncSI_GetDeviceID = SI_Interface::SI_GetDeviceID;
5959 siDeviceControlFncs.pFncSI_GetLanguage = SI_Interface::SI_GetLanguage;
5960 siDeviceControlFncs.pFncSI_GetMaxBatteryLevel = SI_Interface::SI_GetMaxBatteryLevel;
5961 siDeviceControlFncs.pFncSI_GetMaxVolumeLevel = SI_Interface::SI_GetMaxVolumeLevel;
5962 siDeviceControlFncs.pFncSI_GetPlatform = SI_Interface::SI_GetPlatform;
5963 siDeviceControlFncs.pFncSI_GetPowerSource = SI_Interface::SI_GetPowerSource;
5964 siDeviceControlFncs.pFncSI_GetUTCTimeStamp = SI_Interface::SI_GetUTCTimeStamp;
5965 siDeviceControlFncs.pFncSI_ConvertUTCToLocalTime = SI_Interface::SI_ConvertUTCToLocalTime;
5966 siDeviceControlFncs.pFncSI_ConvertLocalToUTCTime = SI_Interface::SI_ConvertLocalToUTCTime;
5967 siDeviceControlFncs.pFncSI_FormatDate = SI_Interface::SI_FormatDate;
5968 siDeviceControlFncs.pFncSI_FormatTimeOfDay = SI_Interface::SI_FormatTimeOfDay;
5969 siDeviceControlFncs.pFncSI_GetVolumeLevel = SI_Interface::SI_GetVolumeLevel;
5970 siDeviceControlFncs.pFncSI_Launch = SI_Interface::SI_Launch;
5971 siDeviceControlFncs.pFncSI_QuitFlashLite = SI_Interface::SI_QuitFlashLite;
5972 siDeviceControlFncs.pFncSI_SetFullScreen = SI_Interface::SI_SetFullScreen;
5973#ifdef __FEATURE_OSK__
5974 siDeviceControlFncs.pFncSI_DisableKeypadCompatibilityMode = SI_Interface::SI_DisableKeypadCompatibilityMode;
5975#endif // __FEATURE_OSK__
5976 siDeviceControlFncs.pFncSI_SetSoftkeys = SI_Interface::SI_SetSoftkeys;
5977 siDeviceControlFncs.pFncSI_StartVibrate = SI_Interface::SI_StartVibrate;
5978 siDeviceControlFncs.pFncSI_ResetSoftkeys = SI_Interface::SI_ResetSoftkeys;
5979 siDeviceControlFncs.pFncSI_GetSoftkeyLocation = SI_Interface::SI_GetSoftKeyLocation;
5980 siDeviceControlFncs.pFncSI_StopVibrate = SI_Interface::SI_StopVibrate;
5981 siDeviceControlFncs.pFncSI_ExtendBacklightDuration = SI_Interface::SI_ExtendBacklightDuration;
5982 siDeviceControlFncs.pFncSI_GetScreenInfo = SI_Interface::SI_GetScreenInfo;
5983 siDeviceControlFncs.pFncSI_GetNetworkInfo = SI_Interface::SI_GetNetworkInfo;
5984 siDeviceControlFncs.pFncSI_GetNetworkInfoString = SI_Interface::SI_GetNetworkInfoString;
5985 siDeviceControlFncs.pFncSI_GetNumberOfSoftkeys = SI_Interface::SI_GetNumberOfSoftkeys;
5986 siDeviceControlFncs.pFncSI_GetCallerInfo = SI_Interface::SI_GetCallerInfo;
5987
5988 //Initialize socket functions
5989 SI_SocketFncs siSocketFncs;
5990 FlashMemSet(&siSocketFncs, 0, sizeof(siSocketFncs));
5991 siFunctions.pSISocketFncs = &siSocketFncs;
5992#ifdef FEATURE_XML_SOCKET
5993 if (iConfig.iMode & KSupportNetwork)
5994 {
5995 siSocketFncs.pFncSI_OpenSocket = SI_Interface::SI_OpenSocket;
5996 siSocketFncs.pFncSI_CloseSocket = SI_Interface::SI_CloseSocket;
5997 siSocketFncs.pFncSI_SocketSend = SI_Interface::SI_SocketSend;
5998 }
5999#endif //FEATURE_XML_SOCKET
6000
6001#if defined(FEATURE_ACHW) && (ACHW_DRAWING_LIB == ACHW_DRAWING_LIB_IS_OPENGL_ES)
6002 SI_OpenGLESFncs siOpenGLESFncs;
6003 FlashMemSet(&siOpenGLESFncs, 0, sizeof(siOpenGLESFncs));
6004 siFunctions.pSIOpenGLESFncs = &siOpenGLESFncs;
6005 siOpenGLESFncs.pFncSI_glIsTexture = SI_Interface::SI_glIsTexture;
6006 siOpenGLESFncs.pFncSI_glGetError = SI_Interface::SI_glGetError;
6007 siOpenGLESFncs.pFncSI_glActiveTexture = SI_Interface::SI_glActiveTexture;
6008 siOpenGLESFncs.pFncSI_glAlphaFuncx = SI_Interface::SI_glAlphaFuncx;
6009 siOpenGLESFncs.pFncSI_glBindBuffer = SI_Interface::SI_glBindBuffer;
6010 siOpenGLESFncs.pFncSI_glBindTexture = SI_Interface::SI_glBindTexture;
6011 siOpenGLESFncs.pFncSI_glBlendFunc = SI_Interface::SI_glBlendFunc;
6012 siOpenGLESFncs.pFncSI_glBufferData = SI_Interface::SI_glBufferData;
6013 siOpenGLESFncs.pFncSI_glClear = SI_Interface::SI_glClear;
6014 siOpenGLESFncs.pFncSI_glClearColorx = SI_Interface::SI_glClearColorx;
6015 siOpenGLESFncs.pFncSI_glClearDepthx = SI_Interface::SI_glClearDepthx;
6016 siOpenGLESFncs.pFncSI_glClientActiveTexture = SI_Interface::SI_glClientActiveTexture;
6017 siOpenGLESFncs.pFncSI_glColor4x = SI_Interface::SI_glColor4x;
6018 siOpenGLESFncs.pFncSI_glColorMask = SI_Interface::SI_glColorMask;
6019 siOpenGLESFncs.pFncSI_glDeleteTextures = SI_Interface::SI_glDeleteTextures;
6020 siOpenGLESFncs.pFncSI_glDepthFunc = SI_Interface::SI_glDepthFunc;
6021 siOpenGLESFncs.pFncSI_glDepthMask = SI_Interface::SI_glDepthMask;
6022 siOpenGLESFncs.pFncSI_glDisable = SI_Interface::SI_glDisable;
6023 siOpenGLESFncs.pFncSI_glDisableClientState = SI_Interface::SI_glDisableClientState;
6024 siOpenGLESFncs.pFncSI_glDrawArrays = SI_Interface::SI_glDrawArrays;
6025 siOpenGLESFncs.pFncSI_glEnable = SI_Interface::SI_glEnable;
6026 siOpenGLESFncs.pFncSI_glEnableClientState = SI_Interface::SI_glEnableClientState;
6027 siOpenGLESFncs.pFncSI_glFinish = SI_Interface::SI_glFinish;
6028 siOpenGLESFncs.pFncSI_glGenTextures = SI_Interface::SI_glGenTextures;
6029 siOpenGLESFncs.pFncSI_glGetIntegerv = SI_Interface::SI_glGetIntegerv;
6030 siOpenGLESFncs.pFncSI_glHint = SI_Interface::SI_glHint;
6031 siOpenGLESFncs.pFncSI_glLineWidthx = SI_Interface::SI_glLineWidthx;
6032 siOpenGLESFncs.pFncSI_glLoadIdentity = SI_Interface::SI_glLoadIdentity;
6033 siOpenGLESFncs.pFncSI_glLoadMatrixx = SI_Interface::SI_glLoadMatrixx;
6034 siOpenGLESFncs.pFncSI_glMatrixMode = SI_Interface::SI_glMatrixMode;
6035 siOpenGLESFncs.pFncSI_glMultMatrixx = SI_Interface::SI_glMultMatrixx;
6036 siOpenGLESFncs.pFncSI_glOrthox = SI_Interface::SI_glOrthox;
6037 siOpenGLESFncs.pFncSI_glPixelStorei = SI_Interface::SI_glPixelStorei;
6038 siOpenGLESFncs.pFncSI_glPolygonOffsetx = SI_Interface::SI_glPolygonOffsetx;
6039 siOpenGLESFncs.pFncSI_glPopMatrix = SI_Interface::SI_glPopMatrix;
6040 siOpenGLESFncs.pFncSI_glPushMatrix = SI_Interface::SI_glPushMatrix;
6041 siOpenGLESFncs.pFncSI_glScalex = SI_Interface::SI_glScalex;
6042 siOpenGLESFncs.pFncSI_glScissor = SI_Interface::SI_glScissor;
6043 siOpenGLESFncs.pFncSI_glShadeModel = SI_Interface::SI_glShadeModel;
6044 siOpenGLESFncs.pFncSI_glTexCoordPointer = SI_Interface::SI_glTexCoordPointer;
6045 siOpenGLESFncs.pFncSI_glTexEnvx = SI_Interface::SI_glTexEnvx;
6046 siOpenGLESFncs.pFncSI_glTexEnvxv = SI_Interface::SI_glTexEnvxv;
6047 siOpenGLESFncs.pFncSI_glTexImage2D = SI_Interface::SI_glTexImage2D;
6048 siOpenGLESFncs.pFncSI_glTexParameterx = SI_Interface::SI_glTexParameterx;
6049 siOpenGLESFncs.pFncSI_glTexSubImage2D = SI_Interface::SI_glTexSubImage2D;
6050 siOpenGLESFncs.pFncSI_glTranslatex = SI_Interface::SI_glTranslatex;
6051 siOpenGLESFncs.pFncSI_glVertexPointer = SI_Interface::SI_glVertexPointer;
6052 siOpenGLESFncs.pFncSI_glViewport = SI_Interface::SI_glViewport;
6053#endif // defined(FEATURE_ACHW) && (ACHW_DRAWING_LIB == ACHW_DRAWING_LIB_IS_OPENGL_ES)
6054
6055
6056#ifdef FEATURE_EXTENSION
6057 SI_MiscFncs siMiscFncs;
6058 FlashMemSet(&siMiscFncs, 0, sizeof(siMiscFncs));
6059 siMiscFncs.pFncSI_GetPluginInfo = SI_Interface::SI_GetPluginInfo;
6060 siMiscFncs.pFncSI_GetDisplayRectCoord = SI_Interface::SI_GetDisplayRectCoord;
6061#ifdef FEATURE_AMCEXTENSIONS
6062 siMiscFncs.pFncSI_GetExtensionPlatformInfo = SI_Interface::SI_GetExtensionPlatformInfo;
6063 siMiscFncs.pFncSI_GetSecurityContextPermissions = SI_Interface::SI_GetSecurityContextPermissions;
6064#endif
6065 siFunctions.pSIMiscFncs = &siMiscFncs;
6066#endif
6067 // Initialize the MMI functions to null in case there is no MMI
6068 siFunctions.pSIMMIFncs=NULL;
6069
6070 SI_DebugFncs siDebugFncs;
6071 FlashMemSet(&siDebugFncs, 0, sizeof(siDebugFncs));
6072 siFunctions.pSIDebugFncs = &siDebugFncs;
6073
6074 siDebugFncs.pFncSI_Debug = SI_Interface::SI_Debug;
6075
6076 SI_ImageFncs siImageFncs;
6077 FlashMemSet(&siImageFncs, 0, sizeof(siImageFncs));
6078 siFunctions.pSIImageFncs = &siImageFncs;
6079
6080 siImageFncs.pFncSI_GetImageInfo = SI_Interface::SI_GetImageInfo;
6081 siImageFncs.pFncSI_CancelImageRequest = SI_Interface::SI_CancelImageRequest;
6082
6083 SI_FileAccessFncs siFileAccessFncs;
6084 FlashMemSet(&siFileAccessFncs, 0, sizeof(siFileAccessFncs));
6085 siFunctions.pSIFileAccessFncs = &siFileAccessFncs;
6086
6087 siFileAccessFncs.pFncSI_OpenFile = SI_Interface::SI_OpenFile;
6088 siFileAccessFncs.pFncSI_CloseFile = SI_Interface::SI_CloseFile;
6089 siFileAccessFncs.pFncSI_ReadFile = SI_Interface::SI_ReadFile;
6090 siFileAccessFncs.pFncSI_GetFileSize = SI_Interface::SI_GetFileSize;
6091 siFileAccessFncs.pFncSI_SeekFile = SI_Interface::SI_SeekFile;
6092
6093
6094 siFunctions.SIVersion = 1;
6095 siFunctions.sizeof_SI_Fncs = sizeof(siFunctions);
6096
6097#ifdef FEATURE_EXTERNAL_API
6098
6099 SI_ExternalAPIFncs siExternalAPIFuncs;
6100 FlashMemSet(&siExternalAPIFuncs, 0, sizeof(siExternalAPIFuncs));
6101 siFunctions.pSIExternalAPIFncs = &siExternalAPIFuncs;
6102
6103 siExternalAPIFuncs.pFncSI_EvalJs = SI_Interface::SI_EvaluateJScript;
6104 siExternalAPIFuncs.pFncSI_DoFlashCall = SI_Interface::SI_DoFlashCall;
6105 siExternalAPIFuncs.pFncSI_GetDomObjectId = SI_Interface::SI_GetDOMObjectID;
6106
6107#endif //FEATURE_EXTERNAL_API
6108
6109#ifdef FEATURE_TESTAUTOMATION
6110 SI_TestAutomationFncs siTestAutoFuncs; //Do not move this out of here as it is used in the call "iFiObject.FI_CreatePlayer()" below
6111 if(iConfig.iMode & KPlayerInATSMode)
6112 {
6113 FlashMemSet(&siTestAutoFuncs, 0, sizeof(siTestAutoFuncs));
6114
6115 siTestAutoFuncs.pFncSI_WriteFile = SI_Interface::SI_WriteFile;
6116 siTestAutoFuncs.pFncSI_GenerateMouseEvent = SI_Interface::SI_GenerateMouseEvent;
6117 siTestAutoFuncs.pFncSI_GenerateKeyEvent = SI_Interface::SI_GenerateKeyEvent;
6118 siTestAutoFuncs.pFncSI_GetAutomationConfigurationContent = SI_Interface::SI_GetAutomationConfigurationContent;
6119
6120 siFunctions.pSITestAutomationFncs = &siTestAutoFuncs;
6121 }
6122#endif
6123
6124 unsigned long fiConfigFlags = KfiConfigFlags;
6125
6126#ifdef FEATURE_OPENVG
6127 if(iOpenVgMode) {
6128 fiConfigFlags |= FI_UseOpenVG;
6129 }
6130#endif
6131
6132 if (iConfig.iMode & KSupportSVG)
6133 {
6134 fiConfigFlags |= FI_FlashLiteSVG;
6135 }
6136
6137 if (iConfig.iMode & KSupportSharedObject)
6138 {
6139 fiConfigFlags |= FI_SharedObjects;
6140 }
6141
6142 if( iConfig.iHelixFlvMode )
6143 {
6144 fiConfigFlags |= FI_ExternalVideoBuffering;
6145 fiConfigFlags |= FI_ExternalVideoRendering;
6146 }
6147 /* Eroom: 574 - FullScreen feature in Plugin Mode */
6148 //if (iControl != NULL) {
6149 /* Set this flag only for browser plugin */
6150 if(ePlugin == iExecutionMode)
6151 {
6152 fiConfigFlags |= FI_PluginMode;
6153 }
6154 TInt keyboardLayout = 0;
6155 RProperty::Get(KCRUidAvkon, KAknKeyBoardLayout, keyboardLayout);
6156 TPtiKeyboardType layout = (TPtiKeyboardType)keyboardLayout;
6157 if(layout!=EPtiKeyboardNone)
6158 {
6159 //IF keypad is available 4way navigation is enabled
6160 fiConfigFlags |= FI_4WayNavigation;
6161 }
6162 else
6163 {
6164 //If keypad is not available we enable 4way navigation only if OSK is enabled.
6165 //OSK is available only in viewer
6166 //if(!iBrowserPluginActive)
6167 if(iExecutionMode == eStandAlone)
6168 {
6169 #ifdef __FEATURE_OSK__
6170 fiConfigFlags |= FI_4WayNavigation;
6171 #endif//__FEATURE_OSK__
6172 }
6173 }
6174
6175//Load ATS Library
6176#ifdef FEATURE_ATS_AUTOMATION
6177 SI_Fncs atsFunctions;
6178 if((iConfig.iMode & KPlayerInATSMode) && iXMLFlag)
6179 {
6180 iATSHandler->LoadATSLibraryL(&atsFunctions,&siFunctions);
6181 //ExtendBacklight(200);
6182 }
6183#endif
6184
6185 iFiObject.SetEngine(this);
6186
6187 iFIConfigFlags = fiConfigFlags;
6188
6189#ifdef FEATURE_ATS_AUTOMATION
6190 if((iConfig.iMode & KPlayerInATSMode) && iXMLFlag)
6191 {
6192 iFiObject.FI_CreatePlayer(iPlayerStaticHeap, iPlayerStaticHeapSize, atsFunctions, fiConfigFlags);
6193 }
6194 else
6195 {
6196 iFiObject.FI_CreatePlayer(iPlayerStaticHeap, iPlayerStaticHeapSize, siFunctions, fiConfigFlags);
6197 }
6198
6199#else
6200 iFiObject.FI_CreatePlayer(iPlayerStaticHeap, iPlayerStaticHeapSize, siFunctions, fiConfigFlags);
6201#endif
6202
6203 iMMObject = iFiObject.GetMMObject();
6204
6205#ifdef FEATURE_OPENVG
6206 if(iOpenVgMode) {
6207 iFiObject.FI_ConfigureHardwareRendering(&iHwConfig);
6208 }
6209#endif
6210
6211//setup library and exchange function pointers.
6212#ifdef FEATURE_ATS_AUTOMATION
6213 if((iConfig.iMode & KPlayerInATSMode) && iXMLFlag)
6214 {
6215 iATSHandler->SetUpATSLibrary(iMMObject,fiConfigFlags);
6216 }
6217#endif
6218
6219 TBool success = EFalse;
6220
6221 if (iMMObject)
6222 {
6223#ifdef FEATURE_INLINE_TEXT_ENTRY
6224 // CPlatformFlashEngine gets reused across multiple player instances
6225 if ( NULL == iTextNavigation )
6226 {
6227 iTextNavigation = new AMP_VirtualTextNavigation;
6228 }
6229
6230 // Every time we create a player, we need to register for notification
6231 if ( iTextNavigation )
6232 {
6233 success = ETrue;
6234 }
6235#else
6236 success = ETrue;
6237#endif
6238 }
6239
6240 return success;
6241}
6242
6243_LIT8(KSvgFileFirstFewBytes, "<svg");
6244_LIT8(KSvgzFile1FirstFewBytes, "\037\213"); // zlib compressed -- could be SVGZ
6245_LIT8(KSvgzFile2FirstFewBytes, "\170\234"); // zlib compressed -- could be SVGZ
6246
6247const TUint KLongestFirstFewBytesData = 4;
6248//SecuritySandbox
6249
6250
6251void CPlatformFlashEngine::TrustContentL(const TPtrC &aSwfFileName)
6252{
6253 if(iTrustStore)
6254 iTrustStore->TrustContentL(aSwfFileName);
6255
6256}
6257//SecuritySandbox
6258
6259TBool CPlatformFlashEngine::IsContentTrustedL(const TPtrC &aSwfFileName)
6260{
6261 TBool res = EFalse;
6262 if(!iTrustStore)
6263 {
6264 iTrustStore= CFlashTrustStore::NewL();
6265 }
6266 //check if aSwFileName is already trusted
6267 if(iTrustStore)
6268 {
6269 TRAP_IGNORE(res =iTrustStore->IsContentTrustedL(aSwfFileName));
6270 }
6271 return res;
6272}
6273TBool CPlatformFlashEngine::CanContentBeTrusted(const TDesC8& aSwfURL)
6274{
6275 RFs fsSession = CEikonEnv::Static()->FsSession();
6276 DriveInfo::TDriveArray driveArray;
6277 TInt err = ETrue;//This is used to find if we get any errors in getting drive info and pathinfo
6278 if(KErrNone == DriveInfo::GetUserVisibleDrives( fsSession, driveArray ))
6279 {
6280 err = EFalse;
6281 TInt i=0;
6282 TInt driveCount=driveArray.Count();
6283 for(i=0; i < driveCount; i++)
6284 {
6285 TDriveNumber drive( driveArray[ i ] );
6286 TFileName path;
6287 if(KErrNone==PathInfo::GetRootPath( path, drive ))
6288 {
6289 TBuf8 <KMaxFileName> trustedPath;
6290 trustedPath.Copy(path);
6291 trustedPath.Append(PathInfo::OthersPath());
6292 TInt pos;
6293 pos = trustedPath.Find(KBackwardSlash);
6294 while(pos!=KErrNotFound)
6295 {
6296 trustedPath.Replace(pos,1,KForwardSlash);
6297 pos =trustedPath.Find(KBackwardSlash);
6298 }
6299 trustedPath.Append(KTrustedDir);
6300 if(KErrNotFound != aSwfURL.FindF(trustedPath))
6301 {
6302 return ETrue;
6303 }
6304 }
6305 else
6306 {
6307 err = ETrue;
6308 break;
6309 }
6310 }
6311 }
6312 if(err)//If there is a error in getting user visible drives/rootpath we check the hardcoded paths
6313 {
6314 if(( KErrNotFound != aSwfURL.FindF( KOthersTrustedDir))||
6315 ( KErrNotFound != aSwfURL.FindF( KTrustedPhoneDirPath)))
6316 {
6317 return ETrue;
6318 }
6319 }
6320 //Some application send file:/// and hence offset returned would not be 0,
6321 // hence checking for KErrNotFound
6322 if(( KErrNotFound != aSwfURL.FindF( KTrustedZDirPrivate))||
6323 ( KErrNotFound != aSwfURL.FindF( KShowroomDirPrivate)))
6324 {
6325 return ETrue;
6326 }
6327
6328 return EFalse;
6329}
6330
6331void CPlatformFlashEngine::StartMovieL(char* aSwfURL, const U8* aSwfData, U32 aSwfLength, TBool aResetIAPAccess, TBool aFirstMovie)
6332{
6333 CleanupStack::PushL(aSwfURL);
6334
6335 // reset deviceID permission check flag.
6336 iAllowPhoneCall = EAllow_NotSet;
6337
6338 iNotifyEndOfMovie = ETrue;
6339
6340 if(aResetIAPAccess)
6341 {
6342 iAllowNetAccessId = EAllow_NotSet;
6343 iPromptForIAP=ETrue; // make the User select again for the next movie...
6344 }
6345
6346 iPanMode = EFalse;
6347
6348 iRedraw = ETrue;
6349
6350 // make sure that soft-keys are reset back to defaults before loading a new movie.
6351 ResetSoftKeys();
6352
6353#ifdef FEATURE_OPENVG
6354 if(iOpenVgMode)
6355 {
6356 //DestroyEgl();
6357
6358 TRAPD(err,CreateEglSurfaceL());
6359 if(err)
6360 {
6361 DestroyEgl(); //cleanup
6362 FreeBits();
6363 iRenderToBitmap = ETrue; //Switch to blitting via wserv
6364 iOpenVgMode = EFalse;
6365
6366 TRect rect(0,0,iFrameBufferSize.iWidth,iFrameBufferSize.iHeight);
6367 ((MFlashEngine*)this)->InitializeL(rect,EFalse);
6368 }
6369 }
6370#endif
6371
6372 iPlayerState = EPlayerOK;
6373
6374 if (aFirstMovie )
6375 {
6376 if(iMMObject)
6377 {
6378 StopTimer();
6379 DestroyPlayer();
6380 if(iSoundHandler)
6381 {
6382 iSoundHandler->StopSound();
6383 iSoundHandler->CleanupCachedFiles(iFs);
6384 }
6385 }
6386 if(!CreatePlayerL())
6387 {
6388 User::LeaveNoMemory();
6389 }
6390 }
6391
6392 //if(!iBrowserPluginActive)
6393 {
6394 /*if(iFlashUI)
6395 iFlashUI->ClearErrors();*/
6396 iFlashClientIf->ClearErrors();
6397 }
6398
6399 ClearBitmap();
6400
6401 TInt count=0;
6402// char** array=AllocReadResourceArrayIntoFlashStringArrayL(count, R_FLASH_SUPPORTED_IMAGE_MIME_TYPES_ARRAY);
6403 char** array= MediaRecognizer::GetImageDecoderSupportedFormatsL(this,count);
6404
6405 iFiObject.FI_SetupDeviceImage((unsigned short)count, (const char**) array);
6406 TInt i;
6407 for(i=0; i<count; i++)
6408 {
6409 delete[] array[i];
6410 }
6411 delete[] array;
6412 array=NULL;
6413
6414// array=AllocReadResourceArrayIntoFlashStringArrayL(count, R_FLASH_SUPPORTED_VIDEO_MIME_TYPES_ARRAY);
6415 TInt resoffset = FlashEngineRscHandler::LoadEngineResourceFileL();
6416 array=MediaRecognizer::GetMMFsupportedFormatsL(this,count, EFalse
6417 ,R_FLASH_SUPPORTED_VIDEO_MIME_TYPES_ARRAY); //get video mime types from MMF
6418
6419 iFiObject.FI_SetupDeviceVideo((unsigned short)count, (const char**) array);
6420 for(i=0; i<count; i++)
6421 {
6422 delete[] array[i];
6423 }
6424 delete[] array;
6425 FlashEngineRscHandler::DeleteEngineResourceFile(iEnv, resoffset);
6426
6427 if(iSoundHandler)
6428 {
6429 iSoundHandler->InitializeSoundL(this);
6430 }
6431
6432 iFiObject.FI_SetFrameBuffer( NULL, (TUint16)iFrameBufferSize.iWidth, (TUint16)iFrameBufferSize.iHeight,
6433 FrameBufferPitch(), FrameBufferDisplayFormat());
6434
6435 FI_Rect fiRect;
6436 fiRect.xmin = (short) iRect.xmin;
6437 fiRect.ymin = (short) iRect.ymin;
6438 fiRect.xmax = (short) iRect.xmax;
6439 fiRect.ymax = (short) iRect.ymax;
6440
6441 if (!iFiObject.FI_SetDisplayRect(&fiRect ))
6442 {
6443 PLAYEROUTPUT ("PlatformBitBuffer error");
6444 }
6445
6446 else
6447 {
6448 if (iWindowMode != EWindow)
6449 {
6450#if defined (FEATURE_WINDOWLESS) && defined(FEATURE_BG_TRANSPARENCY)
6451 iFiObject.FI_SetBackgroundAlpha(iConfig.iBackgroundAlpha, EFalse);
6452#endif
6453 }
6454 /*
6455#ifdef FEATURE_BG_TRANSPARENCY
6456 if(iConfig.iBackgroundAlpha < 255)
6457 {
6458 iFiObject.FI_SetBackgroundAlpha(iConfig.iBackgroundAlpha, iConfig.iPlayerBlendsBackground);
6459 }
6460#endif //FEATURE_BG_TRANSPARENCY
6461*/
6462
6463 TBool couldBeSVG = EFalse;
6464 TBool couldBeSWF = EFalse;
6465
6466 if (aSwfLength > KLongestFirstFewBytesData)
6467 {
6468 TPtrC8 content(aSwfData, aSwfLength);
6469
6470 if (content.Left(KSWFFileFirstFewBytes.iTypeLength).CompareF(KSWFFileFirstFewBytes) == 0)
6471 {
6472 couldBeSWF = ETrue;
6473 }
6474 else if (content.Left(KSWCFileFirstFewBytes.iTypeLength).CompareF(KSWCFileFirstFewBytes) == 0)
6475 {
6476 couldBeSWF = ETrue;
6477 }
6478 else if (iConfig.iMode & KSupportSVG)
6479 {
6480 if (content.FindF(KSvgFileFirstFewBytes) >= 0)
6481 {
6482 couldBeSVG = ETrue;
6483 }
6484 else if(content.Left(KSvgzFile1FirstFewBytes.iTypeLength).CompareF(KSvgzFile1FirstFewBytes) == 0)
6485 {
6486 couldBeSVG = ETrue;
6487 }
6488 else if(content.Left(KSvgzFile2FirstFewBytes.iTypeLength).CompareF(KSvgzFile2FirstFewBytes) == 0)
6489 {
6490 couldBeSVG = ETrue;
6491 }
6492 }
6493
6494 }
6495
6496 if (couldBeSWF)
6497 {
6498 iSvgMode = EFalse;
6499
6500 FI_CodePage fiCodepage;
6501 TInt codepage;
6502 GetLanguageInfo(codepage, fiCodepage);
6503
6504 ChangeCodePageL(codepage);
6505
6506 // Set the native codepage on the Flash Lite player
6507 iFiObject.FI_SetNativeCodePage(fiCodepage);
6508 iFiObject.FI_SetTextFieldBoundaryBehavior( FI_TextFieldExitsFirstAndLastLineBoundary | FI_TextFieldCursorCyclesStartAndEndBoundary );
6509 FI_SecuritySandbox sSandbox = FI_UseDefault; //dont change this default value, if FI_LocalTrusted set
6510 //then browser streaming cases get messed up
6511
6512 const char* ptrUrlSchemeStripped = StripPrefix( aSwfURL, "file://" );
6513 if(ptrUrlSchemeStripped)
6514 {
6515 //Trusted folder set by the host , so return FI_LocalTrusted, do not change this.
6516 //This is required for ATS security, cross scripting, loadVars and MSO to pass
6517 //else is UseDefault(default sandbox) where core player will decide the sandbox.
6518 TPtrC8 pSwfUrl( (TText8*)ptrUrlSchemeStripped );
6519 //Check if the content is prest in default trust directory
6520 if (CanContentBeTrusted(pSwfUrl))
6521 {
6522 sSandbox = FI_LocalTrusted;
6523
6524 }
6525 //In automation mode, security sandbox prompts should be disabled
6526 #if defined(FEATURE_PERFORMANCE_AUTOMATION) || defined(FEATURE_ATS_AUTOMATION) || defined(FEATURE_TESTAUTOMATION)
6527 if((iConfig.iMode & KPlayerInATSMode) || (iConfig.iMode & KPerformanceTestMode))
6528 {
6529 if(KErrNotFound == pSwfUrl.FindF(KNoAutoTrust))
6530 {
6531 sSandbox = FI_LocalTrusted;
6532
6533 }
6534 }
6535 #endif
6536
6537 //here falsh stub applications can be in trusted sandbox.
6538 if(InstanceInTrustedSandBox())
6539 {
6540 sSandbox = FI_LocalTrusted;
6541
6542 }
6543 //SecuritySandbox
6544 if(/*!iBrowserPluginActive && */sSandbox != FI_LocalTrusted)
6545 {
6546 HBufC *pathToDisplay = CreateEpocStringLC(ptrUrlSchemeStripped, FlashStrLen(ptrUrlSchemeStripped));
6547
6548 TPtrC fileName = pathToDisplay->Des();
6549 //Check if content is already trusted by user
6550 if(IsContentTrustedL(fileName))
6551 {
6552 sSandbox = FI_LocalTrusted;
6553 }
6554
6555 CleanupStack::PopAndDestroy(pathToDisplay);
6556 }
6557
6558 }
6559 //eroom761 fix:
6560 if (iHTMLBaseURL != NULL)
6561 {
6562 struct FI_BrowserURLInfo pURLInfoIn;
6563
6564 if (iEngineSecurityContextUrl)
6565 {
6566 pURLInfoIn.pURLIn = (const char*)(iEngineSecurityContextUrl->Des().Ptr());
6567 }
6568 else
6569 {
6570 pURLInfoIn.pURLIn = (const char*)(iHTMLBaseURL->Des().Ptr());
6571 }
6572
6573 if(sSandbox == FI_LocalTrusted )
6574 pURLInfoIn.bIsTrusted = ETrue;
6575 else
6576 pURLInfoIn.bIsTrusted = EFalse;
6577 pURLInfoIn.pageAccessType = EPageUrlNormal;
6578
6579 iFiObject.FI_SetContainerSecurityContext(&pURLInfoIn);
6580 }
6581
6582 if((iAllowScriptAccess >= 0 ) && (iAllowScriptAccess <= 2 ))
6583 {
6584 iFiObject.FI_SetScriptAccess(iAllowScriptAccess);
6585 }
6586
6587
6588 if (iFiObject.FI_SetSWFDataBuffer( aSwfURL, aSwfData, aSwfLength, false, FI_SwfBufferCopy, sSandbox ))
6589 {
6590 iIsRunning = ETrue;
6591 StartTimer();
6592 iPauseFlags = ENotPaused;
6593 }
6594
6595
6596 if(iFlashVarsPresent)
6597 {
6598
6599 if(iFlashVarVal)
6600 {
6601 RBuf8 params;
6602 params.ReAlloc( ( iFlashVarVal->Length() + 1 ) );
6603 params.Copy( *iFlashVarVal );
6604 CleanupClosePushL( params );
6605 iFiObject.FI_SetFlashVars( (const char*)( params.PtrZ()),ETrue );
6606 //Free memory
6607 CleanupStack::PopAndDestroy( ¶ms );
6608 }
6609 }
6610
6611 #ifdef __FEATURE_PRE_COMPILED_SWF
6612 SetPreInstalledASClassL( );
6613
6614 #ifdef FEATURE_BINDING_PREINSTALLED_LIB
6615 iFiObject.FI_SetPreInstalledASClass(KAsLibrarySwfData,KAsLibrarySwfFileSize,EFalse);
6616 #endif //FEATURE_BINDING_PREINSTALLED_LIB
6617
6618 #endif //__FEATURE_PRE_COMPILED_SWF
6619 }
6620 else if (couldBeSVG)
6621 {
6622 if (iConfig.iMode & KSupportSVG)
6623 {
6624 iSvgMode = ETrue;
6625 ChangeCodePageL(KCharacterSetIdentifierUtf8);
6626 if (iFiObject.FI_SetSVGDataBuffer( aSwfURL, aSwfData, aSwfLength ))
6627 {
6628 iIsRunning = ETrue;
6629 StartTimer();
6630 iPauseFlags = ENotPaused;
6631 }
6632 }
6633 }
6634 }
6635
6636 CleanupStack::PopAndDestroy(aSwfURL);
6637
6638 //if(!iBrowserPluginActive)
6639 if(iExecutionMode == eStandAlone)
6640 {
6641 SetQuality(iQuality);
6642 }
6643 //if (iBrowserPluginActive && iMMObject)
6644 if((iExecutionMode == ePlugin) && iMMObject)
6645 {
6646 iFiObject.FI_SetLooping(iLoop );
6647 iFiObject.FI_SetQuality(iSwfQuality);
6648 if(iBackgroundColorPresent)
6649 {
6650 iFiObject.FI_SetBackgroundColor( iRed, iGreen, iBlue );
6651 }
6652 }
6653 //if(iBrowserPluginActive && iScaleValue >=0)
6654 if((iExecutionMode == ePlugin) && iScaleValue >=0)
6655 {
6656#ifdef FEATURE_WEB_BROWSABILITY
6657 iFiObject.FI_SetScaleMode(iScaleValue);
6658#endif
6659 }
6660
6661 //if(iBrowserPluginActive && iAlignValue >= 0)
6662 if(iExecutionMode == ePlugin)
6663 {
6664#ifdef FEATURE_WEB_BROWSABILITY
6665 if (iAlignValue >= 0)
6666 {
6667 iFiObject.FI_SetAlignMode(iAlignValue);
6668 }
6669
6670 iFiObject.FI_SetAllowNetworking(iAllowNetworking);
6671#endif
6672 }
6673
6674
6675 //Moving iFiObject.FI_SetBaseURL here
6676 if (iHTMLBaseURL!= NULL)
6677 iFiObject.FI_SetBaseURL((const char*)iHTMLBaseURL->Des().Ptr());
6678
6679 iSwfStarted = ETrue;
6680}
6681
6682TUint16 CPlatformFlashEngine::FrameBufferPitch()
6683{
6684 TUint16 pitch = 0;
6685#ifdef FEATURE_OPENVG
6686 if(iOpenVgMode) {
6687 pitch = iFrameBufferSize.iWidth * TDisplayModeUtils::NumDisplayModeBitsPerPixel(iDisplayFormat);
6688 }
6689 else
6690#endif
6691 {
6692 if(iWindowMode == EWindow)
6693 {
6694 pitch = iBitmap->DataStride();
6695 }
6696#ifdef FEATURE_WINDOWLESS
6697 else
6698 {
6699 pitch = iWlessSurface->DataStride();
6700 }
6701#endif
6702 }
6703
6704 return pitch;
6705}
6706
6707char** CPlatformFlashEngine::AllocReadResourceArrayIntoFlashStringArrayL(TInt& aCount, TInt aResourceId)
6708{
6709 CDesCArray* array = iEnv->ReadDesC16ArrayResourceL(aResourceId);
6710 CleanupStack::PushL(array);
6711 aCount=array->Count();
6712
6713 char** charArray=new(ELeave) char* [aCount];
6714 CleanupStack::PushL(charArray);
6715
6716 TInt i = 0;
6717 for(i=0;i<aCount;i++)
6718 {
6719 charArray[i]=CreateFlashStringLC(array->MdcaPoint(i));
6720 }
6721
6722 CleanupStack::Pop(i+1,charArray);
6723 CleanupStack::PopAndDestroy(array);
6724 return charArray;
6725}
6726
6727
6728#ifdef LOG_MESSAGE
6729_LIT(KDateString1,"%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B");
6730_LIT(KDateString2,"%:0%H%:1%T%:2%S.%C%:3\n");
6731const unsigned short KDateStrLength = 30;
6732
6733void CPlatformFlashEngine::WriteLogMsgL(const char* aMsg, const TBool aShowElapsedTime)
6734#else
6735void CPlatformFlashEngine::WriteLogMsgL(const char* /*aMsg*/, const TBool /*aShowElapsedTime*/)
6736#endif
6737 {
6738#ifdef LOG_MESSAGE
6739 TInt endOfFile = 0;
6740 TTime currentTime;
6741 currentTime.HomeTime();
6742
6743 TBuf<KDateStrLength> dateString;
6744 currentTime.FormatL(dateString, KDateString2);
6745 char* cDateTimeStr = CreateFlashString( dateString );
6746
6747 TBuf8<256> cStr;
6748 cStr.Append(TPtrC8((TUint8*)cDateTimeStr));
6749 delete cDateTimeStr;
6750
6751 cStr.Append(KLitLogSeparator);
6752 cStr.Append(TPtrC8((TUint8*)aMsg));
6753
6754 if (iLogFile)
6755 {
6756 iLogFile->Write(cStr);
6757 iLogFile->Flush();
6758 iLogFile->Close();
6759 User::LeaveIfError(iLogFile->Open(iFs, KFlashLogFile, EFileWrite | EFileShareExclusive));
6760 iLogFile->Seek(ESeekEnd, endOfFile);
6761 }
6762
6763 if (aShowElapsedTime)
6764 {
6765 cStr.Copy(KLitElapsedTime);
6766 currentTime.UniversalTime();
6767 TTimeIntervalMicroSeconds elaspedMicroSec = currentTime.MicroSecondsFrom(iLastTimeStamp);
6768 cStr.AppendNum(elaspedMicroSec.Int64());
6769 cStr.Append(KLitCrCr);
6770
6771 if (iLogFile)
6772 {
6773 iLogFile->Write(cStr);
6774 iLogFile->Flush();
6775 iLogFile->Close();
6776 User::LeaveIfError(iLogFile->Open(iFs, KFlashLogFile, EFileWrite | EFileShareExclusive));
6777 iLogFile->Seek(ESeekEnd, endOfFile);
6778 }
6779 }
6780#endif // LOG_MESSAGE
6781}
6782
6783#ifdef LOG_MESSAGE
6784void CPlatformFlashEngine::WriteLogMsgWithIntL(const char* aMsg, TInt aNum)
6785#else
6786void CPlatformFlashEngine::WriteLogMsgWithIntL(const char* /*msg*/, TInt /*aNum*/)
6787#endif
6788{
6789#ifdef LOG_MESSAGE
6790 TInt endOfFile = 0;
6791 TTime currentTime;
6792 currentTime.HomeTime();
6793 TBuf<KDateStrLength> dateString;
6794 currentTime.FormatL(dateString, KDateString2);
6795 char* cDateTimeStr = CreateFlashString( dateString );
6796
6797 TBuf8<256> cStr;
6798 cStr.Append(TPtrC8((TUint8*)cDateTimeStr));
6799 delete cDateTimeStr;
6800
6801 cStr.Append(KLitLogSeparator);
6802 cStr.Append(TPtrC8((TUint8*)aMsg));
6803 cStr.Append(KLitValSep);
6804 cStr.AppendNum(aNum);
6805 cStr.Append(KLitCrCr);
6806 if (iLogFile)
6807 {
6808 iLogFile->Write(cStr);
6809 iLogFile->Flush();
6810 iLogFile->Close();
6811 User::LeaveIfError(iLogFile->Open(iFs, KFlashLogFile, EFileWrite | EFileShareExclusive));
6812 iLogFile->Seek(ESeekEnd, endOfFile);
6813 }
6814
6815#endif // LOG_MESSAGE
6816}
6817
6818void CPlatformFlashEngine::PlayStep( TBool canInterrupt )
6819{
6820 /*
6821 This condition is to ensure that there is no recursive FI_DoPlay call.
6822
6823 There is a possibility of a recursive call if CActiveSchedulerWait is used any of the SI calls or AS Extension/fscommand2 implementation.
6824 e.g: when a dialog box is displayed - wherein, the currently AO RunL is suspended, while another doplay is free
6825 to be scheduled from a different timer. (low priority timer or platform timer).
6826
6827 This condition is not mandatory as FI_DoPlay itself has a recursive FI guard. However, any FI calls tailing DoPlay,
6828 inside the same RunL or another AO might fail as it might be called from within an ongoing but suspended DoPlay.
6829 */
6830 if (iInDoPlay)
6831 {
6832 return;
6833 }
6834
6835 if (!iMMObject)
6836 {
6837 return;
6838 }
6839 TUint16 tstatus;
6840 TUint16 pstatus;
6841 if (iSvgMode)
6842 {
6843#ifdef FEATURE_OPENVG
6844 SetCurrentEglContext();
6845#endif
6846 pstatus = iFiObject.FI_DoPlay(true);
6847 tstatus = pstatus & 0xFFCF;
6848 }
6849 else
6850 {
6851#ifdef PERFORMANCE_LOG
6852 // Log time information to a file
6853 TRAPD(err,WriteLogMsgL("Before calling DoPlay\n", FALSE));
6854 iLastTimeStamp.UniversalTime();
6855#endif // PERFORMANCE_LOG
6856
6857 if( iFrameBufferResized && !iInDoPlay )
6858 {
6859 TRAPD(err, InitializeL(iInitInfo.iRect, iInitInfo.iResize, iInitInfo.iLandscape));
6860 if (err != KErrNone)
6861 {
6862 NotifyClientError(EGeneralError, ETrue, ETrue);
6863 }
6864 iFrameBufferResized = EFalse;
6865 }
6866
6867#ifdef FEATURE_OPENVG
6868 SetCurrentEglContext();
6869#endif
6870
6871 iInDoPlay = ETrue;
6872 pstatus = iFiObject.FI_DoPlay(false);
6873 //This is required because core player does a or of two return values.
6874 //FI_DoPlayFrameRateLagging and FI_DoPlayActionsPendingFlag have been introduced in Flashlite3.1.6
6875 //These can be used of improving performance.
6876 tstatus = pstatus & 0xFFCF;
6877 iInDoPlay = EFalse;
6878
6879 // In case of these two error codes, DoPlay() need to be reexecuted.
6880 if( pstatus == FI_RenderingInterruptedByTimeout || pstatus == FI_SystemInterrupt )
6881 {
6882#ifdef FEATURE_OPENVG
6883 SetCurrentEglContext();
6884#endif
6885 iInDoPlay = ETrue;
6886 pstatus = iFiObject.FI_DoPlay(false);
6887 tstatus = pstatus & 0xFFCF;
6888 iInDoPlay = EFalse;
6889 }
6890
6891#ifdef PERFORMANCE_LOG
6892 TRAPD(err, WriteLogMsgL("After calling DoPlay\n", TRUE));
6893#endif // PERFORMANCE_LOG
6894
6895 }
6896
6897 if (iPlayerState == EPlayerStoppedError)
6898 {
6899 // reset soft keys
6900 AbortPlayer();
6901 }
6902
6903 if(iReplayFlag)
6904 {
6905 TInt temp = iZoomFactor;
6906 iZoomFactor = 0;
6907 TInt dummy;
6908 while(temp)
6909 {
6910 Zoom(EZoomIn,dummy);
6911 temp--;
6912 }
6913 //iZoomFactor = iZoomFactor/2;
6914 iReplayFlag = EFalse;
6915 }
6916
6917#ifndef USE_VPU2
6918 CFLPlatformDecoderInterface* decoderInstance = NULL;
6919
6920 if(iConfig.iHelixFlvMode )
6921 {
6922
6923 for(TInt n=0; n < iFlvDecoderArray.Count(); n++)
6924 {
6925 decoderInstance = iFlvDecoderArray[n];
6926
6927 if( !decoderInstance ) continue;
6928
6929 TTimeIntervalMicroSeconds videoPosition = decoderInstance->GetVideoPosition();
6930
6931 if(videoPosition.Int64() < KMaxVideoPositioToBlt)
6932 {
6933 DrawVideoRect();
6934 }
6935 }
6936 }
6937#endif
6938
6939 switch(tstatus)
6940 {
6941 case FI_FrameBufferNotUpdated:
6942 break;
6943
6944 case FI_FrameBufferUpdated:
6945 case FI_DoPlayFrameRateLagging:
6946 {
6947 //Backlight handling moved to ExtendBacklightForVideoPlayback
6948 DrawBitBuffer();
6949
6950 }
6951 break;
6952
6953 case FI_RenderingInterruptedByTimeout:
6954 case FI_SystemInterrupt:
6955 {
6956 //This makes the doplay synchronous if doplay to long time it starves the other threads.
6957 //pstatus = iFiObject.FI_DoPlay(false);
6958 }
6959 break;
6960
6961 // handle error cases
6962 case FI_FrameBufferUpdatedWithError:
6963 {
6964 if( (iFLVPlayStat) && (iFLVStatus!=ENetStreamPlayStop) && (iFLVStatus!=ENetStreamPlayPause) )
6965 {
6966 ExtendBacklight(1);
6967 }
6968 DrawBitBuffer();
6969 }
6970 break;
6971
6972 case FI_FrameBufferNotUpdatedWithError:
6973 case FI_RenderingInterruptedByTimeoutWithError:
6974 case FI_SystemInterruptWithError:
6975 break;
6976
6977 default: return;
6978 }
6979
6980
6981#if defined(FEATURE_PERFORMANCE_AUTOMATION) || defined(FEATURE_ATS_AUTOMATION) || defined (FEATURE_TESTAUTOMATION)
6982 if((iConfig.iMode & KPlayerInATSMode) || (iConfig.iMode & KPerformanceTestMode))
6983 {
6984 User::ResetInactivityTime();
6985 }
6986#endif
6987
6988 //notify client that play is ended if Loop is 1
6989 if ((KLoopOff == iLoop)
6990 && iNotifyEndOfMovie
6991 && (iFiObject.FI_FrameNumber() >= iFiObject.FI_NumberOfFrames()))
6992 {
6993 NotifyFlashStatus(EPlayComplete,NULL);
6994 iNotifyEndOfMovie = EFalse;
6995 }
6996
6997 if (iRequestedScreenChange && !iInDoPlay)
6998 {
6999 if ((iChangeScreenSizeRequest == EChangeScreenFullScreen)
7000 && !PlayerStoppedWithError())
7001 {
7002 MDisplay* display = iFlashClientIf->GetDisplay();
7003 TRAPD(err, display->SetFullScreenL());
7004 if (err != KErrNone)
7005 {
7006 //iFlashUI->NotifyClientError(EGeneralError, ETrue, ETrue);
7007 MUserNotiferIf* userNotifierIf =
7008 iFlashClientIf->GetUserNotifierIf();
7009 if (userNotifierIf)
7010 userNotifierIf->NotifyClientError(EGeneralError, ETrue, ETrue);
7011 }
7012 }
7013 else if ((iChangeScreenSizeRequest == EChangeScreenAppScreen)
7014 && !PlayerStoppedWithError())
7015 {
7016 MDisplay* display = iFlashClientIf->GetDisplay();
7017 TRAPD(err, display->SetAppScreenL());
7018 if (err != KErrNone)
7019 {
7020 //iFlashUI->NotifyClientError(EGeneralError, ETrue, ETrue);
7021 MUserNotiferIf* userNotifierIf =
7022 iFlashClientIf->GetUserNotifierIf();
7023 if (userNotifierIf)
7024 userNotifierIf->NotifyClientError(EGeneralError, ETrue, ETrue);
7025 }
7026 }
7027 iRequestedScreenChange = EFalse;
7028 iChangeScreenSizeRequest = EChangeScreenNull;
7029 }
7030
7031#ifdef FORCE_REFRESH_WORKAROUND
7032 if(iForceRedraw)
7033 {
7034 ForceRedraw();
7035 }
7036#endif
7037
7038}
7039
7040
7041TUint8 ParseHexCharL(TChar ch)
7042{
7043 TUint c = ch;
7044 if ( '0' <= c && c <= '9' )
7045 {
7046 c = c-'0';
7047 }
7048 else if ( 'A' <= c && c <= 'F' )
7049 {
7050 c = c-'A'+KAsciiOffset;
7051 }
7052 else if ( 'a' <= c && c <= 'f' )
7053 {
7054 c = c-'a'+KAsciiOffset;
7055 }
7056 else
7057 {
7058 User::Leave(KErrCorrupt);
7059 }
7060 return (TUint8)c;
7061}
7062
7063HBufC8* DecodeURLDes8LC(const TDesC8& aURL)
7064{
7065 // alloc buffer to return. We know this is big enough since unescaping only makes URL smaller
7066 HBufC8* hBufURLDecoded = HBufC8::NewLC(aURL.Length());
7067 TPtr8 ptrURLDecoded = hBufURLDecoded->Des();
7068 for (TInt i = 0; i < aURL.Length(); i++)
7069 {
7070 TUint8 c = aURL[i];
7071 if ('%' == c && (i+2 < aURL.Length()))
7072 {
7073 TChar h1 = aURL[++i]; // MSB
7074 TChar h2 = aURL[++i]; // LSB
7075 TUint8 n1 = ParseHexCharL(h1);
7076 TUint8 n2 = ParseHexCharL(h2);
7077 c = static_cast<TUint8>((n1 * 16) + n2);
7078 }
7079 ptrURLDecoded.Append(c);
7080 }
7081 return hBufURLDecoded;
7082}
7083
7084HBufC* CPlatformFlashEngine::ConvertEncodingLC(const TDesC8& aStr, TBool aIsEncoded, TBool aIsUTF8)
7085//
7086// Convert URL data from 8-bit ANSI/MBCS/UTF=8 to unicode and decode
7087//
7088{
7089 HBufC* hBufUrlConverted = NULL;
7090 if (iCharacterConverter)
7091 {
7092 TPtrC8 ptrURL(aStr);
7093 hBufUrlConverted = HBufC::NewLC(ptrURL.Length());
7094 TPtr ptrUrlConverted = hBufUrlConverted->Des();
7095
7096 HBufC8* hBuf8UrlDecoded = NULL;
7097
7098 if (aIsEncoded)
7099 {
7100 // need to decode prior to conversion to Unicode
7101 hBuf8UrlDecoded = DecodeURLDes8LC(aStr);
7102 ptrURL.Set(*hBuf8UrlDecoded);
7103 }
7104
7105 if (aIsUTF8)
7106 {
7107 ChangeCodePageL(KCharacterSetIdentifierUtf8);
7108 }
7109
7110 // convert to Unicode
7111 TInt state = CCnvCharacterSetConverter::KStateDefault;
7112 iCharacterConverter->ConvertToUnicode(ptrUrlConverted, ptrURL, state);
7113
7114
7115 // cleanup
7116 if (hBuf8UrlDecoded)
7117 {
7118 CleanupStack::PopAndDestroy(hBuf8UrlDecoded);
7119 }
7120 }
7121 else
7122 {
7123 User::Leave(KErrNotReady);
7124 }
7125
7126 return hBufUrlConverted;
7127}
7128
7129HBufC* CPlatformFlashEngine::ConvertToUnicodeLC(const TDesC8& aStr, TBool aIsUTF8)
7130//
7131// Convert URL data from 8-bit ANSI/MBCS/UTF=8 to unicode
7132//
7133{
7134 HBufC* hBufUrlConverted = NULL;
7135 if (iCharacterConverter)
7136 {
7137 TPtrC8 ptrURL(aStr);
7138 hBufUrlConverted = HBufC::NewLC(ptrURL.Length());
7139 TPtr ptrUrlConverted = hBufUrlConverted->Des();
7140
7141 if (aIsUTF8)
7142 {
7143 ChangeCodePageL(KCharacterSetIdentifierUtf8);
7144 }
7145
7146 // convert to Unicode
7147 TInt state = CCnvCharacterSetConverter::KStateDefault;
7148 iCharacterConverter->ConvertToUnicode(ptrUrlConverted, ptrURL, state);
7149
7150 }
7151 else
7152 {
7153 User::Leave(KErrNotReady);
7154 }
7155
7156 return hBufUrlConverted;
7157}
7158
7159unsigned short CPlatformFlashEngine::HandleURLL(struct MM_Object* aMMObj, struct FI_GetURLCallInfo* aUrlInfo)
7160//
7161// Main handler in the engine responsible for parsing/converting and acting on URLs
7162// passes processed URL onto other handlers such as HandleTelURLL(), HandleMailToL() etc.
7163//
7164{
7165 const TChar KPostDataSeparator('?');
7166 const TChar KColon(':');
7167 unsigned short retVal = 0;
7168 // URL is always 8-bit data, either in UTF-8 or ANSI/MBCS
7169 // URL may also be encoded (http://www.blooberry.com/indexdot/html/topics/urlencoding.htm)
7170
7171 // Note, that even if useCodePage is true (i.e. ANSI/MBCS) we may be sent a (part) URL in UTF-8 - see table below
7172
7173 /*
7174
7175 1. Non-ASCII strings are variables outside of getURL call.
7176
7177 | useCodePage = false | useCodePage = true
7178 ==========================================================================
7179 getURL
7180 url attached data | url-encoded UTF-8 strings | url-encoded MBCS strings
7181 postData | url-encoded UTF-8 strings | url-encoded MBCS strings
7182
7183 2. Non-ASCII strings are part of the url in the getURL call.
7184
7185 | useCodePage = false | useCodePage = true
7186 ==========================================================================
7187 url | UTF-8 strings | UTF-8 strings
7188
7189 */
7190
7191 // so we may need to do some processing on the URL before passing to apps
7192 // this means decoding (removing % chars) prior to converting if necessary
7193 // code based on changes made to Win32 harness in changelist 180326 by jzengh
7194
7195 if(!aUrlInfo)
7196 return false;
7197 TBool urlIsUTF8 = aUrlInfo->isUTF8;
7198 TBool urlIsEncoded = aUrlInfo->isURLEncoded;
7199
7200 TPtrC8 ptrUrl((TUint8*)aUrlInfo->url, aUrlInfo->urlLength); // raw url passed in
7201 HBufC* hBufURL = NULL;
7202
7203 // handle URL
7204 if (ptrUrl.Locate(KColon) != KErrNotFound)
7205 {
7206 TInt queryStrStartPos = ptrUrl.Locate(KPostDataSeparator);
7207 if (queryStrStartPos == KErrNotFound)
7208 {
7209 hBufURL = CreateEpocStringLC(aUrlInfo->url, aUrlInfo->urlLength);
7210 }
7211 else
7212 {
7213 // We only want to convert/decode the query string (after the '?')
7214 TPtrC8 ptrPureURL = ptrUrl.Left(queryStrStartPos);
7215 TPtrC8 ptrQueryStr = ptrUrl.Mid(queryStrStartPos);
7216
7217 HBufC* hBufQueryStr = NULL;
7218 HBufC* hBufPureStr = NULL;
7219
7220 // if the URL has got a query string, but it's not an http or
7221 // https address then it must be for another messaging app, so we
7222 // need to decode query string before we can pass it to the mail
7223 // app.
7224 if ( (ptrUrl.Find(KProtocolPrefixHttp) == 0) ||
7225 (ptrUrl.Find(KProtocolPrefixHttps) == 0) )
7226 {
7227 // If URL starts with http:// or https://
7228 // do 8 bit to 16 bit conversion.
7229 hBufQueryStr = ConvertToUnicodeLC(ptrQueryStr, urlIsUTF8);
7230 }
7231 else
7232 {
7233 hBufQueryStr = ConvertEncodingLC(ptrQueryStr, urlIsEncoded, urlIsUTF8);
7234 hBufPureStr = ConvertEncodingLC(ptrPureURL, urlIsEncoded, urlIsUTF8);
7235 }
7236 TInt len = ptrPureURL.Length();
7237 if(hBufPureStr)
7238 {
7239 len = hBufPureStr->Length();
7240 }
7241
7242 hBufURL = HBufC::NewLC(ptrPureURL.Length() + hBufQueryStr->Length());
7243 TPtr ptrBufURL = hBufURL->Des();
7244 if (hBufPureStr)
7245 {
7246 ptrBufURL.Copy(*hBufPureStr);
7247 }
7248 else
7249 {
7250 ptrBufURL.Copy(ptrPureURL);
7251 }
7252 ptrBufURL.Append(*hBufQueryStr);
7253 CleanupStack::Pop(hBufURL);
7254 if (hBufPureStr)
7255 {
7256 CleanupStack::PopAndDestroy(hBufPureStr);
7257 }
7258 CleanupStack::PopAndDestroy(hBufQueryStr);
7259 CleanupStack::PushL(hBufURL);
7260 }
7261
7262 // URL has a scheme
7263 TPtrC ptrUrlSchemeStripped;
7264 if (StripPrefix(*hBufURL, KProtocolPrefixVideoCall, ptrUrlSchemeStripped))
7265 {
7266 // video call should be supported, but the Series60 SDKs do not have any APIs yet...
7267 retVal = 0;
7268 }
7269 else if (StripPrefix(*hBufURL, KProtocolPrefixTelCall, ptrUrlSchemeStripped))
7270 {
7271 // tel call
7272 retVal = HandleTelL(ptrUrlSchemeStripped);
7273 }
7274 else if (StripPrefix(*hBufURL, KProtocolPrefixEmail, ptrUrlSchemeStripped))
7275 {
7276 // email
7277 retVal = HandleMailToL(ESMTP, ptrUrlSchemeStripped, ETrue);
7278 }
7279 else if (StripPrefix(*hBufURL, KProtocolPrefixSMS, ptrUrlSchemeStripped))
7280 {
7281 // SMS
7282 retVal = HandleMailToL(ESMS, ptrUrlSchemeStripped, ETrue);
7283 }
7284 else if (StripPrefix(*hBufURL, KProtocolPrefixMMS, ptrUrlSchemeStripped))
7285 {
7286 // MMS
7287 retVal = HandleMailToL(EMMS, ptrUrlSchemeStripped, ETrue);
7288 }
7289 // Note, must check for "unix style" file:/// urls (triple slash) before other style (double slash)
7290 /* AKAR-7UDFZ3: In case of Plugin & Widget mode, we should be passing
7291 * the file:// URL to browser directly, instead of handling it in Host engine side.
7292 * Currently with this change, browser does not launch the URL in case Widget mode,
7293 * changes are required from browser side also(EJPY-7UT74J).
7294 */
7295 //else if (!iBrowserPluginActive &&
7296 else if ((iExecutionMode == eStandAlone) &&
7297 (StripPrefix(*hBufURL, KProtocolPrefixFileUnixStyle, ptrUrlSchemeStripped) ||
7298 StripPrefix(*hBufURL, KProtocolPrefixFile, ptrUrlSchemeStripped)))
7299 {
7300 HandleFileURLL(ptrUrlSchemeStripped, aUrlInfo);
7301 retVal = 1;
7302 }
7303 else if (StripPrefix(*hBufURL, KProtocolPrefixExtendedRenderingMyData, ptrUrlSchemeStripped) ||
7304 StripPrefix(*hBufURL, KProtocolPrefixExtendedRenderingSystem, ptrUrlSchemeStripped))
7305 {
7306 // Do not process any Extended rendering -specific requests
7307 retVal = 0;
7308 }
7309 else
7310 {
7311 // if not one of the above schema, send it to the browser.
7312
7313 // Unfortunately, the WWW_OpenURL message doesn't support post data.
7314 // We'll try to fake it with a GET.
7315 HBufC* hBufPostData = NULL;
7316 HBufC* fullUrl = NULL;
7317 TPtrC ptrFullURL;
7318 unsigned short result = 0;
7319 if (aUrlInfo->postData)
7320 {
7321 // Post data may need to be decoded/converted from UTF-8
7322 TPtrC8 ptrPostData(aUrlInfo->postData,aUrlInfo->postDataLength);
7323 // hBufPostData = ConvertToUnicodeLC(ptrPostData, urlIsUTF8);
7324 // rborcic 2005/09/25 - converting the text to Unicode isn't always valid
7325 // in most cases, it makes more sense to URL encode the non-ASCII data.
7326 hBufPostData = URLEncodePostDataLC(ptrPostData);
7327
7328 if (hBufPostData)
7329 {
7330
7331 // create some allocation space
7332 const TInt maxLen=ptrUrl.Length()+hBufPostData->Length() + 1; // 1 for ?
7333 fullUrl=HBufC::NewLC(maxLen);
7334
7335 // get the heap into a TPtr
7336 TPtr ptr(fullUrl->Des());
7337
7338 // set the data from the URL
7339 HBufC* hBufPureUrl = CreateEpocStringLC((const char*)ptrUrl.Ptr(), ptrUrl.Length());
7340 ptr.Append(*hBufPureUrl);
7341
7342 ReplaceAll(ptr, KCharBackslash, KCharForwardSlash); // To replace any backslash in the URL
7343
7344 //if (iBrowserPluginActive)
7345 if (iExecutionMode == ePlugin)
7346 {
7347 MPluginStreamIf* streamIf = iFlashClientIf->GetStreamIf();
7348 if(streamIf)
7349 {
7350 if(aUrlInfo->target)
7351 {
7352 HBufC* hTargetString = CreateEpocStringLC(aUrlInfo->target, strlen(aUrlInfo->target));
7353 if(hTargetString->Compare(_L("")) != 0)
7354 {
7355 result = streamIf->OpenUrlL(*hBufPureUrl, hTargetString->Des(), *hBufPostData);
7356 }
7357 else
7358 {
7359 result = streamIf->OpenUrlL(*hBufPureUrl, *hBufPostData);
7360 }
7361 CleanupStack::PopAndDestroy(hTargetString);
7362 }
7363 else
7364 {
7365 result = streamIf->OpenUrlL(*hBufPureUrl, *hBufPostData);
7366 }
7367 }
7368 CleanupStack::PopAndDestroy(hBufPureUrl);
7369 CleanupStack::PopAndDestroy(fullUrl);
7370 CleanupStack::PopAndDestroy(hBufPostData);
7371 CleanupStack::PopAndDestroy(hBufURL);
7372
7373 return result;
7374 }
7375 CleanupStack::PopAndDestroy(hBufPureUrl);
7376 ptr.Append(KPostDataSeparator);
7377 ptr.Append(*hBufPostData);
7378 ptrFullURL.Set(*fullUrl);
7379 }
7380 }
7381 else
7382 {
7383 //if (iBrowserPluginActive)
7384 if (iExecutionMode == ePlugin)
7385 {
7386 TPtrC nullDes(NULL, 0);
7387
7388 // create some allocation space
7389 const TInt maxLen=ptrUrl.Length()+ 1; // 1 for ?
7390
7391 // set the data from the URL
7392 HBufC* hBufPureUrl = CreateEpocStringLC((const char*)ptrUrl.Ptr(), ptrUrl.Length());
7393
7394 MPluginStreamIf* streamIf = iFlashClientIf->GetStreamIf();
7395 if(streamIf)
7396 {
7397 if(aUrlInfo->target)
7398 {
7399 HBufC* hTargetString = CreateEpocStringLC(aUrlInfo->target, strlen(aUrlInfo->target));
7400 if(hTargetString->Compare(_L("")) != 0)
7401 {
7402 result = streamIf->OpenUrlL(*hBufPureUrl, hTargetString->Des(), nullDes);
7403 }
7404 else
7405 {
7406 result = streamIf->OpenUrlL(*hBufPureUrl, nullDes);
7407 }
7408 CleanupStack::PopAndDestroy(hTargetString);
7409 }
7410 else
7411 {
7412 result = streamIf->OpenUrlL(*hBufPureUrl, nullDes);
7413 }
7414 }
7415
7416
7417 CleanupStack::PopAndDestroy(hBufPureUrl);
7418 CleanupStack::PopAndDestroy(hBufURL);
7419
7420 return result;
7421 }
7422 ptrFullURL.Set(*hBufURL);
7423 }
7424
7425 // Due to a redraw problem with the Web app, we have to exit flash if we are embedded.
7426 // To exit flash we must leave right back to the Active Scheduler due to CEikAppUi::Exit() design.
7427 // We cannot leave through player code, so must leave in a call stack without player functionality.
7428 // Therefore we will always launch the web browser async, then if we are embedded, we will be able to exit
7429 // cleanly.
7430
7431 //copy what we need, then queue the app for launching...
7432
7433 const TDesC* deses[2];
7434 deses[0]=&KLitBrowser;
7435 deses[1]=&ptrFullURL;
7436
7437 //if (!iBrowserPluginActive)
7438 if(iExecutionMode == eStandAlone)
7439 {
7440 if (QueryAllowNetAccessL())
7441 {
7442 QueueSILaunchL(aMMObj,2, &(deses[0]),NULL,EFalse);
7443 }
7444 }
7445
7446 // cleanup the allocation space - if used
7447 if (fullUrl)
7448 {
7449 CleanupStack::PopAndDestroy(fullUrl);
7450 }
7451 if(hBufPostData)
7452 {
7453 CleanupStack::PopAndDestroy(hBufPostData);
7454 }
7455
7456 retVal = 1;
7457 }
7458 }
7459 else
7460 {
7461 hBufURL = CreateEpocStringLC(aUrlInfo->url, aUrlInfo->urlLength);
7462 retVal = HandleRelativeUrlL(*hBufURL, aUrlInfo);
7463 }
7464 CleanupStack::PopAndDestroy(hBufURL);
7465 return retVal;
7466}
7467
7468
7469void CPlatformFlashEngine::HandleFileURLL(const TDesC& aUrl, struct FI_GetURLCallInfo* aOriginalUrlInfo)
7470{
7471
7472 if (iNewFile)
7473 { // must have received another request between processing the request and the next timer tick.
7474 // Ignore the old request.
7475 delete iNewFile;
7476 iNewFile = NULL;
7477 }
7478
7479
7480 //host needs to search for '?' and remove it and everything after it.
7481 //We can't handle GET style arguments here which was appended and sent by core player.
7482 //Refer eroom:377
7483
7484 TPtrC url = aUrl;
7485 TInt pos = url.Find(KFlhExtraChar);
7486 if(pos != KErrNotFound)
7487 {
7488 url.Set(url.Left(pos));
7489 }
7490
7491 // TODO: do we need to pre-parse the url and replace | char with colon drive delim : ???
7492 TPtrC ptrUrlExt = url.Right(KFlhFileExtensionSWF().Length());
7493
7494 // Copy URL to local buffer where we can manipulate it
7495 HBufC* hBufUrl = url.AllocLC();
7496 TPtr ptrUrl = hBufUrl->Des();
7497 ReplaceAll(ptrUrl,KCharForwardSlash,KCharBackslash);
7498
7499
7500 // check to make sure this is a SWF, otherwise redirect it.
7501 if (ptrUrlExt.CompareF(KFlhFileExtensionSWF) != 0 && ptrUrlExt.CompareF(KFlhFileExtensionSVG) != 0)
7502 {
7503 // redirect
7504 RFile file;
7505 TInt err = file.Open(iFs, *hBufUrl, EFileRead | EFileShareExclusive | EFileStream);
7506 file.Close();
7507 if (err != KErrNone)
7508 {
7509 ForceRefresh();
7510
7511 if (err != KErrNone)
7512 {
7513 //if(!iBrowserPluginActive)
7514 if(iExecutionMode == eStandAlone)
7515 {
7516 //iFlashUI->NotifyDataAccessError((char*)aOriginalUrlInfo->url, ECompleteFailedFileNotFound);
7517 MUserNotiferIf* userNotifierIf =
7518 iFlashClientIf->GetUserNotifierIf();
7519 if (userNotifierIf)
7520 userNotifierIf->NotifyDataAccessError((char*) aOriginalUrlInfo->url,ECompleteFailedFileNotFound);
7521 }
7522 User::Leave(err);
7523 }
7524
7525 }
7526
7527 else
7528 {
7529 HBufC* fileBuf=HBufC::NewLC(KSchemeFile().Length()+aUrl.Length());
7530 TPtr fileURL(fileBuf->Des());
7531 fileURL.Append(KSchemeFile);
7532 fileURL.Append(aUrl);
7533 HandleBrowserURLL(fileURL);
7534 CleanupStack::PopAndDestroy(fileBuf);
7535 }
7536 }
7537 else
7538 {
7539 TPtrC ptrFileURL(*hBufUrl);
7540 // remove leading slashes (now converted to backslashes)
7541 TInt i = 0;
7542 const TInt count = ptrFileURL.Length();
7543 while (i<count && ptrFileURL[i] == KCharBackslash)
7544 {
7545 i++;
7546 }
7547 if(i==count)
7548 {
7549 ptrFileURL.Set(KNullDesC);
7550 }
7551 else
7552 {
7553 ptrFileURL.Set(ptrFileURL.Mid(i));
7554 }
7555 TInt err;
7556 RFile file;
7557
7558 TFileName fname;
7559
7560 if (ptrFileURL.Locate(':') == KErrNotFound)
7561 {
7562 fname.Copy(PathInfo::PhoneMemoryRootPath());
7563 fname.Append(PathInfo::OthersPath());
7564 }
7565
7566 fname.Append(ptrFileURL);
7567
7568 iNewFile = fname.AllocL();
7569
7570 err = file.Open(iFs, *iNewFile, EFileRead | EFileShareExclusive | EFileStream);
7571
7572 if (err != KErrNone)
7573 {
7574 fname.SetLength(0);
7575 if (ptrFileURL.Locate(':') == KErrNotFound)
7576 {
7577 fname.Copy(PathInfo::MemoryCardRootPath());
7578 fname.Append(PathInfo::OthersPath());
7579 }
7580 fname.Append(ptrFileURL);
7581
7582 delete iNewFile;
7583 iNewFile=NULL;
7584
7585 // Save the new file name.. so that we can open it when the Async Event Handler is triggered.
7586 iNewFile = fname.AllocL();
7587
7588 err = file.Open(iFs, *iNewFile, EFileRead | EFileShareExclusive | EFileStream);
7589 }
7590
7591 if (err == KErrNone)
7592 {
7593 file.Close();
7594 TriggerAsyncEvent();
7595 }
7596 else
7597 {
7598 delete iNewFile;
7599 iNewFile = NULL;
7600 ForceRefresh();
7601 //if(!iBrowserPluginActive)
7602 if(iExecutionMode == eStandAlone)
7603 {
7604 //iFlashUI->NotifyDataAccessError((char*)aOriginalUrlInfo->url, ECompleteFailedFileNotFound);
7605 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
7606 if (userNotifierIf)
7607 userNotifierIf->NotifyDataAccessError((char*)aOriginalUrlInfo->url, ECompleteFailedFileNotFound);
7608 }
7609 }
7610 }
7611 CleanupStack::PopAndDestroy(hBufUrl);
7612}
7613
7614HBufC* ResolveRelativeUrlL(const TDesC& aBaseURL, TDesC& aRelURL)
7615{
7616 const TUint16* s = aRelURL.Ptr();
7617 TInt tailSpot = 0;
7618 TInt up = 1;
7619 TInt i;
7620 TInt relURLlen = aRelURL.Length();
7621
7622 for (i=0;i<relURLlen;)
7623 {
7624 if (*s == '.')
7625 {
7626 s++; i++;
7627 if (*s == '.')
7628 {
7629 s++; i++;
7630 if (*s == KCharBackslash || *s == KCharForwardSlash) // handles "../" case
7631 {
7632 up++;
7633 s++; i++;
7634 tailSpot = i;
7635 }
7636 }
7637 else if (*s == KCharBackslash || *s == KCharForwardSlash) // handles "./" case
7638 {
7639 s++; i++;
7640 tailSpot = i;
7641 }
7642 }
7643 else
7644 {
7645 s++; i++;
7646 }
7647 }
7648
7649
7650 TInt strLen = aBaseURL.Length() - 1;
7651 TInt lastSlash = strLen;
7652
7653 for (i=strLen;i>=0;i--)
7654 {
7655 if (aBaseURL[i] == KCharBackslash || aBaseURL[i] == KCharForwardSlash)
7656 {
7657 up--;
7658 if (up == 0)
7659 {
7660 lastSlash = i;
7661 break;
7662 }
7663 }
7664 }
7665
7666 TInt tailLen = relURLlen - tailSpot;
7667 TUint16* pNewURL = new(ELeave) TUint16[lastSlash+tailLen+2];
7668 CleanupStack::PushL(pNewURL);
7669
7670 for (i=0;i<=lastSlash;i++)
7671 {
7672 pNewURL[i] = aBaseURL[i];
7673 }
7674
7675 for (i=0;i<tailLen;i++)
7676 {
7677 pNewURL[i+lastSlash+1] = aRelURL[tailSpot+i];
7678 }
7679 pNewURL[lastSlash+tailLen+1] = '\0';
7680 HBufC* hNewURL = HBufC::NewL(lastSlash+tailLen+2);
7681 hNewURL->Des().Copy(pNewURL);
7682 CleanupStack::PopAndDestroy(pNewURL);
7683
7684 return hNewURL;
7685}
7686
7687
7688unsigned short CPlatformFlashEngine::HandleRelativeUrlL(const TDesC& aUrl, struct FI_GetURLCallInfo* aOriginalUrlInfo)
7689{
7690
7691 unsigned short retVal = 0;
7692 if (iBaseURL == NULL)
7693 {
7694 //if(!iBrowserPluginActive)
7695 if(iExecutionMode == eStandAlone)
7696 {
7697 //iFlashUI->NotifyDataAccessError((char*)aOriginalUrlInfo->url, ECompleteFailedFileNotFound);
7698 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
7699 if (userNotifierIf)
7700 userNotifierIf->NotifyDataAccessError((char*)aOriginalUrlInfo->url, ECompleteFailedFileNotFound);
7701 }
7702 }
7703 else
7704 {
7705 TPtrC ptrUrl = aUrl;
7706 if (ptrUrl[0] == KCharForwardSlash)
7707 {
7708 ptrUrl.Set(ptrUrl.Mid(1));
7709 }
7710
7711 HBufC* hUrl = ptrUrl.AllocLC();
7712 HBufC* newURL = ResolveRelativeUrlL(*iBaseURL, *hUrl);
7713 CleanupStack::PopAndDestroy(hUrl);
7714 CleanupStack::PushL(newURL);
7715
7716 FI_GetURLCallInfo urlInfo;
7717 urlInfo.url = CreateFlashStringL(*newURL);
7718 urlInfo.urlLength = (TUint16)FlashStrLen(urlInfo.url);
7719 urlInfo.pEventInfo = NULL;
7720 urlInfo.postData = NULL;
7721 urlInfo.postDataLength = 0;
7722
7723 retVal = SI_Interface::SI_GetURL(iMMObject, &urlInfo);
7724
7725 delete[] (char*)(urlInfo.url);
7726 CleanupStack::PopAndDestroy(newURL);
7727
7728 }
7729 return retVal;
7730}
7731
7732
7733TUint16 CPlatformFlashEngine::HandleTelL(const TDesC& aTelString)
7734{
7735 // check string for invalid characters
7736 TChar c = 0;
7737 TBuf<KMaxSymbianPhoneNumberLength> sSymbianPhoneNumber;
7738 TBool badChar = EFalse;
7739 TInt count = 0;
7740 for (count = 0; count < aTelString.Length(); count++)
7741 {
7742 c = aTelString[count];
7743 switch (c)
7744 {
7745 // these chars are allowed by Symbian
7746 case '0':
7747 case '1':
7748 case '2':
7749 case '3':
7750 case '4':
7751 case '5':
7752 case '6':
7753 case '7':
7754 case '8':
7755 case '9':
7756 case '#':
7757 case '*':
7758 case '+':
7759 case 'w':
7760 sSymbianPhoneNumber.Append(c);
7761 if (count >= KMaxSymbianPhoneNumberLength)
7762 {
7763 continue;
7764 }
7765 break;
7766
7767 case 'p':
7768 // The RCall::Dial() API ignores everything after the 'p', and some v2 FP1 phones crash when there's a 'p' in
7769 // the dial string, so we might as well ignore everything after the 'p'.
7770 count = aTelString.Length();
7771 continue;
7772
7773 // these chars are OK, but Symbian doesn't like them.
7774 case '(':
7775 case ')':
7776 case ' ':
7777 case '-':
7778 case '.':
7779 break;
7780
7781
7782 default:
7783 badChar = ETrue;
7784 }
7785 }
7786
7787 if (badChar || (count == 0))
7788 {
7789 //if(!iBrowserPluginActive)
7790 {
7791 //iFlashUI->NotifyClientError(EInvalidTelURLError, EFalse, EFalse);
7792
7793 }
7794 return 1;
7795 }
7796 else
7797 {
7798 if (QueryAllowPhoneCallL(sSymbianPhoneNumber))
7799 {
7800 CPhoneMonitor* phoneMonitor = GetPhoneMonitorL();
7801 if(phoneMonitor)
7802 phoneMonitor->MakeCallL(sSymbianPhoneNumber);
7803 }
7804 return 0;
7805 }
7806}
7807
7808void CPlatformFlashEngine::NotifyFocusChangeL(TBool aIsActive)
7809{
7810 if (aIsActive)
7811 {
7812 Pause(EReasonBackground);
7813#ifdef FEATURE_OPENVG
7814 if(iOpenVgMode)
7815 {
7816 if (!IsForegroundTask())
7817 SwitchToSoftwareRendering(ETrue);
7818 else
7819 DestroyEglSurface();
7820 }
7821#endif
7822
7823 }
7824 else
7825 {
7826 if (IsForegroundTask())
7827 {
7828#ifdef FEATURE_OPENVG
7829 if(iOpenVgMode)
7830 {
7831 if(iEGLSurface.surface == EGL_NO_SURFACE && iSwfStarted)
7832 CreateEglSurfaceL();
7833 }
7834 else
7835 {
7836 TBool nativeVideo = EFalse;
7837 if(iConfig.iHelixFlvMode && iFlvDecoderArray.Count())
7838 nativeVideo = ETrue;
7839
7840 if(!nativeVideo)
7841 {
7842#ifdef FEATURE_WATCH_GPU_MEM
7843 if(!iGPUMemLow)
7844#endif
7845 SwitchToHwxRendering(ETrue);
7846 }
7847 }
7848#endif
7849
7850 //if (!iBrowserPluginActive)
7851 if(iExecutionMode == eStandAlone)
7852 {
7853 ResumeL(EReasonBackground, EFalse);
7854 }
7855 //if (iBrowserPluginActive)
7856 else
7857 {
7858 ResumeL(EReasonBackground, ETrue);
7859 }
7860 }
7861 }
7862}
7863
7864void CPlatformFlashEngine::LaunchAppL(TFixedArray<TUid,5>* aUidsOfAppToLaunch, TInt aNumUidsToTry, TInt aArgc, HBufC** aArgv)
7865{
7866 // initialize what is needed and push on the cleanup stack
7867 // find the app
7868 RApaLsSession apaSession;
7869 User::LeaveIfError(apaSession.Connect());
7870 CleanupClosePushL(apaSession);
7871
7872 TInt error=KErrNotFound;
7873 TApaAppInfo info;
7874
7875 for(TInt jj=0;jj<aNumUidsToTry && error;jj++)
7876 {
7877 error=apaSession.GetAppInfo(info,aUidsOfAppToLaunch->At(jj));
7878 }
7879
7880 User::LeaveIfError(error);
7881
7882#if (defined(SYMBIAN_SUPPORT_UI_FRAMEWORKS_V1) || !defined(SYMBIAN_HIDE_UI_FRAMEWORKS_V1)) && !defined(SYMBIAN_REMOVE_UI_FRAMEWORKS_V1)
7883 // now form the command line and run the application...
7884 CApaCommandLine* cl=CApaCommandLine::NewLC();
7885
7886 // append args to string
7887 if ( aArgc > 1 )
7888 {
7889 TInt lenNeeded=0;
7890
7891 for (TInt i=1; i < aArgc; i++)
7892 {
7893 const TDesC* des = aArgv[i];
7894 lenNeeded += des->Length() + 1;
7895 }
7896
7897 HBufC* argBuf = HBufC::NewLC(lenNeeded);
7898 TPtr argPtr = argBuf->Des();
7899
7900 for (TInt j=1; j < aArgc; j++)
7901 {
7902 const TDesC* des = aArgv[j];
7903 argPtr.Append(*des);
7904
7905 if( (j+1) < aArgc )
7906 {
7907 argPtr.Append(KLitSpace);
7908 }
7909 }
7910
7911 cl->SetFullCommandLineL(argPtr);
7912
7913 CleanupStack::PopAndDestroy(argBuf);
7914 }
7915
7916 cl->SetLibraryNameL(info.iFullName);
7917
7918 User::LeaveIfError(apaSession.StartApp(*cl));
7919
7920 CleanupStack::PopAndDestroy(cl);
7921 CleanupStack::PopAndDestroy(&apaSession);
7922
7923#else
7924
7925 TFindFile findFile( iFs );
7926 TInt ret = findFile.FindByDir(info.iFullName, KNullDesC);
7927
7928 CApaCommandLine* cmdLine = CApaCommandLine::NewLC ( );
7929
7930 cmdLine->SetExecutableNameL( findFile.File() );
7931
7932 cmdLine->SetCommandL( EApaCommandOpen );
7933
7934 // append args to string
7935 if ( aArgc > 1 )
7936 {
7937 TInt lenNeeded=0;
7938
7939 for (TInt i=1; i < aArgc; i++)
7940 {
7941 const TDesC* des = aArgv[i];
7942 lenNeeded += des->Length() + 1;
7943 }
7944
7945 HBufC* argBuf = HBufC::NewLC(lenNeeded);
7946 TPtr argPtr = argBuf->Des();
7947
7948 for (TInt j=1; j < aArgc; j++)
7949 {
7950 const TDesC* des = aArgv[j];
7951 argPtr.Append(*des);
7952
7953 if( (j+1) < aArgc )
7954 {
7955 argPtr.Append(KLitSpace);
7956 }
7957 }
7958
7959 cmdLine->SetDocumentNameL(argPtr);
7960 CleanupStack::PopAndDestroy(argBuf);
7961 }
7962
7963 User::LeaveIfError ( apaSession.StartApp(*cmdLine) );
7964 CleanupStack::PopAndDestroy(cmdLine);
7965 CleanupStack::PopAndDestroy(&apaSession);
7966
7967#endif
7968}
7969
7970
7971void CPlatformFlashEngine::LaunchAppL(const TDesC &aPath, const TDesC &aArgs)
7972{
7973 RApaLsSession ls;
7974 User::LeaveIfError(ls.Connect());
7975 CleanupClosePushL( ls );
7976
7977 if ( aArgs == KNullDesC )
7978 {
7979 CApaCommandLine* cmdLine = CApaCommandLine::NewLC ( );
7980 cmdLine->SetExecutableNameL( aPath );
7981 cmdLine->SetCommandL( EApaCommandOpen );
7982 User::LeaveIfError ( ls.StartApp(*cmdLine) );
7983 CleanupStack::PopAndDestroy(cmdLine);
7984 CleanupStack::PopAndDestroy(&ls);
7985 return;
7986 }
7987
7988 TBuf16<256> urlBuf;
7989 TPtrC ptrUrl(aArgs);
7990 if(iFlashUid.iUid==KNullUidValue)
7991 {
7992 TInt resoffset = FlashEngineRscHandler::LoadEngineResourceFileL();
7993 TResourceReader reader;
7994 iEnv->CreateResourceReaderLC(reader,R_FLASH_FLASH_UID_VALUE);
7995 iFlashUid.iUid=reader.ReadInt32();
7996 CleanupStack::PopAndDestroy(); //reader
7997 FlashEngineRscHandler::DeleteEngineResourceFile(iEnv, resoffset);
7998 }
7999 TBool isLocalFile = EFalse;
8000 TPtrC ptrUrlSchemeStripped;
8001 isLocalFile = StripPrefix(ptrUrl, KProtocolPrefixFileUnixStyle, ptrUrlSchemeStripped);
8002 if (!isLocalFile)
8003 {
8004 isLocalFile = StripPrefix(ptrUrl, KProtocolPrefixFile, ptrUrlSchemeStripped);
8005 }
8006
8007 if (isLocalFile)
8008 {
8009 HBufC16* pathBuf = ptrUrlSchemeStripped.AllocLC(); // 2
8010 TPtr16 ptrPath = pathBuf->Des();
8011 ReplaceAll(ptrPath, KCharForwardSlash, KCharBackslash);
8012
8013 RFile file;
8014 TInt errValue = file.Open(iFs, ptrPath, EFileRead);
8015 if (errValue != KErrNone)
8016 {
8017 User::Leave (KErrNotFound);
8018 }
8019 file.Close();
8020 TDataType dataType;
8021 TUid uid;
8022 User::LeaveIfError(ls.AppForDocument(ptrPath, uid, dataType));
8023 if (uid != iFlashUid)
8024 {
8025 TApaTaskList taskList (iEnv->WsSession());
8026 TApaTask task = taskList.FindApp(uid);
8027 if (task.Exists())
8028 {
8029 User::LeaveIfError(task.SwitchOpenFile(ptrPath));
8030 task.BringToForeground();
8031 }
8032 else
8033 {
8034 TThreadId threadId;
8035 User::LeaveIfError(ls.StartDocument(ptrPath, threadId));
8036 }
8037 }
8038 else
8039 {
8040 // Construct URL of form "file://e:/Others/subdir/document.html".
8041 urlBuf.Copy(aArgs);
8042 ReplaceAll(urlBuf, KCharBackslash, KCharForwardSlash);
8043 }
8044 CleanupStack::PopAndDestroy(pathBuf); // 1
8045 }
8046 else
8047 {
8048 urlBuf.Copy(ptrUrl);
8049 ReplaceAll(urlBuf, KCharBackslash, KCharBackslash);
8050 }
8051
8052 TApaTaskList taskList(iEnv->WsSession());
8053 TApaTask task = taskList.FindApp(iFlashUid);
8054 TThreadId id;
8055 ls.StartDocument(urlBuf, id);
8056 CleanupStack::PopAndDestroy(&ls);
8057}
8058
8059void CPlatformFlashEngine::ForceRefresh()
8060{
8061 // ??? We need to clear the frame buffer if the player is not active or
8062 // simply refresh. We don't want the call to FI_UpdateRect. We need to
8063 // fix this.
8064// iFiObject.FI_UpdateRect(rect);
8065
8066 DrawBitBuffer();
8067}
8068
8069
8070void CPlatformFlashEngine::StopPlaying()
8071{
8072 if (iPlayerState != EPlayerStoppedError)
8073 {
8074 iPlayerState = EPlayerStoppedError;
8075 }
8076 else
8077 {
8078 return;
8079 }
8080
8081 iIsRunning = EFalse;
8082 StopTimer();
8083
8084 if(iSoundHandler)
8085 {
8086 iSoundHandler->StopSound();
8087 iSoundHandler->CleanupCachedFiles(iFs);
8088 }
8089}
8090
8091void CPlatformFlashEngine::AbortPlayer()
8092{
8093 if ( iMMObject )
8094 {
8095 StopTimer();
8096 if(iSoundHandler)
8097 {
8098 iSoundHandler->StopSound();
8099 iSoundHandler->CleanupCachedFiles(iFs);
8100 }
8101 DestroyPlayer();
8102 }
8103
8104 //if(!iBrowserPluginActive)
8105 if(iExecutionMode == eStandAlone)
8106 {
8107 TRAP_IGNORE(ResetSoftkeysAndScreenL(iFlashClientIf->GetDisplay())); // abort player should not be able to leave
8108 }
8109}
8110
8111TBool CPlatformFlashEngine::GetCurrentFont(CFont*& aFont)
8112{
8113 if(iCurrentFontId > 0)
8114 {
8115 TBool ret = ETrue;
8116 aFont = iFontMapTable->GetFont(iCurrentFontId);
8117 if(!aFont)
8118 ret = EFalse;
8119
8120 return (ret);
8121 }
8122
8123 //TODO: Can be moved to a function
8124 CFbsBitmapDevice* bitmapDevice = NULL;
8125
8126 if(iWindowMode == EWindow)
8127 {
8128 bitmapDevice = iBitmapDevice;
8129#ifdef FEATURE_OPENVG
8130 if(iOpenVgMode) {
8131 bitmapDevice = iAuxTextBitmapDevice;
8132 }
8133#endif
8134 }
8135#ifdef FEATURE_WINDOWLESS
8136 else
8137 {
8138 bitmapDevice = iWlessDevice;
8139 }
8140#endif
8141
8142 if (!iDefaultFont && bitmapDevice)
8143 {
8144 _LIT(kMyFontName,"SwissA");
8145 TFontSpec myFontSpec(kMyFontName,KDefaultFontSize);
8146 myFontSpec.iFontStyle.SetPosture ( EPostureUpright );
8147 myFontSpec.iFontStyle.SetStrokeWeight ( EStrokeWeightNormal );
8148
8149 bitmapDevice->GetNearestFontInPixels(iDefaultFont, myFontSpec);
8150 iDefaultFontBitmapDevice = bitmapDevice;
8151 }
8152
8153 if (iDefaultFont)
8154 {
8155 aFont = iDefaultFont;
8156 return 1;
8157 }
8158
8159 return 0;
8160}
8161
8162unsigned short CPlatformFlashEngine::SetCurrentFont(void* aPFontId)
8163{
8164 iCurrentFontId = (TInt) aPFontId;
8165 return 1;
8166}
8167
8168unsigned short CPlatformFlashEngine::DestroyFont(void* aPFontId)
8169{
8170 TInt fontId = (TInt)aPFontId;
8171
8172 if(iCurrentFontId == fontId)
8173 iCurrentFontId = 0;
8174
8175 CFont* font = iFontMapTable->GetFontEntryFromFontId(fontId);
8176#ifdef FEATURE_OPENVG
8177 if (iOpenVgMode && font && iAuxTextBitmapDevice)
8178 {
8179 iAuxTextBitmapDevice->ReleaseFont(font);
8180 }
8181 else
8182#endif
8183 {
8184 if(iWindowMode == EWindow)
8185 {
8186 if (font && iBitmapDevice)
8187 {
8188 iBitmapDevice->ReleaseFont(font);
8189 }
8190 }
8191#ifdef FEATURE_WINDOWLESS
8192 else
8193 {
8194 if(font && iWlessDevice)
8195 {
8196 iWlessDevice->ReleaseFont(font);
8197 }
8198 }
8199#endif //FEATURE_WINDOWLESS
8200 }
8201
8202 iFontMapTable->RemoveFontEntry(fontId);
8203
8204 return 1;
8205}
8206
8207/*MFlashClientAppInfo* CPlatformFlashEngine::GetAppInfoIf() const
8208{
8209 return iAppInfo;
8210}*/
8211
8212/*
8213MFlashUI* CPlatformFlashEngine::GetUI()
8214{
8215 return iFlashUI;
8216}
8217
8218MFlashPlugin* CPlatformFlashEngine::GetPlugin()
8219{
8220 return iControl;
8221}
8222*/
8223
8224/* private */
8225CFbsBitGc* CPlatformFlashEngine::GetBitmapContext()
8226{
8227 if(!iRenderToBitmap)
8228 return NULL;
8229
8230 if (iWindowMode == EWindow)
8231 {
8232 if (iBitmapGc)
8233 {
8234 return iBitmapGc;
8235 }
8236 }
8237#ifdef FEATURE_WINDOWLESS
8238 else
8239 {
8240 if (this->iWlessGc)
8241 {
8242 return iWlessGc;
8243 }
8244 }
8245#endif //FEATURE_WINDOWLESS
8246
8247
8248 if (iWindowMode == EWindow)
8249 {
8250 if (KErrNone != iBitmapDevice->CreateContext(iBitmapGc))
8251 {
8252 iBitmapGc = NULL;
8253 }
8254
8255 return iBitmapGc;
8256 }
8257#ifdef FEATURE_WINDOWLESS
8258 else
8259 {
8260 if(iWlessDevice)
8261 {
8262 if (KErrNone != this->iWlessDevice->CreateContext(this->iWlessGc))
8263 {
8264 iWlessGc = NULL;
8265 }
8266
8267 return iWlessGc;
8268 }
8269 }
8270#endif //FEATURE_WINDOWLESS
8271
8272 return NULL;
8273}
8274
8275CFbsBitGc* CPlatformFlashEngine::GetTextBitmapContext()
8276{
8277 CFbsBitGc* gc = NULL;
8278
8279#ifdef FEATURE_OPENVG
8280 if(iOpenVgMode)
8281 {
8282 gc = GetAuxTextBitmapContext();
8283 }
8284 else
8285#endif
8286 {
8287 gc = GetBitmapContext();
8288 }
8289
8290 return gc;
8291}
8292
8293
8294
8295CWindowGc* CPlatformFlashEngine::GetWindowContext()
8296{
8297 if (iWindowGc)
8298 {
8299 delete iWindowGc;
8300 iWindowGc = NULL;
8301 }
8302
8303 CWsScreenDevice* pScreenDevice = iEnv->ScreenDevice();
8304 if ( pScreenDevice->CreateContext(iWindowGc) != KErrNone )
8305 {
8306 iWindowGc = NULL;
8307 }
8308 else
8309 {
8310 MDisplay* display = iFlashClientIf->GetDisplay();
8311 RWindow* lWindow = display->GetWindow();
8312 iWindowGc->Activate(*lWindow);
8313 /*
8314 if(iBrowserPluginActive)
8315 {
8316 RWindow lWindow = iControl->GetWindow();
8317 iWindowGc->Activate(lWindow);
8318 }
8319 else
8320 {
8321 RWindow* lWindow = iFlashUI->GetWindow();
8322 iWindowGc->Activate(*lWindow);
8323 }
8324 */
8325 }
8326 return iWindowGc;
8327}
8328
8329void CPlatformFlashEngine::BeginTextDraw()
8330{
8331}
8332
8333void CPlatformFlashEngine::EndTextDraw()
8334{
8335}
8336
8337TBool CPlatformFlashEngine::DrawTextL(const struct FI_Text* aText, struct FI_TextInfo* aTextInfo, void* aBits, TInt aWidth, TInt aHeight)
8338{
8339
8340 TBool lReturnValue = ETrue;// If Text is not rendered on screen, lReturnValue must be changed to False
8341
8342 CFbsBitGc* pGc = GetTextBitmapContext();
8343 CFont * pFont = NULL;
8344
8345 CWsBitmap* lBitmap = NULL;
8346 CFbsBitmapDevice* lBitmapDevice = NULL;
8347 TUint32 bgTextBitmapColor = 0;
8348 if (aBits)
8349 {
8350 {
8351 pGc = NULL;
8352 // Initialize background color of text bitmap to something other than the color of the text itself.
8353 if (aTextInfo->red == 0 && aTextInfo->green == 0
8354 && aTextInfo->blue == 0)
8355 {
8356 bgTextBitmapColor = 0xFFFFFFFF;
8357 }
8358 else
8359 {
8360 bgTextBitmapColor = 0x00000000;
8361 }
8362
8363 if ((lBitmap = new CWsBitmap(iEnv->WsSession())) == NULL
8364 || (lBitmap->Create(TSize(aWidth, aHeight), EColor16MU)
8365 != KErrNone) || (lBitmapDevice
8366 = CFbsBitmapDevice::NewL(lBitmap)) == NULL)
8367 {
8368 if (lBitmap)
8369 delete lBitmap;
8370 lReturnValue = EFalse;
8371 return lReturnValue;
8372 }
8373 if (KErrNone != lBitmapDevice->CreateContext(pGc))
8374 {
8375 pGc = NULL;
8376 if(lBitmap)
8377 delete lBitmap;
8378 if(lBitmapDevice)
8379 delete lBitmapDevice;
8380 lReturnValue = EFalse;
8381 return lReturnValue;
8382 }
8383 // pGc->UseBrushPattern(lBitmap);
8384 //pGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
8385 lBitmap->BeginDataAccess();
8386
8387 TUint32* ptrStartBmp = lBitmap->DataAddress();
8388 memset(ptrStartBmp,bgTextBitmapColor,aWidth * aHeight*4);
8389
8390 lBitmap->EndDataAccess(ETrue);
8391 }
8392
8393 }
8394 if ( pGc && GetCurrentFont( pFont ) )
8395 {
8396
8397 TPtrC ptr( aText->text.utf16String, aText->textLen );
8398 TRect rect(aTextInfo->xMin, aTextInfo->yMin, aTextInfo->xMax,
8399 aTextInfo->yMax);
8400
8401 TRgb color(aTextInfo->red, aTextInfo->green, aTextInfo->blue);
8402
8403 TPoint pt( aTextInfo->xPos, aTextInfo->yPos );
8404
8405 pGc->SetPenColor( color );
8406
8407 pGc->SetClippingRect( rect );
8408 pGc->UseFont( pFont );
8409
8410 /*Fix for RC case ou1cimx1#482693. We are supposed
8411 to call FI_SetDirtyRect function whenever device doesn't
8412 support rendering of text at particular degree as it
8413 consumes lot of cpu*/
8414 if(aTextInfo->rotation == 0)
8415 {
8416 pGc->DrawText( ptr, pt );
8417 }
8418 else
8419 {
8420 TInt rotation = aTextInfo->rotation >> 16;
8421 if (rotation < 0)
8422 {
8423 rotation += 360;
8424 }
8425 else if (rotation >= 360)
8426 {
8427 rotation -= 360;
8428 }
8429
8430 if (rotation == 90)
8431 {
8432 //Draw Text Vertically Downward.
8433 pGc->DrawTextVertical(ptr, pt, EFalse);
8434 }
8435 else if (rotation == 270)
8436 {
8437 //Draw text vertically Upward.
8438 pGc->DrawTextVertical(ptr, pt, ETrue);
8439 }
8440 else if (rotation == 0)// This is hit if rotation is passed as 0 or 360.
8441 {
8442 pGc->DrawText(ptr, pt );
8443 }
8444 else
8445 {
8446 //Since, Symbian can't rotate 180 degrees, we made some adjustments
8447 //above to simulate the position of the rotated character(s). However, since the
8448 //character(s) itself isn't rotated we might be drawing the text outside the dirty
8449 //region calculated by the player. So we should, therefore, call FI_SetDirtyRect on
8450 //the player with the new dirty rect. Not doing so will leave the artifacts of the drawn
8451 //characters here in the next frame.
8452 FI_Rect unrotatedDirtyRect;
8453 unrotatedDirtyRect.xmin = aTextInfo->xMin;
8454 unrotatedDirtyRect.xmax = aTextInfo->xMax;
8455 unrotatedDirtyRect.ymin = aTextInfo->yMin;
8456 unrotatedDirtyRect.ymax = aTextInfo->yMax;
8457 if (rotation == 180)
8458 {
8459 // would handle 180 degree rotation, but Symbian doesn't support that
8460 // simulate rotating 180 by shifting the drawing point.
8461 pt.iY += pFont->AscentInPixels();
8462 pt.iX -= pFont->TextWidthInPixels(ptr);
8463
8464 unrotatedDirtyRect.xmin
8465 = (short) (unrotatedDirtyRect.xmin
8466 - (short) pFont->TextWidthInPixels(ptr));
8467 unrotatedDirtyRect.ymax
8468 = (short) (unrotatedDirtyRect.ymax
8469 + (short) pFont->AscentInPixels());
8470 pGc->DrawText(ptr, pt );
8471 iFiObject.FI_SetDirtyRect(&unrotatedDirtyRect, false);
8472 }
8473 else // for all other angles text is not rendered on screen.
8474 {
8475 lReturnValue = EFalse;
8476 iFiObject.FI_SetDirtyRect(&unrotatedDirtyRect, false);
8477 }
8478 }
8479 }
8480 pGc->DiscardFont();
8481 pGc->CancelClippingRect();
8482 }
8483 if(lBitmap)
8484 {
8485 //iEnv->WsSession().Flush();
8486 // Copy only the text to the buffer given by the core player not the whole bitmap.Hence commenting the memcopy.
8487 TUint32* src = NULL;
8488 TUint32* dst = NULL;
8489 TInt srcWidth = aTextInfo->xMax - aTextInfo->xMin;
8490 TInt srcHeight = aTextInfo->yMax - aTextInfo->yMin;
8491 TInt srcIncr,dstIncr;
8492
8493 src = lBitmap->DataAddress() + (aTextInfo->yMin * aWidth)
8494 + aTextInfo->xMin;
8495 dst = (TUint32*)aBits + (aTextInfo->yMin * aWidth) + aTextInfo->xMin;
8496 srcIncr = dstIncr = aWidth;
8497
8498 TUint32 d = 0xFF000000 | ((aTextInfo->red) << 16)
8499 | ((aTextInfo->green) << 8) | (aTextInfo->blue);
8500 TInt i, j;
8501 TUint32* dstPix,*srcPix;
8502
8503 lBitmap->BeginDataAccess();
8504
8505 for( j = 0; j < srcHeight; ++j )
8506 {
8507 dstPix = dst;
8508 srcPix = src;
8509 dst+= dstIncr;
8510 src+= srcIncr;
8511 for ( i = 0; i < srcWidth; ++i )
8512 {
8513 if(*srcPix != bgTextBitmapColor)
8514 *dstPix = d;
8515 ++srcPix;
8516 ++dstPix;
8517 }
8518 }
8519
8520 lBitmap->EndDataAccess(ETrue);
8521
8522 delete lBitmap;
8523 if(lBitmapDevice)
8524 {
8525 delete lBitmapDevice;
8526 if(pGc)
8527 delete pGc;
8528 }
8529 }
8530
8531// Fix for refresh problems in text contents
8532// iSource bug 12069
8533/* Removed calling of ForceRedraw(), as this fix caused DCTS failures.
8534 * ERoom: 934 & 947. iSource: 12069 also works fine without calling ForceRedraw().
8535 */
8536
8537 return lReturnValue;
8538}
8539
8540TBool CPlatformFlashEngine::IsForegroundTask()
8541{
8542 return iForeground;
8543}
8544
8545void CPlatformFlashEngine::NotifyPhoneActiveL(TBool aIsActive)
8546{
8547 if(!iMMObject) //i.e. player is not created and swf playing is not started hence we will pause inside
8548 // DoRunL().
8549 {
8550 iPauseforActiveCall = ETrue;
8551 return;
8552 }
8553// if (!iBrowserPluginActive)
8554 if(iExecutionMode == eStandAlone)
8555 {
8556 if (aIsActive)
8557 {
8558 //If Engine is Not Already Paused for another Reason
8559 if(!IsPaused())
8560 {
8561 //Multiple Calls to Enable Pause Blinker are not
8562 //Possible, as only first time we get this function
8563 //Call with (aActive == TRUE) the Engine may not be
8564 //Paused. Next time, it has to be Paused!
8565 iFlashClientIf->NotifyPhoneActiveL(ETrue); //Enable Pause Blinker
8566 }
8567 Pause(EReasonPhone);
8568 }
8569 else
8570 {
8571 ResumeL(EReasonPhone, ETrue);
8572 if(!IsPaused())//Engine has Resumed!
8573 {
8574 //Multiple Calls to this are Possible,if this function
8575 //is called with EFalse multiple times,but this does
8576 //not have any side effects as we are Disabling only if
8577 //Engine has resumed and (in PlayerControl) if Blinker
8578 //is currently Active.
8579 iFlashClientIf->NotifyPhoneActiveL(EFalse); //Disable Pause Blinker
8580 }
8581 }
8582 /*if(iFlashUI)
8583 {
8584 iFlashUI->NotifyPhoneActiveL(aIsActive);
8585 }*/
8586 //iFlashClientIf->NotifyPhoneActiveL(aIsActive);
8587
8588 }
8589 else
8590 {
8591 if(aIsActive)
8592 {
8593 iCurrentVolume = GetVolume();
8594 SetVolume(iCurrentVolume|KMuteMask);
8595 Pause(EReasonPhone);
8596 }
8597 else
8598 {
8599 ResumeL(EReasonPhone, ETrue);
8600 //if muted unmute
8601 iCurrentVolume = GetVolume();
8602 if(iCurrentVolume & KMuteMask)
8603 {
8604 SetVolume(iCurrentVolume&KUnMuteMask);
8605 }
8606 }
8607
8608 }
8609 iPauseforActiveCall = EFalse;
8610
8611}
8612
8613void CPlatformFlashEngine::ResetSoftKeys()
8614{
8615 TInt i;
8616 for(i=0; i<iSoftkeyArraySize; i++)
8617 {
8618 delete iSoftkeyArray[i];
8619 iSoftkeyArray[i] = 0;
8620 }
8621 iChangeKeysRequest = EChangeScreenResetSoftkeys;
8622 TriggerAsyncEvent();
8623}
8624
8625#ifdef FEATURE_INLINE_TEXT_ENTRY
8626void CPlatformFlashEngine::RestoreSoftKeys( )
8627{
8628 iChangeKeysRequest = EChangeScreenResetSoftkeys;
8629
8630 if ( iSoftkeyArray )
8631 {
8632 // We invoke the SetSoftKeys if iSoftkeyArray contains actual values
8633 // Otherwise, we ResetSoftKeys
8634 TBool containsSoftKeyValues = false;
8635 for ( TInt i=0; i < iSoftkeyArraySize && !containsSoftKeyValues; i++ )
8636 {
8637 containsSoftKeyValues = ( NULL != iSoftkeyArray[i] );
8638 }
8639
8640 if ( containsSoftKeyValues )
8641 {
8642 iChangeKeysRequest = EChangeScreenSetSoftkeys;
8643 }
8644 }
8645
8646 TriggerAsyncEvent();
8647}
8648#endif // FEATURE_INLINE_TEXT_ENTRY
8649
8650void CPlatformFlashEngine::SetSoftKeys(HBufC** aKeyStrings, TInt aKeyCount)
8651{
8652 if (iSoftkeyArray)
8653 {
8654 TInt i;
8655 for (i=0; i<aKeyCount; i++)
8656 {
8657 if (i < iSoftkeyArraySize)
8658 {
8659 if(aKeyStrings[i])
8660 {
8661 delete iSoftkeyArray[i];
8662 iSoftkeyArray[i] = aKeyStrings[i];
8663 }
8664 }
8665 else
8666 {
8667 // Make sure that we delete any softkey strings
8668 // that we can't use.
8669 delete aKeyStrings[i];
8670 }
8671 }
8672 }
8673
8674 iChangeKeysRequest = EChangeScreenSetSoftkeys;
8675 TriggerAsyncEvent();
8676}
8677
8678void CPlatformFlashEngine::ConvertCStringToUTF16L(const char* aSrcCString, FI_ReturnString* aDstString)
8679{
8680 TInt strLen = FlashStrLen(aSrcCString);
8681
8682 // Create the result string
8683 HBufC16* resultString = HBufC16::NewLC(strLen+1);
8684 TPtr resultDes = resultString->Des();
8685
8686 // Create a buffer for the unconverted text - initialised with the input descriptor
8687
8688 TPtrC8 cString;
8689 if (aSrcCString)
8690 {
8691 cString.Set((TUint8*)aSrcCString);
8692 }
8693
8694 // Create a "state" variable and initialise it with CCnvCharacterSetConverter::KStateDefault
8695 // After initialisation the state variable must not be tampered with.
8696 // Simply pass into each subsequent call of ConvertToUnicode()
8697 TInt state = CCnvCharacterSetConverter::KStateDefault;
8698
8699 // Request the character converter to perform the conversion
8700 const TInt returnValue = iCharacterConverter->ConvertToUnicode(resultDes, cString, state);
8701
8702 // check to see that the descriptor isnt corrupt - leave if it is
8703 if (returnValue == CCnvCharacterSetConverter::EErrorIllFormedInput)
8704 {
8705 User::Leave(KErrCorrupt);
8706 }
8707 else if (returnValue != 0) // future-proof against "TError" expanding
8708 {
8709 User::Leave(KErrGeneral);
8710 }
8711
8712 // Copy it back to dstString
8713 aDstString->SetUTF16String( aDstString, resultDes.PtrZ() );
8714
8715 // Clean up stack
8716 CleanupStack::PopAndDestroy(resultString);
8717}
8718
8719// This function converts UTF-16 to CString and return to caller
8720char* CPlatformFlashEngine::ConvertUTF16ToCStringL(const FI_UTF16Char* aSrcUnicodeString)
8721{
8722
8723 // Create a buffer for the unconverted text - initialised with the input descriptor
8724 TPtrC16 unicodeText((TUint16*)aSrcUnicodeString);
8725
8726 // Create a small output buffer.
8727 TBuf8<100> outputBuffer;
8728
8729 char* currentString=NULL;
8730 CleanupStack::PushL(currentString);
8731
8732 for(;;) // conversion loop
8733 {
8734 // Reset the buffer
8735 outputBuffer.Zero();
8736
8737 // Start conversion. When the output buffer is full, return the
8738 // number of characters that were not converted
8739 const TInt returnValue = iCharacterConverter->ConvertFromUnicode(outputBuffer, unicodeText);
8740
8741 // check to see that the descriptor isnt corrupt - leave if it is
8742 if (returnValue == CCnvCharacterSetConverter::EErrorIllFormedInput)
8743 {
8744 User::Leave(KErrCorrupt);
8745 }
8746 else if (returnValue < 0) // future-proof against "TError" expanding
8747 {
8748 User::Leave(KErrGeneral);
8749 }
8750
8751 // Do something here to store the contents of the output buffer.
8752 // Finish conversion if there are no unconverted characters in the remainder buffer
8753
8754 char* tempString = ReAllocString(currentString,(const char*)outputBuffer.Ptr(),outputBuffer.Length());
8755 User::LeaveIfNull(tempString);
8756 CleanupStack::PopAndDestroy(currentString);
8757 currentString = tempString;
8758 tempString = NULL;
8759 CleanupStack::PushL(currentString); // new one
8760
8761 // Remove the converted source text from the remainder buffer.
8762 // The remainder buffer is then fed back into loop
8763 unicodeText.Set(unicodeText.Right(returnValue));
8764
8765 // If there 's no more remaining characters to convert... done!!!
8766 if (returnValue == 0)
8767 {
8768 break;
8769 }
8770 }
8771
8772 CleanupStack::Pop(currentString);
8773 return currentString;
8774}
8775
8776// This function converts UTF-16 string to c-string then send it back to core
8777void CPlatformFlashEngine::ConvertUTF16ToCStringL(const FI_UTF16Char* aSrcUnicodeString, FI_ReturnString* aDstString)
8778{
8779 char* resultString=ConvertUTF16ToCStringL(aSrcUnicodeString);
8780
8781 ASSERT(resultString); // debug only check - if this is null should have left already
8782 aDstString->SetCString( aDstString, resultString );
8783 delete resultString;
8784
8785}
8786
8787TInt32 CPlatformFlashEngine::GetAvailableDynamicMemory()
8788{
8789 TInt32 size = (TInt32)iPlayerDynamicHeapMaxSize - (TInt32)iPlayerDynamicHeapAlloced;
8790 return size;
8791}
8792
8793TUint32 CPlatformFlashEngine::MemBlockSize()
8794{
8795 return KMemoryBlockSize;
8796}
8797
8798void* CPlatformFlashEngine::AllocateDynamicMemory(TUint16 aNumBlocks)
8799{
8800
8801#if defined (PLUG_IN_MEM_ALLOC) && !defined (__WINSCW__)
8802 MPluginMemHandlerIf* memHdlrIf = GetPluginMemHandlerIf();
8803
8804 if(memHdlrIf)
8805 {
8806 if(memHdlrIf->IsMemAllocSupported())
8807 {
8808 return memHdlrIf->AllocMem(aNumBlocks);
8809 }
8810 }
8811#endif
8812
8813 //Check for 3MB free RAM limit before every allocation
8814
8815 TInt freeRAM=0;
8816 TInt r = HAL::Get(HAL::EMemoryRAMFree,freeRAM);
8817
8818 if((r!=KErrNone) || ( freeRAM < KRAMFreeCheckMark))
8819 {
8820
8821 return NULL;
8822 }
8823
8824
8825 TInt size = aNumBlocks * KMemoryBlockSize;
8826
8827 // check to see if this allocation will exceed our limit.
8828 // if ((iPlayerDynamicHeapAlloced + size) > iPlayerDynamicHeapMaxSize)
8829 if ((iPlayerDynamicHeapAlloced + size) > GetMaxHeapSize())
8830 {
8831 return NULL;
8832 }
8833
8834 TAny* mem = User::Alloc(size);
8835 if (!mem)
8836 {
8837 return NULL;
8838 }
8839
8840 DynamicMemBlock* pBlock = new DynamicMemBlock();
8841 if (pBlock)
8842 {
8843 pBlock->numBlocks = aNumBlocks;
8844 pBlock->mem = mem;
8845 pBlock->pNext = iDynamicMemBlocks;
8846 iDynamicMemBlocks = pBlock;
8847 // iPlayerDynamicHeapAlloced += size;
8848 AddDynHeapAlloced(size);
8849 }
8850 else
8851 {
8852 User::Free(mem);
8853 mem = NULL;
8854 }
8855
8856 return mem;
8857}
8858
8859void CPlatformFlashEngine::FreeDynamicMemory(TAny* aMemory)
8860{
8861#if defined (PLUG_IN_MEM_ALLOC) && !defined (__WINSCW__)
8862 MPluginMemHandlerIf* memHdlrIf = GetPluginMemHandlerIf();
8863
8864 if(memHdlrIf)
8865 {
8866 if(memHdlrIf->IsMemAllocSupported())
8867 {
8868 return memHdlrIf->FreeMem(aMemory);
8869 }
8870 }
8871#endif
8872
8873 TInt size = 0;
8874 DynamicMemBlock* pBlock = iDynamicMemBlocks;
8875 DynamicMemBlock* pPrevBlock = NULL;
8876 while (pBlock)
8877 {
8878 if (pBlock->mem == aMemory)
8879 {
8880 User::Free(pBlock->mem);
8881 if (pPrevBlock)
8882 {
8883 pPrevBlock->pNext = pBlock->pNext;
8884 }
8885 else
8886 {
8887 iDynamicMemBlocks = pBlock->pNext;
8888 }
8889 size = pBlock->numBlocks * KMaxInt;
8890 delete pBlock;
8891 break;
8892 }
8893 pPrevBlock = pBlock;
8894 pBlock = pBlock->pNext;
8895 }
8896 //iPlayerDynamicHeapAlloced -= size;
8897 DynHeapFreed(size);
8898}
8899
8900TUint CPlatformFlashEngine::GetMaxHeapSize()
8901 {
8902 MPluginMemHandlerIf* memHdlrIf = GetPluginMemHandlerIf();
8903
8904 if(memHdlrIf)
8905 return memHdlrIf->GetMaxHeapSize();
8906 else
8907 return iPlayerDynamicHeapMaxSize;
8908
8909/* AK
8910 if (iFlashClientIf->GetPluginMemHdlrIf())
8911 return iFlashClientIf->GetPluginMemHdlrIf()->GetMaxHeapSize();
8912 else
8913 return iPlayerDynamicHeapMaxSize;
8914*/
8915 /* if( iBrowserPluginActive && iFlashClientIf->GetPluginMemHdlrIf() )
8916 {
8917 return iFlashClientIf->GetPluginMemHdlrIf()->GetMaxHeapSize();
8918 }
8919 else if( !iBrowserPluginActive && iFlashUI )
8920 {
8921 return iPlayerDynamicHeapMaxSize;
8922 }
8923
8924 return iPlayerDynamicHeapMaxSize;
8925
8926
8927 */
8928 }
8929
8930void CPlatformFlashEngine::AddDynHeapAlloced(TUint size)
8931{
8932 /*if( iBrowserPluginActive && iFlashClientIf->GetPluginMemHdlrIf() )
8933 {
8934 iFlashClientIf->GetPluginMemHdlrIf()->AddDynHeapAlloced(size);
8935 }*/
8936
8937 MPluginMemHandlerIf* pluginMemHdlr = iFlashClientIf->GetPluginMemHdlrIf();
8938 if (pluginMemHdlr)
8939 pluginMemHdlr->AddDynHeapAlloced(size);
8940
8941 iPlayerDynamicHeapAlloced += size;
8942}
8943
8944void CPlatformFlashEngine::DynHeapFreed(TUint size)
8945{
8946 MPluginMemHandlerIf* pluginMemHdlr = iFlashClientIf->GetPluginMemHdlrIf();
8947 //if( iBrowserPluginActive && iFlashClientIf->GetPluginMemHdlrIf() )
8948 if( pluginMemHdlr )
8949 {
8950 pluginMemHdlr->DynHeapFreed(size);
8951 }
8952
8953 iPlayerDynamicHeapAlloced -= size;
8954}
8955
8956void CPlatformFlashEngine::GetInputTextL(const TUint16* aInitialString, TUint aStrLen, TUint aMaxNumChars, TUint aTextFlags)
8957{
8958 ASSERT(iGetInputTextRequest == NULL);
8959 // We don't queue up GetInputText requests. Only handle the first one.
8960 if (iGetInputTextRequest == NULL)
8961 {
8962 iGetInputTextRequest = new(ELeave) TGetInputTextData;
8963 TPtrC16 ptr(aInitialString, aStrLen);
8964 iGetInputTextRequest->iInitialString = ptr.AllocL();
8965 iGetInputTextRequest->iMaxNumChars = aMaxNumChars;
8966 iGetInputTextRequest->iTextFlags = aTextFlags;
8967 TriggerAsyncEvent();
8968 }
8969}
8970
8971HBufC* CPlatformFlashEngine::GetFlashVersion()
8972{
8973 HBufC* verBuf = NULL;
8974
8975 const char* verString = iFiObject.FI_GetVersion();
8976 if (verString)
8977 {
8978 TRAP_IGNORE(verBuf = CreateEpocStringL(verString,FlashStrLen(verString)));
8979 }
8980 return verBuf;
8981}
8982
8983TInt CPlatformFlashEngine::GetVolume()
8984{
8985 if (iSoundHandler)
8986 {
8987 return iSoundHandler->GetVolume();
8988 }
8989 else
8990 {
8991 return 0;
8992 }
8993}
8994
8995void CPlatformFlashEngine::SetVolume(TInt aVolume)
8996{
8997 DEBUGPRINT("CPlatformFlashEngine::SetVolume aVolume : [%d]", aVolume);
8998 if( !iSoundHandler )
8999 {
9000 return;
9001 }
9002
9003 iSoundHandler->SetVolume(aVolume);
9004
9005 // in case the sound handler fiddled with the volume somehow...
9006 if(iVideoEngine)
9007 TRAP_IGNORE(iVideoEngine->NotifyNewVolumeLevelL(iSoundHandler->GetVolume()));
9008
9009 THXVDCmdArg arg;
9010
9011 if (aVolume & KMuteMask)
9012 {
9013 arg.iVolume = 0;
9014 }
9015 else
9016 {
9017 arg.iVolume = iSoundHandler->GetVolume();
9018 }
9019
9020 EngineDispatchHXCommand(EHXVDCmdSetVolume, arg);
9021}
9022
9023
9024const TInt32 KFixedPointPosTen = 0x000A0000;
9025const TInt32 KFixedPointNegTen = 0xFFF60000;
9026
9027void CPlatformFlashEngine::OffsetPointToPan(TPoint& aPoint, TInt aType)
9028{
9029 if(IsPanning() && (aType == TPointerEvent::EDrag))
9030 {
9031 // In Panning mode, translate the Flash content by ten units up/down or left/right
9032 // on directional key events
9033
9034 if(aPoint.iX > 0)
9035 {
9036 if(aPoint.iY > 0)
9037 iFiObject.FI_Translate(KFixedPointPosTen, KFixedPointPosTen);
9038 else if(aPoint.iY < 0)
9039 iFiObject.FI_Translate(KFixedPointPosTen, KFixedPointNegTen);
9040 else
9041 iFiObject.FI_Translate(KFixedPointPosTen, 0);
9042 }
9043 else if(aPoint.iX < 0)
9044 {
9045 if(aPoint.iY > 0)
9046 iFiObject.FI_Translate(KFixedPointNegTen, KFixedPointPosTen);
9047 else if(aPoint.iY < 0)
9048 iFiObject.FI_Translate(KFixedPointNegTen, KFixedPointNegTen);
9049 else
9050 iFiObject.FI_Translate(KFixedPointNegTen, 0);
9051 }
9052 else
9053 {
9054 if(aPoint.iY > 0)
9055 iFiObject.FI_Translate(0, KFixedPointPosTen);
9056 else if(aPoint.iY < 0)
9057 iFiObject.FI_Translate(0, KFixedPointNegTen);
9058 else
9059 iFiObject.FI_Translate(0, 0);
9060 }
9061
9062
9063 PlayStep(ETrue);
9064
9065 }
9066}
9067
9068
9069void CPlatformFlashEngine::OfferPointerEventL(TPoint& aPoint, TInt aType)
9070{
9071 TInt type = FI_EventNoEvent;
9072 /****No Touch support for IME control temporary. See HSAA-6RTA5A.****/
9073 //Determine if a Flash control exists under the specified mouse location and
9074 //if it is a TextField then returns 3.
9075
9076 //if (iFiObject.FI_DoHitTest(aPoint.iX, aPoint.iY) != 3)
9077 {
9078
9079 NPPDebug(LOG_NONE, ETrue,_L("CPlatformFlashEngine::OfferPointerEventL::type = %d"), aType);
9080
9081 switch(aType)
9082 {
9083 case TPointerEvent::EButton1Down:
9084 //case TPointerEvent::EButton2Down:
9085 //case TPointerEvent::EButton3Down:
9086 type = FI_EventMouseDown;
9087 break;
9088
9089 case TPointerEvent::EButton1Up:
9090 //case TPointerEvent::EButton2Up:
9091 //case TPointerEvent::EButton3Up:
9092 type = FI_EventMouseUp;
9093 break;
9094
9095 case TPointerEvent::EMove:
9096 type = FI_EventMouseMove;
9097 break;
9098 case TPointerEvent::EDrag:
9099 type = FI_EventMouseMove;
9100
9101 break;
9102 }
9103 if( iPstatus == FI_RenderingInterruptedByTimeout || iPstatus == FI_SystemInterrupt || iPstatus == FI_ActionScriptInterruptedByTimeout)
9104 return;
9105 iFiObject.FI_OfferMouseEvent ( aPoint.iX, aPoint.iY, type );
9106 PlayStep(ETrue);
9107 }
9108}
9109
9110
9111TBool CPlatformFlashEngine::IsControlPresent(const TPoint& aPoint)
9112{
9113 if( iPstatus == FI_RenderingInterruptedByTimeout || iPstatus == FI_SystemInterrupt || iPstatus == FI_ActionScriptInterruptedByTimeout)
9114 return EFalse;
9115 //Determine if a Flash control exists under the specified mouse location and
9116 //if it is 1 then it means no control.
9117
9118 TInt result = iFiObject.FI_DoHitTest(aPoint.iX, aPoint.iY);
9119 if( result == 1 )
9120 {
9121 iControlPresent = EFalse;
9122 return EFalse;
9123 }
9124 iControlPresent = ETrue;
9125 return ETrue;
9126}
9127
9128
9129void CPlatformFlashEngine::SetInputTextL(const TDesC& aNewStr)
9130{
9131 // check for 0x2029 (this is the paragraph separator unicode value
9132 // which seems to be used as newline separator)
9133 // and map it to 0x0A (LF), which is what Flash uses internally
9134 // to keep track of the end of a line.
9135
9136 HBufC* buf = HBufC::NewLC(aNewStr.Length()+1);
9137
9138 TPtr des = buf->Des();
9139 des.Copy(aNewStr);
9140 des.ZeroTerminate();
9141
9142 const TInt strLen=buf->Length();
9143
9144 for (TInt i = 0; i < strLen; i++)
9145 {
9146 if (des[i] == KUnicodeParagraphSeparator)
9147 {
9148 des[i] = FLASH_LINE_FEED_CHAR;
9149 }
9150 }
9151
9152
9153 FI_Text txt = { { ((char*) des.Ptr()) }, FI_UTF16EncodingForm, strLen };
9154 iFiObject.FI_SetInputText(&txt);
9155 CleanupStack::PopAndDestroy(buf);
9156}
9157
9158void CPlatformFlashEngine::CancelInputText()
9159{
9160 iFiObject.FI_CancelInputText();
9161}
9162
9163void CPlatformFlashEngine::QueueSILaunchL(struct MM_Object* aMMObj, TUint16 aArgc, const TDesC** aArgv, struct FI_PlayerEventInfo* /*aEventInfo*/, TInt16 aIsEmbedded)
9164{
9165 CQueuedSILaunch* siLaunch=CQueuedSILaunch::NewL(aMMObj, aArgc, aArgv, aIsEmbedded);
9166 iLaunchQueue.AddLast(*siLaunch);
9167 if(!iLaunchQueueHandler->IsActive())
9168 {
9169 iLaunchQueueHandler->Start();
9170 }
9171}
9172
9173void CPlatformFlashEngine::DoRunL(const CActive* aActive)
9174{
9175 if(aActive == iBacklightExtensionTimer && !NoBackLightProcessing())
9176 {
9177 User::ResetInactivityTime();
9178 if(iExtendBacklight == EOn)
9179 iBacklightExtensionTimer->After(KBacklightExtensionTime);
9180
9181 return;
9182 }
9183
9184 // Resuming on Network prompt timeout
9185 if( aActive == iIAPTimer )
9186 {
9187 // We timed out
9188 ResumeOnNetworkPrompt();
9189 return;
9190 }
9191
9192 //Mp3Streaming
9193 if (aActive == iMp3Timer)
9194 {
9195 if(iMp3PlayStateObserver)
9196 {
9197 iMp3PlayStateObserver->MP3PlayStateChangedL(EFlashNoMP3Stream);
9198 }
9199 return;
9200 }
9201
9202 if(aActive == iTimer || aActive == iLowestPriorityActiveObj)
9203 {
9204 iLowestPriorityActiveObj->Cancel();
9205 iTimer->Cancel();
9206
9207 // Re-queue the timer for interval = iDelay.
9208 if( iPauseFlags==ENotPaused && !iIsStopped && !iTimer->IsActive() )
9209 {
9210 iTimer->After(iDelay);
9211 }
9212
9213 // timer tick - this calls to the core player which does the time consuming stuff
9214 PlatformTimerTick();
9215
9216 // NOTE: Above PlatformTimerTick() may take some time = x.
9217 // If x < iDelay, there is no problem. Other low priority active objects still gets scheduled.
9218 // If x > iDelay, then other high low priority active objects may starve because iTimer will always be scheduled.
9219 // So, reissue iTimer but use a low priority AObj to reschedule ONCE ourselves.
9220
9221 if( iTimer->iStatus != KRequestPending && iPauseFlags==ENotPaused )
9222 {
9223 iTimer->Cancel();
9224 iTimer->After(iDelay);
9225 iLowestPriorityActiveObj->Start();
9226 }
9227 }
9228 else
9229 {
9230 // must be the queued launcher
9231 CQueuedSILaunch* siLaunch;
9232 while(!(iLaunchQueue.IsEmpty()))
9233 {
9234 siLaunch=iLaunchQueue.First();
9235 siLaunch->LaunchL();
9236 iLaunchQueue.Remove(*siLaunch);
9237 delete siLaunch;
9238 }
9239 }
9240 // TSW : EPSS-7ZV8L8 This is hack to put pause on player when we open a flash content
9241 // while call is ongoing after first doplay so that user will have some frames in display
9242 // user should'nt feel like bad user experience displaying blank white screen.
9243
9244 if(iPauseforActiveCall && IsPhoneCallActive()) //check for Call is active at time of pasuing.
9245 {
9246 NotifyPhoneActiveL(IsPhoneCallActive());
9247 }
9248
9249}
9250
9251TInt CPlatformFlashEngine::DoRunError(const CActive* aActive, TInt /*aError*/)
9252{
9253 if(aActive==iTimer)
9254 {
9255 ASSERT(EFalse); // should never happen - PlatformTimerTick() cannot leave - debug mode assert
9256 }
9257 //Mp3Streaming
9258 else if (aActive == iMp3Timer)
9259 {
9260 if(iMp3PlayStateObserver)
9261 {
9262 TRAP_IGNORE(iMp3PlayStateObserver->MP3PlayStateChangedL(EFlashNoMP3Stream));
9263 }
9264 return KErrNone;
9265 }
9266 else
9267 {
9268 // there was a launch failure, requeue, but remove the head item...
9269 CQueuedSILaunch* head=iLaunchQueue.First();
9270 iLaunchQueue.Remove(*head);
9271 delete head;
9272 if(!(iLaunchQueue.IsEmpty()))
9273 {
9274 iLaunchQueueHandler->Start();
9275 }
9276 }
9277 return KErrNone; // Flash already shows an error for SI_Launch failures!
9278}
9279
9280TInt CPlatformFlashEngine::ExtendBacklight(TUint16 aDuration)
9281{
9282 // Get the current time
9283 if(!NoBackLightProcessing())
9284 {
9285 //screensaver app will handle backlight, dont interfere
9286 if(iBkLightHandler)
9287 {
9288 iBkLightHandler->ExtendBacklight(aDuration);
9289 }
9290 }
9291
9292 return 1;
9293}
9294
9295void CPlatformFlashEngine::ExtendBacklightForVideoPlayback(TBacklightStatus aOnOrOff)
9296{
9297 // Get the current time
9298 if(!NoBackLightProcessing())
9299 {
9300 iExtendBacklight = aOnOrOff;
9301
9302 //Extend the backlight when the video is playing
9303 if(iExtendBacklight == EOn)
9304 {
9305 if(!iBacklightExtensionTimer)
9306 {
9307 TRAPD(err, iBacklightExtensionTimer = CFlhTimerObject::NewL(CActive::EPriorityStandard,
9308 *this));
9309 if(err != KErrNone)
9310 {
9311 iBacklightExtensionTimer = NULL;
9312 return;
9313 }
9314
9315 //Reset the inactivity time right here as the timer will
9316 //expire only after 2 secs
9317 User::ResetInactivityTime();
9318 }
9319
9320 iBacklightExtensionTimer->Cancel();
9321 iBacklightExtensionTimer->After(KBacklightExtensionTime);
9322 }
9323 else
9324 {// Stop extending the backlight when the video is either
9325 // paused or stopped or when playback is complete
9326 if(iBacklightExtensionTimer)
9327 {
9328 iBacklightExtensionTimer->Cancel();
9329 }
9330 }
9331 }
9332 return;
9333}
9334
9335void CPlatformFlashEngine::ExtendBackLightWhileSeekingLocalFlv()
9336{
9337 //Reset the inactivity time
9338 User::ResetInactivityTime();
9339}
9340
9341TUint32 CPlatformFlashEngine::GetConnectedIAPIdL()
9342{
9343 __UHEAP_MARK;
9344 TUint32 iapId = 0;
9345
9346 RSocketServ socketServ;
9347 User::LeaveIfError(socketServ.Connect());
9348 CleanupClosePushL(socketServ);
9349
9350 RConnection connection;
9351 User::LeaveIfError(connection.Open(socketServ));
9352 CleanupClosePushL(connection);
9353 TUint activeConnectionCount;
9354 User::LeaveIfError(connection.EnumerateConnections(activeConnectionCount));
9355 if(activeConnectionCount)
9356 {
9357 TPckgBuf<TConnectionInfoV2> connectionInfo;
9358 TInt err = KErrNone;
9359 for(TUint i=1; i<=activeConnectionCount && !iapId; i++)
9360 {
9361 err = connection.GetConnectionInfo(i, connectionInfo);
9362 if(err == KErrNone)
9363 {
9364 iapId = connectionInfo().iIapId;
9365 }
9366 }
9367 }
9368 CleanupStack::PopAndDestroy(&connection);
9369 CleanupStack::PopAndDestroy(&socketServ);
9370 __UHEAP_MARKEND;
9371 return iapId;
9372}
9373
9374TBool CPlatformFlashEngine::GetNetworkInfoL(unsigned short aInfoType, TDes8& aRetString)
9375 {
9376 /*
9377 if(!iNetworkInfo)
9378 { //ok ,object not created , delayed creation will be done now
9379 if(!NoETelSuppport())
9380 { //let us create object now
9381 iNetworkInfo = CNetworkInfo::NewL();
9382 }
9383 }
9384 */
9385 CNetworkInfo* networkInfo = GetNetworkInfoL();
9386 if(networkInfo)
9387 return networkInfo->GetNetworkInfo( aInfoType, aRetString);
9388
9389 return EFalse;
9390 }
9391
9392TBool CPlatformFlashEngine::GetNetworkInfoL(unsigned short aInfoType, long& aRetVal)
9393 {
9394 /*
9395 if(!iNetworkInfo)
9396 {//ok ,object not created , delayed creation will be done now
9397 if(!NoETelSuppport())
9398 { //let us create object now
9399 iNetworkInfo = CNetworkInfo::NewL();
9400 }
9401 }
9402 */
9403 CNetworkInfo* networkInfo = GetNetworkInfoL();
9404 if(networkInfo)
9405 return networkInfo->GetNetworkInfo( aInfoType, aRetVal);
9406
9407 return EFalse;
9408 }
9409
9410TBool CPlatformFlashEngine::GetSubscriberInfoL(unsigned short aInfoType, TDes8& aRetString)
9411 {
9412 /*if(!iSubscriberInfo)
9413 {//ok ,object not created , delayed creation will be done now
9414 if(!NoETelSuppport())
9415 { //let us create object now
9416 iSubscriberInfo = CSubscriberInfo::NewL();
9417 }
9418 }*/
9419
9420 CSubscriberInfo* subscriberInfo = GetSubscriberInfoL();
9421 if(subscriberInfo)
9422 return subscriberInfo->GetSubscriberInfo(aInfoType,aRetString);
9423
9424 return EFalse;
9425 }
9426
9427TBool CPlatformFlashEngine::GetRegistrationStatusL(unsigned short aInfoType, long& aRetValue)
9428 {
9429 /*if(!iRegistrationStatus)
9430 {//ok ,object not created , delayed creation will be done now
9431 if(!NoETelSuppport())
9432 { //let us create object now
9433 iRegistrationStatus = CRegistrationStatus::NewL();
9434 }
9435 }*/
9436
9437 CRegistrationStatus* registrationStatus = GetRegistrationStatusL();
9438
9439 if(registrationStatus)
9440 return registrationStatus->GetRegistrationStatus(aInfoType,aRetValue);
9441
9442 return EFalse;
9443 }
9444
9445
9446const TUint32 KFixedPointTwo = 0x00020000L; // 2.0 in 16:16 fixed point
9447const TUint32 KFixedPointHalf = 0x00008000L; // 0.5 in 16:16 fixed point
9448TBool CPlatformFlashEngine::Zoom(TReal aScaleFactor)
9449{
9450 TUint32 fixedScaleFactor = ConvertFromFloatToFixed16(aScaleFactor);
9451
9452 TUint32 x = iFrameBufferSize.iWidth << 15;
9453 TUint32 y = iFrameBufferSize.iHeight << 15;
9454
9455 return iFiObject.FI_Scale(fixedScaleFactor, x, y);
9456}
9457
9458TUint32 CPlatformFlashEngine::ConvertFromFloatToFixed16(TReal aFloatRep)
9459{
9460 TUint32 fixedPointRep = aFloatRep;
9461
9462 aFloatRep -= fixedPointRep; //get decimal part only
9463 fixedPointRep <<= 16;
9464 TUint16 decimalPart = 0;
9465 TReal powerOfHalf = 0.5;
9466 for(int i = 1 ; i <= 16; i++) //subtract by powers of half 16 times
9467 {
9468 if((aFloatRep - powerOfHalf) >= 0)
9469 {
9470 aFloatRep = aFloatRep - powerOfHalf;
9471 decimalPart += ( 0x10000 >> i); //left shift n times when subtracting nth power of half
9472 }
9473 if(aFloatRep == 0)
9474 {
9475 break;
9476 }
9477 else
9478 {
9479 powerOfHalf = powerOfHalf * 0.5;
9480 }
9481 }
9482// decimalPart = (~decimalPart);
9483 fixedPointRep += decimalPart; //add one's complement of binary rep of decimal part
9484 return fixedPointRep;
9485}
9486
9487
9488TBool CPlatformFlashEngine::Zoom(TInt aMode, TInt& aCurrentZoomLevel)
9489{
9490 TBool success = EFalse;
9491 switch(aMode)
9492 {
9493 case EZoomIn:
9494 {
9495 if(iZoomFactor >= KMaxZoomLevel)
9496 {
9497 aCurrentZoomLevel = iZoomFactor;
9498 return EFalse; //we dont handle more than 5 times
9499 }
9500
9501 // x and y are 16:16 fixed point numbers.
9502 // shift by 15 bits to get same effect as divide by 2 and shift by 16 bits.
9503 TUint32 x = iFrameBufferSize.iWidth << 15;
9504 TUint32 y = iFrameBufferSize.iHeight << 15;
9505 success = iFiObject.FI_Scale(KFixedPointTwo, x, y);
9506 if(success)
9507 {
9508 iZoomFactor++;
9509 aCurrentZoomLevel = iZoomFactor;
9510 }
9511 else
9512 {
9513 aCurrentZoomLevel = iZoomFactor;
9514 }
9515 }
9516 break;
9517
9518 case EZoomOut:
9519 if (iZoomFactor > 0)
9520 {
9521 // x and y are 16:16 fixed point numbers.
9522 // shift by 15 bits to get same effect as divide by 2 and shift by 16 bits.
9523 TUint32 x = iFrameBufferSize.iWidth << 15;
9524 TUint32 y = iFrameBufferSize.iHeight << 15;
9525 success = iFiObject.FI_Scale(KFixedPointHalf, x, y);
9526 if(success)
9527 {
9528 iZoomFactor--;
9529 aCurrentZoomLevel = iZoomFactor;
9530 }
9531 }
9532 break;
9533
9534 case EShowAll:
9535 iZoomFactor = 0;
9536 aCurrentZoomLevel = iZoomFactor;
9537 break;
9538 }
9539
9540 // Make sure that pan mode is turned off if we zoom out.
9541 if (iZoomFactor == 0)
9542 {
9543 iFiObject.FI_ResetTransform();
9544 iPanMode = EFalse;
9545 }
9546
9547 return success;
9548}
9549
9550TBool CPlatformFlashEngine::IsZoomable()
9551{
9552 TUint16 status = iFiObject.FI_GetZoomAndPanEnabled();
9553 if ((status != 0) && !IsPaused())
9554 {
9555 return ETrue;
9556 }
9557 else
9558 {
9559 return EFalse;
9560 }
9561}
9562
9563void CPlatformFlashEngine::TriggerAsyncEvent()
9564{
9565 iAsyncEventHandler->TriggerEvent();
9566}
9567
9568
9569
9570TBool CPlatformFlashEngine::QueryAllowNetAccessL()
9571 {
9572 TBool rval = EFalse;
9573 TBool userAllows = EFalse;
9574
9575 if(iAllowNetAccessId==EAllow_NotSet || iAllowNetAccessId==EAllow_Deny)
9576 {
9577 //if(!iBrowserPluginActive)
9578 if(iExecutionMode == eStandAlone)
9579 {
9580 //userAllows=iFlashUI->QueryAllowNetAccessL();
9581 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
9582 if(userNotifierIf)
9583 {
9584 userAllows = userNotifierIf->QueryAllowNetAccessL();
9585 }
9586 }
9587 else
9588 {
9589 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
9590 if(userNotifierIf)
9591 userAllows=userNotifierIf->QueryAllowNetAccessL();
9592 }
9593 if(userAllows)
9594 {
9595 iAllowNetAccessId=EAllow_Allow;
9596 }
9597 else
9598 {
9599 iAllowNetAccessId=EAllow_Deny;
9600 }
9601 }
9602 if(iAllowNetAccessId==EAllow_Allow)
9603 {
9604 rval=ETrue;
9605 }
9606
9607 return rval;
9608}
9609
9610
9611
9612TPtrC CPlatformFlashEngine::MatchedStringFromArrayL(TInt aArrayResId, const TDesC& aMatch)
9613{
9614 const TInt count=iItemValuePairArrays->Count();
9615
9616 CFlhItemValuePairList* ivpl=NULL;
9617 CFlhItemValuePairList* candidate=NULL;
9618
9619 for(TInt i=count-1;i>=0;i--)
9620 {
9621 candidate=(*iItemValuePairArrays)[i];
9622 if(candidate->Id()==aArrayResId)
9623 {
9624 ivpl=candidate;
9625 break;
9626 }
9627 }
9628
9629 if(!ivpl)
9630 {
9631 // array not loaded yet
9632 ivpl=CFlhItemValuePairList::NewLC(*iEnv,aArrayResId);
9633 iItemValuePairArrays->AppendL(ivpl);
9634 CleanupStack::Pop(ivpl);
9635 }
9636
9637 return ivpl->ValueForKeyL(aMatch);
9638}
9639
9640short CPlatformFlashEngine::GetSoftKeyLocation() const
9641{
9642 return iSoftkeyLocation;
9643}
9644
9645void CPlatformFlashEngine::SetSoftKeyLocation()
9646{
9647 AknLayoutUtils::TAknCbaLocation cbaloc(AknLayoutUtils::CbaLocation());
9648 if(cbaloc==AknLayoutUtils::EAknCbaLocationLeft)
9649 {
9650 iSoftkeyLocation=1;
9651 }
9652 else if(cbaloc==AknLayoutUtils::EAknCbaLocationRight)
9653 {
9654 iSoftkeyLocation=3;
9655 }
9656 else if(cbaloc==AknLayoutUtils::EAknCbaLocationBottom)
9657 {
9658 iSoftkeyLocation=2;
9659 }
9660 else
9661 {
9662 iSoftkeyLocation=0; //top
9663 }
9664}
9665void CPlatformFlashEngine::HandleSoftKeyLocationChangedL()
9666{
9667#ifdef FEATURE_DEBUG_SOFTKEY_LOCATION
9668 iSoftkeyLocation=(short)(iSoftkeyLocation+1);
9669 if(iSoftkeyLocation > (short) 3)
9670 iSoftkeyLocation = (short) 0;
9671 #pragma message ("error - FEATURE_DEBUG_SOFTKEY_LOCATION is defined - must never be defined for shipping code")
9672#else // FEATURE_DEBUG_SOFTKEY_LOCATION
9673 iSoftkeyLocation=GetSoftkeyLocationFromOS();
9674#endif //FEATURE_DEBUG_SOFTKEY_LOCATION
9675 NotifyCorePlayerOfSoftkeyLocationChangeL();
9676 if(iPauseFlags!=ENotPaused && !iIsStopped)
9677 {
9678 PlayStep(ETrue); // force the screen to draw correctly for the new size. Softkeys will not move until playback resumes
9679 }
9680}
9681
9682void CPlatformFlashEngine::NotifyCorePlayerOfSoftkeyLocationChangeL()
9683{
9684 // triggers the onResize event (or <Insert> key equivalent in AS1)
9685 MDisplay* display = iFlashClientIf->GetDisplay();
9686 if(display)
9687 {
9688 display->ResetScreenInCurrentModeL();
9689 }
9690
9691}
9692
9693TBool CPlatformFlashEngine::IsPhoneCallActive()
9694{
9695 CPhoneMonitor* phoneMonitor = NULL;
9696 TRAP_IGNORE(phoneMonitor = GetPhoneMonitorL());
9697 if (phoneMonitor && phoneMonitor->IsCallActive())
9698 {
9699 return ETrue;
9700 }
9701 return EFalse;
9702}
9703
9704#ifdef FEATURE_OPENVG
9705CFbsBitGc* CPlatformFlashEngine::GetAuxTextBitmapContext()
9706{
9707 if (iAuxTextBitmapGc) {
9708 return iAuxTextBitmapGc;
9709 }
9710
9711 if (KErrNone != iAuxTextBitmapDevice->CreateContext(iAuxTextBitmapGc)) {
9712 iAuxTextBitmapGc = NULL;
9713 }
9714
9715 return iAuxTextBitmapGc;
9716}
9717#endif
9718
9719// ----------------------------------------------------------------------
9720// TBool CPlatformFlashEngine::IsSoundPlaying() const
9721//
9722// The function returns whether the sound is present and playing
9723// ----------------------------------------------------------------------
9724//
9725
9726TBool CPlatformFlashEngine::IsSoundPlaying() const
9727{
9728 if( iSoundHandler )
9729 {
9730 return iSoundHandler->IsPlaying();
9731 }
9732
9733 return EFalse;
9734}
9735
9736// This function retuns the video rect
9737TRect CPlatformFlashEngine::GetVideoRectL()
9738{
9739 return iVideoRect.iRect;
9740}
9741
9742// This function informs the engine of the region in which video will be drawn.
9743
9744void CPlatformFlashEngine::SetVideoRectL(const FI_Rect* aRect, const TVideoType& aVideoType)
9745{
9746
9747 // keep track of the video rect so we can blit only the regions surrounding it.
9748 // if we are called with a NULL rect, it means we aren't playing video anymore
9749
9750 if (aRect == NULL)
9751 {
9752 iVideoRect.iRect.iTl.iX = 0;
9753 iVideoRect.iRect.iTl.iY = 0;
9754 iVideoRect.iRect.SetSize(TSize(0, 0));
9755 iVideoRect.iVideoType = EVideoNone;
9756 }
9757 else
9758 {
9759 iVideoRect.iRect.iTl.iX = aRect->xmin;
9760 iVideoRect.iRect.iTl.iY = aRect->ymin;
9761 iVideoRect.iRect.iBr.iX = aRect->xmax;
9762 iVideoRect.iRect.iBr.iY = aRect->ymax;
9763
9764 iVideoRect.iVideoType = aVideoType;
9765
9766 //Since video rect might be different, cause redraw
9767 iRedraw = ETrue;
9768 }
9769
9770 #ifdef ENABLE_CURSOR
9771
9772 // This is for hiding the cursor within this video rect.
9773 MFlashCursor* cursor = Cursor();
9774 if( cursor && iVideoRect.iVideoType == EDeviceVideo )
9775 {
9776 cursor->SetHiddenWindow(iVideoRect.iRect);
9777 }
9778
9779 #endif // ENABLE_CURSOR
9780
9781}
9782
9783RWindow* CPlatformFlashEngine::GetWindow()
9784{
9785 MDisplay* display = iFlashClientIf->GetDisplay();
9786 if(display)
9787 return display->GetWindow();
9788
9789 return NULL;
9790 //return (RWindow*)(&(iFlashClientIf->GetWindow()));
9791 /*
9792 if(!iBrowserPluginActive)
9793 {
9794 return iFlashUI->GetWindow();
9795 }
9796 else
9797 {
9798 return (RWindow*)(&(iControl->GetWindow()));
9799 }
9800 */
9801}
9802
9803void CPlatformFlashEngine::NotifyFlashError(TInt aErrorCode, TBool aIsCritical, TBool aPersistent)
9804{
9805 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
9806 if(userNotifierIf)
9807 //TRAP_IGNORE(err,userNotifierIf->NotifyFlashError(aErrorCode,aIsCritical,aPersistent)) ;
9808 userNotifierIf->NotifyFlashError(aErrorCode,aIsCritical,aPersistent);
9809
9810 /*
9811 if(!iBrowserPluginActive)
9812 {
9813 TRAP(err,iFlashUI->NotifyFlashError(aErrorCode,aIsCritical,aPersistent)) ;
9814 }
9815 else
9816 {
9817 TRAP(err,iUserNotifierIf->NotifyFlashError(aErrorCode,aIsCritical,aPersistent)) ;
9818 }
9819 */
9820}
9821
9822void CPlatformFlashEngine::NotifyClientError(TInt aErrorCode, TBool aIsCritical, TBool aPersistent)
9823 {
9824 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
9825 if(userNotifierIf)
9826 userNotifierIf->NotifyClientError(aErrorCode,aIsCritical,aPersistent);
9827 //TRAP(err,iUserNotifierIf->NotifyClientError(aErrorCode,aIsCritical,aPersistent)) ;
9828 /*
9829 if(!iBrowserPluginActive)
9830 {
9831 TRAP(err,iFlashUI->NotifyClientError(aErrorCode,aIsCritical,aPersistent)) ;
9832 }
9833 else
9834 {
9835 TRAP(err,iUserNotifierIf->NotifyFlashError(aErrorCode,aIsCritical,aPersistent)) ;
9836 }
9837 */
9838 }
9839
9840void CPlatformFlashEngine::NotifyFlashStatus(TInt aFlashStatus, TAny* aParam)
9841{
9842 //TInt err ;
9843
9844 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
9845 if(userNotifierIf)
9846 //if(iUserNotifierIf)
9847 {
9848 userNotifierIf->NotifyFlashStatus(aFlashStatus,aParam);
9849 //TRAP(err,iUserNotifierIf->NotifyFlashStatus(aFlashStatus,aParam)) ;
9850 }
9851}
9852
9853void CPlatformFlashEngine::NotifyDataAccessError(const char* aUrl, TInt aErrorCode)
9854{
9855 //TInt err ;
9856 MUserNotiferIf* userNotifierIf = iFlashClientIf->GetUserNotifierIf();
9857
9858 if(userNotifierIf)
9859 {
9860 //TRAP(err,iUserNotifierIf->NotifyDataAccessError(aUrl,aErrorCode)) ;
9861 userNotifierIf->NotifyDataAccessError(aUrl,aErrorCode);
9862 }
9863/* else //TODO: need to add the method to plugin interface
9864 {
9865 TRAP(err,iUserNotifierIf->NotifyDataAccessError(aUrl,aErrorCode)) ;
9866 } */
9867}
9868
9869
9870TBool CPlatformFlashEngine::NoGetURLSupport()
9871{
9872 return (iConfig.iMode & KSupportNoGetURL)? ETrue: EFalse;
9873}
9874
9875TBool CPlatformFlashEngine::NoVibraSupport()
9876{
9877 return (iConfig.iMode & KSupportNoVibra)? ETrue: EFalse;
9878}
9879
9880TBool CPlatformFlashEngine::NoSoundSupport()
9881{
9882 return (iConfig.iMode & KSupportNoSound)? ETrue: EFalse;
9883}
9884
9885TBool CPlatformFlashEngine::NoBackLightProcessing()
9886{
9887 return (iConfig.iMode & KSupportNoBackLightProcessing)? ETrue: EFalse;
9888}
9889
9890TBool CPlatformFlashEngine::NoIncomingCallMonitor()
9891{
9892 return (iConfig.iMode & KSupportNoCallMonitor)? ETrue: EFalse;
9893}
9894
9895#ifdef FEATURE_OPENVG
9896void CPlatformFlashEngine::InitializeEglL()
9897{
9898 iEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
9899 if (iEGLDisplay == NULL) {
9900 User::Leave(KErrGeneral);
9901 }
9902
9903 if (!iEGLInitialized && eglInitialize( iEGLDisplay, NULL, NULL ) == EGL_FALSE ) {
9904 User::Leave(KErrGeneral);
9905 }
9906
9907 if(!iEGLInitialized) {
9908 iHostEngineGlobals->AddEGLClient((TAny*)this);
9909 iEGLInitialized = ETrue;
9910 }
9911
9912 ChooseEglConfigL();
9913
9914 eglBindAPI(EGL_OPENVG_API);
9915
9916 // Create a rendering context
9917 if(iEGLContext == EGL_NO_CONTEXT)
9918 {
9919 iEGLContext = eglCreateContext(iEGLDisplay, iEGLConfig, EGL_NO_CONTEXT, NULL );
9920 if (iEGLContext == EGL_NO_CONTEXT)
9921 {
9922 User::Leave(KErrGeneral);
9923 }
9924 }
9925
9926 /* Get the EGL max supported width & height for choosen EGL config */
9927 InitEGLMaxDimensionL();
9928}
9929
9930void CPlatformFlashEngine::ChooseEglConfigL()
9931{
9932 if(iEGLConfig)
9933 {
9934 return;
9935 }
9936
9937 EGLConfig *configList = NULL;
9938 EGLint numOfConfigs = 0;
9939 EGLint configSize = 0;
9940
9941 // Get the number of possible EGLConfigs
9942 if ( eglGetConfigs( iEGLDisplay, configList, configSize, &numOfConfigs ) == EGL_FALSE )
9943 {
9944 DEBUGPRINT("ChooseEglConfigL: eglGetConfigs: returned EGL_FALSE");
9945 User::Leave(KErrGeneral);
9946 }
9947
9948 configSize = numOfConfigs;
9949
9950 // Allocate memory for the configList
9951 configList = (EGLConfig*) User::AllocLC( sizeof(EGLConfig)*configSize );
9952
9953 RWindow* rWindow = GetWindow();
9954 TDisplayMode dispMode = rWindow->DisplayMode();
9955 TInt bufferSize = TDisplayModeUtils::NumDisplayModeBitsPerPixel(rWindow->DisplayMode());
9956
9957 EGLint eglPixmapSurfaceType = EGL_PIXMAP_BIT;
9958#if !defined(EGL_SINGLE_BUFFERING) && defined(FORCE_REFRESH_WORKAROUND)
9959 eglPixmapSurfaceType |= EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
9960#endif
9961
9962 const TInt KAlphaMaskSize = 8; //8 bits are required for a 24bit color surface
9963
9964 const EGLint KEGLPixmapConfig[] =
9965 {
9966 EGL_BUFFER_SIZE, bufferSize,
9967 EGL_SURFACE_TYPE, eglPixmapSurfaceType,
9968 EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
9969 EGL_ALPHA_MASK_SIZE, KAlphaMaskSize,
9970 EGL_NONE
9971 };
9972
9973 EGLint eglWindowSurfaceType = EGL_WINDOW_BIT;
9974#if !defined(EGL_SINGLE_BUFFERING) && defined(FORCE_REFRESH_WORKAROUND)
9975 eglWindowSurfaceType |= EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
9976#endif
9977
9978 const EGLint KEGLWindowConfig[] =
9979 {
9980 EGL_BUFFER_SIZE, bufferSize,
9981 EGL_SURFACE_TYPE, eglWindowSurfaceType,
9982 EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
9983 EGL_ALPHA_MASK_SIZE, KAlphaMaskSize,
9984 EGL_NONE
9985 };
9986
9987 TBool success = EFalse;
9988 if(iRenderToBitmap)
9989 {
9990 success = (eglChooseConfig(iEGLDisplay, KEGLPixmapConfig, configList, configSize, &numOfConfigs) == EGL_TRUE);
9991 }
9992 else
9993 {
9994 success = (eglChooseConfig(iEGLDisplay, KEGLWindowConfig, configList, configSize, &numOfConfigs) == EGL_TRUE);
9995 }
9996
9997 if(!success || numOfConfigs == 0)
9998 {
9999 DEBUGPRINT("ChooseEglConfigL: eglChooseConfig: returned %d numOfConfigs: %d",success, numOfConfigs);
10000 CleanupStack::PopAndDestroy();
10001 User::Leave(KErrGeneral);
10002 }
10003
10004 // returned by eglChooseConfig are sorted so
10005 // that the best matching EGLConfig is first in
10006 // the list.
10007 iEGLConfig = configList[0];
10008 CleanupStack::PopAndDestroy(); // Free configList, not used anymore.
10009
10010}
10011
10012void CPlatformFlashEngine::InitEGLMaxDimensionL()
10013{
10014 DEBUGPRINT("CPlatformFlashEngine::InitEGLMaxDimensionL:");
10015
10016 EGLBoolean retErrWidth, retErrHeight;
10017 retErrWidth = eglGetConfigAttrib(iEGLDisplay, iEGLConfig, EGL_MAX_PBUFFER_WIDTH, &iEGLMaxSupportedWidth);
10018 retErrHeight = eglGetConfigAttrib(iEGLDisplay, iEGLConfig, EGL_MAX_PBUFFER_HEIGHT, &iEGLMaxSupportedHeight);
10019
10020 if (retErrWidth == EGL_FALSE || retErrHeight == EGL_FALSE)
10021 {
10022 DEBUGPRINT("GetMaxSupportedDimensionL: returned EGL_FALSE");
10023
10024 iEGLMaxSupportedWidth = KMaxSupportedFrameDimension;
10025 iEGLMaxSupportedHeight = KMaxSupportedFrameDimension;
10026 }
10027
10028 DEBUGPRINT("GetMaxSupportedDimensionL: returned maxWidth: %d maxHeight: %d",
10029 iEGLMaxSupportedWidth, iEGLMaxSupportedHeight);
10030}
10031
10032void CPlatformFlashEngine::CreateEglSurfaceL()
10033{
10034 DEBUGPRINT("CPlatformFlashEngine::CreateEglSurfaceL: iEGLInitialized: %d", iEGLInitialized);
10035 DestroyEgl(); //destroy if any surface is available.
10036
10037 if (!iEGLInitialized)
10038 {
10039 InitializeEglL();
10040 }
10041
10042 RWindow* rWindow = GetWindow();
10043
10044 if(iRenderToBitmap)
10045 {
10046 iEGLSurface.surface = (void*) eglCreatePixmapSurface(iEGLDisplay, iEGLConfig, iBitmap, NULL);
10047 }
10048 else
10049 {
10050 iEGLSurface.surface = (void*) eglCreateWindowSurface(iEGLDisplay, iEGLConfig, rWindow, KWinSurfaceAttribList);
10051 }
10052
10053 if (iEGLSurface.surface == EGL_NO_SURFACE)
10054 {
10055 DEBUGPRINT("CPlatformFlashEngine::CreateEglSurfaceL(), eglCreateXXXSurface() failed! Error = %d", eglGetError());
10056 User::Leave(KErrGeneral);
10057 }
10058
10059#if !defined(EGL_SINGLE_BUFFERING) && defined(FORCE_REFRESH_WORKAROUND)
10060 if( eglSurfaceAttrib(iEGLDisplay, (EGLSurface)iEGLSurface.surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED) == EGL_FALSE )
10061 {
10062 DEBUGPRINT("CPlatformFlashEngine::CreateEglSurfaceL(), eglSurfaceAttrib() failed! Error = %d", eglGetError());
10063 User::Leave(KErrGeneral);
10064 }
10065#endif
10066
10067 /* Make the context current. Binds context to the current rendering thread and surface.*/
10068 SetCurrentEglContext();
10069
10070#ifdef USE_VPU2 // only if VPU2 and OPENVG are enabled.
10071 //Alpha has to be enabled on egl, everytime egl is bound to a window.
10072 EnableAlphaOnEgl(rWindow);
10073#endif
10074
10075 iRenderingWindow = rWindow;
10076 iCurrentWindowSize = rWindow->Size();
10077
10078 FI_Rect fiRect;
10079 fiRect.xmin = (short) 0;
10080 fiRect.ymin = (short) 0;
10081 fiRect.xmax = (short) iFrameBufferSize.iWidth;
10082 fiRect.ymax = (short) iFrameBufferSize.iHeight;
10083
10084 iFiObject.FI_SetDirtyRect(&fiRect, 1); //dont care return value.
10085}
10086
10087void CPlatformFlashEngine::DestroyEgl()
10088{
10089 DEBUGPRINT("CPlatformFlashEngine::DestroyEgl: iOpenVgMode: %d", iOpenVgMode);
10090 //RC: ou1cimx1#668194
10091 //if(!iOpenVgMode)
10092 // return;
10093
10094 DestroyEglSurface();
10095
10096 if (iEGLContext != EGL_NO_CONTEXT)
10097 {
10098 eglDestroyContext(iEGLDisplay, iEGLContext);
10099 iEGLContext = EGL_NO_CONTEXT;
10100 }
10101
10102 if(iEGLInitialized)
10103 {
10104 iHostEngineGlobals->RemoveEGLClient((TAny*)this);
10105 iEGLInitialized = EFalse;
10106 }
10107
10108 if (iEGLDisplay != EGL_NO_DISPLAY && iHostEngineGlobals->NumEGLClients() == 0)
10109 {
10110
10111 if(eStandAlone==iExecutionMode)
10112 {
10113 TInt err = KErrNone;
10114 //As browser is also HW rendered, these functions are called by browser. Todo: Dynamically check if browser is HW rendered.
10115 err = eglTerminate(iEGLDisplay); // Release resources associated with EGL and OpenGL ES
10116
10117 if(err)
10118 DEBUGPRINT("EGL Terminated, %d", err);
10119
10120 /*RC:ou1cimx1#513829 Reason: EGL maintains a small amount of per-thread state, including the error status
10121 returned by eglGetError, so to relase these memory we need to call eglReleaseThread, to set EGL to its state
10122 at thread initialization*/
10123 eglReleaseThread();
10124 }
10125 iEGLDisplay = NULL;
10126
10127 }
10128
10129/*
10130 * FIXME:
10131 * Temporarily commented out.
10132 * EGL needs to be initialized and terminated only once irrespective of the number of plugin instances.
10133 * Trying to terminate it for each instance may cause the phone to hang as the otehr instance may try to write to the surface
10134 if (iEGLDisplay)
10135 {
10136 TInt err = eglTerminate(iEGLDisplay); // Release resources associated with EGL and OpenGL ES
10137 iEGLDisplay = NULL;
10138 DEBUGPRINT("EGL Terminated, %d", err);
10139 }
10140*/
10141}
10142
10143#if defined(FEATURE_OPENVG) && defined(USE_VPU2)
10144void CPlatformFlashEngine::EnableAlphaOnEgl(RWindow* aWindow)
10145{
10146 ASSERT(aWindow != NULL);
10147
10148 if(iCompositionControl)
10149 {
10150 delete iCompositionControl;
10151 iCompositionControl = NULL;
10152 }
10153
10154 TRAPD(err,iCompositionControl = CAlfCompositionSource::NewL(*aWindow));
10155 if(err == KErrNone)
10156 iCompositionControl->EnableAlpha(ETrue);
10157 //else
10158 // handle error
10159
10160 delete iCompositionControl;
10161 iCompositionControl = NULL;
10162}
10163#endif
10164
10165void CPlatformFlashEngine::RecreateSurfaceL(RWindow* aWindow)
10166{
10167 if(iEGLDisplay == EGL_NO_DISPLAY||
10168 // if the surface is NULL (may not be visible) then no point in creating it
10169 //as it'll anyway be created when it comes into view
10170 iEGLSurface.surface == EGL_NO_SURFACE)
10171 {
10172 return;
10173 }
10174
10175#ifndef EGL_SINGLE_BUFFERING
10176 TSize currentWindowSize = aWindow->Size();
10177 // Due to the limitation of the EGL implementation (CPAY-7VJEE8) the egl surface is automatically
10178 // resized *only* if the new area is less than or equal to the prev area
10179
10180 //EAJI-84ZBAG: When User has Paused, and switch from FS to NS(New Window size is smaller)
10181 //EGL Surface should be automatically resized(CPAY-7VJEE8), but only Blank Screen is displayed.
10182 //Cannot be fixed from NGA Team now.
10183 //Workaround: If User has Paused, Always Recreate Whole Surface regardless of Window Size
10184 // instead of depending on Automatic Resize of EGL Surface
10185 if ( ((currentWindowSize.iWidth <= iCurrentWindowSize.iWidth && currentWindowSize.iHeight <= iCurrentWindowSize.iHeight) ||
10186 (currentWindowSize.iWidth <= iCurrentWindowSize.iHeight&& currentWindowSize.iHeight <= iCurrentWindowSize.iWidth)) &&
10187 (iRenderingWindow == aWindow) && (!(iPauseFlags & EReasonUser ))
10188 )
10189
10190 {
10191 iCurrentWindowSize = currentWindowSize;
10192
10193 FI_Rect fiRect;
10194 fiRect.xmin = (short) 0;
10195 fiRect.ymin = (short) 0;
10196 fiRect.xmax = (short) iFrameBufferSize.iWidth;
10197 fiRect.ymax = (short) iFrameBufferSize.iHeight;
10198
10199 iFiObject.FI_SetDirtyRect(&fiRect, 1); //dont care return value.
10200
10201#ifdef FORCE_REFRESH_WORKAROUND
10202 iForceRedraw = ETrue;
10203#endif
10204 return;
10205 }
10206#endif
10207
10208 eglMakeCurrent( iEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
10209
10210 eglDestroySurface(iEGLDisplay, (EGLSurface)iEGLSurface.surface); //dont care return value.
10211
10212 if(iRenderToBitmap) {
10213 iEGLSurface.surface = (void*) eglCreatePixmapSurface(iEGLDisplay, iEGLConfig, iBitmap, NULL);
10214 }
10215 else {
10216 iEGLSurface.surface = (void*) eglCreateWindowSurface(iEGLDisplay, iEGLConfig, aWindow, KWinSurfaceAttribList);
10217 }
10218
10219 if (iEGLSurface.surface == EGL_NO_SURFACE)
10220 {
10221 DEBUGPRINT("CPlatformFlashEngine::RecreateSurfaceL(), eglCreateXXXSurface() failed! Error = %d", eglGetError());
10222 User::Leave(KErrGeneral);
10223 }
10224
10225#if !defined(EGL_SINGLE_BUFFERING) && defined(FORCE_REFRESH_WORKAROUND)
10226 if( eglSurfaceAttrib(iEGLDisplay, (EGLSurface)iEGLSurface.surface, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED) == EGL_FALSE )
10227 {
10228 DEBUGPRINT("CPlatformFlashEngine::RecreateSurfaceL(), eglSurfaceAttrib() failed! Error = %d", eglGetError());
10229 User::Leave(KErrGeneral);
10230 }
10231#endif
10232
10233 iCurrentWindowSize = GetWindow()->Size();
10234
10235 eglBindAPI(EGL_OPENVG_API);
10236
10237 /* Make the context current. Binds context to the current rendering thread and surface.*/
10238 if (eglMakeCurrent(iEGLDisplay, (int) iEGLSurface.surface, (int) iEGLSurface.surface, iEGLContext) == EGL_FALSE)
10239 {
10240 DEBUGPRINT("CPlatformFlashEngine::RecreateSurfaceL(), eglMakeCurrent() failed! Error = %d", eglGetError());
10241 User::Leave(KErrGeneral);
10242 }
10243
10244 iRenderingWindow = aWindow;
10245 iRedraw = ETrue;
10246
10247#ifdef USE_VPU2 // only if VPU2 and OPENVG are enabled.
10248 //Alpha has to be enabled on egl, everytime egl is bound to a window.
10249 EnableAlphaOnEgl(aWindow);
10250#endif
10251
10252 FI_Rect fiRect;
10253 fiRect.xmin = (short) 0;
10254 fiRect.ymin = (short) 0;
10255 fiRect.xmax = (short) iFrameBufferSize.iWidth;
10256 fiRect.ymax = (short) iFrameBufferSize.iHeight;
10257
10258 iFiObject.FI_SetDirtyRect(&fiRect, 1); //dont care return value.
10259#ifdef FORCE_REFRESH_WORKAROUND
10260 iForceRedraw = ETrue;
10261#endif
10262}
10263
10264void CPlatformFlashEngine::DestroyEglSurface()
10265{
10266 DEBUGPRINT("CPlatformFlashEngine::DestroyEgl: iEGLDisplay: %d", iEGLDisplay);
10267 if(iEGLDisplay == EGL_NO_DISPLAY)
10268 return;
10269
10270 eglMakeCurrent(iEGLDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
10271
10272 if (iEGLSurface.surface != EGL_NO_SURFACE)
10273 {
10274 eglDestroySurface(iEGLDisplay, (EGLSurface) iEGLSurface.surface);
10275 iEGLSurface.surface = EGL_NO_SURFACE;
10276 }
10277
10278}
10279
10280void CPlatformFlashEngine::SetCurrentEglContext()
10281{
10282 if(!iOpenVgMode)
10283 return;
10284
10285 /* Make the context current. Binds context to the current rendering thread and surface.*/
10286 if (eglMakeCurrent(iEGLDisplay, (int) iEGLSurface.surface, (int) iEGLSurface.surface, iEGLContext) == EGL_FALSE)
10287 {
10288 //_LIT(KMakeCurrentFailed, "eglMakeCurrent failed");
10289 //We need to check if we this is a critical error and show broken flash icon not user panic
10290 //User::Panic(KMakeCurrentFailed, 0);
10291 }
10292}
10293
10294TInt CPlatformFlashEngine::SwitchToSoftwareRendering(TBool aSync)
10295{
10296 if(iInDoPlay || !iMMObject)
10297 {
10298 return KErrGeneral;
10299 }
10300 iRenderingSwitchType = ESwitchRenderingHWToSW;
10301 if(!aSync)
10302 {
10303 TCallBack cbk(ToggleRenderingMode,(TAny*)(this));
10304 if(iRenderToggleTimer)
10305 {
10306 delete iRenderToggleTimer;
10307 iRenderToggleTimer = NULL;
10308 }
10309 TRAPD(err,iRenderToggleTimer = CFlhTimerObject2::NewL(CActive::EPriorityHigh,cbk));
10310 if(err == KErrNone)
10311 {
10312 iSwitchingToSWRenderingInPrgress = ETrue;
10313 iRenderToggleTimer->After(0);
10314 }
10315 }
10316 else
10317 {
10318 DoToggleRenderingMode();
10319 }
10320
10321 return KErrNone;
10322}
10323
10324TInt CPlatformFlashEngine::SwitchToHwxRendering(TBool aSync)
10325{
10326 if(iInDoPlay || !iMMObject)
10327 {
10328 return KErrGeneral;
10329 }
10330 iRenderingSwitchType = ESwitchRenderingSWToHW;
10331
10332 if(!aSync)
10333 {
10334 TCallBack cbk(ToggleRenderingMode,(TAny*)(this));
10335 if(iRenderToggleTimer)
10336 {
10337 delete iRenderToggleTimer;
10338 iRenderToggleTimer = NULL;
10339 }
10340 TRAPD(err,iRenderToggleTimer = CFlhTimerObject2::NewL(CActive::EPriorityHigh,cbk));
10341 if(err == KErrNone)
10342 iRenderToggleTimer->After(0);
10343 }
10344 else
10345 {
10346 DoToggleRenderingMode();
10347 }
10348
10349 if(iFlashClientIf)
10350 iFlashClientIf->DrawDirtyRect(iFrameBufferSize);
10351
10352 return KErrNone;
10353}
10354
10355TInt CPlatformFlashEngine::ToggleRenderingMode(TAny* aPtr)
10356{
10357 CPlatformFlashEngine* engine = (CPlatformFlashEngine*)aPtr;
10358 engine->iSwitchingToSWRenderingInPrgress = EFalse;
10359
10360 TInt err = engine->DoToggleRenderingMode();
10361
10362 delete engine->iRenderToggleTimer;
10363 engine->iRenderToggleTimer = NULL;
10364
10365 return err;
10366}
10367
10368TInt CPlatformFlashEngine::DoToggleRenderingMode()
10369{
10370 DEBUGPRINT("CPlatformFlashEngine::%s ++",__FUNCTION__);
10371 if(iOpenVgMode && iRenderingSwitchType == ESwitchRenderingHWToSW)
10372 {
10373 TInt initErr = 0, revertErr = 0;
10374 TInt err = iFiObject.FI_SetRenderMode(FI_RenderMode_Software);
10375 DEBUGPRINT("%s setrendermode %d",__FUNCTION__,err);
10376 if(err != 0)
10377 {//switching to SW rendering was successful
10378 /*RC: ou1cimx1#668194 , Do not destroy last EGL until we have a new request,
10379 as deleting this would make some of the resources orphan e.g. VGPath which are held by Core player and may result
10380 in memory leak. Deletion is done inside CreateEglSurfaceL().
10381 */
10382 //DestroyEgl();
10383 FreeBits();
10384
10385 DEBUGPRINT("CPlatformFlashEngine::%s switching to sw rend success",__FUNCTION__);
10386
10387 iOpenVgMode = EFalse;
10388 iRenderToBitmap = ETrue;
10389
10390 TRAP(initErr,InitializeL(TRect(iFrameBufferSize),EFalse,EFalse));
10391
10392 if(initErr == KErrNone)
10393 DEBUGPRINT("CPlatformFlashEngine::%s initializel success",__FUNCTION__);
10394 }
10395 else
10396 {//switching failed. So set to HW rend again.
10397 if(iFiObject.FI_SetRenderMode(FI_RenderMode_Hardware) == 0)
10398 revertErr = KErrGeneral;
10399 }
10400
10401 if(initErr || revertErr)
10402 {
10403 MUserNotiferIf* userNotifier = iFlashClientIf->GetUserNotifierIf();
10404 if(userNotifier)
10405 {
10406 userNotifier->NotifyClientError(EInsufficientGPUMemoryError, ETrue);
10407 }
10408 return KErrNone;
10409 }
10410 }
10411 else if(iRenderingSwitchType == ESwitchRenderingSWToHW)
10412 {
10413 TInt initErr = 0;
10414 TInt corePlayerSwitchErr=0, eglCreateErr=0;
10415
10416 FreeBits();
10417
10418 iOpenVgMode = ETrue;
10419 iRenderToBitmap = EFalse;
10420
10421 TRAP(eglCreateErr,CreateEglSurfaceL());
10422 if(eglCreateErr)
10423 {
10424 DestroyEgl(); //cleanup
10425 }
10426
10427 if(!eglCreateErr)
10428 {
10429 TRAP(initErr,InitializeL(TRect(iFrameBufferSize),EFalse,EFalse));
10430 }
10431
10432 if(!initErr && !eglCreateErr)
10433 {
10434 corePlayerSwitchErr = iFiObject.FI_SetRenderMode(FI_RenderMode_Hardware);
10435 /* ou1cimx1#476183 : Workaround to ensure that when we have switched to hw rendering,
10436 * the last bitmap blitted to the screen in sw rendering mode is cleared from the
10437 * redraw store, before the new content is rendered onto the egl surface.
10438 * If this is not done previously blitted bitmap stays on top of the egl surface
10439 * and any new content rendered by egl is not visible until the screen is redrawn.
10440 */
10441 if(corePlayerSwitchErr != 0)
10442 {
10443 DrawDirtyRegion(TRect(iFrameBufferSize));
10444 }
10445 }
10446
10447 if(initErr || eglCreateErr || (corePlayerSwitchErr==0))
10448 {
10449 FreeBits();
10450 iOpenVgMode = EFalse;
10451 iRenderToBitmap = ETrue;
10452
10453 TRAP(initErr,InitializeL(TRect(iFrameBufferSize),EFalse,EFalse));
10454 if(!initErr)
10455 {
10456 corePlayerSwitchErr = iFiObject.FI_SetRenderMode(FI_RenderMode_Software);
10457 }
10458 }
10459
10460 if(initErr || (corePlayerSwitchErr==0))
10461 {
10462 DEBUGPRINT("initErr %d corePlayerSwitchErr %d ",initErr,corePlayerSwitchErr);
10463 MUserNotiferIf* userNotifier = iFlashClientIf->GetUserNotifierIf();
10464 if(userNotifier)
10465 {
10466 userNotifier->NotifyClientError(EInsufficientGPUMemoryError, ETrue);
10467 }
10468 return KErrNone;
10469 }
10470 }
10471
10472 return KErrNone;
10473}
10474
10475void CPlatformFlashEngine::HandleGainingForeground()
10476{
10477// Switching to HW rendering is handled in NotifyFocusChange
10478}
10479
10480void CPlatformFlashEngine::HandleLosingForeground()
10481{
10482 if(iOpenVgMode && iMMObject)
10483 {
10484 SwitchToSoftwareRendering(ETrue);
10485 }
10486}
10487
10488
10489/*
10490 EGLint errCode = eglGetError();
10491 const char *s;
10492
10493 switch (errCode)
10494 {
10495 case EGL_SUCCESS:
10496 s = "EGL_SUCCESS";
10497 break;
10498 case EGL_BAD_ACCESS:
10499 s = "EGL_BAD_ACCESS";
10500 break;
10501 case EGL_BAD_ALLOC:
10502 s = "EGL_BAD_ALLOC";
10503 break;
10504 case EGL_BAD_ATTRIBUTE:
10505 s = "EGL_BAD_ATTRIBUTE";
10506 break;
10507 case EGL_BAD_CONFIG:
10508 s = "EGL_BAD_CONFIG";
10509 break;
10510 case EGL_BAD_CONTEXT:
10511 s = "EGL_BAD_CONTEXT";
10512 break;
10513 case EGL_BAD_CURRENT_SURFACE:
10514 s = "EGL_BAD_CURRENT_SURFACE";
10515 break;
10516 case EGL_BAD_DISPLAY:
10517 s = "EGL_BAD_DISPLAY";
10518 break;
10519 case EGL_BAD_MATCH:
10520 s = "EGL_BAD_MATCH";
10521 break;
10522 case EGL_BAD_NATIVE_PIXMAP:
10523 s = "EGL_BAD_NATIVE_PIXMAP";
10524 break;
10525 case EGL_BAD_NATIVE_WINDOW:
10526 s = "EGL_BAD_NATIVE_WINDOW";
10527 break;
10528 case EGL_BAD_PARAMETER:
10529 s = "EGL_BAD_PARAMETER";
10530 break;
10531 case EGL_BAD_SURFACE:
10532 s = "EGL_BAD_SURFACE";
10533 break;
10534 case EGL_NOT_INITIALIZED:
10535 s = "EGL_NOT_INITIALIZED";
10536 break;
10537 case EGL_CONTEXT_LOST:
10538 s = "EGL_CONTEXT_LOST";
10539 break;
10540 default:
10541 s = "other";
10542 }*/
10543
10544#endif
10545
10546#ifdef FORCE_REFRESH_WORKAROUND
10547void CPlatformFlashEngine::ForceRedraw()
10548{
10549 if(iForceRedrawTimer)
10550 {
10551 delete iForceRedrawTimer;
10552 iForceRedrawTimer = NULL;
10553 }
10554
10555 TCallBack cbk(ForceRedrawCallback,(TAny*)(this));
10556 TRAPD(err, iForceRedrawTimer = CFlhTimerObject2::NewL(CActive::EPriorityStandard,cbk));
10557 if(err == KErrNone)
10558 {
10559 iForceRedrawTimer->After(0);
10560 }
10561
10562 iForceRedraw = EFalse;
10563}
10564
10565TInt CPlatformFlashEngine::ForceRedrawCallback(TAny* aPtr)
10566{
10567 CPlatformFlashEngine* engine = (CPlatformFlashEngine*)aPtr;
10568 if(engine)
10569 engine->DoForceRedraw();
10570
10571 return KErrNone;
10572}
10573
10574void CPlatformFlashEngine::DoForceRedraw()
10575{
10576 iRedraw = ETrue;
10577 HandleRedraw();
10578 if(iForceRedrawTimer)
10579 {
10580 delete iForceRedrawTimer;
10581 iForceRedrawTimer = NULL;
10582 }
10583 iForceRedraw = EFalse;
10584
10585}
10586#endif
10587
10588TBool CPlatformFlashEngine::NoETelSuppport()
10589{
10590 return (iConfig.iMode & KSupportNoETelInfo)? ETrue: EFalse;
10591}
10592
10593TBool CPlatformFlashEngine::HasQuertyKBSuppport()
10594{
10595 return (iConfig.iMode & KSupportQuertyKB)? ETrue: EFalse;
10596}
10597
10598TBool CPlatformFlashEngine::InstanceInTrustedSandBox()
10599{
10600 return (iConfig.iMode & KSupportTrustedSandBox)? ETrue: EFalse;
10601
10602}
10603
10604
10605#ifdef FEATURE_VIDEO_DLL
10606FL_ReferenceCountedObjectShare *
10607CPlatformFlashEngine::GetShareForCodec( U32 codecType )
10608{
10609 FL_ReferenceCountedObjectShare * share = NULL;
10610
10611 if ( codecType == kH263Codec )
10612 share = &m_decompressorSorenson;
10613 else if ( codecType == kVP6Codec || codecType == kVP6AlphaCodec )
10614 share = &m_decompressorOn2;
10615 else
10616 {
10617 PLAYERASSERT( false );
10618 share = NULL;
10619 }
10620 return share;
10621}
10622
10623IVideoDecompressorInstance* CPlatformFlashEngine::GetNativeVideoDecompressor(MM_Object* aMMObj, void * aAllocator, U32 codecType)
10624{
10625#ifdef FEATURE_WINDOWLESS
10626 if((iFlashClientIf->GetWMode() != EWindow) && (codecType != AUDIO_ONLY_CODEC))
10627 {
10628 MUserNotiferIf* userNotifier = iFlashClientIf->GetUserNotifierIf();
10629 if(userNotifier)
10630 {
10631 userNotifier->NotifyClientError(KErrNotSupported, ETrue);
10632 }
10633 return NULL;
10634 }
10635#endif //FEATURE_WINDOWLESS
10636
10637#ifdef FEATURE_OPENVG
10638 if(iOpenVgMode)
10639 {
10640 iRenderingSwitchType = ESwitchRenderingHWToSW;
10641 TCallBack cbk(ToggleRenderingMode,(TAny*)(this));
10642 delete iRenderToggleTimer;
10643 iRenderToggleTimer = NULL;
10644 TRAPD(err,iRenderToggleTimer = CFlhTimerObject2::NewL(CActive::EPriorityHigh,cbk));
10645 if(err == KErrNone)
10646 {
10647 iSwitchingToSWRenderingInPrgress = ETrue;
10648 iRenderToggleTimer->After(0);
10649 }
10650 }
10651#endif
10652
10653 IVideoDecompressorInstance* instance = NULL;
10654 TRAPD(error, instance = CreateNativeVideoDecompressorL(aMMObj, aAllocator, codecType));
10655 if( error != KErrNone )
10656 {
10657 return NULL;
10658 }
10659
10660 return instance;
10661}
10662
10663
10664IVideoDecompressorInstance* CPlatformFlashEngine::CreateNativeVideoDecompressorL(MM_Object* aMMObj, void * aAllocator, U32 codecType)
10665{
10666 // If Ph2 (helix mode) feature is present,
10667 // then we take the operating mode (Ph1/Ph2) based on whether the video is embedded video or not.
10668
10669// Commented : AK
10670 /* if( iConfig.iHelixFlvMode )
10671 {
10672 if( metaData && metaData->isEmbeddedVideo )
10673 {
10674 iConfig.iHelixFlvMode = EFalse;
10675 }
10676 else
10677 iConfig.iHelixFlvMode = ETrue;
10678
10679 }
10680 else
10681 iConfig.iHelixFlvMode = EFalse;
10682
10683 return CreateFlvDecompressorL(aMMObj, aAllocator, codecType);
10684 */
10685 if( iConfig.iHelixFlvMode )
10686 {
10687 return CreateFlvDecompressorL(aMMObj, aAllocator, codecType);
10688 }
10689 else
10690 {
10691 if( !iFlvDecoder )
10692 {
10693 iFlvDecoder = CFLPlatformDecoderInterface::NewL(UserMode());
10694 }
10695 if( iFlvDecoder )
10696 {
10697 SetVideoRectL(NULL, EVideoNone);
10698
10699 return iFlvDecoder->CreateVideoDecompressorL(aMMObj, aAllocator, codecType);
10700 }
10701 }
10702
10703 return NULL;
10704}
10705
10706
10707IVideoDecompressorInstance* CPlatformFlashEngine::CreateFlvDecompressorL(MM_Object* aMMObj, void * aAllocator, U32 codecType)
10708{
10709 IVideoDecompressorInstance* decoder = NULL;
10710
10711 iFlvDecoder = CFLPlatformDecoderInterface::NewL(UserMode());
10712
10713 if (iFlvDecoder)
10714 {
10715 iFlvDecoderArray.AppendL(iFlvDecoder);
10716
10717 SetVideoRectL(NULL, EVideoNone);
10718
10719 decoder= iFlvDecoder->CreateVideoDecompressorL(aMMObj, aAllocator, codecType);
10720 //commenting this SetMaxVideoFramesToProcess does have performance impact for external video rendering and buffering
10721 //default is set to 300 by coreplayer and new exact seek functionality is dependant on max frames to process
10722 /* if(iConfig.iHelixFlvMode)
10723 iFiObject.FI_SetMaxVideoFramesToProcess(KMaxVideoFramesToProcess);*/
10724
10725 return decoder;
10726 }
10727
10728 return NULL;
10729}
10730
10731TUserMode CPlatformFlashEngine::UserMode()
10732{
10733 TUserMode uMode = EUnknownMode;
10734 //iBrowserPluginActive ? uMode = EPluginMode : uMode = EApplicationMode;
10735 (iExecutionMode == eStandAlone) ? uMode = EApplicationMode : uMode = EPluginMode;
10736 return uMode;
10737}
10738
10739void CPlatformFlashEngine::DestroyVideoDecompressor(MM_Object * aMMObj, IVideoDecompressorInstance *aDecompressorInstance)
10740{
10741 for( TInt n=0; n < iFlvDecoderArray.Count(); n++ )
10742 {
10743 CFLPlatformDecoderInterface* decoderInstance;
10744
10745 for( TInt n=0; n < iFlvDecoderArray.Count(); n++ )
10746 {
10747 decoderInstance = iFlvDecoderArray[n];
10748
10749 if( decoderInstance->DecompresssorInstance() == aDecompressorInstance )
10750 {
10751 iFlvDecoderArray.Remove(n);
10752
10753 decoderInstance->DestroyVideoDecompressor(aMMObj, aDecompressorInstance);
10754
10755 delete decoderInstance;
10756 }
10757 }
10758
10759 // When the list becomes empty, make the rect NULL.
10760 // We are making the rect = NULL because other videos may still have some rect.
10761
10762 if( !iFlvDecoderArray.Count() )
10763 {
10764 TRAP_IGNORE(SetVideoRectL(NULL, EVideoNone));
10765 }
10766 }
10767
10768 //Switch back to HW rendering on destruction of last FLVDecoder instance.
10769 if(0==iFlvDecoderArray.Count() && iSwfInDestruction==EFalse)
10770 {
10771 SwitchToHwxRendering(EFalse);
10772 }
10773}
10774
10775void CPlatformFlashEngine::UpdateVideoScreen()
10776{
10777 if( !iFlvDecoderArray.Count() && !iVideoRect.iRect.IsEmpty() && iVideoEngine && iVideoRect.iVideoType == EDeviceVideo )
10778 {
10779 TRAP_IGNORE(iVideoEngine->NotifySizeChangedL());
10780 }
10781
10782 if( !iConfig.iHelixFlvMode )
10783 {
10784 return;
10785 }
10786
10787 if( !iFlvDecoderArray.Count() )
10788 {
10789 return;
10790 }
10791
10792 THXVDCmdArg arg;
10793 EngineDispatchHXCommand(EHXVDCmdRefreshScreen, arg);
10794}
10795
10796#endif
10797
10798#ifdef FEATURE_WEB_BROWSABILITY
10799MHostScriptHandler* CPlatformFlashEngine::GetScriptHandler()
10800{
10801 return iHostScriptHandler;
10802}
10803
10804TDesC8& CPlatformFlashEngine::GetMovieId()
10805{
10806if(iName)
10807{
10808 return (*iName);
10809}
10810
10811TRAP_IGNORE(iName = HBufC8::NewL(KDefaultNameLength));
10812 return(*iName);
10813
10814}
10815#endif
10816
10817#ifdef __FEATURE_PRE_COMPILED_SWF
10818
10819TBool CPlatformFlashEngine::GetClassFileBufL(const char* aFilename, int aFileLen, unsigned char*& aBuf, int& aLen)
10820{
10821 RFile file;
10822
10823 HBufC* fileName = CreateEpocStringLC(aFilename,aFileLen);
10824
10825 TInt ret = file.Open(iFs, *fileName, EFileRead | EFileShareExclusive | EFileStream);
10826 if(ret != KErrNone)
10827 {
10828 CleanupStack::PopAndDestroy(fileName);
10829 return EFalse;
10830 }
10831 CleanupClosePushL(file);
10832
10833 User::LeaveIfError(file.Size(aLen));
10834
10835 // Length + 1 because the buffer needs to be null terminated
10836
10837 aBuf = new(ELeave) unsigned char[aLen + 1];
10838
10839 TPtr8 bufptr( (TUint8*)aBuf, aLen );
10840
10841 User::LeaveIfError(file.Read(bufptr));
10842
10843 aBuf[aLen] = '\0';
10844
10845 CleanupStack::PopAndDestroy(&file);
10846 CleanupStack::PopAndDestroy(fileName);
10847
10848 file.Close();
10849 return ETrue;
10850
10851}
10852
10853void CPlatformFlashEngine::FreeClassFileBuf(unsigned char*& aBuf)
10854{
10855 if (aBuf)
10856 delete aBuf;
10857 aBuf=NULL;
10858}
10859
10860#ifdef __FEATURE_PRE_COMPILED_SWF_RSC
10861void CPlatformFlashEngine::SetPreInsASClassFromRscL ()
10862{
10863 TInt count,i;
10864 TInt resoffset = FlashEngineRscHandler::LoadEngineResourceFileL();
10865 char** array=AllocReadResourceArrayIntoFlashStringArrayL(count, R_FLASH_SUPPORTED_PREINSTALLED_AS_CLASS);
10866
10867 for(i=0;i<count;i++)
10868 {
10869 unsigned char* classSwfData = NULL;
10870 int classLen;
10871 if(GetClassFileBufL(array[i],FlashStrLen(array[i]), classSwfData, classLen))
10872 {
10873 iFiObject.FI_SetPreInstalledASClass(classSwfData, classLen, false);
10874 FlashMemSet(classSwfData,0,classLen);
10875 FreeClassFileBuf(classSwfData);
10876 }
10877 delete[] array[i];
10878 }
10879
10880 delete[] array;
10881 array=NULL;
10882 FlashEngineRscHandler::DeleteEngineResourceFile(iEnv, resoffset);
10883}
10884#endif // __FEATURE_PRE_COMPILED_SWF_RSC
10885
10886void CPlatformFlashEngine::SetPreInstalledASClassL( )
10887{
10888
10889#ifdef __FEATURE_PRE_COMPILED_SWF_RSC
10890 SetPreInsASClassFromRscL ();
10891#endif // __FEATURE_PRE_COMPILED_SWF_RSC
10892
10893 if (0 == iConfig.iActScriptExtensions)
10894 return;
10895
10896 //get iConfig.Reserved1
10897 //extract each
10898 TPtrC8 temp_ASClasses, temp_ASClass;
10899 const TChar KASClassSeparator = ';';
10900 temp_ASClasses.Set(iConfig.iActScriptExtensions->Mid(0));
10901
10902 TInt pos = 0;
10903 while (KErrNotFound != pos)
10904 {
10905 pos = temp_ASClasses.Locate(KASClassSeparator);
10906 if (KErrNotFound == pos)
10907 {
10908 temp_ASClass.Set(temp_ASClasses.Mid (0));
10909 }
10910 else
10911 {
10912 temp_ASClass.Set(temp_ASClasses.Left(pos));
10913 temp_ASClasses.Set(temp_ASClasses.Mid(pos+1));
10914 }
10915
10916 //Call FI_Func on temp_ASClasses
10917 CallFI_SetPreInstASClassL (temp_ASClass, false);
10918 }
10919}
10920
10921TBool CPlatformFlashEngine::HasSwfExtension( const TDesC& aStr )
10922{
10923 TInt len = aStr.Length();
10924 return ( len >= 4 &&
10925 (aStr[len-4] == '.' &&
10926 (aStr[len-3] == 's' || aStr[len-3] == 'S') &&
10927 (aStr[len-2] == 'w' || aStr[len-2] == 'W') &&
10928 (aStr[len-1] == 'f' || aStr[len-1] == 'F') ) );
10929}
10930
10931void CPlatformFlashEngine::CallFI_SetPreInstASClassL (TDesC8 &aASClass, unsigned short aBIsNativeLibrary)
10932{
10933
10934 TBuf <KMaxFileName> asClassPath;
10935
10936 // now get the UID for the process we are running
10937 TUid uid(User::Identity());
10938 TPtrC uidName(uid.Name().Mid(1,8));
10939
10940
10941 //Convert aASClass to Unicode
10942 TBuf <KMaxFileName> libName;
10943 TInt state = CCnvCharacterSetConverter::KStateDefault;
10944 User::LeaveIfError(iCharacterConverter->ConvertToUnicode(libName, aASClass, state));
10945 if (!HasSwfExtension (libName))
10946 {
10947 return;
10948 }
10949
10950 //Find if the ASClass is present in app private dir
10951 RFs fs;
10952 TInt err = fs.Connect();
10953 TBool found;
10954
10955 asClassPath.Append(KLitPvt);
10956
10957 asClassPath.Append(uidName);
10958 asClassPath.Append(KPathDelimiter);
10959 asClassPath.Append (libName);
10960
10961 TUint attVal = 0;
10962 found = fs.Att(asClassPath,attVal);
10963
10964 //Find if the ASClass is present in app private dir
10965
10966 if (found == KErrNone)
10967 {
10968 TBuf8 <KMaxFileName> classpath;
10969 User::LeaveIfError(iCharacterConverter->ConvertFromUnicode(classpath, asClassPath));
10970 unsigned char* classSwfData = NULL;
10971 int classLen;
10972 if(GetClassFileBufL((const char*)classpath.Ptr(),asClassPath.Length (), classSwfData, classLen))
10973 {
10974 iFiObject.FI_SetPreInstalledASClass(classSwfData, classLen, aBIsNativeLibrary);
10975 FreeClassFileBuf(classSwfData);
10976 }
10977 }
10978
10979 fs.Close();
10980}
10981
10982#endif //__FEATURE_PRE_COMPILED_SWF
10983
10984#ifdef FEATURE_MULTIPLE_DRIVE
10985TInt CPlatformFlashEngine::SearchASLibL(TDes& aFile)
10986 {
10987 RFs fs;
10988 TInt err = fs.Connect();
10989 HBufC* driveRootPath =HBufC::NewLC(KMaxFileName);
10990 TPtr ptrRootPath=driveRootPath->Des();
10991
10992 TInt intDrive;
10993 TInt found =KErrNone ;
10994 TUint attVal = 0;
10995 DriveInfo::TDriveArray driveArray;
10996
10997 User::LeaveIfError( DriveInfo::GetUserVisibleDrives( fs, driveArray ) );
10998
10999 for(TInt i=0; i < driveArray.Count(); i++)
11000 {
11001 TChar driveLetter = driveArray.LetterAt(i);
11002 User::LeaveIfError( RFs::CharToDrive(driveLetter, intDrive) );
11003 User::LeaveIfError( PathInfo::GetRootPath(ptrRootPath, intDrive) );
11004 ptrRootPath.Append(aFile);
11005
11006 found = fs.Att(ptrRootPath,attVal);
11007 if(found)
11008 break;
11009 }
11010 CleanupStack::PopAndDestroy(driveRootPath);
11011 fs.Close();
11012 return found;
11013 }
11014 #endif/// FEATURE_MULTIPLE_DRIVE
11015
11016void CPlatformFlashEngine::FLVideoStarted(TInt32 aCodecType)
11017{
11018 TInt dummy = 0;
11019 iIsVideoContent = ETrue;
11020 Zoom(EShowAll, dummy);
11021 iFLVPlayStat = ETrue; //playing flv
11022
11023 // readjust dynamic heap
11024 iPlayerDynamicHeapMaxSize = GetFLVMaxDynHeapSize() ;
11025
11026
11027
11028 //do setup soundhandler
11029 if(iSoundHandler)
11030 iSoundHandler->HandleFlvSetup(aCodecType);
11031
11032 MFlashVideoClientIf* flvClientIf = iFlashClientIf->GetFlvClientIf();
11033
11034 //if(iBrowserPluginActive)
11035 if(iExecutionMode == ePlugin)
11036 {
11037 if(flvClientIf)
11038 {
11039 flvClientIf->FLVideoStarted();
11040 }
11041 }
11042 else
11043 {
11044 if(flvClientIf)
11045 {
11046 flvClientIf->FLVideoStarted();
11047 /* Make an async event to make another FI call for clearing
11048 * previous transformations */
11049 iFitVideoToScreen = ETrue;
11050 TriggerAsyncEvent();
11051 }
11052 }
11053}
11054
11055void CPlatformFlashEngine::VideoIsEmbedded(TBool aEmbeddedVideo)
11056{
11057 MFlashVideoClientIf* flvClientIf = iFlashClientIf->GetFlvClientIf();
11058
11059 flvClientIf->VideoIsEmbedded(aEmbeddedVideo);
11060}
11061
11062#ifdef __FEATURE_UI_LANDSCAPE_FULLSCREEN
11063void CPlatformFlashEngine::FLVideoFinished()
11064{
11065 //if(!iBrowserPluginActive && iFlashUI)
11066 if(eStandAlone==iExecutionMode)
11067 {
11068 iFitVideoToScreen = EFalse;
11069 //iFlashUI->FLVideoFinished();
11070 MFlashVideoClientIf* flvClientIf = iFlashClientIf->GetFlvClientIf();
11071 if(flvClientIf)
11072 flvClientIf->FLVideoFinished();
11073 }
11074}
11075#endif //__FEATURE_UI_LANDSCAPE_FULLSCREEN
11076
11077unsigned short CPlatformFlashEngine::QueueHttpRequestL(unsigned short aStreamId, HBufC* hUrl, HBufC* hPost)
11078 {
11079 THttpRequestInfo* httpRequestInfo = new (ELeave) THttpRequestInfo;
11080 httpRequestInfo->iUrl = hUrl;
11081 httpRequestInfo->iPost = hPost;
11082 httpRequestInfo->iStreamId = aStreamId;
11083 httpRequestInfo->iIsFired = EFalse;
11084
11085 if(iRequestArray)
11086 {
11087 iRequestArray->AppendL(httpRequestInfo);
11088 }
11089 else
11090 {
11091 iRequestArray = new(ELeave) CArrayPtrSeg<THttpRequestInfo>(1);
11092 iRequestArray->AppendL(httpRequestInfo);
11093 }
11094
11095 FireNextRequestL();
11096
11097 return 1;
11098 }
11099
11100TInt CPlatformFlashEngine::NumOfRequestsFired()
11101 {
11102 TInt retVal = 0;
11103
11104 if(!iRequestArray)
11105 {
11106 return retVal;
11107 }
11108
11109 for( TInt i = 0; i < iRequestArray->Count(); i++)
11110 {
11111 TBool isTrue = ( iRequestArray->At(i) )->iIsFired;
11112 if( isTrue != EFalse )
11113 {
11114 retVal++;
11115 }
11116 }
11117 return retVal;
11118 }
11119
11120unsigned short CPlatformFlashEngine::FireNextRequestL()
11121 {
11122 unsigned short result = 0;
11123 if( NumOfRequestsFired() < KMaxNumberOfRequests )
11124 {
11125 if (iRequestArray)
11126 {
11127 MPluginStreamIf* streamIf = iFlashClientIf->GetStreamIf();
11128
11129 for( TInt i = 0; i < iRequestArray->Count(); i++)
11130 {
11131
11132 if( ( iRequestArray->At(i) )->iIsFired == EFalse )
11133 {
11134 THttpRequestInfo* httpRequestInfo = iRequestArray->At(i);
11135 httpRequestInfo->iIsFired = ETrue;
11136
11137 if ( httpRequestInfo->iPost )
11138 {
11139 if(streamIf)
11140 result = streamIf->OpenStreamL(httpRequestInfo->iStreamId, *(httpRequestInfo->iUrl),
11141 KNullDesC,0,*(httpRequestInfo->iPost));
11142 }
11143 else
11144 {
11145 TPtrC nullDes;
11146 if(streamIf)
11147 result = streamIf->OpenStreamL(httpRequestInfo->iStreamId, *(httpRequestInfo->iUrl),
11148 KNullDesC,0,nullDes);
11149 }
11150
11151 break;
11152 }
11153 }//for
11154 }
11155 }
11156 return result;
11157 }
11158
11159void CPlatformFlashEngine::RemoveCompletedRequest(TUint16 aStreamId)
11160 {
11161
11162 if(!iRequestArray)
11163 return;
11164
11165 THttpRequestInfo* httpRequestInfo=NULL;
11166
11167 for (TInt i=0;i<iRequestArray->Count(); i++)
11168 {
11169 httpRequestInfo = iRequestArray->At(i);
11170
11171 if( httpRequestInfo && ( httpRequestInfo )->iStreamId == aStreamId )
11172 {
11173 delete httpRequestInfo;//let us delete it first
11174
11175 iRequestArray->Delete(i);
11176
11177 break;
11178 }
11179
11180 }
11181
11182
11183 if (iRequestArray && iRequestArray->Count() == 0)
11184 {
11185 delete iRequestArray;
11186 iRequestArray = NULL;
11187 }
11188 }
11189
11190void CPlatformFlashEngine::RemoveAllRequest()
11191{
11192 if(!iRequestArray)
11193 return;
11194
11195 THttpRequestInfo* httpRequestInfo=NULL;
11196
11197 while(iRequestArray->Count())
11198 {
11199 httpRequestInfo = iRequestArray->At(0);
11200
11201 delete httpRequestInfo;
11202
11203 iRequestArray->Delete(0);
11204
11205 }
11206
11207 delete iRequestArray;
11208 iRequestArray = NULL;
11209}
11210
11211void CPlatformFlashEngine::SetFLVStatus(const char* code)
11212{
11213 if( !code )
11214 {
11215 return;
11216 }
11217
11218 TInt len;
11219
11220 const char* KStatusBufferEmpty = "NetStream.Buffer.Empty";
11221 const char* KStatusBufferFull = "NetStream.Buffer.Full";
11222 const char* KStatusBufferFlush = "NetStream.Buffer.Flush";
11223 const char* KStatusStart = "NetStream.Play.Start";
11224 const char* KStatusStop = "NetStream.Play.Stop";
11225 const char* KStatusSeekNotify = "NetStream.Seek.Notify";
11226 const char* KStatusPause = "NetStream.Play.Pause";
11227 const char* KStatusResume = "NetStream.Play.Resume";
11228
11229 for(len=0;code[len]!='\0';len++)//Findng out the length of status string
11230 ;
11231 if(!strncmp(code,KStatusBufferEmpty,len))
11232 {
11233 iFLVStatus = ENetStreamBufferEmpty;
11234 }
11235
11236 if(!strncmp(code,KStatusBufferFull,len))
11237 {
11238 iFLVStatus = ENetStreamBufferFull;
11239 }
11240
11241 if(!strncmp(code,KStatusBufferFlush,len))
11242 {
11243 iFLVStatus = ENetStreamBufferFlush;
11244 }
11245
11246 if(!strncmp(code,KStatusStart,len))
11247 {
11248 iFLVStatus = ENetStreamPlayStart;
11249 }
11250
11251 if(!strncmp(code,KStatusStop,len))
11252 {
11253 iFLVStatus = ENetStreamPlayStop;
11254 }
11255
11256 if(!strncmp(code,KStatusPause,len))
11257 {
11258 iFLVStatus = ENetStreamPlayPause;
11259 }
11260
11261 if(!strncmp(code,KStatusResume,len))
11262 {
11263 iFLVStatus = ENetStreamPlayResume;
11264 }
11265
11266 if(!strncmp(code,KStatusSeekNotify,len))
11267 {
11268 iFLVStatus = ENetStreamNull;
11269 }
11270}
11271
11272
11273void CPlatformFlashEngine::SetScreenMode()
11274{
11275 if( !iConfig.iHelixFlvMode || !iFlvDecoderArray.Count() )
11276 {
11277 return;
11278 }
11279
11280 THXVDCmdArg arg;
11281
11282 //TODO : Revisit this part..check if this is ok for browser plugin
11283 MDisplay* display = iFlashClientIf->GetDisplay();
11284 if (display->IsFullScreenMode())
11285 {
11286 arg.iScreenMode = EFullScreenMode;
11287 }
11288 else
11289 {
11290 arg.iScreenMode = ENormalScreenMode;
11291 }
11292
11293
11294 /*if( iFlashUI )
11295 {
11296 if( iFlashUI->IsFullScreenMode() )
11297 {
11298 arg.iScreenMode = EFullScreenMode;
11299 }
11300 else
11301 {
11302 arg.iScreenMode = ENormalScreenMode;
11303 }
11304 }
11305 else if( iFlashClientIf->GetDisplay() )
11306 {
11307 if( iFlashClientIf->GetDisplay()->IsFullScreenMode() )
11308 {
11309 arg.iScreenMode = EFullScreenMode;
11310 }
11311 else
11312 {
11313 arg.iScreenMode = ENormalScreenMode;
11314 }
11315 }*/
11316
11317 EngineDispatchHXCommand(EHXVDCmdSetScreenMode, arg);
11318}
11319
11320void CPlatformFlashEngine::SetEglContainerWindow(RWindow* aWindow)
11321{
11322#ifdef FEATURE_OPENVG
11323 if(iOpenVgMode && iRenderingWindow != aWindow)
11324 {//current rendering window iRenderingWindow will be updated
11325 //when the egl surface is recreated.
11326 TRAPD(err, RecreateSurfaceL(aWindow));
11327 if(err != KErrNone)
11328 {
11329 SwitchToSoftwareRendering();
11330 }
11331 }
11332#endif
11333}
11334
11335void CPlatformFlashEngine::SetVideoWindow(RWindow* aWindow)
11336{
11337 // Propagate window change to renderers.
11338 if( iConfig.iHelixFlvMode && iFlvDecoderArray.Count() )
11339 {
11340 THXVDCmdArg arg;
11341 arg.iWindow = aWindow;
11342
11343 EngineDispatchHXCommand(EHXVDCmdSetWindow, arg);
11344 }
11345
11346 if(iVideoEngine && iVideoEngine->HasActivePlayback())
11347 {
11348 iVideoEngine->SetVideoWindow(aWindow);
11349 }
11350}
11351
11352void CPlatformFlashEngine::SetVideoDisplayRectL(const TRect& aVideoRect, const TRect& aClipRect)
11353{
11354 //if( !iControl || !iConfig.iHelixFlvMode )
11355 if((iExecutionMode != ePlugin) || !iConfig.iHelixFlvMode )
11356 {
11357 return;
11358 }
11359
11360 THXVDCmdArg arg;
11361 arg.iDisplayRect = aVideoRect;
11362 arg.iClipRect = aClipRect;
11363
11364 EngineDispatchHXCommand(EHXVDCmdSetDisplayRect, arg);
11365
11366 // if using CVideoObject, we have to send the new rect to that object.
11367 if( iVideoEngine )
11368 iVideoEngine->NotifyScrollL();
11369
11370}
11371
11372void CPlatformFlashEngine::PauseVideo()
11373{
11374 //if( !iControl || !iConfig.iHelixFlvMode )
11375 if((iExecutionMode!=ePlugin) || !iConfig.iHelixFlvMode )
11376 {
11377 return;
11378 }
11379
11380 THXVDCmdArg arg;
11381 EngineDispatchHXCommand(EHXVDCmdPause, arg);
11382}
11383
11384void CPlatformFlashEngine::ResumeVideo()
11385{
11386 DEBUGPRINT("CPlatformFlashEngine::ResumeVideo()++");
11387 //if( !iControl || !iConfig.iHelixFlvMode )
11388 if((iExecutionMode!=ePlugin) || !iConfig.iHelixFlvMode )
11389 {
11390 return;
11391 }
11392
11393 THXVDCmdArg arg;
11394 EngineDispatchHXCommand(EHXVDCmdResume, arg);
11395 DEBUGPRINT("CPlatformFlashEngine::ResumeVideo()--");
11396}
11397
11398void CPlatformFlashEngine::PlayVideo()
11399{
11400 //if( !iControl || !iConfig.iHelixFlvMode )
11401 if((iExecutionMode!=ePlugin) || !iConfig.iHelixFlvMode )
11402 {
11403 return;
11404 }
11405
11406 THXVDCmdArg arg;
11407 EngineDispatchHXCommand(EHXVDCmdPlay, arg);
11408}
11409
11410
11411void CPlatformFlashEngine::SeekFlv()
11412{
11413 if( !iFlvDecoder || !iConfig.iHelixFlvMode )
11414 {
11415 return;
11416 }
11417
11418 THXVDCmdArg arg;
11419 EngineDispatchHXCommand(EHXVDCmdSeek, arg);
11420}
11421
11422
11423TInt32 CPlatformFlashEngine::GetFLVMaxDynHeapSize()
11424 {
11425 return iPlatformConfig->GetVideoDynHeapSize();
11426 }
11427
11428FI_Interface& CPlatformFlashEngine::GetFIObject()
11429{
11430 return iFiObject;
11431}
11432
11433TBool CPlatformFlashEngine::IsStereoSupported()
11434{
11435 if(iConfig.iMode & KSupportStereo)
11436 {
11437 return ETrue;
11438 }
11439
11440 return EFalse;
11441}
11442
11443void CPlatformFlashEngine::HandleWidgetError(TBool videoError)
11444{
11445 // Check if the embed parameter is set, which implies that it is a custom
11446 // widget and we traverse back to the previous page. If not then it is a
11447 // generic case and we need to handle it separately.
11448 if (iHostEngineGlobals->GetNoOfPlugins() != 1 || !(iFlashClientIf->IsWidgetMode()))
11449 return;
11450 const char *js_command;
11451 if (iPassOnException && videoError)
11452 {
11453 // The following string is the Java Script command to navigate to the
11454 // previous page.
11455 js_command = "try \
11456 { \
11457 document.getElementById(\"swfObject\").SetReturnValue(__flash__toXML(onPlayerError(\"PlayerError\")) ); \
11458 } catch (e) \
11459 { \
11460 document.getElementById(\"swfObject\").SetReturnValue(\"<undefined/>\"); \
11461 }";
11462 }
11463 else
11464 {
11465 js_command = "javascript:window.close();";
11466 TBufC<128> KResFile(_L("flash2engine.rsc") );
11467 TInt resOffset = LoadPluginResourceL(KResFile);
11468 HBufC* textResource = StringLoader::LoadL( R_FLASH_ERR_EIKON_GENERAL );
11469 CleanupStack::PushL( textResource );
11470 CAknErrorNote* note = new ( ELeave ) CAknErrorNote( ETrue );
11471 note->ExecuteLD( *textResource );
11472 CleanupStack::PopAndDestroy( textResource );
11473 CEikonEnv::Static()->DeleteResourceFile(resOffset);
11474 }
11475
11476 //RC Error:ou1cimx1#519118 Crash seen SI_EvaluateJavascript call
11477 if(iHostScriptHandler && iHostScriptHandler->GetPluginScriptHandler())
11478 iHostScriptHandler->GetPluginScriptHandler()->EvaluateJavaScript(js_command);
11479}
11480void CPlatformFlashEngine::HandleHelixError(const TInt& aError)
11481{
11482 HandleWidgetError(true);
11483 if( aError != KErrNone && iConfig.iHelixFlvMode )
11484 {
11485 MFlashVideoClientIf* flvClientIf = iFlashClientIf->GetFlvClientIf();
11486 if(flvClientIf)
11487 flvClientIf->HandleVideoError(aError);
11488 /*
11489 // Handle error
11490 if( GetPlugin() )
11491 {
11492 GetPlugin()->HandleVideoError(aError);
11493 }
11494 else if( GetUI() )
11495 {
11496 GetUI()->HandleVideoError(aError);
11497 }
11498 */
11499 }
11500}
11501
11502#ifdef __FEATURE_FLV_RECOG_PLAY
11503
11504 RFile* CPlatformFlashEngine::GetRFileHandleForPlay()
11505 {
11506 /*if(iFlashUI)
11507 {
11508 return iFlashUI->GetRFileHandleForPlay();
11509 }*/
11510
11511 return this->iFlashClientIf->GetRFileHandleForPlay();
11512
11513 //return NULL;
11514 }
11515
11516#endif
11517#ifdef FEATURE_EXTENSION
11518
11519PluginInfo* CPlatformFlashEngine::GetPluginInfoL(struct MM_Object* /*aMMObj*/,
11520 struct ExtensionInterface* pEI)
11521 {
11522
11523 PluginInfo* pInfo= NULL;
11524 //if(!iBrowserPluginActive)// || //Not browser plugin -> Viewer app/Stub app
11525 //(iBrowserPluginActive && (iInteractionMode == EWidgetMode))) //Plugin in widget mode
11526 if(iExecutionMode == eStandAlone)
11527 {
11528
11529 PluginInfo* temp= NULL;
11530 PluginInfo* temp1 = NULL;
11531
11532 RImplInfoPtrArray pASExtensionImplArray;
11533
11534 REComSession::ListImplementationsL(KASExtInterfaceUid, pASExtensionImplArray);
11535 TInt noOfImplfound = pASExtensionImplArray.Count();
11536 for (TInt lIndex(0); lIndex < noOfImplfound; ++lIndex)
11537 {
11538 HBufC8* pluginName =EscapeUtils::ConvertFromUnicodeToUtf8L(pASExtensionImplArray[lIndex]->DisplayName());
11539 CleanupStack::PushL(pluginName);
11540
11541 CASExtensionDelegate* pImpl= NULL;
11542 TRAPD(err,pImpl = CASExtensionDelegate::NewL(*pluginName));
11543 CleanupStack::PopAndDestroy(pluginName);
11544
11545 if((err == KErrNone) && pImpl )
11546 {
11547 TRAPD(err1, temp = pImpl->GetPluginInfoL(this, pEI));
11548 if( (err1 == KErrNone) && temp)
11549 {
11550 if(lIndex == 0 )
11551 {
11552 pInfo = temp;
11553 temp1 = temp;
11554 }
11555 else
11556 {
11557 temp1->reserved1 = temp;
11558 temp1 = temp;
11559 }
11560 pImpl->InitPlugin( CASExtensionDelegate::EOpCodeSMCheckNeeded , (TAny*)iConfig.iSMCheckNeeded );
11561 }
11562 }
11563 }
11564
11565 for (TInt lIndex(0); lIndex < noOfImplfound; ++lIndex)
11566 {
11567 CImplementationInformation* lTempImplInfo = pASExtensionImplArray[0];
11568 pASExtensionImplArray.Remove(0);
11569 delete lTempImplInfo;
11570 }
11571
11572 pASExtensionImplArray.ResetAndDestroy();
11573 temp = NULL;
11574 temp1 = NULL;
11575 }
11576
11577 return pInfo;
11578 }
11579
11580void CPlatformFlashEngine::ProcessHostCmdL(const TDesC& aCommandName, RASExtensionArgArray& aArgArray, TInt& aReturnValue)
11581 {
11582
11583 if(!aCommandName.Compare(KASCmdResumePlayer))
11584 {
11585 if(iPauseFlags == EReasonBackground && (aArgArray.Count() == 1))
11586 {
11587 TBool lBringToForeground = TBool(aArgArray[0]->pVariableValue);
11588
11589 MDeviceExtnIf* deviceIf = iFlashClientIf->GetDeviceIf();
11590 if(deviceIf)
11591 deviceIf->ResumeOnEventL(lBringToForeground);
11592
11593 //todo put the check for widget mode and call the resume on plugin control
11594 /*
11595 if((iInteractionMode == EWidgetMode )&& iControl)
11596
11597 {
11598 this->iFlashClientIf->GetDeviceIf()->ResumeOnEventL(lBringToForeground);
11599 aReturnValue = 0;
11600 }
11601 else if(iFlashUI)
11602 {
11603 this->iFlashClientIf->GetDeviceIf()->ResumeOnEventL(lBringToForeground);
11604 aReturnValue = 0;
11605 }
11606 */
11607 }
11608 }
11609 else if(!aCommandName.Compare(KDisableAutoRoataion))
11610 {
11611 if((aArgArray.Count() == 1) && ((aArgArray[0]->variableType == kExtnVarTypeBoolean)))
11612 {
11613 TBool lAuotRotationMode = TBool(aArgArray[0]->pVariableValue);
11614
11615 MDisplay* display = iFlashClientIf->GetDisplay();
11616 if(display)
11617 {
11618 display->SetAutoRotationModeL(lAuotRotationMode);
11619 aReturnValue = 0;
11620 }
11621 }
11622 }
11623 else if (!aCommandName.Compare(KExpediteConnection))
11624 {
11625 #ifdef FEATURE_XML_SOCKET
11626 if (iSocketEngine) //safe to access directly..
11627 {
11628 iSocketEngine->ExpediteConnectionL();
11629 aReturnValue = 0;
11630 }
11631 #endif
11632 }
11633 else
11634 {
11635 aReturnValue = KASErrNotSupported; //not Supported
11636 }
11637
11638 }
11639#endif
11640
11641#ifdef FEATURE_WATCH_GPU_MEM
11642void CPlatformFlashEngine::GPUMemoryLow(TBool aLow)
11643{
11644 iGPUMemLow = aLow;
11645
11646 if(iOpenVgMode && iGPUMemLow && !iIsInitialized)
11647 {
11648 iOpenVgMode = EFalse;
11649 iRenderToBitmap = ETrue;
11650 }
11651
11652#if 0
11653 if(!iOpenVgMode || !iGPUMemLow)
11654 return;
11655
11656 if(!iEGLInitialized)
11657 return;
11658
11659 iRenderingSwitchType = ESwitchRenderingHWToSW;
11660 DoToggleRenderingMode();
11661#endif
11662}
11663#endif
11664
11665#ifdef SELF_IAD_UPDATE
11666void CPlatformFlashEngine::HandleIADCheck( MIadUpdateCallback* aIADUpdateCompleteCallback, FlashEngineConfig& aConfig )
11667{
11668 // we do not check for updates if the mode is
11669 // * Screen saver
11670 // * tutorial
11671
11672 if( !aConfig.iCheckIADUpdate )
11673 return;
11674 NPPDebug( LOG_ALL, IsBrowserPluginActive(), _L("void CPlatformFlashEngine::HandleIADCheck( MIadUpdateCallback* aIADUpdateCompleteCallback ) ++ ") );
11675
11676 // NOTE: we'll trap all the errors and not pass it back to the engine
11677 // as the IAD check is not critical
11678
11679 // iIADUpdateChecker is in HostEngineGlobals and hence it'll be deleted when the last instance
11680 // of the HostEngine is deleted.
11681
11682 CIADUpdateChecker* iIADUpdateChecker = iHostEngineGlobals->IADUpdateChecker(
11683 KFlashLitePackageID,
11684 KNullDesC,
11685 KNullDesC,
11686 KNullDesC8,
11687 EFalse,
11688 aIADUpdateCompleteCallback
11689 );
11690
11691 if( !iIADUpdateChecker )
11692 {
11693 // the IAD object could not be created for some reason.
11694 // continue with the host engine creation as IAD update check isn't _that_ critical
11695 NPPDebug( LOG_ALL, IsBrowserPluginActive(), _L("!iIADUpdateChecker") );
11696 return;
11697 }
11698
11699 NPPDebug( LOG_ALL,IsBrowserPluginActive(), _L("iIADUpdateChecker") );
11700
11701 // check which state the update process is in...
11702 CIADUpdateChecker::TIadUpdateStatus updateStatus = iIADUpdateChecker->UpdateStatus();
11703 NPPDebug( LOG_ALL,IsBrowserPluginActive(), _L("updateStatus : %d"), updateStatus );
11704
11705
11706 /*
11707 * Continue only if we haven't checked for updates of if the update check has failed.
11708 * Return otherwise
11709 */
11710 if( !( updateStatus == CIADUpdateChecker::KUpdateNotStarted
11711 || updateStatus == CIADUpdateChecker::KUpdateFailed
11712 )
11713 )
11714 {
11715 return;
11716 }
11717
11718 // the update checker and the observer class were successfully created.
11719 // no we go ahead and initiate the update process.
11720
11721 if( iIADUpdateChecker->IsUpdateSupported() )
11722 {
11723 NPPDebug( LOG_ALL,IsBrowserPluginActive(), _L("IAD Update supported") );
11724 DEBUGPRINT("IAD Update Supported");
11725
11726 TRAPD( updateError, iIADUpdateChecker->CheckUpdateL() );
11727 if( updateError != KErrNone )
11728 {
11729 // there was some error while checking for updates.
11730 // lets not bother the user.
11731
11732 NPPDebug( LOG_ALL,IsBrowserPluginActive(), _L("updateError != KErrNone") );
11733 delete iIADUpdateChecker;
11734 iIADUpdateChecker = NULL;
11735 }
11736 }
11737
11738 NPPDebug( LOG_ALL,IsBrowserPluginActive(), _L("void CPlatformFlashEngine::HandleIADCheck( MIadUpdateCallback* aIADUpdateCompleteCallback ) --") );
11739
11740}
11741
11742void CPlatformFlashEngine::DestroyIADComponents()
11743{
11744 // iIADUpdateChecker is in HostEngineGlobals and hence it'll be deleted when the last instance
11745 // of the HostEngine is deleted.
11746/*
11747 if( iIADUpdateChecker )
11748 {
11749 delete iIADUpdateChecker;
11750 iIADUpdateChecker = NULL;
11751 }
11752*/
11753}
11754
11755#endif
11756
11757void CPlatformFlashEngine::NotifyFullScreen(TBool aFullScreen)
11758{
11759 iFiObject.FI_NotifyFullScreenStatus(aFullScreen);
11760}
11761
11762void CPlatformFlashEngine::SetFullScreenViaFSCommand(TBool aFullScreen)
11763{
11764 iFullScreenViaFSCommand = aFullScreen;
11765}
11766
11767TBool CPlatformFlashEngine::IsOpenVgRenderingMode()
11768{
11769 return iOpenVgMode;
11770}
11771
11772TBool CPlatformFlashEngine::IsRenderingToBitmap()
11773{
11774 return iRenderToBitmap;
11775}
11776
11777void CPlatformFlashEngine::SetSwfHasVideo(TBool aVideo)
11778{
11779 if(aVideo)
11780 {
11781 iSwfHasVideo++;
11782 }
11783 else
11784 {
11785 iSwfHasVideo--;
11786 if(iSwfHasVideo<0) // Most likely will not happen. But just incase...
11787 iSwfHasVideo = 0;
11788 }
11789}
11790
11791void CPlatformFlashEngine::SetSwfHasAudio(TBool aAudio)
11792{
11793 if(aAudio)
11794 {
11795 iSwfHasAudio++;
11796 }
11797 else
11798 {
11799 iSwfHasAudio--;
11800 if(iSwfHasAudio<0) // Most likely will not happen. But just incase...
11801 iSwfHasAudio = 0;
11802 }
11803}
11804
11805TUint16 CPlatformFlashEngine::FrameBufferDisplayFormat()
11806{
11807 return iFrameBufferDisplayFormat;
11808}
11809
11810#ifdef DUMP_DIRTY_RECTS
11811void CPlatformFlashEngine::DumpDirtyRects(TRect aDirtyRect)
11812#else
11813void CPlatformFlashEngine::DumpDirtyRects(TRect /*aDirtyRect*/)
11814#endif
11815{
11816#ifdef DUMP_DIRTY_RECTS
11817 if(iBitmapToBeDumped == NULL)
11818 {
11819 return;
11820 }
11821
11822 iDirtyRectNum++;
11823
11824 TBuf<64> lFileName;
11825 lFileName.AppendFormat(_L("C:\\data\\others\\dirtyrectdump%d"),iDirtyRectNum);
11826 lFileName.AppendFormat(_L(".raw"));
11827 iDirtyRectDumpFile.Replace(iFs,lFileName,EFileWrite);
11828
11829 TSize lSize = iBitmapToBeDumped->SizeInPixels();
11830
11831 TUint8* lTempAddr = (TUint8*)iBitmapToBeDumped->DataAddress() +
11832 ((lSize.iWidth * 4) * aDirtyRect.iTl.iY) + aDirtyRect.iTl.iX * 4;
11833
11834 TInt lLengthWritten = 0;
11835 for(TInt lYLine=aDirtyRect.iTl.iY; lYLine <= aDirtyRect.iBr.iY; lYLine++ )
11836 {
11837 TPtr8 lPtr(lTempAddr, aDirtyRect.Width() * 4, aDirtyRect.Width() * 4);
11838 iDirtyRectDumpFile.Write(lPtr);
11839 lLengthWritten += aDirtyRect.Width() * 4;
11840 lTempAddr += (lSize.iWidth * 4);
11841 }
11842
11843 TBuf8<128> lBuf;
11844 lBuf.AppendFormat(_L8("Dirty rect=(%d,%d,%d,%d), size=%d\r\n"),aDirtyRect.iTl.iX,aDirtyRect.iTl.iY,aDirtyRect.Width(),aDirtyRect.Height(),lLengthWritten);
11845 iDirtyRectLengthsFile.Write(lBuf);
11846
11847 iDirtyRectDumpFile.Close();
11848#endif
11849}
11850
11851void CPlatformFlashEngine::ShowRedrawRegions(TRect /*aDirtyRect*/, CWindowGc& /*aWGc*/)
11852{
11853#ifdef SHOW_REDRAW_REGIONS //useful only in ph2
11854 DEBUGPRINT("Drawing dirty rect regions %d %d %d %d", aDirtyRect.iTl.iX, aDirtyRect.iTl.iY,
11855 aDirtyRect.iBr.iX, aDirtyRect.iBr.iY);
11856 aWGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
11857 aWGc.SetPenColor(KRgbRed);
11858 aWGc.SetBrushStyle(CGraphicsContext::ENullBrush);
11859 aWGc.DrawRect(aDirtyRect);
11860#endif
11861}
11862
11863void CPlatformFlashEngine::ResizeBitmapsL(TSize aSize)
11864{
11865 ResizeFrameBufferBitmapL(aSize);
11866#ifdef FEATURE_OPENVG
11867 if(iOpenVgMode)
11868 ResizeAuxTextBitmapL(aSize);
11869#endif
11870}
11871
11872void CPlatformFlashEngine::ResizeFrameBufferBitmapL(TSize aSize)
11873{
11874 if(!iRenderToBitmap)
11875 return;
11876
11877 iBitmapSize.x = aSize.iWidth;
11878 iBitmapSize.y = aSize.iHeight;
11879
11880 TInt errd = KErrNone;
11881 errd = iBitmap->Resize(TSize(iBitmapSize.x, iBitmapSize.y));
11882 if (errd == KErrNone) {
11883 errd = iBitmapDevice->Resize(TSize(iBitmapSize.x, iBitmapSize.y));
11884 }
11885
11886 if(errd != KErrNone) {
11887 FreeFrameBufferBits();
11888 }
11889
11890 User::LeaveIfError(errd);
11891
11892 TUint32* da = iBitmap->DataAddress();
11893 TInt len = iBitmap->SizeInPixels().iWidth * iBitmap->SizeInPixels().iHeight;
11894 for(TInt i=0;i<len;i++) {
11895 *(da+i) = KRgbBlack.Value();
11896 }
11897
11898 CFbsBitGc* bGc = GetBitmapContext();
11899 if(bGc) {
11900 bGc->Resized();
11901 }
11902}
11903
11904#ifdef FEATURE_OPENVG
11905void CPlatformFlashEngine::ResizeAuxTextBitmapL(TSize aSize)
11906{
11907 TInt errd = KErrNone;
11908
11909 iAuxTextBitmapSize.x = aSize.iWidth;
11910 iAuxTextBitmapSize.y = aSize.iHeight;
11911
11912 errd = iAuxTextBitmap->Resize(TSize(iAuxTextBitmapSize.x, iAuxTextBitmapSize.y));
11913 if (errd == KErrNone) {
11914 errd = iAuxTextBitmapDevice->Resize(TSize(iAuxTextBitmapSize.x, iAuxTextBitmapSize.y));
11915 }
11916
11917 if(errd != KErrNone) {
11918 FreeAuxTextBits();
11919 }
11920
11921 User::LeaveIfError(errd);
11922
11923 CFbsBitGc* gc = GetAuxTextBitmapContext();
11924 if (gc) {
11925 gc->Resized();
11926 }
11927}
11928#endif
11929
11930
11931void CPlatformFlashEngine::RecreateBitmapsL(TSize aSize)
11932{
11933 RecreateFrameBufferBitmapL(aSize);
11934#ifdef FEATURE_OPENVG
11935 RecreateAuxTextBitmapL(aSize);
11936#endif
11937}
11938
11939
11940void CPlatformFlashEngine::RecreateFrameBufferBitmapL(TSize aSize)
11941{
11942 if(!iRenderToBitmap)
11943 return;
11944
11945 FreeFrameBufferBits();
11946 if (!CreateFrameBufferBitsL(aSize)) {
11947 User::Leave(KErrNoMemory);
11948 }
11949}
11950
11951#ifdef FEATURE_OPENVG
11952void CPlatformFlashEngine::RecreateAuxTextBitmapL(TSize aSize)
11953{
11954 if(!iOpenVgMode)
11955 return;
11956
11957 FreeAuxTextBits();
11958 if (!CreateAuxTextBitsL(aSize)) {
11959 User::Leave(KErrNoMemory);
11960 }
11961}
11962#endif
11963
11964#ifndef USE_SYNC_MSO
11965CFlhShObjEngine* CPlatformFlashEngine::GetShObjEngine()
11966{
11967 if(iShObjEngine)
11968 return iShObjEngine;
11969
11970 if(!(iConfig.iMode & KSupportSharedObject))
11971 return NULL;
11972
11973 if(iSwfPath == NULL)
11974 return NULL;
11975
11976 TFileName persistentDirectory;
11977 if(iFlashClientIf)
11978 iFlashClientIf->GetPersistentDirectory(*iSwfPath,persistentDirectory);
11979/*
11980 if(iFlashUI)
11981 iFlashUI->GetPersistentDirectory(*iSwfPath,persistentDirectory);
11982 else if(iControl)
11983 iControl->GetPersistentDirectory(*iSwfPath,persistentDirectory);
11984*/
11985 TRAP_IGNORE(iShObjEngine = CFlhShObjEngine::NewL(iFs, *iFileUtils, persistentDirectory, *this));
11986 return iShObjEngine;
11987}
11988#else
11989CSharedObjectHandler* CPlatformFlashEngine::GetShObjHandler()
11990 {
11991 if (iSharedObjHandler)
11992 return iSharedObjHandler;
11993
11994 if (!(iConfig.iMode & KSupportSharedObject))
11995 return NULL;
11996
11997 if (iSwfPath == NULL)
11998 return NULL;
11999
12000 TFileName persistentDirectory;
12001 if (iFlashClientIf)
12002 iFlashClientIf->GetPersistentDirectory(*iSwfPath, persistentDirectory);
12003
12004 TRAP_IGNORE(iSharedObjHandler = CSharedObjectHandler::NewL(*this, persistentDirectory));
12005 // iSharedObjHandler is NULL by default. If it could not be created, return the default value, which is NULL
12006 return iSharedObjHandler;
12007 }
12008#endif //USE_SYNC_MSO
12009
12010HBufC* CPlatformFlashEngine::GetSwfGuidLC()
12011{
12012 AMP_ReturnString returnString(FI_NativeEncodingForm);
12013 FI_ReturnString* fiSwfGUID = returnString.Wrapper();
12014
12015 User::LeaveIfError(iFiObject.FI_GetThisSWFGUID(fiSwfGUID));
12016
12017 TPtr8 guidDes((TUint8*)returnString.GetTemporaryCString(),returnString.GetLength(),returnString.GetLength());
12018
12019 HBufC* swfGUID16 = HBufC::NewLC(guidDes.Length());
12020
12021 //Since guid is english alpha-numeric, it is safe to use Copy to convert from 8-bit string to 16-bit string.
12022 swfGUID16->Des().Copy(guidDes);
12023
12024 return swfGUID16;
12025}
12026
12027
12028CHttpEngine* CPlatformFlashEngine::GetHttpEngine()
12029{
12030 if (iConfig.iMode & KSupportNetwork)
12031 {
12032 if (!iHttpEngine)
12033 {
12034 TRAP_IGNORE(iHttpEngine = CHttpEngine::NewL(this));
12035 }
12036 }
12037 return iHttpEngine;
12038}
12039
12040CIPConnMgr* CPlatformFlashEngine::GetIPConnectionMgr()
12041 {
12042 if(!iIPConnMgr)
12043 {
12044 TRAP_IGNORE(iIPConnMgr = CIPConnMgr::NewL(this));
12045 }
12046 return iIPConnMgr;
12047 }
12048CLocalHttpEngine* CPlatformFlashEngine::GetLocalHttpEngine()
12049{
12050 if (iConfig.iMode & KSupportNetwork)
12051 {
12052 if (!iLocalHttpEngine)
12053 {
12054 TRAP_IGNORE(iLocalHttpEngine = CLocalHttpEngine::NewL());
12055 }
12056 }
12057 return iLocalHttpEngine;
12058}
12059
12060#ifdef FEATURE_XML_SOCKET
12061CFlashSocketEngine* CPlatformFlashEngine::GetSocketEngine()
12062{
12063 if (!iSocketEngine)
12064 {
12065 TRAP_IGNORE(iSocketEngine = CFlashSocketEngine::NewL(*this));
12066 }
12067
12068 return iSocketEngine;
12069}
12070#endif
12071
12072CFileEngine* CPlatformFlashEngine::GetFileEngine()
12073{
12074 if (iConfig.iMode & KSupportLocalFile)
12075 {
12076 if (!iFileEngine)
12077 {
12078 TRAP_IGNORE(iFileEngine = CFileEngine::NewL());
12079 }
12080 }
12081 return iFileEngine;
12082}
12083
12084CVideoEngine* CPlatformFlashEngine::GetVideoEngine()
12085{
12086 if (iConfig.iMode & KSupportVideo)
12087 {
12088 if (!iVideoEngine)
12089 {
12090 TRAP_IGNORE(iVideoEngine = CVideoEngine::NewL(*this, iFs));
12091 }
12092 }
12093 return iVideoEngine;
12094}
12095
12096CImageConverter* CPlatformFlashEngine::GetImageConverter()
12097{
12098 if(!iImageConverter)
12099 {
12100 TRAP_IGNORE(iImageConverter = CImageConverter::NewL(*this));
12101 }
12102
12103 return iImageConverter;
12104}
12105
12106CPlatformInfo* CPlatformFlashEngine::GetPlatformInfo()
12107{
12108 if (!iPlatformInfo)
12109 {
12110 TRAP_IGNORE(iPlatformInfo = CPlatformInfo::NewL(this));
12111 }
12112
12113 return iPlatformInfo;
12114}
12115
12116CPhoneInfo* CPlatformFlashEngine::GetPhoneInfo()
12117{
12118 if (!NoETelSuppport())
12119 {
12120 if (!iPhoneInfo)
12121 {
12122 TRAP_IGNORE(iPhoneInfo = CPhoneInfo::NewL());
12123 }
12124 return iPhoneInfo;
12125 }
12126 return NULL;
12127}
12128
12129CNetworkInfo* CPlatformFlashEngine::GetNetworkInfoL()
12130 {
12131 if(!NoETelSuppport())
12132 {
12133 if(eStandAlone==iExecutionMode)
12134 {
12135 if (!iNetworkInfo)
12136 {
12137 iNetworkInfo = CNetworkInfo::NewL();
12138 }
12139 }
12140 return iNetworkInfo;
12141 }
12142 return NULL;
12143 }
12144
12145CSubscriberInfo* CPlatformFlashEngine::GetSubscriberInfoL()
12146 {
12147 if (!NoETelSuppport())
12148 {
12149 if (eStandAlone == iExecutionMode)
12150 {
12151 if (!iSubscriberInfo)
12152 {
12153 iSubscriberInfo = CSubscriberInfo::NewL();
12154 }
12155 }
12156 return iSubscriberInfo;
12157 }
12158 return NULL;
12159 }
12160
12161CRegistrationStatus* CPlatformFlashEngine::GetRegistrationStatusL()
12162 {
12163 if (!NoETelSuppport())
12164 {
12165 if (eStandAlone == iExecutionMode)
12166 {
12167 if (!iRegistrationStatus)
12168 {
12169 iRegistrationStatus = CRegistrationStatus::NewL();
12170 }
12171 }
12172 return iRegistrationStatus;
12173 }
12174 return NULL;
12175 }
12176
12177CPhoneBatteryInfo* CPlatformFlashEngine::GetBatteryInfoL()
12178 {
12179 if (!NoETelSuppport())
12180 {
12181 //Should Work For All Modes including Widget and BrowserPlugin modes.
12182 //if (eStandAlone == iExecutionMode)
12183 {
12184 if (!iBatteryInfo)
12185 {
12186 iBatteryInfo = CPhoneBatteryInfo::NewL();
12187 }
12188 }
12189 return iBatteryInfo;
12190 }
12191 return NULL;
12192 }
12193
12194CPhoneSignalInfo* CPlatformFlashEngine::GetPhoneSignalInfoL()
12195 {
12196 if (!NoETelSuppport())
12197 {
12198 //if (eStandAlone == iExecutionMode)
12199 {
12200 if (!iSignalInfo)
12201 {
12202 iSignalInfo = CPhoneSignalInfo::NewL();
12203 }
12204 }
12205 return iSignalInfo;
12206 }
12207 return NULL;
12208 }
12209
12210CPhoneChargingInfo* CPlatformFlashEngine::GetPhoneChargingInfoL()
12211 {
12212 if (!NoETelSuppport())
12213 {
12214 if (eStandAlone == iExecutionMode)
12215 {
12216 if (!iChargingInfo)
12217 {
12218 iChargingInfo = CPhoneChargingInfo::NewL();
12219 }
12220 }
12221 return iChargingInfo;
12222 }
12223 return NULL;
12224 }
12225
12226CPhoneMonitor* CPlatformFlashEngine::GetPhoneMonitorL()
12227 {
12228 if (!NoIncomingCallMonitor())
12229 {
12230 if(!iPhoneMonitor)
12231 {
12232 iPhoneMonitor = new (ELeave) CPhoneMonitor();
12233 iPhoneMonitor->ConstructL(this);
12234 }
12235 return iPhoneMonitor;
12236 }
12237 return NULL;
12238 }
12239
12240TInt CPlatformFlashEngine::GetOTFont(unsigned char** aFont, TBool aBold)
12241{
12242 // Get the font data from the policy server
12243 CFlashRTPolicyClient* policyClient = NULL;
12244 TRAPD( error,
12245 policyClient = CFlashRTPolicyClient::NewL(); );
12246
12247 if(error == KErrNone )
12248 {
12249 unsigned char* font = NULL;
12250 error = policyClient->ReadFont( &(font), aBold );
12251 (*aFont) = font;
12252 delete policyClient;
12253 }
12254 return error;
12255}
12256
12257TBool CPlatformFlashEngine::IsTouchSupported()
12258{
12259 return AknLayoutUtils::PenEnabled();
12260}
12261
12262/*
12263 * 1. Check if the File requested is a .jpeg file
12264 * 2. If a .jpg file, check the resolution and see if the resolution is more than say VGA(640X480)
12265 * 3. If resolution is more return ETrue else return EFalse;
12266 */
12267TBool CPlatformFlashEngine::ImageDownScalingRequiredL(const TDesC& aFileName)
12268{
12269 TBool imageDSReq = EFalse;
12270 TBool isJpegFile = EFalse;
12271 CContent* content = CContent::NewLC(aFileName);
12272 if(content)
12273 {
12274 HBufC* tmpMIME = HBufC::NewLC( KMaxDataTypeLength );
12275
12276 TPtr mimePtr( tmpMIME->Des() );
12277
12278 content->GetStringAttribute(EMimeType, mimePtr );
12279
12280 isJpegFile = (0 != mimePtr.CompareF(KJPEGMimeType))? EFalse : ETrue ;
12281
12282 CleanupStack::PopAndDestroy(tmpMIME);
12283 }
12284 CleanupStack::PopAndDestroy(content);
12285 if(!isJpegFile)
12286 {
12287 return imageDSReq;
12288 }
12289
12290 /* Now that the file is having .jpg extension check its Resulution */
12291 CImageDecoder* decoder = CImageDecoder::FileNewL(iFs,aFileName, CImageDecoder::EOptionAlwaysThread);
12292 TFrameInfo frameInfo = decoder->FrameInfo(0);
12293 TSize aDeviceScreenSize = CCoeEnv::Static()->ScreenDevice()->SizeInPixels();
12294 if(frameInfo.iOverallSizeInPixels.iWidth > aDeviceScreenSize.iWidth || frameInfo.iOverallSizeInPixels.iHeight >aDeviceScreenSize.iHeight)
12295 {
12296 imageDSReq = ETrue;
12297 }
12298 delete decoder;
12299 return imageDSReq;
12300}
12301
12302CSharedMemoryManager* CPlatformFlashEngine::GetSharedMemoryManagerL()
12303{
12304 if(!iSharedMemMgr)
12305 iSharedMemMgr = CSharedMemoryManager::CreateInstanceL();
12306
12307 return iSharedMemMgr;
12308}
12309#ifdef FEATURE_AMCEXTENSIONS
12310int CPlatformFlashEngine::LoadPluginResourceL(const TDesC& aFileName)
12311 {
12312 TInt resOffset = -1;
12313 TBuf16<128> aResourcePath(_L("\\resource\\apps"));
12314 TInt fileNameLength = aFileName.Length();
12315 TFileName resourceFileName;
12316 CEikonEnv* env = CEikonEnv::Static();
12317 RFs fileServerSession = env->FsSession();
12318 if (fileNameLength > 4)
12319 {
12320 TBuf16<128> fName = aFileName.Mid(0, fileNameLength - 4);
12321 TBuf16<512> variantFile;
12322 _LIT16( KFormat, ":%S\\%S.r%S%d");
12323 TInt languageID = User::Language();
12324 TBuf16<8> leadingZero;
12325 leadingZero.Copy(_L(""));
12326 if (languageID < 10)
12327 leadingZero.Copy(_L("0"));
12328 for (TInt i = EDriveY; i >= EDriveA; i--)
12329 {
12330 TChar driveLetter;
12331 fileServerSession.DriveToChar(i, driveLetter);
12332 variantFile.Append(driveLetter);
12333 variantFile.AppendFormat(KFormat, &aResourcePath, &fName,
12334 &leadingZero, languageID);
12335 resourceFileName.Copy(variantFile);
12336 TBool fileExists = BaflUtils::FileExists(
12337 env->FsSession(), resourceFileName);
12338 if (fileExists)
12339 {
12340 resOffset = env->AddResourceFileL(resourceFileName);
12341 return resOffset;
12342 }
12343 }
12344 TChar driveLetterZ;
12345 fileServerSession.DriveToChar(EDriveZ, driveLetterZ);
12346 variantFile.Append(driveLetterZ);
12347 variantFile.AppendFormat(KFormat, &aResourcePath, &fName,
12348 &leadingZero, languageID);
12349 resourceFileName.Copy(variantFile);
12350 TBool fileExists = BaflUtils::FileExists(
12351 env->FsSession(), resourceFileName);
12352 if (fileExists)
12353 {
12354 resOffset = env->AddResourceFileL(resourceFileName);
12355 return resOffset;
12356 }
12357 _LIT16( KNearestLangFormat, ":%S\\%S");
12358 for (TInt i = EDriveY; i >= EDriveA; i--)
12359 {
12360 TChar driveLetter;
12361 fileServerSession.DriveToChar(i, driveLetter);
12362 variantFile.Append(driveLetter);
12363 variantFile.AppendFormat(KNearestLangFormat,
12364 &aResourcePath, &aFileName); // use the filename that was passed in
12365 resourceFileName.Copy(variantFile);
12366 BaflUtils::NearestLanguageFile(env->FsSession(),
12367 resourceFileName);
12368 TBool fileExists = BaflUtils::FileExists(
12369 env->FsSession(), resourceFileName);
12370 if (fileExists)
12371 {
12372 resOffset = env->AddResourceFileL(
12373 resourceFileName);
12374 return resOffset;
12375 }
12376 }
12377 variantFile.Append(driveLetterZ);
12378 variantFile.AppendFormat(KNearestLangFormat, &aResourcePath,
12379 &aFileName);
12380 resourceFileName.Copy(variantFile);
12381 BaflUtils::NearestLanguageFile(env->FsSession(),
12382 resourceFileName);
12383 fileExists = BaflUtils::FileExists(env->FsSession(),
12384 resourceFileName);
12385 if (fileExists)
12386 {
12387 resOffset = env->AddResourceFileL(resourceFileName);
12388 return resOffset;
12389 }
12390 }
12391 return resOffset; // -1
12392 }
12393TBool CPlatformFlashEngine::QueryAllowDenyL(const TDesC& aQueryText)
12394 {
12395 TBool rval = EFalse;
12396 TBufC<128> KResFile(_L("FlashlitePlugin.rsc") );
12397 TInt resOffset = CPlatformFlashEngine::LoadPluginResourceL(KResFile);
12398 CAknQueryDialog* dlg = CAknQueryDialog::NewL();
12399 TInt result = (dlg->ExecuteLD(R_SAFLASH_DIALOG_ALLOW_DENY, aQueryText));
12400 if (result)
12401 {
12402 rval = ETrue;
12403 }
12404 CEikonEnv::Static()->DeleteResourceFile(resOffset);
12405 return rval;
12406 }
12407 #endif
12408
12409#ifdef FEATURE_COLLECT_BITMAP
12410
12411TInt CPlatformFlashEngine::ToggleBrowserRendering(EBrPluginRenderingMode aMode)
12412{
12413 if(aMode == EBrowserRenderingMode)
12414 {
12415 iIgnoreDrawBitBuffer = ETrue;
12416 if(iOpenVgMode)
12417 {
12418 PlayStep(ETrue);
12419 TRAPD(err, CopyLastRenderedFrameToBitmapL());
12420 if(err)
12421 {
12422 iIgnoreDrawBitBuffer = EFalse;
12423 return err;
12424 }
12425 }
12426 }
12427 else
12428 {
12429 iIgnoreDrawBitBuffer = EFalse;
12430 if(iLastRenderedBitmap)
12431 {
12432 delete iLastRenderedBitmap;
12433 iLastRenderedBitmap = NULL;
12434 }
12435 }
12436
12437 return KErrNone;
12438}
12439CFbsBitmap* CPlatformFlashEngine::GetLastRenderedBitmap()
12440{
12441 if(iOpenVgMode)
12442 return iLastRenderedBitmap;
12443 else
12444 return iBitmap;
12445}
12446
12447void CPlatformFlashEngine::CopyLastRenderedFrameToBitmapL()
12448{
12449 if(iLastRenderedBitmap && iLastRenderedBitmap->SizeInPixels() != iCurrentWindowSize)
12450 {
12451 delete iLastRenderedBitmap;
12452 iLastRenderedBitmap = NULL;
12453 }
12454
12455 if(iLastRenderedBitmap == NULL)
12456 {
12457 iLastRenderedBitmap = new(ELeave) CFbsBitmap();
12458 TInt err = iLastRenderedBitmap->Create(iCurrentWindowSize,iDisplayFormat);
12459 if(err != KErrNone)
12460 {
12461 delete iLastRenderedBitmap;
12462 iLastRenderedBitmap = NULL;
12463 User::Leave(err);
12464 }
12465 }
12466
12467 if(iLastRenderedBitmap)
12468 eglCopyBuffers(iEGLDisplay, (EGLSurface)iEGLSurface.surface, iLastRenderedBitmap);
12469}
12470#endif
12471
12472//end of file