upnpsharing/upnpsharingalgorithm/inc/upnpsharingalgorithmimpl.h
branchIOP_Improvements
changeset 40 08b5eae9f9ff
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
       
     1 /*
       
     2 * Copyright (c) 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:  Header file for the CUPnPSharingAlgorithm class.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_UPNP_SHARING_ALGORITHM_IMPL_H
       
    19 #define C_UPNP_SHARING_ALGORITHM_IMPL_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <upnpmediaserverclient.h>
       
    23 #include "upnpsharingalgorithm.h"
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class CUpnpContainer;
       
    27 class CUpnpItem;
       
    28 class CUpnpSharingAO;
       
    29 class CUpnpCdsLiteObjectArray;
       
    30 class CUpnpCdsLiteObject;
       
    31 class CUpnpContainerResolver;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36 *  CUPnPSharingAlgorithm class definition
       
    37 *
       
    38 *  @lib upnpsharingalgorithm.lib
       
    39 *  @since S60 5.2
       
    40 */
       
    41 NONSHARABLE_CLASS( CUpnpSharingAlgorithmImpl )
       
    42                     : public CBase,
       
    43                       MUpnpSharingAlgorithm
       
    44     {
       
    45 
       
    46     public: // Constructors and destructor
       
    47 
       
    48         /**
       
    49          * Two-phased constructor.
       
    50          */
       
    51         static CUpnpSharingAlgorithmImpl* NewL();
       
    52 
       
    53         /**
       
    54          * Two-phased constructor.
       
    55          */
       
    56         static CUpnpSharingAlgorithmImpl* NewLC();
       
    57 
       
    58         /**
       
    59          * Destructor.
       
    60          */
       
    61         virtual ~CUpnpSharingAlgorithmImpl();
       
    62 
       
    63     public:
       
    64 
       
    65         /**
       
    66          * Check if item is shared based on item filename
       
    67          *
       
    68          * @since S60 5.2
       
    69          * @param aFileName, file to be checked
       
    70          * @return TBool, ETrue if item is shared, EFalse otherwise
       
    71          */
       
    72         IMPORT_C TBool IsFileSharedL( const TFileName &aFileName );
       
    73 
       
    74     public:
       
    75 
       
    76     // From base class MUpnpSharingAlgorithm
       
    77 
       
    78         /**
       
    79          * From MUpnpSharingAlgorithm
       
    80          * See base class definition
       
    81          */
       
    82         void ShareFileL( const TFileName &aFileName );
       
    83 
       
    84         /**
       
    85          * From MUpnpSharingAlgorithm
       
    86          * See base class definition
       
    87          */
       
    88         void UnshareFileL( const TFileName &aFileName );
       
    89 
       
    90         /**
       
    91          * From MUpnpSharingAlgorithm
       
    92          * See base class definition
       
    93          */
       
    94         CUpnpCdsLiteObjectArray& ReadSharedContent( );
       
    95 
       
    96         /**
       
    97         * From MUpnpSharingAlgorithm
       
    98         * See base class definition
       
    99         */
       
   100         void Close();
       
   101 
       
   102     private: // Private business logic methods
       
   103 
       
   104         /**
       
   105          * Checks if file exists
       
   106          * Leaves with KErrArgument if file not exist
       
   107          *
       
   108          * @since S60 5.2
       
   109          * @param aFileName, filename with path
       
   110          */
       
   111         void CheckFileExistenceL( const TFileName& aFileName );
       
   112 
       
   113         /**
       
   114          * Checks if there are empty containers in the tree and
       
   115          * unshares them
       
   116          * Leaves with symbian error codes in error cases
       
   117          *
       
   118          * @since S60 5.2
       
   119          * @param aParentId, parent container id where item locates
       
   120          * @return TBool, ETrue if container is unshared, EFalse otherwise
       
   121          */
       
   122         TBool UnshareEmptyContainersL( TDesC8& aParentId );
       
   123 
       
   124         /**
       
   125          * Shares containers based on item metadata
       
   126          * Leaves with Symbian error codes if error
       
   127          *
       
   128          * @since S60 5.2
       
   129          * @param aContainerArray, container structure for item
       
   130          */
       
   131         void ShareContainersL(
       
   132                     RPointerArray<CUpnpContainer>& aContainerArray );
       
   133 
       
   134         /**
       
   135          * Unshares objects and removes from cdsliteobjectarray
       
   136          * Leaves with Symbian error codes if error
       
   137          *
       
   138          * @since S60 5.2
       
   139          * @param aContainerArray, container structure
       
   140          */
       
   141         void RemoveSharedObjectsL(
       
   142                     RPointerArray<CUpnpContainer>& aContainerArray );
       
   143 
       
   144         /**
       
   145          * Shares reference items with containers
       
   146          * Leaves with Symbian error codes if error
       
   147          *
       
   148          * @since S60 5.2
       
   149          * @param aItem, item to be shared
       
   150          */
       
   151         void ShareReferenceObjectsL( CUpnpItem* aItem );
       
   152 
       
   153         /**
       
   154          * Shares reference item with container
       
   155          * Leaves with Symbian error codes if error
       
   156          *
       
   157          * @since S60 5.2
       
   158          * @param aContainerArray, reference container array
       
   159          * @param aOriginalObject, original item
       
   160          * @param aItem, reference item to be shared. Item gets data on
       
   161          *               sharing based on original item data
       
   162          */
       
   163         void ShareReferenceObjectL(
       
   164                             RPointerArray<CUpnpContainer>& aContainerArray,
       
   165                             CUpnpCdsLiteObject& aOriginalObject,
       
   166                             CUpnpItem& aItem );
       
   167 
       
   168         /**
       
   169          * Finds original object's reference objects and ushares them.
       
   170          * Leaves with Symbian error codes if error
       
   171          *
       
   172          * @since S60 5.2
       
   173          * @param aOriginalObject, original cds object
       
   174          */
       
   175         void UnshareReferenceObjectsL( CUpnpCdsLiteObject& aOriginalObject );
       
   176 
       
   177         /**
       
   178          * Starts server offline mode if not started yet
       
   179          *
       
   180          * @since S60 5.2
       
   181          */
       
   182         void StartServer();
       
   183 
       
   184         /**
       
   185          * Checks if file is protected
       
   186          * Leaves with KErrAccessDenied if file is protected
       
   187          *
       
   188          * @since S60 5.2
       
   189          * @param aFileName, filename with path
       
   190          */
       
   191         void CheckFileProtectionL( const TFileName& aFileName );
       
   192         
       
   193     private: // Second-phase contstruction
       
   194 
       
   195         /**
       
   196          * Default c++ constructor
       
   197          */
       
   198         CUpnpSharingAlgorithmImpl() {};
       
   199 
       
   200         /**
       
   201          * Second-phase constructor.
       
   202          */
       
   203         void ConstructL();
       
   204 
       
   205     private: // Data members
       
   206 
       
   207         /**
       
   208          * Asyncronous file sharing handler. Owned
       
   209          */
       
   210         CUpnpSharingAO*                         iSharingAO;
       
   211 
       
   212         /**
       
   213          * Shared content array. Owned.
       
   214          */
       
   215         CUpnpCdsLiteObjectArray*                iSharedContentArray;
       
   216 
       
   217         /**
       
   218          * Media server session handle. Owned
       
   219          */
       
   220         RUpnpMediaServerClient                  iMediaServer;
       
   221 
       
   222         /**
       
   223          * Container structure resolver. Owned
       
   224          */
       
   225         CUpnpContainerResolver*                 iContainerResolver;
       
   226 
       
   227     };
       
   228 
       
   229 #endif // C_UPNP_SHARING_ALGORITHM_IMPL_H
       
   230 
       
   231 // End of file