satengine/satserver/Commands/LaunchBrowserCmd/inc/CLaunchBrowserHandler.h
changeset 33 8d5d7fcf9b59
child 53 25b8d29b7c59
equal deleted inserted replaced
32:1f002146abb4 33:8d5d7fcf9b59
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  LaunchBrowser command handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CLAUNCHBROWSERHANDLER_H
       
    20 #define CLAUNCHBROWSERHANDLER_H
       
    21 
       
    22 #include <etelsat.h>
       
    23 #include <etelpckt.h>
       
    24 #include <w32std.h>             // WsSession
       
    25 #include <apgtask.h>            // TApaTask
       
    26 #include <DocumentHandler.h>    // KWmlcHandler
       
    27 
       
    28 #include "CSatCommandHandler.h"
       
    29 #include "SatSTypes.h"          // TSatQuery
       
    30 
       
    31 class MSatUtils;
       
    32 class RCmManager;
       
    33 class RCmConnectionMethod;
       
    34 
       
    35 /**
       
    36  *  Command handler for LaunchBrowser command.
       
    37  *
       
    38  *  @lib LaunchBrowserCmd.lib
       
    39  *  @since S60 v3.0
       
    40  */
       
    41 class CLaunchBrowserHandler : public CSatCommandHandler
       
    42     {
       
    43     
       
    44 public:
       
    45 
       
    46     static CLaunchBrowserHandler* NewL( MSatUtils* aUtils );
       
    47 
       
    48     virtual ~CLaunchBrowserHandler();
       
    49 
       
    50 // from base class MSatCommand
       
    51 
       
    52     /**
       
    53      * From MSatCommand.
       
    54      * Response from the client.
       
    55      *
       
    56      */
       
    57     void ClientResponse();
       
    58 
       
    59 // from base class CSatCommandHandler
       
    60 
       
    61     /**
       
    62      * From CSatCommandHandler.
       
    63      * Event notification.
       
    64      *
       
    65      * @param aEvent An event that is occured.
       
    66      */
       
    67     void Event( TInt aEvent );
       
    68 
       
    69 protected:
       
    70 
       
    71 // from base class CActive
       
    72 
       
    73     /**
       
    74      * From CActive.
       
    75      * Cancels the usat request.
       
    76      *
       
    77      */
       
    78     void DoCancel();
       
    79     
       
    80 // from base class CSatCommandHandler
       
    81 
       
    82     /**
       
    83      * From CSatCommandHandler.
       
    84      * Requests the command notification.
       
    85      *
       
    86      * @param aStatus Request status
       
    87      */
       
    88     void IssueUSATRequest( TRequestStatus& aStatus );
       
    89 
       
    90     /**
       
    91      * From CSatCommandHandler.
       
    92      * Precheck before executing the command.
       
    93      *
       
    94      * @return TBool indicating command is currently allowed.
       
    95      */
       
    96     TBool CommandAllowed();
       
    97 
       
    98     /**
       
    99      * From CSatCommandHandler.
       
   100      * Need for ui session.
       
   101      *
       
   102      * @return TBool indicating need of ui session.
       
   103      */
       
   104     TBool NeedUiSession();
       
   105 
       
   106     /**
       
   107      * From CSatCommandHandler.
       
   108      * Called when USAT API notifies that command.
       
   109      *
       
   110      */
       
   111     void HandleCommand();
       
   112 
       
   113     /**
       
   114      * From CSatCommandHandler.
       
   115      * Indicates the failure of launching ui client.
       
   116      *
       
   117      */
       
   118     void UiLaunchFailed();
       
   119 
       
   120 private:
       
   121 
       
   122     CLaunchBrowserHandler();
       
   123 
       
   124     void ConstructL();
       
   125 
       
   126     /**
       
   127      * Checks if Browser application is launched.
       
   128      *
       
   129      * @return The result of the operation.
       
   130      */
       
   131     TBool BrowserExists();
       
   132 
       
   133     /**
       
   134      * Closes the Browser application if it is active.
       
   135      *
       
   136      * @return The result of the operation.
       
   137      */
       
   138     void CloseBrowser();
       
   139 
       
   140     /**
       
   141      * Launches The Browser with URL.
       
   142      *
       
   143      * @param aParam, Reference to the parameter for the Browser
       
   144      * application.
       
   145      * @param aAccessPointUid, Reference to the accesspoint uid.
       
   146      */
       
   147     void LaunchWithUrlL( 
       
   148         const TDesC& aParam,
       
   149         const TUid& aAccessPointUid );
       
   150 
       
   151     /**
       
   152      * Handle the Launch Browser command.
       
   153      *
       
   154      */
       
   155     void LaunchBrowserL();
       
   156 
       
   157     /**
       
   158      * Starts timer. Function returns as the given time has elapsed or
       
   159      * timer is cancelled.
       
   160      *
       
   161      * @param aDelay Delay from the function call to complete function in
       
   162      *               microseconds
       
   163      * @param aInterval Interval to complete wait after aDelay, zero by
       
   164      *                  default
       
   165      */
       
   166     void After(
       
   167         const TTimeIntervalMicroSeconds32& aDelay,
       
   168         const TTimeIntervalMicroSeconds32& aInterval = 0 );
       
   169 
       
   170     /**
       
   171      * Called after given delay in After function.
       
   172      * Causes the After function to complete
       
   173      *
       
   174      * @param aPtr Pointer to itself since this is static function
       
   175      * @return whether to call function again after an interval
       
   176      */
       
   177     static TInt DelayCallBack( TAny* aPtr );
       
   178 
       
   179     /**
       
   180      * Create a new APN with given parameters using Access Point engine.
       
   181      *
       
   182      * @param aApName APN name.
       
   183      * @param aProxyServerAddr Proxy/Gateway server address.
       
   184      * @param aProxyPortNumber Proxy server port number.
       
   185      * @param aIPvType Gateway address IP type.
       
   186      *
       
   187      * @return the ID for the new APN
       
   188      */
       
   189     TUint32 CreateAccessPointL( const TDesC16& aApName,
       
   190         const TDesC16& aProxyServerAddr,
       
   191         const TUint32 aProxyPortNumber,
       
   192         const RPacketContext::TProtocolType& aIPvType );
       
   193 
       
   194     /**
       
   195      * Select an Access Point by the given gateway address. Create one if
       
   196      * there is not a corresponding AP.
       
   197      * 
       
   198      * @return IAP id from GCF connection method.
       
   199      */
       
   200     TUint32 GetAccessPointByGatewayAddressL();
       
   201     
       
   202     /**
       
   203      * Get an Access Point by default.
       
   204      *
       
   205      * @return IAP id from default connection method.
       
   206      */ 
       
   207     TUint32 GetAccessPointByDefaultL();
       
   208 
       
   209     /**
       
   210      * Get default Url by access point id.
       
   211      *
       
   212      * @param aApId Input IAP id by given connection method.
       
   213      * @return Default Url by given connection method.
       
   214      */    
       
   215     HBufC* GetDefaultUrlByAccessPointLC( TUint32 aApId );
       
   216 
       
   217     /**
       
   218      * A gateway address is required to be a IP address in 
       
   219      * connection method, so it is necessary to check 
       
   220      * the validity of the gateway address to avioding leave in
       
   221      * APE.
       
   222      *
       
   223      * @param aAddress A gateway address.
       
   224      * @return EIPv4 if the gateway address is a valid IPv4 address.
       
   225      *         EIPv6 if the gateway address is a valid IPv6 address.
       
   226      *         otherwise return 0 to indicate a invalid IP address.
       
   227      */
       
   228     TInt ValidateGatewayAddress( const TDesC16& aAddress );
       
   229 
       
   230     /**
       
   231      * Check the validity of a IPv4 address.
       
   232      *
       
   233      * @param aAddress A IPv4 address.
       
   234      * @return ETrue if the address is a valid IPv4 address.
       
   235      */
       
   236     TBool ValidateIPv4Address( const TDesC16& aAddress );
       
   237 
       
   238     /**
       
   239      * Check the validity of a IPv6 address.
       
   240      *
       
   241      * @param aAddress A IPv6 address.
       
   242      * @return ETrue if the address is a valid IPv6 address.
       
   243      */
       
   244     TBool ValidateIPv6Address( const TDesC16& aAddress );
       
   245 
       
   246     /**
       
   247      * Convert a descriptor to a integer.
       
   248      *
       
   249      * @param aAddress A descriptor.
       
   250      * @return Integer value.
       
   251      */
       
   252     TInt ConvertDesToInt( const TDesC16& aValue );
       
   253          
       
   254     /**
       
   255      * Check the validity of a descriptor in hex.
       
   256      *
       
   257      * @param aAddress A descriptor.
       
   258      * @return ETrue if each character in the descriptor is a valid 
       
   259      *         hexadecimal.
       
   260      */
       
   261     TBool ValidateHexadecimal( const TDesC16& aHex );
       
   262         
       
   263     /**
       
   264      * Separate the port number from a address if it is existing. For example, 
       
   265      * 210.13.246.172:8080.
       
   266      *
       
   267      * @param aAddress A address.
       
   268      * @param aPureAddr The pure address without any additional info.
       
   269      * @param aPortNumber The port number.
       
   270      * @return None.
       
   271      */
       
   272     void SeparatePortNumberFromAddress( const TDesC16& aAddress, 
       
   273         TDes16& aPureAddr, TUint32& aPortNumber );
       
   274          
       
   275     /**
       
   276      * Fulfill connecion method with default params.
       
   277      *
       
   278      * @param aCmManager Connection method manager.
       
   279      * @param aCm Output reference to RCmConnectionMethod.
       
   280      * @return None
       
   281      */    
       
   282     void FulfillConnnectionMethodL( RCmManager& aCmManager,
       
   283                                     RCmConnectionMethod& aCm );
       
   284    
       
   285     /**
       
   286      * Check the validity of offered bearer type
       
   287      *
       
   288      * @param aCm reference to RCmConnectionMethod.
       
   289      * @param aIsValid Output KErrNone if connection method is valid.
       
   290      * @return None
       
   291      */     
       
   292     void ValidateBearerTypeL( RCmConnectionMethod& aCm, TInt& aIsValid );
       
   293     
       
   294     /**
       
   295      * Get default connection method.
       
   296      *
       
   297      * @param aCmManager Input Connection method manager.
       
   298      * @param aDefCm Output reference to RCmConnectionMethod.
       
   299      * @param aIsValid Output KErrNone if found
       
   300      * @return None
       
   301      */       
       
   302     void GetDefConnMethodL( RCmManager& aCmManager,
       
   303                             RCmConnectionMethod& aDefCm,
       
   304                             TInt& aIsValid );  
       
   305     
       
   306 private: // data
       
   307 
       
   308     /**
       
   309      * LaunchBrowser command data.
       
   310      */
       
   311     RSat::TLaunchBrowserV2 iLaunchBrowserData;
       
   312 
       
   313     /**
       
   314      * LaunchBrowser command package.
       
   315      */
       
   316     RSat::TLaunchBrowserV2Pckg iLaunchBrowserPckg;
       
   317 
       
   318     /**
       
   319      * Response from client
       
   320      */
       
   321     RSat::TLaunchBrowserRspV2 iLaunchBrowserRsp;
       
   322 
       
   323     /**
       
   324      * Response package.
       
   325      */
       
   326     RSat::TLaunchBrowserRspV2Pckg iLaunchBrowserRspPckg;
       
   327 
       
   328     /**
       
   329      * Query command data
       
   330      */
       
   331     TSatQueryV1 iQueryData;
       
   332 
       
   333     /**
       
   334      * Query package
       
   335      */
       
   336     TSatQueryV1Pckg iQueryPckg;
       
   337 
       
   338     /**
       
   339      * Query response
       
   340      */
       
   341     TSatQueryRspV1 iQueryRsp;
       
   342 
       
   343     /**
       
   344      * Query response package
       
   345      */
       
   346     TSatQueryRspV1Pckg iQueryRspPckg;
       
   347 
       
   348     /**
       
   349      * Window server session
       
   350      */
       
   351     RWsSession iWsSession;
       
   352 
       
   353     /**
       
   354      * Application UID of the Browser.
       
   355      */
       
   356     TUid iUidWmlBrowser;
       
   357 
       
   358     /**
       
   359      * Indicates does this command need UI session ot not
       
   360      */
       
   361     TBool iNeedUiSession;
       
   362 
       
   363     /**
       
   364      * Blocker for After
       
   365      */
       
   366     CActiveSchedulerWait iAfterWait;
       
   367 
       
   368     /**
       
   369      * Timer used in After
       
   370      */
       
   371     CPeriodic* iAfterTimer;
       
   372                 
       
   373     /**
       
   374      * Flag to signal that command has icon data
       
   375      * To be removed when icons are allowed in this command
       
   376      */
       
   377     TBool iIconCommand;
       
   378     };
       
   379 
       
   380 #endif      // CLAUNCHBROWSERHANDLER_H
       
   381