messagingappbase/smartmessaging/oplogobc/inc/OperatorLogoBioControl.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 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 *     Bio control for Operator Logos.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef COPERATORLOGOCONTROL_H
       
    22 #define COPERATORLOGOCONTROL_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <msgbiocontrol.h>              // for CMsgBioControl
       
    26 #include <RPhCltServer.h>               // RPhCltServer
       
    27 #include <bldvariant.hrh>
       
    28 
       
    29 // MACROS
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class COpLogoAOCallBack;
       
    33 class MIHLScaler;
       
    34 
       
    35 #ifdef RD_PHONE_CLIENT_EXT
       
    36 class CPhCltImageHandler;
       
    37 class CPhCltImageParams;
       
    38 #else
       
    39 class CPhCltExtImageHandler;
       
    40 class CPhCltExtImageParams;
       
    41 #endif
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 /**
       
    46  * Bio control for Operator Logos.
       
    47  */
       
    48 class COperatorLogoBioControl:
       
    49     public CMsgBioControl
       
    50     {
       
    51     public:  // Constructor and destructor
       
    52 
       
    53         /**
       
    54          * Two-phased constructor
       
    55          * @param aObserver Reference to the Bio control observer.
       
    56          * @param aSession Reference to Message Server session.
       
    57          * @param aId Id of the message.
       
    58          * @param aEditorOrViewerMode Enum control's mode
       
    59          * @param aFile A pointer to a file name of file based bio
       
    60          *        control.         
       
    61          * @return The newly created object.
       
    62          */
       
    63         IMPORT_C static CMsgBioControl* NewL(
       
    64             MMsgBioControlObserver& aObserver,
       
    65             CMsvSession* aSession,
       
    66             TMsvId aId,
       
    67             TMsgBioMode aEditorOrViewerMode,
       
    68             const RFile* aFile);
       
    69          
       
    70         /**
       
    71         * Destructor.
       
    72         */
       
    73         ~COperatorLogoBioControl();
       
    74 
       
    75 
       
    76     public: // Functions from virtual MMsgBioControl
       
    77 
       
    78         /**
       
    79         * Calculates and sets size for a Bio control
       
    80         * according to aSize.
       
    81         * The height of the Bio control may be less or more than requested by
       
    82         * aSize, but the width must be exactly the same. If width of the Bio
       
    83         * control is not the same as given by aSize, the width must be reset
       
    84         * back to requested one.
       
    85         * @param aSize A reference to the suggested size and new size.
       
    86         */
       
    87         void SetAndGetSizeL( TSize& aSize );
       
    88 
       
    89         /**
       
    90         * This is called by the container to allow the Bio
       
    91         * control to add a menu item.
       
    92         * @param aMenuPane Reference to the application's menu.
       
    93         */
       
    94         void SetMenuCommandSetL( CEikMenuPane& aMenuPane );
       
    95 
       
    96         /**
       
    97         * Returns a rectangle slice of the bio controls
       
    98         * viewing area. It is used by the CMsgEditorView class for scrolling
       
    99         * the screen.
       
   100         * @return TRect to show viewing area
       
   101         */
       
   102         TRect CurrentLineRect() const;
       
   103 
       
   104         /**
       
   105         * Returns true if Focus change is possible.
       
   106         * @param aDirection The direction to be checked.
       
   107         * @return if it is possible, returns ETrue, and vice versa
       
   108         */
       
   109         TBool IsFocusChangePossible( TMsgFocusDirection aDirection ) const;
       
   110 
       
   111         /**
       
   112         * The container application obtains a header text
       
   113         * from the bio control.
       
   114         * @return The header text.
       
   115         */
       
   116         HBufC* HeaderTextL()  const;
       
   117 
       
   118         /**
       
   119         * The command handler.
       
   120         * The Bio Control should only handle its own commands that it has set
       
   121         * using the function SetMenuCommandSetL().
       
   122         * @param aCommand ID of command to be handled.
       
   123         * @return If the command is handled, it returns ETrue, and vice versa
       
   124         */
       
   125         TBool HandleBioCommandL(TInt aCommand);
       
   126 
       
   127         /**
       
   128         * The application can get the option menu permissions using this
       
   129         * function.
       
   130         * @return The option menu permission flags. If the flag is off it
       
   131         * means that the option menu command is not recommended with this
       
   132         * Bio Control.
       
   133         */
       
   134         TUint32 OptionMenuPermissionsL() const;
       
   135 
       
   136         /**
       
   137         * Get the virtual height of the control's content.
       
   138         * @return virtual height in pixels.
       
   139         */
       
   140         TInt VirtualHeight();
       
   141 
       
   142         /**
       
   143         * Get the position of invisible cursor.
       
   144         * @return cursor position in pixels.
       
   145         */
       
   146         TInt VirtualVisibleTop();
       
   147 
       
   148     public: // Functions from CCoeControl
       
   149 
       
   150         /**
       
   151         * A CCoeControl virtual for handling key events.
       
   152         * @param aKeyEvent The key event.
       
   153         * @param aType TEventCode
       
   154         * @return EKeyWasConsumed or EKeyWasNotConsumed
       
   155         */
       
   156         TKeyResponse OfferKeyEventL(
       
   157             const TKeyEvent& aKeyEvent,TEventCode aType );
       
   158 
       
   159         /**
       
   160          * Returns a bio control's a context sensitive help.
       
   161 		 * @param aHelpContext Help context.
       
   162          */
       
   163         void GetHelpContext(TCoeHelpContext& aHelpContext) const;        
       
   164 		
       
   165     public: // TCallBack
       
   166 
       
   167        /**
       
   168         * TCallBack function for image scaling.
       
   169         * @param aPtr this class instance
       
   170         * @return always zero
       
   171         */        
       
   172         static TInt ScalingReady( TAny* aPtr );				
       
   173 
       
   174     protected: // Functions from CCoeControl
       
   175 
       
   176         /**
       
   177         * Gives the number of sub controls.
       
   178         * @return count of controls be included in this component
       
   179         */
       
   180         TInt CountComponentControls() const;
       
   181 
       
   182         /**
       
   183         * Returns a pointer to a certain sub control.
       
   184         * @param aIndex Index for control
       
   185         * @return Pointer to component in question.
       
   186         */
       
   187         CCoeControl* ComponentControl( TInt aIndex ) const;
       
   188 
       
   189         /**
       
   190         * This is called by the CONE framework, and gives this control a
       
   191         * chance to manage the layout of its sub controls.
       
   192         */
       
   193         void SizeChanged();
       
   194 
       
   195         /**
       
   196         * This is called when focus is lost or gained, and is used
       
   197         * for setting the focus of the list box.
       
   198         * @param aDrawNow
       
   199         */
       
   200         void FocusChanged( TDrawNow aDrawNow );
       
   201 
       
   202         /**
       
   203         * Sets the container window for this control. The container
       
   204         * control uses this function to set the same window for this control.
       
   205         * @param aContainer container
       
   206         */
       
   207         void SetContainerWindowL( const CCoeControl& aContainer );
       
   208         
       
   209         /**
       
   210          * Handles bitmap drawing.
       
   211          */    
       
   212         void Draw(const TRect& aRect) const;
       
   213 
       
   214     private: // New functions
       
   215 
       
   216        /**
       
   217         * Helper method which creates or rescales iScaledBitmap unless
       
   218         * image hasn't been loaded or conversion is currently ongoing.
       
   219         * @param aSize size for which to scale
       
   220         * @return ETrue if scaling was possible
       
   221         */
       
   222         TBool ScaleIfPossibleL( TSize aSize );
       
   223 
       
   224        /**
       
   225         * Callback method called when image scaling is ready.
       
   226         */
       
   227         void DoScalingReady();
       
   228 
       
   229        /**
       
   230         * Panic wrapper.
       
   231         * @param aCode panic code
       
   232         */
       
   233         void Panic(TInt aCode);        
       
   234         
       
   235     private: // Constructors
       
   236 
       
   237         /**
       
   238         * Constructor is prohibited.
       
   239         * @param aObserver Reference to the Bio control observer.
       
   240         * @param aSession Reference to Message Server session.
       
   241         * @param aId Id of the message in Message Server.
       
   242         * @param aEditorOrViewerMode control's mode
       
   243         */
       
   244         COperatorLogoBioControl( MMsgBioControlObserver& aObserver,
       
   245                               CMsvSession* aSession,
       
   246                               TMsvId aId,
       
   247                               TMsgBioMode aEditorOrViewerMode );
       
   248 
       
   249 
       
   250         /**
       
   251         * By default Symbian OS constructor is private.
       
   252         */
       
   253         void ConstructL();
       
   254 
       
   255     private: // New functions
       
   256 
       
   257         /**
       
   258         * Reads operator logo file and detach embedded OTA-bitmap from it.
       
   259         * Bitmap will be saved to the temp file.
       
   260         * @param aReadStream Stream where to get headers off.
       
   261         */
       
   262         void DetachHeadersFromOpLogoL( RFileReadStream& aReadStream );
       
   263         
       
   264         /**
       
   265         * Decode MCC and MNC information and set corresponding members.
       
   266         * @param aFmcc first part of mobile country code
       
   267         * @param aSmcc second part of mobile country code
       
   268         * @param aMnc mobile network code
       
   269         */
       
   270         void SetMccAndMnc( TUint8 aFmcc, TUint8 aSmcc, TUint8 aMnc );
       
   271 
       
   272         /**
       
   273         * Write bitmap to temporary file from the stream
       
   274         * @param aReadStream stream where to write
       
   275         */
       
   276         void WriteBitmapToTempFileL( RFileReadStream& aReadStream );
       
   277 
       
   278         /**
       
   279         * Try to read operator logo to stream from the file,
       
   280         * @param aReadStream Read logo in it.
       
   281         */
       
   282         void OpenOperatorLogoL( RFileReadStream& aReadStream );
       
   283 
       
   284         /**
       
   285         * Creates bitmap
       
   286         */
       
   287         void CreateBitmapL() ;
       
   288 
       
   289         /**
       
   290         * Try to save logo.
       
   291         */
       
   292         void TrySaveBitmapL();
       
   293 
       
   294 #ifdef RD_PHONE_CLIENT_EXT        
       
   295         /**
       
   296         * Checks if oplogo already exists in phone server.
       
   297         * @param aImageHandler reference
       
   298         */
       
   299         TBool LogoExistsL( 	CPhCltImageHandler& aImageHandler,
       
   300         					CPhCltImageParams* aLogoParams );
       
   301 #else        					
       
   302         /**
       
   303         * Checks if oplogo already exists in phone server.
       
   304         * @param aImageHandler reference
       
   305         */
       
   306         TBool LogoExistsL( 	CPhCltExtImageHandler& aImageHandler,
       
   307         					CPhCltExtImageParams* aLogoParams );
       
   308 #endif
       
   309 
       
   310         /**
       
   311         * Detaches and returns the size of temporary bitmap
       
   312         * @return the size of bitmap
       
   313         */
       
   314         TSize DetachSizeFromTempBitmapL();
       
   315 
       
   316         /**
       
   317         * Calculates cropper rectangle
       
   318         * @aparam aSize, the original size of bitmap
       
   319         * @return calculated rect
       
   320         */
       
   321         TRect CalculateCropRect( TSize aSize );
       
   322 
       
   323         /**
       
   324         * Opens and reads the file to descriptor for CheckMsgFormatL.
       
   325         * @return TBool is message valid.
       
   326         */
       
   327         TBool CheckMsgValidityL();
       
   328 
       
   329         /**
       
   330         * Checks the format of message data and returns the result as TBool.
       
   331         * @return TBool is the message valid or not.
       
   332         */
       
   333         TBool CheckMsgFormatL( RFile aFile, TPtr8 aPtr );
       
   334 
       
   335         /**
       
   336         * Gets MCC and MNC from ETel and compares those against
       
   337         * message's MCC and MNC return are those MCCs' and MNCs' same.
       
   338         */
       
   339         TBool IsClearingMessageL();
       
   340                
       
   341         /**
       
   342         * Resets bitmaps, scaler.
       
   343         */        
       
   344         void Reset();        
       
   345 
       
   346 #ifndef RD_PHONE_CLIENT_EXT
       
   347         /**
       
   348         * Load phone server client library so that oplogo can be saved. 
       
   349         */        
       
   350         void LoadLibraryLC();
       
   351 #endif
       
   352 
       
   353     private: // Hidden away
       
   354 
       
   355         /**
       
   356         * C++ default constructor, hidden away from outsiders.
       
   357         */
       
   358         COperatorLogoBioControl();
       
   359 
       
   360         /**
       
   361         * Copy-constructor is prohibited.
       
   362         */
       
   363         COperatorLogoBioControl( const COperatorLogoBioControl& aSource );
       
   364 
       
   365         /**
       
   366         * Assignment operator is prohibited.
       
   367         */
       
   368         const COperatorLogoBioControl& operator=(
       
   369             const COperatorLogoBioControl& aSource );
       
   370 
       
   371     private: //Data
       
   372 
       
   373         // Connection to phone server for saving oplogo
       
   374         RPhCltServer iPhoneServer;
       
   375 
       
   376         /// Own: Active object which calls callback method when
       
   377         /// scaling has finished    
       
   378         COpLogoAOCallBack* iScalingAO;      
       
   379         
       
   380         /// Own: Bitmap, unscaled original
       
   381         CFbsBitmap* iBitmap;   
       
   382         
       
   383         /// Own: Bitmap, scaled for current layout size
       
   384         CFbsBitmap* iScaledBitmap;
       
   385         
       
   386         /// Own: Bitmap scaler
       
   387         MIHLScaler* iScaler;    
       
   388 
       
   389         ///Temporary file name and path
       
   390         TFileName iTempPathAndName;
       
   391 
       
   392         /// does the msg header contain linefeed.
       
   393         TBool iLineFeedExists;
       
   394 
       
   395         /// Mobile country code
       
   396         TInt iMcc;
       
   397 
       
   398         /// Mobile Network Code
       
   399         TInt iMnc;
       
   400 
       
   401 #ifndef RD_PHONE_CLIENT_EXT        
       
   402         /// The library where the PhoneClient Extension is located.
       
   403         RLibrary    iControlDllLibrary;       
       
   404 #endif
       
   405         
       
   406         // file server session handle
       
   407         RFs iFs; 
       
   408         
       
   409         // temp file has been successfully created
       
   410         TBool iTempFileExists;
       
   411     };
       
   412 
       
   413 #endif // COPERATORLOGOCONTROL_H
       
   414 
       
   415 //  End of File