upnpsharing/upnpcontentserver/inc/upnpcontentsharerao.h
branchIOP_Improvements
changeset 40 08b5eae9f9ff
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
       
     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 active object class defition
       
    15  *
       
    16 */
       
    17 
       
    18 #ifndef __UPNPCONTENTSHARERAO_H__
       
    19 #define __UPNPCONTENTSHARERAO_H__
       
    20 
       
    21 
       
    22 // Include Files
       
    23 #include <e32base.h>
       
    24 #include <badesca.h>  //for CDesCArray
       
    25 
       
    26 #include "upnpsharingcallback.h"
       
    27 #include "upnpcontentserverdefs.h"
       
    28 #include "upnpsharingrequest.h"
       
    29 
       
    30 #include "upnpsharingalgorithm.h"
       
    31 
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class MUpnpSharingCallback;
       
    35 
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 *  Active object class for file sharing
       
    41 *  @since S60 5.2
       
    42 */
       
    43 NONSHARABLE_CLASS( CUpnpContentSharerAo ) : public CActive
       
    44 {
       
    45 
       
    46 public: // Constructors and destructor
       
    47     
       
    48     /**
       
    49      * Two-phased constructor.
       
    50      * @since S60 5.2
       
    51      * @param aEngine Callback to handler
       
    52      * @param aSharingAlgorithm Pointer to SharingAlgorithm
       
    53      */
       
    54     static CUpnpContentSharerAo *NewL( 
       
    55         MUpnpSharingCallback* aEngine,
       
    56         MUpnpSharingAlgorithm* aSharingAlgorithm );
       
    57     
       
    58     /**
       
    59      * Destructor.
       
    60      * @since S60 5.2
       
    61      */ 
       
    62     virtual ~CUpnpContentSharerAo();
       
    63     
       
    64 protected: //From CActive
       
    65     /**
       
    66      * See CActive
       
    67      */
       
    68     virtual void RunL();
       
    69     
       
    70     /**
       
    71      * See CActive
       
    72      */
       
    73     virtual void DoCancel();
       
    74     
       
    75     /**
       
    76      * See CActive
       
    77      */
       
    78     TInt RunError(TInt aError);
       
    79 
       
    80 public: //new functions
       
    81     
       
    82     /**
       
    83      * Starts file sharing process
       
    84      * @since S60 5.2
       
    85      * @param aSharingRequest List of files to be shared
       
    86      */
       
    87     void StartSharing( const CUpnpSharingRequest *aSharingRequest );
       
    88     
       
    89     /**
       
    90      * Checks that if sharing is ongoing
       
    91      * @since S60 5.2
       
    92      * @return ETrue if sharing is ongoing, otherwise EFalse
       
    93      */
       
    94     TBool SharingOngoing();
       
    95 
       
    96     /**
       
    97      * Stops sharing process
       
    98      * @since S60 5.2
       
    99      */
       
   100     void StopSharing();
       
   101     
       
   102     /**
       
   103      * Forces to set progress in next file sharing process 
       
   104      * @since S60 5.2
       
   105      */
       
   106     void ForceSetProgress();
       
   107 
       
   108 private:
       
   109     
       
   110     /**
       
   111      * C++ default constructor.
       
   112      * @since S60 5.2
       
   113      * @param aEngine Pointer to handler callback
       
   114      * @param aSharingAlgorithm Pointer to SharingAlgorithm
       
   115      */
       
   116     CUpnpContentSharerAo( MUpnpSharingCallback *aEngine, 
       
   117         MUpnpSharingAlgorithm* aSharingAlgorithm );
       
   118     
       
   119     /**
       
   120      * By default Symbian 2nd phase constructor is private.
       
   121      * @since S60 5.2
       
   122      */
       
   123     void ConstructL();
       
   124     
       
   125     /**
       
   126      * Writes sharing status to file with upnpselectionwriter
       
   127      * @since S60 5.2
       
   128      */
       
   129     void WriteSharingStatusL();
       
   130     
       
   131     /**
       
   132      * Shares and unshares one file from each array
       
   133      * @since S60 5.2
       
   134      * @return error code
       
   135      */
       
   136     TInt DoSingleOperation();
       
   137     
       
   138     /**
       
   139      * Sets progress to engine
       
   140      * @since S60 5.2
       
   141      */
       
   142     void SetProgressL();
       
   143 
       
   144     /**
       
   145      * Performs complete callback
       
   146      * @param aPtr Pointer to CUpnpContentSharerAo instance
       
   147      * @return KErrNone
       
   148      */
       
   149     static TInt CompleteL( TAny* aPtr );
       
   150     
       
   151 private: 
       
   152     
       
   153     /**
       
   154      * Pointer to calling handler
       
   155      * not owned
       
   156      */
       
   157     MUpnpSharingCallback *iSharingEngine;
       
   158       
       
   159     /**
       
   160      * Pointer to request under work. Request contains lists of file to be 
       
   161      * shared and unshared.
       
   162      * not owned
       
   163      */
       
   164     const CUpnpSharingRequest *iSharingRequest;
       
   165        
       
   166     /**
       
   167      * Pointer to sharing algorith which performs the actual sharing.
       
   168      * Not owned.
       
   169      */
       
   170     MUpnpSharingAlgorithm* iSharingAlgorithm;
       
   171     
       
   172     /**
       
   173      * Index number of current file in share file array
       
   174      */
       
   175     TInt iShareIndex;
       
   176     
       
   177     /**
       
   178      * Index number of current file in unshare file array
       
   179      */
       
   180     TInt iUnshareIndex;
       
   181     
       
   182     /**
       
   183      * Flag if we should cancel current operation
       
   184      */
       
   185     TBool iCancel;
       
   186     
       
   187     /**
       
   188      * Currently processed progress percent
       
   189      */
       
   190     TInt iCurrentProgressPercent;
       
   191   
       
   192     /**
       
   193      * Idle for complete callback
       
   194      * Owned.
       
   195      */
       
   196     CIdle* iIdle;
       
   197 
       
   198     /**
       
   199      * Error code for callback
       
   200      */
       
   201     TInt iError;
       
   202     
       
   203   };
       
   204 
       
   205 #endif  // __UPNPCONTENTSHARINGAO_H__
       
   206 
       
   207 // End of file