browserui/browser/BrowserAppInc/BrowserUtil.h
branchRCL_3
changeset 64 6385c4c93049
parent 63 4baee4f15982
child 65 8e6fa1719340
equal deleted inserted replaced
63:4baee4f15982 64:6385c4c93049
     1 /*
       
     2 * Copyright (c) 2002-2007 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 the License "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 *      Utilities.
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef BROWSER_UTILS_H
       
    22 #define BROWSER_UTILS_H
       
    23 
       
    24 // INCLUDE FILES
       
    25 
       
    26 #include <e32base.h>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 
       
    30 class CFavouritesItem;
       
    31 class TFavouritesWapAp;
       
    32 class MApiProvider;
       
    33 class CAiwGenericParamList;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38 * Static utility and debug support methods. This class cannot be instantiated,
       
    39 * hence the name.
       
    40 */
       
    41 class Util
       
    42     {
       
    43     public:     // types
       
    44 
       
    45         /**
       
    46         * Panic reasons.
       
    47         */
       
    48         enum TPanicReason
       
    49             {
       
    50             EInvalidDirection,
       
    51             EInvalidScrollingUnitType,
       
    52             EUninitializedData,
       
    53             EOutOfRange,
       
    54             ENoChildren,
       
    55             EBadPosition,
       
    56             ENullPointer,
       
    57             EInvalidArgument,
       
    58             EUnExpected,
       
    59             ERootLevel,
       
    60             ENoScriptProxy,
       
    61 			EMissingFont,
       
    62             /// Attempt to remove a non-existing database observer.
       
    63             EActiveBookmarkDbObserverNotFound,
       
    64             /// Event reported from an unexpected listbox control.
       
    65             EFavouritesBadListbox,
       
    66             /// The database table is not open as it ought to be.
       
    67             EFavouritesDbTableIsNotOpen,
       
    68             /// The database table is not closed as it ought to be.
       
    69             EFavouritesDbTableIsNotClosed,
       
    70             /// Unexpected Uid.
       
    71             EFavouritesBadBookmarkUid,
       
    72             /// The Ap Model already exists.
       
    73             EFavouritesApModelAlreadyExists,
       
    74             /// Bad icon index.
       
    75             EFavouritesBadIconIndex,
       
    76             /// Attempt to create filter twice.
       
    77             EFavouritesFilterAlreadyExists,
       
    78             /// Item array count and icon index array count do not match.
       
    79             EFavouritesBadIconIndexArray,
       
    80             /// Model closed with observers still in.
       
    81             EFavouritesObserversStillActive,
       
    82             /// Attempt to remove an observer which is not added / already removed.
       
    83             EFavouritesObserverNotFound,
       
    84             /// Attempt to set AP Observer over an existing one.
       
    85             EApObserverAlreadySet,
       
    86             /// Attempt to set Goto Pane Observer over an existing one.
       
    87             EGotoPaneObserverAlreadySet,
       
    88             /// Some internal limit doe not match the external dependency.
       
    89             ELimitMismatch,
       
    90             /// Internal error.
       
    91             EFavouritesInternal,
       
    92 			/// Undefined AP
       
    93 			EUndefinedAccessPoint,
       
    94 			/// EUnable to set temporary gateway
       
    95 			EUnableToSetTempGw,
       
    96             /// WIM is off but tried to used
       
    97             EUnsupportedFeature,
       
    98             /// Start an incremental operation when another is still running.
       
    99             EIncrementalOperationAlreadyRunning,
       
   100             /// Attempt ot update data which is in use (incremental operations)
       
   101             ECannotUpdateDataInUse,
       
   102 			// Size string is not convertable to integer
       
   103 			EInvalidSizeValue,
       
   104             /// Descriptor-based downloaded content handler already set.
       
   105             EDownloadedContentHandlerAlreadyInitialized,
       
   106             /// File-based downloaded content handler already set.
       
   107             EFileDownloadedContentHandlerAlreadyInitialized
       
   108             };
       
   109 
       
   110     public:     // methods
       
   111 
       
   112         /**
       
   113         * Panic the current thread.
       
   114         * @param aReason Panic reason.
       
   115         */
       
   116         static void Panic( TPanicReason aReason );
       
   117 
       
   118         /**
       
   119         * In debug builds, perform sanity check before application starts and
       
   120 		* panic if some check fails. In release builds, do nothing.
       
   121 		* Whatever "once-only" sanity checking you have, add that to this
       
   122 		* method.
       
   123         */
       
   124         static void SanityCheckL();
       
   125 
       
   126 		/**
       
   127 		* Parses the given URL. Fills username and password fields of the
       
   128 		* given item. Fills URL field with the given url excluding the
       
   129 		* username and password parts.
       
   130 		* @param aUrl URL.
       
   131 		* @param aItem Bookmark item.
       
   132 		*/
       
   133 		static void RetreiveUsernameAndPasswordFromUrlL
       
   134 			( const TDesC& aUrl, CFavouritesItem& aItem );
       
   135 
       
   136 		/**
       
   137 		* Returns descriptor to the middle of the url between '//' and '#'.
       
   138 		* @param aUrl Original url.
       
   139 		* @return Stripped url.
       
   140 		*/
       
   141 		static TPtrC StripUrl( const TDesC& aUrl );
       
   142 
       
   143 		        /**
       
   144         * Create an URL from a file name (file://blabla) and return
       
   145         * it in an allocated buffer. Pushed on cleanup stack; owner is the
       
   146         * caller.
       
   147         * @param aFileName File name.
       
   148         * @return The created URL in a buffer.
       
   149         */
       
   150         static HBufC* UrlFromFileNameLC( const TDesC& aFileName );
       
   151 
       
   152         /**
       
   153         * Check if Disk space goes below critical level if allocating
       
   154         * more disk space.
       
   155         * @param aShowErrorNote If ETrue, a warning note is shown.
       
   156         * @param aBytesToWrite Amount of disk space to be allocated (use an
       
   157         * estimate if exact amount is not known).
       
   158         * @return ETrue if allocation would go below critical level.
       
   159         */
       
   160         static TBool FFSSpaceBelowCriticalLevelL
       
   161             ( TBool aShowErrorNote, TInt aBytesToWrite = 0 );
       
   162 
       
   163         static TBool CheckBookmarkApL( const MApiProvider& aApiProvider, const TFavouritesWapAp& aItem );
       
   164         static TBool IsValidAPFromParamL( const MApiProvider& aApiProvider, TUint32 aIAPid );
       
   165         static TBool CheckApValidityL( const MApiProvider& aApiProvider, const TUint32 aItem );
       
   166         static TUint32 IapIdFromWapIdL( const MApiProvider& aApiProvider, const TUint32 aItem );
       
   167         static TUint32 WapIdFromIapIdL( const MApiProvider& aApiProvider, const TUint32 aItem );
       
   168         static void EncodeSpaces(HBufC*& aString);
       
   169 
       
   170         /**
       
   171         * Allocate a heap buffer for aUrl and make sure the URL is encoded.
       
   172         * If aUrl does not contain a scheme, then a default "http://" 
       
   173         * scheme is prepended to aUrl.
       
   174         * @param aUrl The URL to allocate a buffer for. 
       
   175         * @return The URL in a buffer. 
       
   176         */
       
   177         static HBufC* AllocateUrlWithSchemeL( const TDesC& aUrl );
       
   178     };
       
   179 
       
   180 #endif
       
   181 
       
   182 // End of file