msg_plat/mms_conformance_api/inc/MmsConformance.h
changeset 0 72b543305e3a
child 5 4697dfb2d7ad
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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:  
       
    15 *           Utility class for resolving whether a file can be
       
    16 *           sent over MMS or not.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __MMSCONFORMANCE_H
       
    23 #define __MMSCONFORMANCE_H
       
    24 
       
    25 // INCLUDES
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <e32base.h> // CBase
       
    29 
       
    30 #include <msgmedia.hrh>
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // Message class size limits 
       
    35 // - from OMA MMS Conformance Document v1.2
       
    36 const TInt KClassMaxSizeText        = 30 * 1024;   // 30k
       
    37 const TInt KClassMaxSizeImageRich   = 100 * 1024;  // 100k
       
    38 const TInt KClassMaxSizeVideoRich   = 300 * 1024;  // 300k
       
    39 // - from OMA MMS Conformance Document v1.3
       
    40 const TInt KClassMaxSizeMegapixel   = 600 * 1024;  // 600k
       
    41 
       
    42 // Image size definitions
       
    43 // - from OMA MMS Conformance Document v1.2
       
    44 const TInt KImageBasicWidth         = 160;
       
    45 const TInt KImageBasicHeight        = 120;
       
    46 const TInt KImageRichWidth          = 640;
       
    47 const TInt KImageRichHeight         = 480;
       
    48 // - from OMA MMS Conformance Document v1.3
       
    49 const TInt KImageMegapixelWidth     = 1600;
       
    50 const TInt KImageMegapixelHeight    = 1200;
       
    51 
       
    52 // Video size definitions
       
    53 // - from ITU-T Recommendation H.263
       
    54 //   (referenced from 3GPP TS 26.140
       
    55 //   (referenced from OMA MMS Conformance Document v1.2))
       
    56 const TInt KMmsQCIFSizeWidth        = 176;
       
    57 const TInt KMmsQCIFSizeHeight       = 144;
       
    58 const TInt KMmsSubQCIFSizeWidth     = 128;
       
    59 const TInt KMmsSubQCIFSizeHeight    = 96;
       
    60 
       
    61 // MACROS
       
    62 
       
    63 // FORWARD DECLARATIONS
       
    64 
       
    65 // DATA TYPES
       
    66 
       
    67 // MACROS
       
    68 
       
    69 // FORWARD DECLARATIONS
       
    70 class CMsgMediaInfo;
       
    71 
       
    72 // DATA TYPES
       
    73 
       
    74 enum TMmsConfClass
       
    75     {
       
    76     EMmsClassUnclassified = 0,
       
    77     // The order of classes matter. They must be in "ascending order".
       
    78     EMmsClassText,
       
    79     EMmsClassImageBasic,
       
    80     EMmsClassImageRich,
       
    81     EMmsClassVideoBasic,
       
    82     EMmsClassVideoRich,
       
    83     EMmsClassMegapixel
       
    84     };
       
    85 
       
    86 enum TMmsConfStatus
       
    87     {
       
    88     EMmsConfOk                      = 0x0000,
       
    89     EMmsConfNokDRM                  = 0x0001,
       
    90     EMmsConfNokConversionNeeded     = 0x0002,
       
    91     EMmsConfNokScalingNeeded        = 0x0004,
       
    92     EMmsConfNokTooBig               = 0x0008,
       
    93     EMmsConfNokNotEnoughInfo        = 0x0010,
       
    94     EMmsConfNokNotSupported         = 0x0020,
       
    95     EMmsConfNokFreeModeOnly         = 0x0040,
       
    96     EMmsConfNokCorrupt              = 0x0080
       
    97     };
       
    98 
       
    99 NONSHARABLE_CLASS( TMmsConformance )
       
   100     {
       
   101     public:
       
   102     
       
   103         /**
       
   104         *  Default constructor
       
   105         */
       
   106         inline TMmsConformance();
       
   107 
       
   108         /**
       
   109         *  Constructor
       
   110         */
       
   111         inline TMmsConformance(
       
   112             TMmsConfClass aConfClass,
       
   113             TUint32 aConfStatus,
       
   114             TBool aAdaptation );
       
   115 
       
   116         /**
       
   117         *  Copy constructor
       
   118         *  @param aConformance Data to copy
       
   119         */
       
   120         inline TMmsConformance( const TMmsConformance& aConformance );
       
   121 
       
   122     public: // data
       
   123         TMmsConfClass iConfClass;
       
   124         TUint32 iConfStatus;
       
   125         TBool iCanAdapt;
       
   126     };
       
   127 
       
   128 class CMmsConformance;
       
   129 typedef void (CMmsConformance::*LocalFuncPtr) (void);
       
   130 
       
   131 // FUNCTION PROTOTYPES
       
   132 
       
   133 // CLASS DECLARATION
       
   134 /**
       
   135 * CMmsConformance...
       
   136 *
       
   137 * @lib MsgMedia.lib
       
   138 * @since 3.1
       
   139 */
       
   140 NONSHARABLE_CLASS( CMmsConformance ) : public CBase
       
   141     {
       
   142     public:  // New methods
       
   143 
       
   144         /**
       
   145         * Factory method.
       
   146         *
       
   147         * @param aFs        IN Fileserver session.
       
   148         * @return Pointer to instance in CleanupStack
       
   149         */
       
   150         IMPORT_C static CMmsConformance* NewLC();
       
   151          
       
   152         /**
       
   153         * Factory method.
       
   154         *
       
   155         * @param aFs        IN Fileserver session.
       
   156         * @return Pointer to instance
       
   157         */
       
   158         IMPORT_C static CMmsConformance* NewL();
       
   159 
       
   160         /**
       
   161         * Destructor
       
   162         */
       
   163         virtual ~CMmsConformance();
       
   164         
       
   165         /**
       
   166         * Checks whether the MIME type is MMS conformant or not.
       
   167         *
       
   168         * @param aMimeType  IN Mime type of the file.
       
   169         * @return ETrue, if it's ok to send the 
       
   170         *         EFalse, otherwise
       
   171         */
       
   172         IMPORT_C TBool IsConformantMime( const TPtrC8& aMimeType );
       
   173 
       
   174         /**
       
   175         * Resolves conformance status of the given media object.
       
   176         *
       
   177         * @param aMediaInfo  IN Mime type of the file.
       
   178         * @return ETrue, if it's ok to send the 
       
   179         *         EFalse, otherwise
       
   180         */
       
   181         IMPORT_C TMmsConformance MediaConformance( CMsgMediaInfo& aMediaInfo );
       
   182 
       
   183         /**
       
   184         * Static version of the function that returns
       
   185         * the OMA Conformance Document version
       
   186         * supported by the current implementation.
       
   187         *
       
   188         * @return Conformance version defined in "mmsversion.h"
       
   189         */
       
   190         IMPORT_C static TUint8 ConformanceVersionL();
       
   191         
       
   192         /**
       
   193         * Get the OMA Conformance Document version
       
   194         * supported by the current implementation.
       
   195         *
       
   196         * @return Conformance version defined in "mmsversion.h"
       
   197         */
       
   198         inline TUint8 ConformanceVersion() const;
       
   199         
       
   200         /**
       
   201         * Get maximum send size of a multimedia message
       
   202         *
       
   203         * @return Maximum send size in bytes
       
   204         */
       
   205         inline TUint32 MaxSendSize() const;
       
   206 
       
   207         /**
       
   208         * Set maximum send size for a multimedia message
       
   209         * 
       
   210         * The default max send size (in MMS Settings) can 
       
   211         * be overriden with this function.
       
   212         *
       
   213         * NOTICE! There is no guarantee that the message can
       
   214         *         be sent if the size is defined bigger than
       
   215         *         the default max send size.
       
   216         *
       
   217         * @param    aMaxSize    0, unlimited
       
   218         *                       other value, max send size in bytes
       
   219         */
       
   220         inline void SetMaxSendSize( TUint32 aMaxSize );
       
   221 
       
   222         /**
       
   223         * User changeable creation mode
       
   224         * 
       
   225         * @return   ETrue, user can change MMS Creation mode
       
   226         *           EFalse, otherwise
       
   227         */
       
   228         inline TBool CreationModeUserChangeable() const;
       
   229 
       
   230         /**
       
   231         * Get MMS creation mode
       
   232         * 
       
   233         * @return   ETrue, Set creation mode to "free" (or "guided")
       
   234         *           EFalse, Set creation mode to "restricted"
       
   235         */
       
   236         inline TBool CreationMode() const;
       
   237 
       
   238         /**
       
   239         * Set MMS creation mode
       
   240         * 
       
   241         * The default creation mode (in MMS Settings) can 
       
   242         * be overriden with this function.
       
   243         *
       
   244         * @param    aFree ETrue, Set creation mode to "free"
       
   245         *                 EFalse, Set creation mode to "restricted"
       
   246         */
       
   247         inline void SetCreationMode( TBool aFree );
       
   248 
       
   249         /**
       
   250         * Set image size setting
       
   251         * 
       
   252         * The default image size setting (in MMS Settings) can 
       
   253         * be overriden with this function.
       
   254         *
       
   255         * NOTICE! There is no guarantee that the message can
       
   256         *         be sent if the size is defined bigger than
       
   257         *         the default max send size.
       
   258         *
       
   259         * @param    aImageSize  Image size in pixels
       
   260         */
       
   261         inline void SetImageSizeSetting( TSize aImageSize );
       
   262         
       
   263         /**
       
   264         * CheckCharacterSet
       
   265         *
       
   266         * With this method it is possible to control whether
       
   267         * the conformance of the character set is checked 
       
   268         * for text/plain files. 
       
   269         *
       
   270         * By default character set conformance is checked,
       
   271         * i.e. CheckCharacterSet flag is ETrue.
       
   272         *
       
   273         * If set EFalse the client is responsible for converting
       
   274         * the character set to a conformant one (either US-ASCII
       
   275         * or UTF-8).
       
   276         *
       
   277         * @param aCheck ETrue, character set conformance is checked,
       
   278         *               EFalse, character set conformance is not checked.
       
   279         */
       
   280         inline void CheckCharacterSet( TBool aCheck );
       
   281 
       
   282     private:
       
   283 
       
   284         /**
       
   285         * Constructor.
       
   286         *
       
   287         * @param aFs        IN Fileserver session.
       
   288         */
       
   289         CMmsConformance();
       
   290 
       
   291         /**
       
   292         * 2nd phase constructor.
       
   293         */
       
   294         void ConstructL();
       
   295 
       
   296         /**
       
   297         *
       
   298         */
       
   299         void CheckDRMStatus();
       
   300 
       
   301         /**
       
   302         *
       
   303         */
       
   304         LocalFuncPtr ResolveFunction( const TPtrC8& aMimeType );
       
   305 
       
   306         /**
       
   307         * Determines conformance for text/plain.
       
   308         */
       
   309         void ResolveTextPlain();
       
   310 
       
   311         /**
       
   312         * Determines conformance for application/xhtml+xml.
       
   313         */
       
   314         void ResolveTextXhtml();
       
   315 
       
   316         /**
       
   317         * Determines conformance for audio/amr.
       
   318         */
       
   319         void ResolveAudioAmr();
       
   320         
       
   321         /**
       
   322         * Determines conformance for audio/sp-midi.
       
   323         */
       
   324         void ResolveAudioSpMidi();
       
   325 
       
   326         /**
       
   327         * Determines conformance for image/jpeg.
       
   328         */
       
   329         void ResolveImageJpeg();
       
   330 
       
   331         /**
       
   332         * Determines conformance for image/gif.
       
   333         */
       
   334         void ResolveImageGif();
       
   335 
       
   336         /**
       
   337         * Determines conformance for image/wbmp.
       
   338         */
       
   339         void ResolveImageWbmp();
       
   340 
       
   341         /**
       
   342         * Determines conformance for image/png.
       
   343         */
       
   344         void ResolveImagePng();
       
   345 
       
   346         /**
       
   347         * Determines conformance for video/3gpp.
       
   348         */
       
   349         void ResolveVideo3gpp();
       
   350         
       
   351         /**
       
   352         * Determines conformance for video/3gpp2.
       
   353         */
       
   354         void ResolveVideo3gpp2();
       
   355 
       
   356         /**
       
   357         * Determines conformance for supported attachment MIME types.
       
   358         */
       
   359         void ResolveAttachment();
       
   360 
       
   361         /**
       
   362         * Determines conformance for unsupported attachment MIME types.
       
   363         */
       
   364         void ResolveNonconformantAttachment();
       
   365 
       
   366         /**
       
   367         * Determines conformance based on the file size.
       
   368         *
       
   369         * @return ETrue, if OK to send from file size point of view
       
   370         *         EFalse, otherwise
       
   371         */
       
   372         TBool CheckFileSize();
       
   373 
       
   374         /**
       
   375         * Determines conformance of an image file based on
       
   376         * the file size and the image resolution.
       
   377         *
       
   378         * @return ETrue, if the file was actually initialized as image
       
   379         *         EFalse, otherwise
       
   380         */
       
   381         TBool CheckImageSize();
       
   382 
       
   383         /**
       
   384         * Subfunction of CheckImageSize.
       
   385         * Determines enumeration from image resolution
       
   386         *
       
   387         * @param  aImageSize    Size of the image
       
   388         * @return Smallest class the image resolution fits
       
   389         */
       
   390         TMmsConfClass ClassByImageResolution( TSize aImageSize );
       
   391 
       
   392         /**
       
   393         * Compares size to MMS Settings "Image size".
       
   394         * @param  aImageSize    Size of the image
       
   395         * @return ETrue, width or height (or both) is larger than setting
       
   396         *         EFalse, otherwise
       
   397         */
       
   398         inline TBool LargerThanImageSizeSetting( TSize aImageSize );
       
   399         
       
   400     private: // data
       
   401 
       
   402         enum TResolverFlags
       
   403             {
       
   404             EDrmFeatureFull             = 0x0001,
       
   405             ECreationModeRestricted     = 0x0002,
       
   406             ECreationModeUserChangeable = 0x0004,
       
   407             EMms3gpp2Mode               = 0x0008,
       
   408             ECheckCharacterSet          = 0x0010
       
   409             };
       
   410 
       
   411         CMsgMediaInfo*          iMediaInfo;
       
   412         TMmsConformance         iConformance;
       
   413 
       
   414         TUint32                 iResolverFlags;
       
   415         TUint32                 iMaxSendSize;
       
   416         TSize                   iSettingsImageSize;
       
   417         TUint8                  iMmsVersion;
       
   418         
       
   419     };
       
   420 
       
   421 #include <mmsconformance.inl>
       
   422 
       
   423 #endif // __MMSCONFORMANCE_H