upnpsettings/appwizard/inc/cupnpappwizard.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2008 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:      Header file for the Setup wizard class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef CUPNPAPPWIZARD
       
    24 #define CUPNPAPPWIZARD
       
    25 
       
    26 // INCLUDES
       
    27 #include <e32base.h>
       
    28 #include <AknWaitNoteWrapper.h>  // base class MAknBackgroundProcess
       
    29 
       
    30 #include "upnpfilesharingengine.h" //CUPnPFileSharingEngine & THomeConnectMediaType
       
    31 #include "upnpfilesharingengineobserver.h" //MUPnPFileSharingEngineObserver
       
    32 
       
    33 
       
    34 
       
    35 // CONSTANTS
       
    36 const TInt KUPnPAlwaysAskInd = 0;
       
    37 const TInt KUPnPCreateNewInd = 1;
       
    38 
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 class CAknViewAppUi;
       
    42 class CUPnPSettingsEngine;
       
    43 class CEikonEnv;
       
    44 class CUPnPMultiselectionUi;
       
    45 // CLASS DECLARATION
       
    46 
       
    47 /**
       
    48  * CUPnPAppWizard class
       
    49  *
       
    50  * Class implementing the functionality of the setup wizard
       
    51  * @since S60 v3.1
       
    52  * @lib upnpappwizard.lib
       
    53  */
       
    54 class CUPnPAppWizard : public CBase,
       
    55                        private MUPnPFileSharingEngineObserver,
       
    56                        MAknBackgroundProcess
       
    57     {
       
    58 public:     // Constructors and destructor
       
    59 
       
    60     enum TSharingStarting
       
    61         {
       
    62         ENotActive,
       
    63         EStartingSharing,
       
    64         ESharingStarted
       
    65         };
       
    66 
       
    67     enum TShareArrayState
       
    68         {
       
    69         ESetMarked,
       
    70         EResetArray,
       
    71         EAddToArray
       
    72         };
       
    73     
       
    74     /**
       
    75      * Two-phased constructor.
       
    76      * @since S60 v3.1
       
    77      * @param aFirstStepText, Text for the first wizard step, owned by \
       
    78 client. If length of the aFirstStepText is 0 default text is used
       
    79      * @param aEng, Pointer to filesharing engine instance
       
    80      */
       
    81     IMPORT_C static CUPnPAppWizard* NewL( const TDesC& aFirstStepText,
       
    82                                           CUPnPFileSharingEngine* aEng );
       
    83 
       
    84     /**
       
    85      * Destructor.
       
    86      */
       
    87     virtual ~CUPnPAppWizard();
       
    88 
       
    89 public:     // New functions
       
    90 
       
    91     /**
       
    92      * Starts wizard
       
    93      *
       
    94      * @since S60 v3.1
       
    95      * @return TInt, Error code
       
    96      */
       
    97     IMPORT_C TInt StartL();
       
    98 
       
    99     /**
       
   100 	 * Modifies iShareImgAndVideoArray and iShareMusicArray arrays
       
   101 	 *
       
   102 	 * @param aArrayState
       
   103 	 * @param aValue
       
   104 	 * @param aUiDlg
       
   105 	 */
       
   106     void ModifyMarkedArrayL( TShareArrayState aArrayState 
       
   107     		               , TInt aValue = 0
       
   108     		               , CUPnPMultiselectionUi* aUiDlg = NULL );
       
   109 
       
   110 private:
       
   111     /**
       
   112      * CSelectionStorage class
       
   113      *
       
   114      * Private class for user selections and handling their 
       
   115      * storage and retrieval
       
   116      * @since S60 v3.1
       
   117      */
       
   118     NONSHARABLE_CLASS( CSelectionStorage ) : public CBase
       
   119         {
       
   120         public :
       
   121 
       
   122         enum TSharingStartResult
       
   123             {
       
   124             ESharingStarted,
       
   125             ENothingToShare,
       
   126             ESharingStartFailed
       
   127             };
       
   128         /**
       
   129         * C++ default constructor
       
   130         * @param aSetEng. Pointer to CUPnPSettingsEngine, not owned
       
   131         * @param aFileEng. Pointer to CUPnPFileSharingEngine, not owned
       
   132         */
       
   133         CSelectionStorage( CUPnPSettingsEngine* aSetEng,
       
   134                        CUPnPFileSharingEngine* aFileEng );
       
   135         /**
       
   136         * Destructor.
       
   137         */
       
   138         virtual ~CSelectionStorage();
       
   139 
       
   140         /**
       
   141         * Store locally users selected device name
       
   142         * @since S60 v3.1
       
   143         * @param aDeviceName. The new name
       
   144         */
       
   145         void SetDeviceNameL( TDes& aDeviceName );
       
   146 
       
   147         /**
       
   148         * Get device name from local store of from cenrep
       
   149         * @since S60 v3.1
       
   150         * @param aDeviceName. Descriptor to store the name
       
   151         * @return success of the operation
       
   152         */
       
   153         TInt GetDeviceNameL( TDes& aDeviceName );
       
   154 
       
   155         /**
       
   156         * Sets the IAP id of the user selected IAP
       
   157         * @since S60 v3.1
       
   158         * @param aIapId. Iap id of the selected IAP
       
   159         * @param aIndexForUi, Index of the iap in UI list
       
   160         */
       
   161         void SetIapId( const TInt aIapId,
       
   162                    const TInt aIndexForUi );
       
   163         /**
       
   164         * Function for getting the iapid from local storage or from cenrep
       
   165         * @since S60 v3.1
       
   166         * @param aIapId. Iap id of the selected IAP
       
   167         * @return success of the operation
       
   168         */
       
   169         TInt GetIapId( TInt& aIapId );
       
   170 
       
   171         /**
       
   172         * Initialize Iap name and iap id arrays with some fixed texts
       
   173         * @since S60 v3.1
       
   174         * @param aIapNameArr. Array pointer for the names
       
   175         * @param aIApIdArr. Array pointer for iap IDs
       
   176         */
       
   177         void InitializeIapArraysL( CDesCArray* aIapNameArr,
       
   178                                RArray<TInt64>& aIapIdArr ) const;
       
   179 
       
   180         /**
       
   181         * Stores the user selections from filesharing popus to local storage
       
   182         * @since S60 v3.1
       
   183         * @param aMedia. Type of media
       
   184         * @param aSelections. Array of the selections user has made.
       
   185         * Stored only locally
       
   186         */
       
   187         void SetSharedContent( THomeConnectMediaType aMedia,
       
   188                                CArrayFix<TInt>* aSelections );
       
   189 
       
   190         /**
       
   191         * Stores the devicename and IAP from local store to cenrep
       
   192         * @since S60 v3.1
       
   193         * @return success of the operation
       
   194         */
       
   195         TInt StoreSettingsL();
       
   196         
       
   197         /**
       
   198         * Stores the selected image and video albums from local store to 
       
   199         * cenrep
       
   200         * @since S60 v3.2
       
   201         * @return error code
       
   202         */
       
   203         TInt ImageStoreSharedFilesL();       
       
   204 
       
   205         /**
       
   206         * Gets the users sharing selections as indexes from local storage
       
   207         * @since S60 v3.1
       
   208         * @param aMedia. The kind of selections to get
       
   209         * @param aSelections. Array for selections
       
   210         */
       
   211         void GetSelectionsL( 
       
   212         THomeConnectMediaType aMedia,
       
   213         CArrayFix<TInt>* aSelections );
       
   214 
       
   215         /**
       
   216         * Determines if the is need to start sharing
       
   217         * @since S60 v3.1
       
   218         * @return ETrue if sharing needs to be activated.
       
   219         */
       
   220         TBool HasSomethingToShare() const;
       
   221 
       
   222         /** 
       
   223         * Gets the currently selected IAP index for the listbox UI
       
   224         * @since S60 v3.1
       
   225         * @param aCurrentSelection. The new current selection
       
   226         * @param aIapIdArr. Array of IAP ids of the IAPs shown in listbox
       
   227 
       
   228         */
       
   229         void GetCurrentSelection( TInt& aCurrentSelection,
       
   230                               RArray<TInt64>& aIapIdArr );
       
   231 
       
   232         /** 
       
   233         * Gets the WAP iap associated to given IAPid
       
   234         * @since S60 v3.1
       
   235         * @param aIAPId. Id to match
       
   236         * @return. The id of the corresponding WAP record
       
   237         */
       
   238         TInt ConvertIAPIdL( TInt aIAPId );
       
   239                        
       
   240     private :
       
   241         /**
       
   242         * Pointer to UPnP settings engine
       
   243         * Not owned
       
   244         */
       
   245         CUPnPSettingsEngine* iSetEng;
       
   246 
       
   247         /**
       
   248         * Pointer to UPnP File sharing engine
       
   249         * Not owned
       
   250         */
       
   251         CUPnPFileSharingEngine* iFileEng;
       
   252 
       
   253         /**
       
   254         * Pointer to UPnP device name
       
   255         * Not owned
       
   256         */
       
   257         HBufC* iDeviceName;
       
   258         
       
   259         /**
       
   260         * Users selected IAP id
       
   261         *
       
   262         */
       
   263         TInt iIapId;
       
   264 
       
   265         /**
       
   266         * Index for home network UI, to show the correct item as selected 
       
   267         *
       
   268         */
       
   269         TInt iIndexForUi;
       
   270         
       
   271         /**
       
   272         * The selection of Image& video sharing for Home Network UI
       
   273         */
       
   274         TBool iVisualImageSelection;
       
   275         
       
   276         /**
       
   277         * The selection of music sharing for Home Network UI
       
   278         */
       
   279         TBool iVisualMusicSelection;
       
   280         
       
   281         /**
       
   282         * The Array of the selected indexes user has made for sharing images 
       
   283         * and videos
       
   284         * owned
       
   285         */
       
   286         CArrayFix<TInt>* iImageSelectionArray;
       
   287         /**
       
   288         * The Array of the selected indexes user has made for sharing music 
       
   289         * owned
       
   290         */
       
   291         CArrayFix<TInt>* iMusicSelectionArray;       
       
   292         
       
   293         };
       
   294 
       
   295 
       
   296     /**
       
   297      * Internal states of wizard 
       
   298      */
       
   299     enum TWizardStep
       
   300         {
       
   301         EInfo1 = 0,
       
   302         EInfo2,
       
   303         EDeviceName,
       
   304         EInfo4,
       
   305         EAccessPoint,
       
   306         EInfo6,
       
   307         EShareImages,
       
   308         EShareMusic,
       
   309         EInfo9,
       
   310         EStoreSettings,
       
   311         EFinished
       
   312         };
       
   313 
       
   314     /**
       
   315      * C++ default constructor
       
   316      */
       
   317     CUPnPAppWizard();
       
   318 
       
   319     /**
       
   320      * Show the information note with OK BACK buttons
       
   321      * @since S60 v3.1
       
   322      * @param TInt, resource ID
       
   323      * @return keycode of the button user has pressed.
       
   324      */
       
   325     TInt ShowInfoStepL( TInt aMain ) const;
       
   326 
       
   327     /**
       
   328      * Show the first step. The text is given in constructor
       
   329      * @param TInt, resource ID
       
   330      * @return keycode of the button user has pressed.
       
   331      */
       
   332     TInt ShowFirstStepL( TInt aMain ) const;
       
   333     /**
       
   334      * Shows popup with text and header and edit box
       
   335      * @since S60 v3.1
       
   336      * @param TInt, resource ID
       
   337      * @return keycode of the button user has pressed.
       
   338      */
       
   339     TInt ShowTextStepL( TInt aMain );
       
   340 
       
   341     /**
       
   342      * Show the information note without buttons
       
   343      * @since S60 v3.1
       
   344      * @param TInt, resource ID
       
   345 
       
   346      */
       
   347     void ShowInfoNoteL( TInt aMain ) const;
       
   348 
       
   349     /**
       
   350      * Show the UI dialog with selection list
       
   351      * @since S60 v3.1
       
   352      * @param TInt, resource ID
       
   353      * @return keycode of the button user has pressed.
       
   354      */
       
   355     TInt ShowListStepL( TInt aMain );
       
   356 
       
   357 
       
   358     /**
       
   359      * Determines the next wizard step
       
   360      * @since S60 v3.1
       
   361      * @param TInt& The keycode of the users selection from previous dialog
       
   362 
       
   363      */
       
   364     void SetNextStep( const TInt& aSelection );
       
   365 
       
   366     /**
       
   367      * Shows the step for setting shared content
       
   368      * @since S60 v3.1
       
   369      * @param TInt, resource ID
       
   370      * @return keycode of the button user has pressed.
       
   371      */
       
   372     TInt ShowMultiselectionStepL( TInt aText );
       
   373 
       
   374     /**
       
   375      * Show error note with given resource id
       
   376      * @since S60 v3.1
       
   377      * @param TInt, resource ID
       
   378      */
       
   379     void ShowErrorNoteL( TInt aMain ) const;
       
   380 
       
   381     /**
       
   382      * Show wait note with given resource id
       
   383      * @since S60 v3.1
       
   384      * @param TInt, resource ID
       
   385      */
       
   386     void ShowWaitNoteL( TInt aMain );
       
   387 
       
   388 private: //From MUPnPFileSharingEngineObserver
       
   389     /**
       
   390      * Function informs when file sharing was enabled or disabled
       
   391      * @since S60 3.1
       
   392      * @param aEngine File sharing engine
       
   393      * @param aError, error code
       
   394      * @param aPhase ETrue if current phase is sharing activation,
       
   395      * otherwise EFalse
       
   396      */
       
   397     void HandleSharingStatus( 
       
   398         CUPnPFileSharingEngine& aEngine, 
       
   399         TInt aError,
       
   400         TBool aPhase );
       
   401 
       
   402     /**
       
   403      * Callback to inform if connection has been lost
       
   404      * @since S60 3.1
       
   405      * @param aEngine File sharing engine
       
   406      */ 
       
   407     void HandleSharingConnectionLost( 
       
   408         CUPnPFileSharingEngine& aEngine );
       
   409 
       
   410 private:
       
   411     /** 
       
   412      * Shows progress note to indicate progress of sharing files
       
   413      * @since S60 v3.1
       
   414      * @param TInt, The number of objects
       
   415      */
       
   416     void  ShowProgressNoteL( TInt aObjectCount );
       
   417 
       
   418     /**
       
   419      * Called when waitnote wrapper is finished
       
   420      * From MProgressDialogCallback
       
   421      */
       
   422     void DialogDismissedL( TInt aButtonId );
       
   423 
       
   424     /**
       
   425      * EPOC default constructor.
       
   426      */
       
   427     void ConstructL( const TDesC& aFirstStepText, 
       
   428                      CUPnPFileSharingEngine* aEng );
       
   429 
       
   430     void StepL();
       
   431 
       
   432     TBool IsProcessDone() const;
       
   433 
       
   434     /**
       
   435      * Display info note after starting sharing content
       
   436      * @since S60 v3.1
       
   437      * @param TInt, Id of note header resource
       
   438      * @param TInt, Id of note message resource
       
   439      * @param TInt, Id of note resource
       
   440      */
       
   441     void DisplayInfoL(
       
   442         TInt aHeaderResourceId,
       
   443         TInt aMessageResourceId,
       
   444         TInt aDialogResourceId );
       
   445 
       
   446 
       
   447 private:    // Data
       
   448 
       
   449     CAknViewAppUi* iAppUi;  // Not owned
       
   450     TInt iResFileOffset;   // Resource file offset
       
   451     CEikonEnv* iCoeEnv; // Not owned
       
   452     /**
       
   453      * The position of the wizard
       
   454      */
       
   455     TInt iStep;
       
   456     /**
       
   457      * The class for retrieving and setting shared items
       
   458      */
       
   459     CUPnPFileSharingEngine* iFileEng;
       
   460     /**
       
   461      * The class for setting  the IAP id and deviceName
       
   462      */
       
   463     CUPnPSettingsEngine* iSetEng;
       
   464     /**
       
   465      * The storage for the user selections
       
   466      */
       
   467     CSelectionStorage* iSelections;
       
   468     
       
   469     /**
       
   470      * Wait used in asynchronous operations
       
   471      * Started when there is operation ongoing in filesharingengine
       
   472      */
       
   473     CActiveSchedulerWait iWait;
       
   474 
       
   475     /** 
       
   476      * Array for IAP names
       
   477      */
       
   478     CDesCArray* iIapNameArr;
       
   479     
       
   480     /**
       
   481      * Status of the sharing when starting wizard
       
   482      * ETrue = Sharing on
       
   483      */
       
   484     TBool iSharingState;
       
   485    
       
   486     /**
       
   487      * Text for the first wizard step 
       
   488      *
       
   489      */
       
   490     HBufC* iFirstStepText;
       
   491 
       
   492     /** 
       
   493      * Indicator if starting sharing is ongoing
       
   494      */
       
   495     TInt iStartingSharing;
       
   496 
       
   497     TBool iDialogDismissed;
       
   498     
       
   499     /**
       
   500      * stores indexes if img and/or video is shared marked 
       
   501      */
       
   502     CArrayFix<TInt>* iShareImgAndVideoArray;
       
   503     
       
   504     /**
       
   505      * stores indexes if music is shared marked 
       
   506      */
       
   507     CArrayFix<TInt>* iShareMusicArray;
       
   508     
       
   509     /**
       
   510      * Flag the FeatureManager is initialized or not
       
   511      */
       
   512     TBool iFeatureManagerInitialized;    
       
   513     };
       
   514 
       
   515 #endif  // CUPNPAPPWIZARD
       
   516 
       
   517 // End of File