epoc32/include/mw/documenthandler.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.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:  Definition of CDocumentHandler class.
williamr@2
    15
*                The purpose of the Documenthandler is to offer to applications
williamr@2
    16
*                - wrapper for application embedding
williamr@2
    17
*                - temporary file utility to support data caging for platform security 
williamr@2
    18
*             
williamr@2
    19
*
williamr@2
    20
*/
williamr@2
    21
williamr@2
    22
williamr@2
    23
#ifndef DOCUMENTHANDLER_H
williamr@2
    24
#define DOCUMENTHANDLER_H
williamr@2
    25
williamr@2
    26
//  INCLUDES
williamr@2
    27
#include <e32base.h>
williamr@2
    28
#include <f32file.h>
williamr@2
    29
williamr@2
    30
// CONSTANTS
williamr@2
    31
williamr@2
    32
// App UIDs for handlers. Handlers are identified by the handler application's
williamr@2
    33
// UID. E.g. The handler for WMLC (binary format of Wireless Markup Language)
williamr@2
    34
// is responsible for launching the WMLBrowser. The data type
williamr@2
    35
// application/wap.vnd.wmlc is therefore mapped to the browser's UID,
williamr@2
    36
// 0x10008D39.
williamr@2
    37
williamr@2
    38
const TInt KTextHandler         = 0x1000599d;   // Notepad viever
williamr@2
    39
const TInt KWmlcHandler         = 0x10008D39;   // WML Browser
williamr@2
    40
const TInt KJamHandler          = 0x100009C1;   // JAM
williamr@2
    41
const TInt KAppInstHandler      = 0x101F875A;   // Installer 
williamr@2
    42
const TInt KBioViewerAppHandler = 0x0FC99F01;   // BVA
williamr@2
    43
const TInt KImageViewerHandler  = 0x101f4d90;   // Image viever
williamr@2
    44
const TInt KCertSaveAppHandler  = 0x100059D2;   // Cert response handler app
williamr@2
    45
const TInt KCODHandler          = 0x10008d4a;   // COD handler
williamr@2
    46
const TInt KDDhandler           = 0x10008d3f;   // DD Handler
williamr@2
    47
williamr@2
    48
// A global external mime type for all nokia games.
williamr@2
    49
_LIT8(KGameMimeType, "application/x-NokiaGameData");
williamr@2
    50
_LIT8(KDataTypeODM,"application/vnd.oma.drm.message"); // Not supported by DocumentHandler
williamr@2
    51
_LIT8(KDataTypeDCF,"application/vnd.oma.drm.content"); // Deprecated, do not use from here
williamr@2
    52
                                                     
williamr@2
    53
// Fail reasons
williamr@2
    54
const TInt KBadMimeType         = -12002;        // Mime type conflict etc.
williamr@2
    55
const TInt KMimeNotSupported    = -12003;        // No handler found
williamr@2
    56
const TInt KNullContent         = -12005;        // Empty content
williamr@2
    57
const TInt KDataDirNotFound     = -12006;        // Deprecated - not used
williamr@2
    58
const TInt KExecNotAllowed      = -12007;        // Executables not allowed
williamr@2
    59
const TInt KNoHostProcess       = -12008;        // Deprecated - not used
williamr@2
    60
const TInt KNotInitialized      = -12009;        // Not initialized
williamr@2
    61
const TInt KUserCancel          = -12010;        // User cancelled operation
williamr@2
    62
const TInt KDRMErrSession           = -12011;   // DRM session error.
williamr@2
    63
const TInt KDRMErrNoRights          = -12012;   // Invalid DRM rights.
williamr@2
    64
const TInt KDRMErrRightsDBCorrupted = -12013;   // DRM rights db corrupted.
williamr@2
    65
const TInt KDRMErrInvalidVersion    = -12014;   // Invalid DRM version.
williamr@2
    66
const TInt KDRMErrPreviewRights     = -12015;   // Preview DRM rights.
williamr@2
    67
williamr@2
    68
williamr@2
    69
// DATA TYPES
williamr@2
    70
williamr@2
    71
// API operations to inform special handlers of the entry function.
williamr@2
    72
enum TDocOperation
williamr@2
    73
    {
williamr@2
    74
    EDocCopy,               // CopyL( aFileNameOld, aNameNew, aDataType, aAttr)
williamr@2
    75
    EDocSave,               // SaveL( aContent, aDataType, aAttr )
williamr@2
    76
    EDocSaveAs,             // SaveL( aContent, aDataType,aFileName, aAttr )
williamr@2
    77
    EDocOpenFile,           // OpenFileL( aFileName, aDataType )
williamr@2
    78
    EDocOpenFileEmb,        // OpenFileEmbeddedL( aFileName, aDataType) 
williamr@2
    79
    EDocMove,               // MoveL( aFileNameOld, aNameNew, aDataType, aAttr)
williamr@2
    80
    EDocSilentMove,         // SilentMoveL( aFileNameOld, aNameNew, aRootPaht, aDataType, aAttr)
williamr@2
    81
    EDocSaveTemp,           // SaveTempFileL( aContent, aDataType, aFileName, aSharableFile)
williamr@2
    82
    };
williamr@2
    83
williamr@2
    84
// FORWARD DECLARATIONS
williamr@2
    85
class CDocHandlerBase;                       // Base class for handlers
williamr@2
    86
class CEikProcess;                           // The host process
williamr@2
    87
class MAknServerAppExitObserver;             // Viewer app exit observer 
williamr@2
    88
class TDataType;                             // Mime type handling
williamr@2
    89
class RApaLsSession;                         // App list server session
williamr@2
    90
class CAiwGenericParamList;                  // Generic parameter list 
williamr@2
    91
williamr@2
    92
// CLASS DECLARATION
williamr@2
    93
williamr@2
    94
/**
williamr@2
    95
* Utility class for opening and saving any supported content.
williamr@2
    96
* This class declares an interface for the DocumentHandler, a
williamr@2
    97
* common component in Series60.
williamr@2
    98
*
williamr@2
    99
* The CDocumentHandler class will not itself implement any content
williamr@2
   100
* handling routines. It's responsible for finding out which application
williamr@2
   101
* can handle given data type and constructing a correct handler implementation
williamr@2
   102
* for that application. If the given data type is supported by the system
williamr@2
   103
* but no specific handler is found, the CDocDefaltHandler is then constructed.
williamr@2
   104
* The default handler is an implementation of the CDoCDocHandlerBase class with
williamr@2
   105
* standard "Epoc-style" content handling.
williamr@2
   106
*
williamr@2
   107
* The handler application can be lauched standalone or embedded. The
williamr@2
   108
* Embedded launching is preferred way in Series60.
williamr@2
   109
* Standalone launching means that the application will run in
williamr@2
   110
* it's own process. Embedded launching means that the UI of an
williamr@2
   111
* application, which is responsible for handling given data type,
williamr@2
   112
* is embedded into the parent application. There will be only
williamr@2
   113
* parent applications icon shown in the fast swap window when an
williamr@2
   114
* application is embedded.
williamr@2
   115
*
williamr@2
   116
* Link your application against CommonUI.lib.
williamr@2
   117
*
williamr@2
   118
* <b>An example: </b> 
williamr@2
   119
*<pre> 
williamr@2
   120
* #include <DocumentHandler.h>
williamr@2
   121
*
williamr@2
   122
* <i>// Define DocHandler</i>
williamr@2
   123
* CDocumentHandler* iDocHandler;
williamr@2
   124
* 
williamr@2
   125
* <i>// Construct DocHandler</i>
williamr@2
   126
* void ConstructL()
williamr@2
   127
*    {
williamr@2
   128
*    iDocHandler = CDocumentHandler::NewL();
williamr@2
   129
*
williamr@2
   130
*    <i>// I want to be notified when exit happends. Because I
williamr@2
   131
*    // pass "this" pointer, I have to derive from
williamr@2
   132
*    // MAknServerAppExitObserver class.</i>
williamr@2
   133
*    iDocHandler->SetExitObserver(this)     
williamr@2
   134
*    }
williamr@2
   135
*
williamr@2
   136
* <i>// delete DocHandler</i>
williamr@2
   137
* void ~Myapp()
williamr@2
   138
*    {
williamr@2
   139
*    delete iDocHandler;
williamr@2
   140
*    }
williamr@2
   141
*
williamr@2
   142
*
williamr@2
   143
* <i>// and use like this</i>
williamr@2
   144
*
williamr@2
   145
* void OpenAttachmentL( RFile& aFile,           <i>// A file to be open</i>
williamr@2
   146
*                       TDataType& aDataType )  <i>// DataType can be empty</i>
williamr@2
   147
*   {
williamr@2
   148
*   TInt error = KErrNone;
williamr@2
   149
*   TFileName path;
williamr@2
   150
*
williamr@2
   151
*   <i>
williamr@2
   152
*   // Leaves on system wide errors like disk full, out of memory etc.</i>
williamr@2
   153
*   error = iDocHandler->OpenFileEmbeddedL( aFile, aDataType );
williamr@2
   154
*   // The status code can be either KErrNone or KUserCancel
williamr@2
   155
*
williamr@2
   156
*    }
williamr@2
   157
* </pre>
williamr@2
   158
*
williamr@2
   159
*/
williamr@2
   160
NONSHARABLE_CLASS(CDocumentHandler) : public CBase
williamr@2
   161
    {
williamr@2
   162
    public:        // Constructors and destructor
williamr@2
   163
williamr@2
   164
        /**
williamr@2
   165
        * Two-phased constructor. Leaves on failure.
williamr@2
   166
        *
williamr@2
   167
        * @param aProcess   The host process, which will be
williamr@2
   168
        *                   used for embedded launching.
williamr@2
   169
        *
williamr@2
   170
        * @return           The constructed CDocumentHandler
williamr@2
   171
        * @deprecated in Series60 3.0, instead use NewL without CEikProcess parameter
williamr@2
   172
        */
williamr@2
   173
        IMPORT_C static CDocumentHandler* NewL( CEikProcess* aProcess );
williamr@2
   174
williamr@2
   175
        /**
williamr@2
   176
        * Two-phased constructor. Leaves on failure.
williamr@2
   177
        *
williamr@2
   178
        * @param aProcess   The host process, which will be
williamr@2
   179
        *                   used for embedded launching.
williamr@2
   180
        *
williamr@2
   181
        * @return           The constructed CDocumentHandler
williamr@2
   182
        * @deprecated in Series60 3.0, instead use NewL without CEikProcess parameter
williamr@2
   183
        */
williamr@2
   184
        IMPORT_C static CDocumentHandler* NewLC( CEikProcess* aProcess );
williamr@2
   185
williamr@2
   186
        /**
williamr@2
   187
        * Two-phased constructor. Leaves on failure.
williamr@2
   188
        *
williamr@2
   189
        *
williamr@2
   190
        * @return           The constructed CDocumentHandler
williamr@2
   191
        * @since Series 60 3.0
williamr@2
   192
        */
williamr@2
   193
        IMPORT_C static CDocumentHandler* NewL( );
williamr@2
   194
williamr@2
   195
        /**
williamr@2
   196
        * Two-phased constructor. Leaves on failure.
williamr@2
   197
        *
williamr@2
   198
        *
williamr@2
   199
        * @return           The constructed CDocumentHandler
williamr@2
   200
        * @since Series 60 3.0
williamr@2
   201
        */
williamr@2
   202
        IMPORT_C static CDocumentHandler* NewLC( );
williamr@2
   203
williamr@2
   204
        /**
williamr@2
   205
        * Destructor.
williamr@2
   206
        */
williamr@2
   207
        IMPORT_C virtual ~CDocumentHandler();
williamr@2
   208
williamr@2
   209
    private:        // Constructors and destructor
williamr@2
   210
williamr@2
   211
        /**
williamr@2
   212
        * C++ default constructor.
williamr@2
   213
        */
williamr@2
   214
        CDocumentHandler( );
williamr@2
   215
williamr@2
   216
        /**
williamr@2
   217
        * C++ copy constructor
williamr@2
   218
        */
williamr@2
   219
        CDocumentHandler( const CDocumentHandler& );
williamr@2
   220
williamr@2
   221
        /**
williamr@2
   222
        * By default EPOC constructor is private.
williamr@2
   223
        */
williamr@2
   224
        void ConstructL();
williamr@2
   225
williamr@2
   226
    public:       // New functions, data caging
williamr@2
   227
        
williamr@2
   228
      /**
williamr@2
   229
       * Utility method for opening filehandle from existing file for OpenFileL 
williamr@2
   230
       * calls. The created file handle is meant to be shared across process 
williamr@2
   231
       * boundaries.
williamr@2
   232
       * 
williamr@2
   233
       * This function can leave in some system wide error situation.
williamr@2
   234
       * E.g. out of memory, not enough space in filesystem etc. These
williamr@2
   235
       * errors are usually trapped by the application framework.
williamr@2
   236
       *
williamr@2
   237
       * NOTE! Caller is responsible of closing opened file handle. 
williamr@2
   238
       *
williamr@2
   239
       * @param aFileName  Name (including directory information) for file. 
williamr@2
   240
       *                   This file should exist allready, otherwise this 
williamr@2
   241
       *                   function leaves with KErrNotFound. 
williamr@2
   242
       * @param aSharableFile Returned file handle that can be shared.
williamr@2
   243
       * @since Series 60 3.0
williamr@2
   244
       */
williamr@2
   245
      IMPORT_C void OpenTempFileL(
williamr@2
   246
          const TDesC& aFileName,
williamr@2
   247
          RFile &aSharableFile);
williamr@2
   248
williamr@2
   249
      /**
williamr@2
   250
       * Utility method for save aContent with aDataType temporarily
williamr@2
   251
       * for OpenFileL calls. The created file handle is meant to be shared 
williamr@2
   252
       * across process boundaries.
williamr@2
   253
       *
williamr@2
   254
       * This temporary file will be saved to process private temp directory.
williamr@2
   255
       * Temporary directory will be created if not existing yet. 
williamr@2
   256
       *
williamr@2
   257
       * This function can leave in some system wide error situation.
williamr@2
   258
       * E.g. out of memory, not enough space in filesystem etc. These
williamr@2
   259
       * errors are usually trapped by the application framework.
williamr@2
   260
       *
williamr@2
   261
       * NOTE! Caller is responsible of closing opened file handle!
williamr@2
   262
       * Created temporary file will be deleted in destructor of 
williamr@2
   263
       * DocumentHandler, but caller can delete it self as well.
williamr@2
   264
       *
williamr@2
   265
       * @param aContent   A content data buffer. Narrow descriptor that
williamr@2
   266
       *                   can contain any kind of data.
williamr@2
   267
       * @param aDataType  A data type for the content of the file. If empty
williamr@2
   268
       *                   the DocumentHandler tries to recognize the content.
williamr@2
   269
       * @param aFileName  Use this name for saving. The name must not 
williamr@2
   270
       *                   contain any directory information.
williamr@2
   271
       * @param aSharableFile Returned file handle that can be shared.
williamr@2
   272
       * @since Series 60 3.0
williamr@2
   273
       */
williamr@2
   274
      IMPORT_C void SaveTempFileL(
williamr@2
   275
          const TDesC8& aContent,
williamr@2
   276
          TDataType& aDataType,
williamr@2
   277
          const TDesC& aFileName,
williamr@2
   278
          RFile &aSharableFile);
williamr@2
   279
williamr@2
   280
    public:       // New functions, parameter handling
williamr@2
   281
      
williamr@2
   282
      /**
williamr@2
   283
       * Returns an empty instance of CAiwGenericParamList class. It can be
williamr@2
   284
       * used for example as an input parameter list for API methods.
williamr@2
   285
       * This is just a convinience method and doesn't have
williamr@2
   286
       * to be used. If consumer wants to create input list by itself
williamr@2
   287
       * it is ok. If this method is used, service handler takes care
williamr@2
   288
       * of deleting returned generic parameter list.
williamr@2
   289
       *
williamr@2
   290
       * @return  An empty instance of CAiwGenericParameter list.
williamr@2
   291
       * @since Series 60 3.0
williamr@2
   292
       */
williamr@2
   293
      IMPORT_C CAiwGenericParamList& InParamListL();
williamr@2
   294
williamr@2
   295
      /**
williamr@2
   296
       * Returns a list of possible output parameters handler application
williamr@2
   297
       * may have set after executing the service. The caller is responsible 
williamr@2
   298
       * for deleting the parameter instance if not null.
williamr@2
   299
       *
williamr@2
   300
       * @return   List of output parameters, NULL if nothing set.
williamr@2
   301
       * @deprecated
williamr@2
   302
       */          
williamr@2
   303
      IMPORT_C const CAiwGenericParamList* OutParamList();
williamr@2
   304
williamr@2
   305
    public:       // New functions, open file with filehandle
williamr@2
   306
      
williamr@2
   307
       /**
williamr@2
   308
        * Launches an application in standalone capable of handling
williamr@2
   309
        * data in aSharableFile (using aDatatype if available). 
williamr@2
   310
        * Doesn't save data from the file. In case of DRM protected 
williamr@2
   311
        * files with restricted rights, there will be query asking
williamr@2
   312
        * if user want open file. 
williamr@2
   313
        *
williamr@2
   314
        * This function can leave in some system wide error situation.
williamr@2
   315
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   316
        * also possible error codes from documenthandler.h header file.
williamr@2
   317
        * 
williamr@2
   318
        * @param aSharableFile  A sharable file handle to be passed to
williamr@2
   319
        *                       the launched application
williamr@2
   320
        * @param aDataType  A data type for the content of the file. If empty
williamr@2
   321
        *                   the DocumentHandler tries to recognize the content.
williamr@2
   322
        * @return           KErrNone if success. KUserCancel if the user 
williamr@2
   323
        *                   cancelled the operation. 
williamr@2
   324
        * @since Series 60 3.0
williamr@2
   325
        */
williamr@2
   326
      IMPORT_C TInt OpenFileL(
williamr@2
   327
          RFile& aSharableFile,
williamr@2
   328
          TDataType& aDataType);      
williamr@2
   329
         
williamr@2
   330
       /**
williamr@2
   331
        * Launches an application in embedded (if possible) capable of 
williamr@2
   332
        * handling data in aSharableFile (using aDatatype if available). 
williamr@2
   333
        * Doesn't save data from the file. In case of DRM protected
williamr@2
   334
        * files with restricted rights, there will be query asking
williamr@2
   335
        * if user want open file. 
williamr@2
   336
        *
williamr@2
   337
        * This function can leave in some system wide error situation.
williamr@2
   338
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   339
        * also possible error codes from documenthandler.h header file.
williamr@2
   340
        *
williamr@2
   341
        * @param aSharableFile  A sharable file handle to be passed to
williamr@2
   342
        *                       the launched application. 
williamr@2
   343
        * @param aDataType  A data type for the content of the file. If empty
williamr@2
   344
        *                   the DocumentHandler tries to recognize the content.
williamr@2
   345
        * @param aParamList Parameter list to be passed to handler application.
williamr@2
   346
        * @return           KErrNone if success. KUserCancel if the user 
williamr@2
   347
        *                   cancelled the operation. 
williamr@2
   348
        * @since Series 60 3.0
williamr@2
   349
        */
williamr@2
   350
      IMPORT_C TInt OpenFileEmbeddedL(
williamr@2
   351
          RFile& aSharableFile,
williamr@2
   352
          TDataType& aDataType,
williamr@2
   353
          const CAiwGenericParamList& aParamList);
williamr@2
   354
          
williamr@2
   355
        /**
williamr@2
   356
        * Launches an application in embedded (if possible) capable of 
williamr@2
   357
        * handling data in aSharableFile (using aDatatype if available). 
williamr@2
   358
        * Doesn't save data from the file. In case of DRM protected
williamr@2
   359
        * files with restricted rights, there will be query asking
williamr@2
   360
        * if user want open file. 
williamr@2
   361
        *
williamr@2
   362
        * This function can leave in some system wide error situation.
williamr@2
   363
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   364
        * also possible error codes from documenthandler.h header file.
williamr@2
   365
        *
williamr@2
   366
        * @param aSharableFile  A sharable file handle to be passed to
williamr@2
   367
        *                       the launched application. 
williamr@2
   368
        * @param aDataType  A data type for the content of the file. If empty
williamr@2
   369
        *                   the DocumentHandler tries to recognize the content.
williamr@2
   370
        * @return           KErrNone if success. KUserCancel if the user 
williamr@2
   371
        *                   cancelled the operation. 
williamr@2
   372
        * @since Series 60 3.0
williamr@2
   373
        */
williamr@2
   374
      IMPORT_C TInt OpenFileEmbeddedL(
williamr@2
   375
          RFile& aSharableFile,
williamr@2
   376
          TDataType& aDataType);
williamr@2
   377
     
williamr@2
   378
    public:       // open file with filename
williamr@2
   379
williamr@2
   380
        /**
williamr@2
   381
        * Launches an application standalone capable of handling
williamr@2
   382
        * data in aFilename, with aDataType. Doesn't copy data
williamr@2
   383
        * from the file.
williamr@2
   384
        *
williamr@2
   385
        * This function can leave in some system wide error situation.
williamr@2
   386
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   387
        * also possible error codes from documenthandler.h header file.
williamr@2
   388
        *
williamr@2
   389
        * @param aFileName  Name of the file. Directory path included.
williamr@2
   390
        * @param aDataType  A data type for the content of the file. If empty
williamr@2
   391
        *                   the DocumentHandler tries to recognize the content.
williamr@2
   392
        * @return           KErrNone if success. KUserCancel if the user 
williamr@2
   393
        *                   cancelled the operation.
williamr@2
   394
        */
williamr@2
   395
        IMPORT_C TInt OpenFileL(
williamr@2
   396
            const TDesC& aFileName,
williamr@2
   397
            TDataType& aDataType );
williamr@2
   398
williamr@2
   399
        /**
williamr@2
   400
        * Launches an application embedded capable of handling data in
williamr@2
   401
        * aFilename with aDataType. Doesn't copy data from the file.
williamr@2
   402
        *
williamr@2
   403
        * This function can leave in some system wide error situation.
williamr@2
   404
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   405
        * also possible error codes from documenthandler.h header file.
williamr@2
   406
        *
williamr@2
   407
        * @param aFileName  Name of the file. Directory path included.
williamr@2
   408
        * @param aDataType  A data type for the content of the file. If empty
williamr@2
   409
        *                   the DocumentHandler tries to recognize the content.
williamr@2
   410
        * @return           KErrNone if success. KUserCancel if the user 
williamr@2
   411
        *                   cancelled the operation.
williamr@2
   412
        */
williamr@2
   413
        IMPORT_C TInt OpenFileEmbeddedL(
williamr@2
   414
            const TDesC& aFileName,
williamr@2
   415
            TDataType& aDataType );
williamr@2
   416
williamr@2
   417
    public:       // data saving
williamr@2
   418
williamr@2
   419
        /**
williamr@2
   420
        * Save aContent with aDataType using aAttr to a correct directory.
williamr@2
   421
        * Generates a new name for saving. The storage is usually a filesystem, 
williamr@2
   422
        * but can be anything from application spesific data structures to 
williamr@2
   423
        * a database.
williamr@2
   424
        *
williamr@2
   425
        * This function can leave in some system wide error situation.
williamr@2
   426
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   427
        * also possible error codes from documenthandler.h header file.
williamr@2
   428
        *
williamr@2
   429
        * @param aContent   A content data buffer. Narrow descriptor that
williamr@2
   430
        *                   can contain any kind of data.
williamr@2
   431
        * @param aDataType  A data type for the content of the file. If empty
williamr@2
   432
        *                   the DocumentHandler tries to recognize the content.
williamr@2
   433
        * @param aAttr      Use these file attributes for saving. Your can 
williamr@2
   434
        *                   find these attributes from 
williamr@2
   435
        *                   \epoc32\include\f32file.h header file. 
williamr@2
   436
        *                   If the storage is not a filesystem these 
williamr@2
   437
        *                   attributes are ignored.
williamr@2
   438
        * @return           KErrNone if success. KUserCancel if the user 
williamr@2
   439
        *                   cancelled the operation.
williamr@2
   440
        */
williamr@2
   441
        IMPORT_C TInt SaveL(
williamr@2
   442
            const TDesC8& aContent,
williamr@2
   443
            TDataType& aDataType,
williamr@2
   444
            const TUint aAttr );
williamr@2
   445
williamr@2
   446
        /**
williamr@2
   447
        * Save aBuffer with aDataType using aAttr to a correct storage with a
williamr@2
   448
        * supplied name. The storage is usually a filesystem, but can be 
williamr@2
   449
        * anything from application spesific data structures to a database.
williamr@2
   450
        *
williamr@2
   451
        * This function can leave in some system wide error situation.
williamr@2
   452
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   453
        * also possible error codes from documenthandler.h header file.
williamr@2
   454
        *
williamr@2
   455
        * @param aContent   A content data buffer. Narrow descriptor that
williamr@2
   456
        *                   can contain any kind of data.
williamr@2
   457
        * @param aDataType  A data type for the content of the file. If empty
williamr@2
   458
        *                   the DocumentHandler tries to recognize the content.
williamr@2
   459
        * @param aName      Use this name for saving. The name must not 
williamr@2
   460
        *                   contain any directory information.
williamr@2
   461
        * @param aAttr      Use these file attributes for saving. Your can 
williamr@2
   462
        *                   find these attributes from 
williamr@2
   463
        *                   \epoc32\include\f32file.h header file. 
williamr@2
   464
        *                   If the storage is not a filesystem these 
williamr@2
   465
        *                   attributes are ignored.
williamr@2
   466
        * @return           KErrNone if success. KUserCancel if the user 
williamr@2
   467
        *                   cancelled the operation.
williamr@2
   468
        */
williamr@2
   469
        IMPORT_C TInt SaveL(
williamr@2
   470
            const TDesC8& aContent,
williamr@2
   471
            TDataType& aDataType,
williamr@2
   472
            const TDesC& aName,
williamr@2
   473
            const TUint aAttr );
williamr@2
   474
williamr@2
   475
        /**
williamr@2
   476
        * Copy a file named aFileNameOld to the correct storage using
williamr@2
   477
        * name aNameNew and aFileAttr. If aNameNew is empty, use
williamr@2
   478
        * the old name.
williamr@2
   479
        *
williamr@2
   480
        * This function can leave in some system wide error situation.
williamr@2
   481
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   482
        * also possible error codes from documenthandler.h header file.
williamr@2
   483
        *
williamr@2
   484
        * @param aFileNameOld   Name of the file being copied.
williamr@2
   485
        * @param aNameNew       Name of the new file. If null, use the 
williamr@2
   486
        *                       old name.
williamr@2
   487
        * @param aDataType      A data type for the file. If empty the 
williamr@2
   488
        *                       DocumentHandler tries to recognize type.
williamr@2
   489
        * @param aAttr          Use these file attributes for saving. 
williamr@2
   490
        *                       ReadOnly, ReadWrite.
williamr@2
   491
        * @return               KErrNone if success. KUserCancel if the user 
williamr@2
   492
        *                       cancelled the operation.
williamr@2
   493
        */
williamr@2
   494
        IMPORT_C TInt CopyL(
williamr@2
   495
            const TDesC& aFileNameOld,
williamr@2
   496
            const TDesC& aNameNew,
williamr@2
   497
            TDataType& aDataType,
williamr@2
   498
            const TUint aAttr );
williamr@2
   499
            
williamr@2
   500
        /**
williamr@2
   501
        * Copy a file with handle aFileOld to the correct storage using
williamr@2
   502
        * name aNameNew and aFileAttr. If aNameNew is empty, use
williamr@2
   503
        * the old name.
williamr@2
   504
        *
williamr@2
   505
        * This function can leave in some system wide error situation.
williamr@2
   506
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   507
        * also possible error codes from documenthandler.h header file.
williamr@2
   508
        *
williamr@2
   509
        * @param aFileOld       Handle of the file being copied.
williamr@2
   510
        * @param aNameNew       Name of the new file. If null, use the 
williamr@2
   511
        *                       old name.
williamr@2
   512
        * @param aDataType      A data type for the file. If empty the 
williamr@2
   513
        *                       DocumentHandler tries to recognize type.
williamr@2
   514
        * @param aAttr          Use these file attributes for saving. 
williamr@2
   515
        *                       ReadOnly, ReadWrite.
williamr@2
   516
        * @return               KErrNone if success. KUserCancel if the user 
williamr@2
   517
        *                       cancelled the operation.
williamr@2
   518
        */
williamr@2
   519
        IMPORT_C TInt CopyL(
williamr@2
   520
            const RFile& aFileOld,
williamr@2
   521
            const TDesC& aNameNew,
williamr@2
   522
            TDataType& aDataType,
williamr@2
   523
            const TUint aAttr );
williamr@2
   524
williamr@2
   525
        /**
williamr@2
   526
        * Move a file named aFileNameOld to the correct storage using
williamr@2
   527
        * name aNameNew and aFileAttr. Note that file in the old location 
williamr@2
   528
        * (aFileNameOld) will be removed during this operation.
williamr@2
   529
        *
williamr@2
   530
        * This function can leave in some system wide error situation.
williamr@2
   531
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   532
        * also possible error codes from documenthandler.h header file.
williamr@2
   533
        *
williamr@2
   534
        * @param aFileNameOld   Name of the file being copied.
williamr@2
   535
        * @param aNameNew       Name of the new file. If null, use the 
williamr@2
   536
        *                       default name for this mime-type. 
williamr@2
   537
        * @param aDataType      A data type for the file. If empty the 
williamr@2
   538
        *                       DocumentHandler tries to recognize type.
williamr@2
   539
        * @param aAttr          Use these file attributes for saving. 
williamr@2
   540
        *                       ReadOnly, ReadWrite.
williamr@2
   541
        * @return               KErrNone if success. KUserCancel if the user 
williamr@2
   542
        *                       cancelled the operation.
williamr@2
   543
        * @since Series60 2.8
williamr@2
   544
        */
williamr@2
   545
        IMPORT_C TInt MoveL(
williamr@2
   546
            const TDesC& aFileNameOld,
williamr@2
   547
            const TDesC& aNameNew,
williamr@2
   548
            TDataType& aDataType,
williamr@2
   549
            const TUint aAttr );
williamr@2
   550
williamr@2
   551
        /**
williamr@2
   552
        * Move a file named aFileNameOld to the correct storage using
williamr@2
   553
        * name aNameNew and aFileAttr. This method operates silently, so 
williamr@2
   554
        * nothing will be asked from user. Caller should give root path of 
williamr@2
   555
        * the selected memory. Unique file name will be created automatically 
williamr@2
   556
        * without user interaction. Note that file in the old location 
williamr@2
   557
        * (aFileNameOld) will be removed during this operation. 
williamr@2
   558
        *
williamr@2
   559
        * This function can leave in some system wide error situation.
williamr@2
   560
        * E.g. out of memory, not enough space in filesystem etc. See 
williamr@2
   561
        * also possible error codes from documenthandler.h header file.
williamr@2
   562
        * 
williamr@2
   563
        * @param aFileNameOld   Name of the file being copied.
williamr@2
   564
        * @param aNameNew       Name of the new file. If null, use the 
williamr@2
   565
        *                       default name for this mime-type. 
williamr@2
   566
        * @param aRootPath      Root path of the selected memory where file 
williamr@2
   567
        *                       should be moved.
williamr@2
   568
        * @param aDataType      A data type for the file. If empty the 
williamr@2
   569
        *                       DocumentHandler tries to recognize type.
williamr@2
   570
        * @param aAttr          Use these file attributes for saving. 
williamr@2
   571
        *                       ReadOnly, ReadWrite.
williamr@2
   572
        * @return               KErrNone if success. 
williamr@2
   573
        * @since Series60 3.0
williamr@2
   574
        */
williamr@2
   575
        IMPORT_C TInt SilentMoveL(
williamr@2
   576
            const TDesC& aFileNameOld,
williamr@2
   577
            const TDesC& aNameNew,
williamr@2
   578
            const TDesC& aRootPath,
williamr@2
   579
            TDataType& aDataType,
williamr@2
   580
            const TUint aAttr );
williamr@2
   581
williamr@2
   582
williamr@2
   583
    public:       // query functions
williamr@2
   584
williamr@2
   585
        /**
williamr@2
   586
        * Is the aDataType supported by the system.
williamr@2
   587
        *
williamr@2
   588
        * @param    aDataType Data type for content.
williamr@2
   589
        *
williamr@2
   590
        * @return   True if there is an application capable of handling
williamr@2
   591
        *           aDataType. False if no application can handle
williamr@2
   592
        *           this mime type.
williamr@2
   593
        */
williamr@2
   594
        IMPORT_C TBool CanHandleL( const TDataType& aDataType );
williamr@2
   595
williamr@2
   596
        /**
williamr@2
   597
        * Is opening of aDataType supported by the system.
williamr@2
   598
        *
williamr@2
   599
        * @param    aDataType Data type for content.
williamr@2
   600
        *
williamr@2
   601
        * @return   True if there is an application capable of handling
williamr@2
   602
        *           aDataType. False if no application can handle
williamr@2
   603
        *           this mime type.
williamr@2
   604
        */
williamr@2
   605
        IMPORT_C TBool CanOpenL( const TDataType& aDataType );
williamr@2
   606
williamr@2
   607
        /**
williamr@2
   608
        * Is saving aDataType supported by the system.
williamr@2
   609
        *
williamr@2
   610
        * @param    aDataType Data type for content.
williamr@2
   611
        *
williamr@2
   612
        * @return   True if there is an application capable of handling
williamr@2
   613
        *           aDataType. False if no application can handle
williamr@2
   614
        *           this mime type.
williamr@2
   615
        */
williamr@2
   616
        IMPORT_C TBool CanSaveL( const TDataType& aDataType );
williamr@2
   617
williamr@2
   618
        /**
williamr@2
   619
        * Get the whole path including filename where the content was saved.
williamr@2
   620
        * If the content was not saved to a file, this function returns
williamr@2
   621
        * a name that represents the saved object.  
williamr@2
   622
        * 
williamr@2
   623
        * It may not be possible to open the object with the returned 
williamr@2
   624
        * value, if it's not a real file in the filesystem. This situation
williamr@2
   625
        * may happen when e.g. the handler application stores it's contents in
williamr@2
   626
        * some weird data structure.
williamr@2
   627
        *
williamr@2
   628
        * @param    aPath The path of the saved content.
williamr@2
   629
        *
williamr@2
   630
        * @return   KErrNone if the path was found. KNotInitialised if the  
williamr@2
   631
        *           handler is not initialised.        
williamr@2
   632
        */
williamr@2
   633
        IMPORT_C TInt GetPath( TDes& aPath );   
williamr@2
   634
        
williamr@2
   635
        /**
williamr@2
   636
        * Get the uid of handler application. In case of media files uid is 
williamr@2
   637
        * Media Gallery's uid. This method should be called only succesfully 
williamr@2
   638
        * completed DocumentHandler operations. 
williamr@2
   639
        *
williamr@2
   640
        * @param    aUid Uid of the handler application for the content. 
williamr@2
   641
        *
williamr@2
   642
        * @return   KErrNone if the uid was found. KNotInitialised if the 
williamr@2
   643
        *           handler is not initialised.        
williamr@2
   644
        * @since Series 60 2.8
williamr@2
   645
        */
williamr@2
   646
        IMPORT_C TInt HandlerAppUid( TUid& aUid );   
williamr@2
   647
        
williamr@2
   648
        /**
williamr@2
   649
        * Set an observer for embedded application exit events. 
williamr@2
   650
        * DocumentHandler will delegate embedding applications exit 
williamr@2
   651
        * events to aObserver if it's not NULL:
williamr@2
   652
        * 
williamr@2
   653
        * @param    aObserver Exit observer
williamr@2
   654
        * @since Series 60 3.0
williamr@2
   655
        */
williamr@2
   656
        IMPORT_C void SetExitObserver( MAknServerAppExitObserver* aObserver );
williamr@2
   657
        
williamr@2
   658
        /**
williamr@2
   659
        * Utility method for appending a correct file name extension for some 
williamr@2
   660
        * content. This method should be called if wanted quarantee that file 
williamr@2
   661
        * extension of aFileName is correct with aDataType. 
williamr@2
   662
        *
williamr@2
   663
        * This method uses internal mapping table to find correct file 
williamr@2
   664
        * extension to aFileName. Mapping table contains mainly extensions
williamr@2
   665
        * and datatypes, which cannot be recognized based on the data it self 
williamr@2
   666
        * (No header information etc.). 
williamr@2
   667
        *
williamr@2
   668
        * This method replaces existing extension with correct one at aFileName 
williamr@2
   669
        * if needed. If aDatatype is not found from mapping table or aDatatype
williamr@2
   670
        * is not supported by any application, aFileName will remain unchanged.
williamr@2
   671
        *
williamr@2
   672
        * @param aFileName  Append extension to this filename. 
williamr@2
   673
        * @param aDataType  The content type of the file.
williamr@2
   674
        * @since Series 60 3.0
williamr@2
   675
        */
williamr@2
   676
        IMPORT_C void CheckFileNameExtension(
williamr@2
   677
            TDes& aFileName,
williamr@2
   678
            const TDataType& aDatatype );
williamr@2
   679
        
williamr@2
   680
        /**
williamr@2
   681
        * Get the RApaLsSession.
williamr@2
   682
        *
williamr@2
   683
        * @return Pointer to RApaLsSession
williamr@2
   684
        */
williamr@2
   685
        RApaLsSession* ApaLs();
williamr@2
   686
williamr@2
   687
        /**
williamr@2
   688
        * Get the exit observer.    
williamr@2
   689
        *
williamr@2
   690
        * @return Pointer to exit observer
williamr@2
   691
        * @since Series 60 3.0
williamr@2
   692
        */
williamr@2
   693
        MAknServerAppExitObserver* ServerAppExitObserver() const;
williamr@2
   694
williamr@2
   695
        /**
williamr@2
   696
        * Get the operation code of the api entry function.
williamr@2
   697
        */
williamr@2
   698
        TDocOperation DocOperation() const;
williamr@2
   699
        
williamr@2
   700
        /** 
williamr@2
   701
        * Close sharable FileSession. 
williamr@2
   702
        */
williamr@2
   703
        void CloseSharableFS();
williamr@2
   704
        
williamr@2
   705
        /**
williamr@2
   706
        * Set temporary file, which will be deleted in destructor.
williamr@2
   707
        */
williamr@2
   708
        void SetTempFile( const TDesC& aTempFile);
williamr@2
   709
        
williamr@2
   710
        /**
williamr@2
   711
        * Utility method to find out if there are any applications that 
williamr@2
   712
        * support progressive downloading for a given data type. 
williamr@2
   713
        *        
williamr@2
   714
        * The decision is based on configuration made in central repository.
williamr@2
   715
        *
williamr@2
   716
        * @param aDataType  The content type of the file.
williamr@2
   717
        * @param aUid  An Uid of the applications for the given data type.
williamr@2
   718
        * @return ETrue if progressive download was supported for the given
williamr@2
   719
        *   data type. Otherwise EFalse.
williamr@2
   720
        * @since Series 60 3.1
williamr@2
   721
        */
williamr@2
   722
        IMPORT_C TBool CanHandleProgressivelyL( 
williamr@2
   723
            const TDataType& aDataType, 
williamr@2
   724
            TUid& aUid );
williamr@2
   725
        
williamr@2
   726
        /**
williamr@2
   727
        * Utility method to provide a list of applications that support 
williamr@2
   728
        * progressive downloading. 
williamr@2
   729
        *
williamr@2
   730
        * The list of applications uids is configured central repository.
williamr@2
   731
        *
williamr@2
   732
        * @param aUidList A list of app Uids
williamr@2
   733
        * @since Series 60 3.2
williamr@2
   734
        */            
williamr@2
   735
        IMPORT_C void GetProgressiveDownloadAppUidsL( RArray<TInt32>& aUidList );            
williamr@2
   736
            
williamr@2
   737
    private:        // New functions
williamr@2
   738
williamr@2
   739
        /**
williamr@2
   740
        * Construct a handler for a given data type. A previous handler will 
williamr@2
   741
        * be destroyed and the new one is constructed.
williamr@2
   742
        *
williamr@2
   743
        * The desicion of which handler implementation to use is
williamr@2
   744
        * based on Apparc's AppForDataType query. If the app uid is
williamr@2
   745
        * found for aDataType and there is a hardcoded handler for it,
williamr@2
   746
        * the right handler will be constucted. If the app uid is not found
williamr@2
   747
        * try to match a data type for some handler. The default handler is
williamr@2
   748
        * constructed if no handler entry is found.
williamr@2
   749
        *
williamr@2
   750
        * @param    aUid UID of the handler application.
williamr@2
   751
        * @return   Error code
williamr@2
   752
        */
williamr@2
   753
        TInt FindHandlerL(
williamr@2
   754
            const TDataType& aDataType,
williamr@2
   755
            const TUid& aUid);
williamr@2
   756
williamr@2
   757
        /**
williamr@2
   758
        * Try to find a handler for aUid. Constructs iHandler if found.
williamr@2
   759
        *
williamr@2
   760
        * @param aDataType A data type to pass to a handler
williamr@2
   761
        * @param aUid An uid to search a handler for
williamr@2
   762
        */
williamr@2
   763
        void FindHandlerByUidL( 
williamr@2
   764
            const TUid& aUid, 
williamr@2
   765
            const TDataType& aDataType);
williamr@2
   766
williamr@2
   767
        /**
williamr@2
   768
        * Try to find a handler for aDataType. Constructs iHandler if found.
williamr@2
   769
        *
williamr@2
   770
        * @param aUid      An Uid for handler application.
williamr@2
   771
        * @param aDataType A data type to search a handler for.
williamr@2
   772
        */
williamr@2
   773
        void FindHandlerByMimeTypeL( 
williamr@2
   774
            const TUid& aUid, 
williamr@2
   775
            const TDataType& aDataType);
williamr@2
   776
                                
williamr@2
   777
        /**
williamr@2
   778
        * Makes all the nesessary security checks and maps aDataType to 
williamr@2
   779
        * an UID of the handler application. If system is not able to handle 
williamr@2
   780
        * the content type, or file is DRM protectedfile, aDataType and aUid  
williamr@2
   781
        * will left empty.
williamr@2
   782
        *
williamr@2
   783
        * @param aFileName  Filename
williamr@2
   784
        * @param aDataType  Data type for the file
williamr@2
   785
        * @param aUid       An application UID will be returned if a handler 
williamr@2
   786
        *                   was found.
williamr@2
   787
        * @return           KErrNone if success, error code if failure.
williamr@2
   788
        */
williamr@2
   789
        TInt RecognizeAndCheckFileL(
williamr@2
   790
            const TDesC& aFileName,
williamr@2
   791
            TDataType& aDataType,
williamr@2
   792
            TUid& aUid );     
williamr@2
   793
            
williamr@2
   794
        /**
williamr@2
   795
        * Makes all the nesessary security checks and maps aDataType to 
williamr@2
   796
        * an UID of the handler application. If system is not able to handle 
williamr@2
   797
        * the content type, or file is DRM protectedfile, aDataType and aUid  
williamr@2
   798
        * will left empty.
williamr@2
   799
        *
williamr@2
   800
        * @param aFileHandle Filehandle
williamr@2
   801
        * @param aDataType  Data type for the file
williamr@2
   802
        * @param aUid       An application UID will be returned if a handler 
williamr@2
   803
        *                   was found.
williamr@2
   804
        * @return           KErrNone if success, error code if failure.
williamr@2
   805
        */
williamr@2
   806
        TInt RecognizeAndCheckFileL(
williamr@2
   807
            RFile& aFileHandle,
williamr@2
   808
            TDataType& aDataType,
williamr@2
   809
            TUid& aUid );     
williamr@2
   810
williamr@2
   811
        /**
williamr@2
   812
        * This method lists all supported mime-types of system using 
williamr@2
   813
        * RDebug::Print. On UREL mode this method do nothing.
williamr@2
   814
        */
williamr@2
   815
        void ListSupportedMimeTypesL();
williamr@2
   816
		
williamr@2
   817
        /**
williamr@2
   818
        * Prohibit the assignment operation
williamr@2
   819
        */
williamr@2
   820
        CDocumentHandler operator=( const CDocumentHandler& )  const;
williamr@2
   821
        
williamr@2
   822
        /**
williamr@2
   823
        * Convert a hex string to 32-bit integer.
williamr@2
   824
        */        
williamr@2
   825
        TInt ConvertHexStringToInt32( 
williamr@2
   826
            const TDesC& aHexString, 
williamr@2
   827
            TInt32& aInt );               
williamr@2
   828
williamr@2
   829
    private:          // Data
williamr@2
   830
williamr@2
   831
        /**
williamr@2
   832
        * The entry operation. Handlers can query about the entry function
williamr@2
   833
        * when they need to implement some special behaviour.
williamr@2
   834
        */
williamr@2
   835
        TDocOperation iOperation;
williamr@2
   836
williamr@2
   837
        /**
williamr@2
   838
        * A handler providing operations. 
williamr@2
   839
        */
williamr@2
   840
        CDocHandlerBase* iHandler;
williamr@2
   841
williamr@2
   842
        /**
williamr@2
   843
        * A ApaLs session client.
williamr@2
   844
        */
williamr@2
   845
        RApaLsSession* iApaLs;
williamr@2
   846
        
williamr@2
   847
        /**
williamr@2
   848
        * Notify embedded app's exit event to this observer.
williamr@2
   849
        */
williamr@2
   850
        MAknServerAppExitObserver* iServerAppExitObserver;
williamr@2
   851
        
williamr@2
   852
        /**
williamr@2
   853
        * Holds sharable Fileserver session
williamr@2
   854
        */
williamr@2
   855
        RFs iSharableFS;
williamr@2
   856
williamr@2
   857
        /**
williamr@2
   858
        * Parameter list created using InParamListL function
williamr@2
   859
        */
williamr@2
   860
        CAiwGenericParamList* iInParams;
williamr@2
   861
        
williamr@2
   862
        /**
williamr@2
   863
        * Filename of temporary saved file. This file will be deleted 
williamr@2
   864
        * in destructor of documenthandler
williamr@2
   865
        */
williamr@2
   866
        TFileName iTempFileName;     
williamr@2
   867
        
williamr@2
   868
    };
williamr@2
   869
williamr@2
   870
#endif              // DOCUMENTHANDLER_H
williamr@2
   871
williamr@2
   872
// End of File