epoc32/include/mw/flash_ui.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:  Loads the UI library and creates the instance of the document class.
    15 *
    16 */
    17 
    18 #ifndef __FLASH_UI_H__
    19 #define __FLASH_UI_H__
    20 
    21 #include <eikapp.h>
    22 #include <apparc.h>
    23 #include <apgcli.h>
    24 
    25 
    26 /** @file flash_ui.h
    27  * The API to start Viewer UI for playing Flash content file from a Viewer or a stub 
    28  * application.
    29  *
    30  * The point here is to offer easy-of-use API for stubs applications which has 
    31  * dedicated set of platform security capabilities for rendering private SWF content. 
    32  * However, also standard Flash Viewer can utilize the same API as well. 
    33  *
    34  * Example usage of the API:
    35  *
    36  * @code
    37  * LOCAL_C CApaApplication* NewApplication( )
    38  *     {
    39  *	   return new(ELeave) CFlashStubApplication;
    40  *	   }
    41  *
    42  * GLDEF_C TInt E32Main()
    43  *     {
    44  *     return EikStart::RunApplication(NewApplication);
    45  *     }
    46  * 
    47  * CFlashStubApplication::~CFlashStubApplication()
    48  *     {
    49  *     if (iFlashLibrary.Handle())
    50  *         {
    51  *         iFlashLibrary.Close();
    52  *         }
    53  *     }
    54  * 
    55  * const TUid KUidFlashStubApp = { 0x1027367B };
    56  * 
    57  * TUid CFlashStubApplication::AppDllUid() const
    58  *     {
    59  *     return KUidFlashStubApp;
    60  *     }
    61  * 
    62  * 
    63  * _LIT(KStubFlashContent, "C:\\Data\\Others\\example.swf");
    64  * 
    65  * const TUint32 KContentChecksum = 0;
    66  * 
    67  * CApaDocument* CFlashStubApplication::CreateDocumentL()
    68  *     {
    69  *     FlashUIConfig config;
    70  *     config.iIsMMI = EFalse;
    71  *     config.iIsStubApp = ETrue;
    72  *     config.iContentFileName.Copy(KStubFlashContent);
    73  *     config.iContentChecksum = KContentChecksum;
    74  *     config.iExtensions = NULL;
    75  * 
    76  *     if(!FlashStubsSupported())
    77  *	       {
    78  *	       User::Leave(KErrNotSupported); 	
    79  *         } 
    80  *     return CreateFlashDocumentL(iFlashLibrary, this, config);
    81  *    }
    82  * @endcode
    83  */
    84 
    85 /** 
    86  Structure containing configuration information for UI.
    87  */
    88 struct FlashUIConfig
    89 {
    90 	/** 
    91 	* ETrue if MMI is supported. 
    92 	*/
    93 	TBool iIsMMI;	 
    94 	
    95 	/** 
    96 	* ETrue if is a stub application.
    97 	*/
    98 	TBool iIsStubApp;
    99 	
   100 	/** 
   101 	* The swf file which accesses the MMI features. 
   102 	*/
   103 	TFileName iContentFileName;
   104 
   105 	/** 
   106 	* Check sum for security. 
   107 	*/
   108 	TUint32 iContentChecksum;
   109 
   110 	/** 
   111 	* Name of the ECom plug-in
   112 	*/
   113 	const TDesC8* iExtensions;
   114 
   115 	/** 
   116 	* Reserved for future use 
   117 	*/
   118 	const TDesC8* iReserved1;
   119 
   120 	/** 
   121 	* Reserved for future use 
   122 	*/
   123 	TUint32 iReserved2;
   124 };
   125 
   126 /**
   127 * The Flash UI dll name. 
   128 */
   129 _LIT(KFlashUILibraryName, "flash2ui.dll");
   130 
   131 /** 
   132 * The ordinal of the exported function in the Flash UI dll.
   133 */
   134 const TInt KFlashCreateDocumentOrdinal = 1;
   135 
   136 /** 
   137 * Pointer to a function that creates the document class. 
   138 */
   139 typedef void*	(*PFNC_CreateFlashDocumentL)(CEikApplication* aApp, const FlashUIConfig& aUIConfig);
   140 
   141 class CEikApplication;
   142 /**
   143  *  CreateFlashDocumentL creates a Flash document for an application and
   144  *  starts playing the given SWF file. If there is no S60 Flash Lite
   145  *  Viewer Framework DLL installed in the device, the function leaves with error
   146  *  code returned from the RLibrary::Load. 
   147  *
   148  * @since S60 v3.1
   149  *
   150  * @param aLibrary Handle to the flash UI dll.
   151  * @param aApp Instance of the application class.
   152  * @param aUIConfig Instance of the class that contains the configuration for the UI.
   153  * @return The new document object.
   154  * @leave KErrGeneral Error in using the successfully loaded Flash Viewer Framework DLL 
   155  */
   156 inline CApaDocument* CreateFlashDocumentL(RLibrary& aLibrary, CEikApplication* aApp, const FlashUIConfig& aUIConfig)
   157 {
   158 	CApaDocument* doc = NULL;
   159 	User::LeaveIfError(aLibrary.Load(KFlashUILibraryName));
   160 	PFNC_CreateFlashDocumentL pFncCreateFlashDocumentL = (PFNC_CreateFlashDocumentL)aLibrary.Lookup(KFlashCreateDocumentOrdinal);
   161 	if (pFncCreateFlashDocumentL == NULL)
   162 	{
   163 		User::Leave(KErrGeneral);
   164 	}
   165 	doc = (CApaDocument*)pFncCreateFlashDocumentL(aApp, aUIConfig);
   166 	return doc;
   167 }
   168 
   169 /**
   170  * Checks whether S60 Flash Lite Viewer Framework DLL exists in the device for stub
   171  * applications.
   172  * @return ETrue if Flash Lite stub applications is suppported, EFalse otherwise.
   173  */
   174 inline TBool FlashStubsSupported() 
   175 {
   176 
   177 	RLibrary library;
   178 	TInt err = library.Load(KFlashUILibraryName);
   179 	if(err == KErrNone)
   180 	{
   181 		library.Close();
   182 		return ETrue;
   183 	}
   184 	else
   185 	{
   186 		return EFalse;
   187 	}
   188 }
   189 #endif // __FLASH_UI_H__