upnpsharing/applicationengine/inc/upnpfilesharingengine.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2006-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 "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:      file sharing engine class definition
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef __UPNPFILESHARINGENGINE_H__
       
    23 #define __UPNPFILESHARINGENGINE_H__
       
    24 
       
    25 
       
    26 //  Include Files
       
    27 #include <e32base.h>    // CBase
       
    28 #include <e32std.h>     // TBuf
       
    29 #include <badesca.h>    // for CDesCArray
       
    30 
       
    31 #include "upnpconnectionmonitorobserver.h"
       
    32 #include "upnpcontentserverclient.h"
       
    33 #include "upnpfilesharingengineobserver.h"
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CUpnpContentRequestAO;
       
    37 class CUPnPFileSharingEngineAO;
       
    38 class CUpnpContentShareAO;
       
    39 class CUpnpProgressWatcher;
       
    40 class CUPnPConnectionMonitor;
       
    41 
       
    42 
       
    43 // CONSTANTS
       
    44 
       
    45 
       
    46 // ENUMERATIONS
       
    47 
       
    48 enum THomeConnectMediaType
       
    49     {
       
    50     EImageAndVideo = 0,
       
    51     EPlaylist,
       
    52     EPhotoFile,
       
    53     EVideoFile,
       
    54     EMusicFile
       
    55     };
       
    56 
       
    57 enum THomeConnectSharingStates
       
    58     {
       
    59     ENoChange = -99,
       
    60     EShareNone = 0,
       
    61     EShareMany,
       
    62     EShareAll
       
    63     };    
       
    64 
       
    65 // CLASS DECLARATION
       
    66 
       
    67 /**
       
    68  *  File sharing engine class for UPnP Home Connect Application
       
    69  *  @lib upnpapplicationengine.lib
       
    70  *  @since S60 3.1
       
    71  */
       
    72 class CUPnPFileSharingEngine : public CBase,
       
    73                                public MUPnPConnectionMonitorObserver
       
    74     {
       
    75 
       
    76 private:
       
    77 
       
    78     /**
       
    79      * C++ default constructor.
       
    80      */
       
    81     CUPnPFileSharingEngine();
       
    82 
       
    83     /**
       
    84      * By default Symbian 2nd phase constructor is private.
       
    85      */
       
    86     void ConstructL();
       
    87 
       
    88 public: // Constructors and destructor
       
    89 
       
    90     /**
       
    91      * Two-phased constructor.
       
    92      * @since S60 3.1
       
    93      */
       
    94     IMPORT_C static CUPnPFileSharingEngine* NewL();
       
    95 
       
    96     /**
       
    97      * Two-phased constructor.
       
    98      * @since S60 3.1
       
    99      */
       
   100     IMPORT_C static CUPnPFileSharingEngine* NewLC();
       
   101 
       
   102     /**
       
   103      * Destructor.
       
   104      * @since S60 3.1
       
   105      */
       
   106     IMPORT_C virtual ~CUPnPFileSharingEngine();
       
   107 
       
   108 public:
       
   109 
       
   110     /**
       
   111      * Sets observer for active object
       
   112      * @since S60 3.1
       
   113      * @param aObserver, observer class
       
   114      */
       
   115     IMPORT_C void SetObserver( MUPnPFileSharingEngineObserver* aObserver );
       
   116 
       
   117     /**
       
   118      * Return handle to MUPnPFileSharingEngineObserver interface
       
   119      * @since S60 3.1
       
   120      */
       
   121     IMPORT_C MUPnPFileSharingEngineObserver* Observer();
       
   122 
       
   123     /**
       
   124      * Sets sharing state to on or off
       
   125      * Asynchronous, callback to 
       
   126      * MUPnPFileSharingEngineObserver::HandleSharingStatus
       
   127      * @since S60 3.1
       
   128      * @param aState ETrue to enable sharing, otherwise EFalse
       
   129      */
       
   130     IMPORT_C void SetSharingStateL( TBool aState );
       
   131 
       
   132     /**
       
   133      * Gets file sharing state from local MediaServer
       
   134      * @since S60 3.1
       
   135      * @return ETrue if sharing is ON otherwise EFalse
       
   136      */
       
   137     IMPORT_C TBool SharingStateL();
       
   138 
       
   139     /**
       
   140      * Starts sharing process
       
   141      * Asynchronous, callback to 
       
   142      * MUPnPFileSharingEngineObserver::HandleSharingDone and
       
   143      * MUPnPFileSharingEngineObserver::HandleSharingProgress
       
   144      * @since S60 3.1
       
   145      * @param aType, Type of media to share
       
   146      */
       
   147     IMPORT_C void ShareMediaL( THomeConnectMediaType aType );
       
   148 
       
   149     /**
       
   150      * Updates shared objects
       
   151      * Asynchronous, callback to 
       
   152      * MUPnPFileSharingEngineObserver::HandleSharingDone and
       
   153      * MUPnPFileSharingEngineObserver::HandleSharingProgress
       
   154      * @since S60 3.1
       
   155      * @param aType Type of media to refresh
       
   156      */
       
   157     IMPORT_C void RefreshSharedMediaL( THomeConnectMediaType aType );
       
   158 
       
   159     /**
       
   160      * Gets the selected albums/playlist indexes
       
   161      * Asynchronous, callback to 
       
   162      * MUPnPFileSharingEngineObserver::HandleSelectionIndexes
       
   163      * @since S60 3.1
       
   164      * @param aType Type of media selected
       
   165      */
       
   166     IMPORT_C void RequestSelectionIndexesL( 
       
   167         THomeConnectMediaType aType ) const;
       
   168 
       
   169     /**
       
   170      * Gets the selected albums/playlist indexes
       
   171      * @since S60 3.1
       
   172      * @param aMarkedItems The indexes of the selections user has made\
       
   173 relative to selections received from GetSelectionContentL
       
   174      */
       
   175     IMPORT_C void GetSelectionIndexesL(
       
   176         CArrayFix<TInt>& aMarkedItems ) const;
       
   177 
       
   178     /**
       
   179      * Sets the user selections
       
   180      * @since S60 3.1
       
   181      * @param aType Type of media selected
       
   182      * @param aMarkedItems The indexes of the selections user has made\
       
   183 relative to selections received from GetSelectionContentL
       
   184      */
       
   185     IMPORT_C void SetSelectionIndexesL( 
       
   186         THomeConnectMediaType aType,
       
   187         const CArrayFix<TInt>& aMarkedItems );
       
   188 
       
   189     /**
       
   190      * Requests the album /playlist names
       
   191      * Asynchronous, callback to 
       
   192      * MUPnPFileSharingEngineObserver::HandleSelectionContent
       
   193      * @since S60 3.1
       
   194      * @param aType Type of the media requested
       
   195      */
       
   196     IMPORT_C void RequestSelectionContentL( THomeConnectMediaType aType );
       
   197 
       
   198     /**
       
   199      * Gets the album /playlist names from upnpcontentserver once ready
       
   200      * @since S60 3.1
       
   201      * @param aType Container type
       
   202      * @param aArray Array containng the names for the UI
       
   203      */
       
   204     IMPORT_C void GetSelectionContentL( CDesCArray& aArray ) const;
       
   205 
       
   206     /**
       
   207      * Request information about sharing statuses / progress from the
       
   208      * contentserver. The information is received via callback
       
   209      * @since S60 3.1
       
   210      */
       
   211     IMPORT_C void RequestSharingProgressL();
       
   212 
       
   213     /**
       
   214      * Starts upload listener. Leave in case of error
       
   215      * @since S60 3.1
       
   216      */
       
   217     IMPORT_C void StartUploadListenerL();
       
   218 
       
   219     /**
       
   220      * Stops upload listener. Leave in case of error
       
   221      * @since S60 3.1
       
   222      */
       
   223     IMPORT_C void StopUploadListenerL();
       
   224 
       
   225     /**
       
   226      * Start or stop connection monitoring
       
   227      * @since S60 3.1
       
   228      * @param aState ETrue = Start, EFalse = Stop
       
   229      * @param aStatus TRequestStatus for async operation
       
   230      */
       
   231     void SetConMonStateL( TBool aState, TRequestStatus& aStatus );
       
   232 	
       
   233      /**
       
   234      * Set share file completed flag
       
   235      * @since S60 3.2.3
       
   236      * @param aShareState set ETrue indicate imageandvideo or playlist shared completely, 
       
   237      * perhaps both of them shared completely.
       
   238      * EFalse  indicate imageandvideo or playlist shared incompletely,
       
   239      * perhaps both of them shared completely.
       
   240      */
       
   241     void SetShareFileComplete( TBool aShareState ) ;
       
   242 
       
   243 private:
       
   244 
       
   245     /**
       
   246      * Helper function to copy TInts between arrays of CArrayFix<TInt>&
       
   247      * @since S60 3.1
       
   248      */
       
   249     void CopyTintArrayL( const CArrayFix<TInt>& aSrc,
       
   250                          CArrayFix<TInt>& aDst) const;
       
   251 
       
   252     /**
       
   253      * Helper function to copy descriptors between arrays of CDesCArrays
       
   254      * @since S60 3.1
       
   255      */
       
   256     void CopyCdescArrayL( const CDesCArray& aSrc,
       
   257                           CDesCArray& aDst ) const;
       
   258 
       
   259 private : // From MUPnPConnectionMonitorObserver
       
   260 
       
   261     /**
       
   262      * Update the sharing state variable in case WLAN connection is lost
       
   263      * From MUPnPConnectionMonitorObserver
       
   264      * @since S60 3.1
       
   265      */
       
   266     void ConnectionLost();
       
   267 
       
   268 private: // data
       
   269 
       
   270     /**
       
   271      * Active object for asynchronous file sharing
       
   272      */
       
   273     CUPnPFileSharingEngineAO* iAO;
       
   274     
       
   275     /**
       
   276      * Active object for asynchronous get responce from content server
       
   277      * Owned.
       
   278      */
       
   279     CUpnpContentShareAO* iContentSharer;
       
   280 
       
   281     /**
       
   282      * Active object class retrieving information about selections and
       
   283      * content from upnpcontentserver
       
   284      */
       
   285     CUpnpContentRequestAO* iContentRequestor;
       
   286 
       
   287     /**
       
   288      * Cached image selections
       
   289      */
       
   290     CArrayFixFlat<TInt>* iImageSelections;
       
   291 
       
   292     /**
       
   293      * Cached music selections
       
   294      */
       
   295     CArrayFixFlat<TInt>* iMusicSelections;
       
   296 
       
   297     /**
       
   298      * Client side handle to upnpcontentserver
       
   299      */
       
   300     RUpnpContentServerClient iContentServer;
       
   301 
       
   302     /**
       
   303      * Observer for file sharing state
       
   304      */
       
   305     MUPnPFileSharingEngineObserver* iObserver;
       
   306     
       
   307      /**
       
   308      * Set share file completed flag.      
       
   309      */
       
   310     TBool iShareFileState;
       
   311 
       
   312     /**
       
   313      * Connection monitor
       
   314      */
       
   315     CUPnPConnectionMonitor* iConnMon;
       
   316 
       
   317     /**
       
   318      * Active object handling querying progress
       
   319      */
       
   320     CUpnpProgressWatcher* iProgress;
       
   321 
       
   322     };
       
   323 
       
   324 #endif  // __UPNPFILESHARINGENGINE_H__
       
   325 // End of file
       
   326