voipplugins/accountcreationplugin/engine/inc/acpcontroller.h
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Declarition of CAcpController
       
    15 *
       
    16 */
       
    17 
       
    18  
       
    19 #ifndef ACPCONTROLLER_H
       
    20 #define ACPCONTROLLER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <s32file.h>
       
    24 
       
    25 #include <sipobserver.h>
       
    26 #include <sipprofileregistryobserver.h>
       
    27 #include <sipmanagedprofileregistry.h>
       
    28 
       
    29 #include "accountcreationengineconstants.h"
       
    30 #include "macpxmlhandlerobserver.h"
       
    31 #include "macphttphandlerobserver.h"
       
    32 #include "macpimagehandlerobserver.h"
       
    33 
       
    34 class CFbsBitmap;
       
    35 class CAcpProvider;
       
    36 class CAcpXmlHandler;
       
    37 class CAcpImageHandler;
       
    38 class CAcpHttpHandler;
       
    39 class CAcpImageHandler;
       
    40 class MAcpControllerObserver;
       
    41 class CACPBrowserParams;
       
    42 class MSIPProfileRegistryObserver;
       
    43 class MImageHandlerObserver;
       
    44 
       
    45 /**
       
    46  *  CAcpController class
       
    47  *  Declarition of CAcpController.
       
    48  *
       
    49  *  @lib accountcreationplugin.lib
       
    50  *  @since S60 v3.2
       
    51  */
       
    52 NONSHARABLE_CLASS( CAcpController ) : public CBase,
       
    53                                       public MAcpXmlHandlerObserver,
       
    54                                       public MAcpHttpHandlerObserver,
       
    55                                       public MSIPProfileRegistryObserver,
       
    56                                       public MImageHandlerObserver
       
    57     {
       
    58 public: 
       
    59 
       
    60     /**
       
    61      * Different kind of field types supported by ACP.
       
    62      */
       
    63     enum TFetchTypes
       
    64         {
       
    65         EXml = 0, // provider list in xml form (default)
       
    66         ESis,     // sis file
       
    67         EIcon,    // icon file (png)
       
    68         EAction   // action file containing wbxml provisioning data
       
    69         };    
       
    70 
       
    71     /**
       
    72      * Two-phased constructor.
       
    73      *
       
    74      * @param aObserver Controller observer.
       
    75      */
       
    76     IMPORT_C static CAcpController* NewL(
       
    77         MAcpControllerObserver& aObserver );
       
    78 
       
    79     /**
       
    80      * Two-phased constructor.
       
    81      *
       
    82      * @param aObserver Controller observer.
       
    83      */
       
    84     IMPORT_C static CAcpController* NewLC(
       
    85         MAcpControllerObserver& aObserver );
       
    86 
       
    87     /**
       
    88      * Destructor.
       
    89      */
       
    90     virtual ~CAcpController();
       
    91 
       
    92     /**
       
    93      * Fetches provider list from network and parses it.
       
    94      *
       
    95      * @since S60 v3.2
       
    96      */
       
    97     IMPORT_C void FetchProviderListFromNetworkL();
       
    98 
       
    99     /**
       
   100      * Fetches SIS file from network.
       
   101      *
       
   102      * @since S60 v3.2
       
   103      * @param aSisUrl URL where to download.
       
   104      */
       
   105     IMPORT_C void FetchSisFileFromNetworkL( TDesC8& aSisUrl );
       
   106 
       
   107     /**
       
   108      * Fetches icon file from network.
       
   109      *
       
   110      * @since S60 v3.2
       
   111      * @param aIconUrl URL where to download.
       
   112      */
       
   113     IMPORT_C void FetchIconFileFromNetworkL( TDesC8& aIconUrl );
       
   114 
       
   115     /**
       
   116      * Returns count of providers in providers array.
       
   117      *
       
   118      * @since S60 v3.2
       
   119      * @return Number of providers
       
   120      */
       
   121     IMPORT_C TInt CountOfProviders() const;
       
   122 
       
   123     /**
       
   124      * Returns provider information referenced by index.
       
   125      *
       
   126      * @since S60 v3.2
       
   127      * @param aIndex Provider list index.
       
   128      * @return Pointer to provider name.
       
   129      */
       
   130     IMPORT_C const TPtrC ProviderNameFromIndexL( TInt aIndex ) const;
       
   131 
       
   132     /**
       
   133      * Returns provider information referenced by index.
       
   134      *
       
   135      * @since S60 v3.2
       
   136      * @param aIndex Provider list index.
       
   137      * @return Pointer to provider SIS URL.
       
   138      */
       
   139     IMPORT_C const TPtrC8 ProviderSisUrlFromIndexL( TInt aIndex ) const;
       
   140 
       
   141     /**
       
   142      * Returns provider information referenced by index.
       
   143      *
       
   144      * @since S60 v3.2
       
   145      * @param aIndex Provider list index.
       
   146      * @return Pointer to provider activation URL.
       
   147      */
       
   148     IMPORT_C const TPtrC8 ProviderActivationUrlFromIndexL( 
       
   149         TInt aIndex ) const;
       
   150 
       
   151     /**
       
   152      * Returns provider information referenced by index.
       
   153      *
       
   154      * @since S60 v3.2
       
   155      * @param aIndex Provider list index.
       
   156      * @return pointer Provider creation urlURL.
       
   157      */
       
   158     IMPORT_C const TPtrC8 ProviderCreationUrlFromIndexL( 
       
   159         TInt aIndex ) const;
       
   160 
       
   161     /**
       
   162      * Returns provider information referenced by index.
       
   163      *
       
   164      * @since S60 v3.2
       
   165      * @param aIndex Provider list index.
       
   166      * @return Pointer to provider description.
       
   167      */
       
   168     IMPORT_C const TPtrC ProviderDescriptionFromIndexL( 
       
   169         TInt aIndex ) const;
       
   170 
       
   171     /**
       
   172      * Returns provider information referenced by index.
       
   173      *
       
   174      * @since S60 v3.2
       
   175      * @param aIndex Provider list index.
       
   176      * @return Pointer to provider Type.
       
   177      */
       
   178     IMPORT_C const TPtrC ProviderTypeFromIndexL( TInt aIndex ) const;
       
   179 
       
   180     /**
       
   181      * Returns provider icon URL referenced by index.
       
   182      *
       
   183      * @since S60 v3.2
       
   184      * @param aIndex Provider list index
       
   185      * @return Pointer to provider icon URL.
       
   186      */
       
   187     IMPORT_C const TPtrC8 ProviderIconUrlFromIndexL( TInt aIndex ) const;
       
   188 
       
   189     /**
       
   190      * Returns provider bitmap referenced by index.
       
   191      *
       
   192      * @since S60 v3.2
       
   193      * @param aIndex Provider list index.
       
   194      * @return Pointer to bitmap owned by provider.
       
   195      */
       
   196     IMPORT_C void ProviderBitmapsFromIndexL( TInt aIndex,
       
   197         CFbsBitmap*& aBitmap, CFbsBitmap*& aMask ) const;
       
   198 
       
   199     /**
       
   200      * Stores active list index in provider list view to member data.
       
   201      *
       
   202      * @since S60 v3.2
       
   203      * @param aIndex Index to be stored.
       
   204      */
       
   205     IMPORT_C void SaveActiveIndex( TInt aIndex );
       
   206 
       
   207     /**
       
   208      * Returns active list index from member data.
       
   209      *
       
   210      * @since S60 v3.2
       
   211      * @return Active list index in provider list view.
       
   212      */
       
   213     IMPORT_C TInt ActiveIndex() const;
       
   214 
       
   215     /**
       
   216      * Fetches the needed parameters for provisioning.
       
   217      *
       
   218      * @since S60 v3.2
       
   219      * @param aUrl for URL.
       
   220      */
       
   221     IMPORT_C void FetchParametersL( TDes& aUrl );
       
   222 
       
   223     /**
       
   224      * Cancels ongoing HTTP request.
       
   225      *
       
   226      * @since S60 v3.2
       
   227      */
       
   228     IMPORT_C void CancelHttpRequest();
       
   229 
       
   230     /**
       
   231      * Starts downloading action (wbxml) file from the server.
       
   232      * 
       
   233      * @since S60 v3.2
       
   234      * @param aUrl URL of the action file.
       
   235      */
       
   236     IMPORT_C void FetchActionFileL( const TDesC8& aUrl );
       
   237 
       
   238     /**
       
   239      * Gets session id that was received from the server.
       
   240      * 
       
   241      * @since S60 v3.2
       
   242      * @return Session id descriptor.
       
   243      */
       
   244     IMPORT_C const TDesC8& SessionId();
       
   245     
       
   246 // from base class MAcpXmlHandlerObserver
       
   247     
       
   248     /**
       
   249      * From MAcpXmlHandlerObserver.
       
   250      * Notifies observer when parsing is completed.
       
   251      *
       
   252      * @since S60 v3.2
       
   253      * @param aError System wide error code.
       
   254      */
       
   255     IMPORT_C void NotifyParsingCompleted( TInt aError );
       
   256 
       
   257     /**
       
   258      * From MAcpXmlHandlerObserver.
       
   259      * Notifies when new provider is available.
       
   260      *
       
   261      * @since S60 v3.2
       
   262      * @param aError System wide error code.
       
   263      */
       
   264     IMPORT_C void NotifyParsedProviderL( const CAcpProvider& aProvider );
       
   265 
       
   266 // from base class MAcpHttpHandlerObserver
       
   267 
       
   268     /**
       
   269      * From MAcpHttpHandlerObserver.
       
   270      * Notifies observer about HTTP events.
       
   271      *
       
   272      * @since S60 v3.2
       
   273      * @param aEvent HTTP event.
       
   274      */
       
   275     void NotifyHttpEvent( TInt aEvent );
       
   276 
       
   277     /**
       
   278      * From MAcpHttpHandlerObserver.
       
   279      * Notifies observer about HTTP event errors.
       
   280      *
       
   281      * @since S60 v3.2
       
   282      * @param aError HTTP event error.
       
   283      */
       
   284     void NotifyHttpError( TInt aError );
       
   285 
       
   286     /**
       
   287      * From MAcpHttpHandlerObserver.
       
   288      * Notifies observer about received body.
       
   289      *
       
   290      * @since S60 v3.2
       
   291      * @param aBodyData Body data.
       
   292      */
       
   293     void NotifyBodyReceived( const TDesC8& aBodyData );
       
   294 
       
   295     /**
       
   296      * From MAcpHttpHandlerObserver.
       
   297      * Notifies observer about received header.
       
   298      *
       
   299      * @since S60 v3.2
       
   300      * @param aContentType Content data.
       
   301      */
       
   302     void NotifyContentTypeReceived( const TDesC8& aBodyData );
       
   303 
       
   304     /**
       
   305      * From MAcpHttpHandlerObserver.
       
   306      * Notifies observer about received session id.
       
   307      * 
       
   308      * @since S60 v3.2
       
   309      * @param aSession Id Session id received from the server.
       
   310      */
       
   311     void NotifySessionIdReceivedL( const TDesC8& aSessionId );
       
   312     
       
   313 // from base class MImageHandlerObserver
       
   314 
       
   315     /**
       
   316      * From MImageHandlerObserver.
       
   317      * Notifies completion of image handling.
       
   318      * 
       
   319      * @since S60 v3.2
       
   320      * @param aErr Error code.
       
   321      */
       
   322     void NotifyImageCompletion( TInt aErr );   
       
   323 
       
   324 private:
       
   325 
       
   326     CAcpController( MAcpControllerObserver& aObserver );
       
   327     void ConstructL();
       
   328 
       
   329     /**
       
   330      * Creates XML file from received data.
       
   331      *
       
   332      * @since S60 v3.2
       
   333      * @param aFilename File to be created.
       
   334      */
       
   335     void CreateFileFromDataL( const TDesC& aFilename );
       
   336     
       
   337     /**
       
   338      * Parses received action file for wbxml content and sends it to
       
   339      * provisioning engine.
       
   340      * 
       
   341      * @since S60 v3.2
       
   342      */
       
   343     void HandleActionFileL();
       
   344 
       
   345     /**
       
   346      * Returns next index with an icon URL in the providers list.
       
   347      * 
       
   348      * @since S60 v3.2
       
   349      * 
       
   350      * @param aResultUrl On return points to the icon URL if found.
       
   351      * @return TInt Index in the providers list or KErrNotFound.
       
   352      */
       
   353     TInt NextIndexWithIconUrl( TPtrC8& aResultUrl );
       
   354     
       
   355     /**
       
   356      * Parses a specific header value from head wrapper format.
       
   357      * 
       
   358      * @since S60 v3.2
       
   359      * @param aHeaders Descriptor containing the headers.
       
   360      * @param aParam Parameter to be parsed.
       
   361      * @return Parameter value part of the header.
       
   362      */
       
   363     TPtrC8 GetHeaderParamL( const TDesC8& aHeaders, const TDesC8& aParam );
       
   364     
       
   365     /** 
       
   366      * From MSIPProfileRegistryObserver.
       
   367      * SIP profile information event.
       
   368      *
       
   369      * @since S60 v3.2
       
   370      * @param aProfileId is id for profile
       
   371      * @param aEvent type of information event
       
   372      */
       
   373     void ProfileRegistryEventOccurred(
       
   374         TUint32 aSIPProfileId, 
       
   375         TEvent aEvent );
       
   376 
       
   377     /**
       
   378      * From MSIPProfileRegistryObserver.
       
   379      * An asynchronous error has occurred related to SIP profile.
       
   380      *
       
   381      * @since S60 v3.2
       
   382      * @param aSIPProfileId the id of failed profile 
       
   383      * @param aError a error code
       
   384      */
       
   385     void ProfileRegistryErrorOccurred(
       
   386         TUint32 aSIPProfileId,
       
   387         TInt aError );
       
   388     
       
   389 private: // data
       
   390 
       
   391     /**
       
   392      * Reference for contoller observer.
       
   393      */
       
   394     MAcpControllerObserver& iObserver;
       
   395 
       
   396     /**
       
   397      * Handle to XML parser.
       
   398      * Own.
       
   399      */
       
   400     CAcpXmlHandler* iParser;
       
   401 
       
   402     /**
       
   403      * Handle to HTTP handler.
       
   404      * Own.
       
   405      */
       
   406     CAcpHttpHandler* iHttpHandler;
       
   407 
       
   408     /**
       
   409      * Array for providers.
       
   410      * Own.
       
   411      */
       
   412     RPointerArray<CAcpProvider> iProviders;
       
   413 
       
   414     /**
       
   415      * Active list index, updated when provider specific view is opened.
       
   416      */
       
   417     TInt iActiveIndex;
       
   418 
       
   419     /**
       
   420      * Data fetched from network.
       
   421      * Own.
       
   422      */
       
   423     HBufC8* iData;
       
   424 
       
   425     /**
       
   426      * Type of data fetched from network.
       
   427      */
       
   428     TFetchTypes iType;
       
   429 
       
   430     /**
       
   431      * File server.
       
   432      */
       
   433     RFs iFs; 
       
   434 
       
   435     /**
       
   436      * Name of the file.
       
   437      */
       
   438     TBuf<KNameMaxLength> iFilename;
       
   439 
       
   440     /**
       
   441      * Handler for PnPMS parameters.
       
   442      */
       
   443     CACPBrowserParams* iPnpmsparams;
       
   444 
       
   445     /**
       
   446      * Provides the image convertions.
       
   447      * Own.
       
   448      */
       
   449     CAcpImageHandler* iImageHandler;
       
   450     
       
   451     /**
       
   452      * Session id to be used for all transactions.
       
   453      */
       
   454     HBufC8* iSessionId;
       
   455     
       
   456     /**
       
   457      * For getting SIP events.
       
   458      */
       
   459     CSIPManagedProfileRegistry* iSipModel;
       
   460     
       
   461     /**
       
   462      * A flag telling if the previous download attempt failed.
       
   463      * If it's ETrue, a new connection method is asked during the
       
   464      * next download.
       
   465      */
       
   466     TBool iErrorDownloading;
       
   467     
       
   468     /**
       
   469      * A flag telling if sis packet is downoloaded and sis installation
       
   470      * will be made.
       
   471      */
       
   472     TBool iSisInstallation;
       
   473 
       
   474     /**
       
   475      * File write stream for SIS file downloading.
       
   476      */
       
   477     RFileWriteStream iWs;
       
   478 
       
   479     // For unit testing.
       
   480 #ifdef _DEBUG
       
   481     friend class T_CAcpController;
       
   482 #endif
       
   483     };
       
   484 
       
   485 #endif // ACPCONTROLLER_H
       
   486 
       
   487 // End of file.