upnpavcontroller/upnpavcontrollerclient/inc/upnpavbrowserequest.inl
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2006 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:      a data class containing browse-related data
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 
       
    25 #include "upnpavbrowserequest.h"
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KBrowseMaxStringLen = 255;
       
    29 const TInt KBrowseBufferGranularity = 100;    
       
    30 
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ============================
       
    33 
       
    34 // --------------------------------------------------------------------------
       
    35 // CUpnpAVBrowseRequest::CUpnpAVBrowseRequest
       
    36 // C++ default constructor can NOT contain any code, that
       
    37 // might leave.
       
    38 // --------------------------------------------------------------------------
       
    39 inline CUpnpAVBrowseRequest::CUpnpAVBrowseRequest()
       
    40     {    
       
    41     }
       
    42 
       
    43 // --------------------------------------------------------------------------
       
    44 // CUpnpAVBrowseRequest::ConstructL
       
    45 // Symbian 2nd phase constructor can leave.
       
    46 // --------------------------------------------------------------------------
       
    47 inline void CUpnpAVBrowseRequest::ConstructL()
       
    48     {
       
    49     iId = KNullDesC8().AllocL();
       
    50     iSearchCriteria = KNullDesC8().AllocL();
       
    51     iFilter = KNullDesC8().AllocL();
       
    52     iSortCriteria = KNullDesC8().AllocL();
       
    53     }
       
    54 
       
    55 // --------------------------------------------------------------------------
       
    56 // CUpnpAVBrowseRequest::NewL
       
    57 // Two-phased constructor.
       
    58 // --------------------------------------------------------------------------
       
    59 inline CUpnpAVBrowseRequest* CUpnpAVBrowseRequest::NewL()
       
    60     {
       
    61     CUpnpAVBrowseRequest* self = NewLC();
       
    62     CleanupStack::Pop( self );
       
    63     return self;
       
    64     }
       
    65 
       
    66 // --------------------------------------------------------------------------
       
    67 // CUpnpAVBrowseRequest::NewLC
       
    68 // Two-phased constructor.
       
    69 // --------------------------------------------------------------------------
       
    70 inline CUpnpAVBrowseRequest* CUpnpAVBrowseRequest::NewLC()
       
    71     {
       
    72     CUpnpAVBrowseRequest* self = new( ELeave )
       
    73         CUpnpAVBrowseRequest;    
       
    74     CleanupStack::PushL( self );
       
    75     self->ConstructL();
       
    76     return self;
       
    77     }
       
    78 
       
    79     
       
    80 // --------------------------------------------------------------------------
       
    81 // CUpnpAVBrowseRequest::NewLC
       
    82 // Two-phased constructor.
       
    83 // --------------------------------------------------------------------------
       
    84 inline CUpnpAVBrowseRequest::~CUpnpAVBrowseRequest()
       
    85     {
       
    86     delete iId;
       
    87     delete iSearchCriteria;
       
    88     delete iFilter;
       
    89     delete iSortCriteria;         
       
    90     }
       
    91 
       
    92 // --------------------------------------------------------------------------
       
    93 // CUpnpAVBrowseRequest::NewLC
       
    94 // Two-phased constructor.
       
    95 // --------------------------------------------------------------------------
       
    96 inline void CUpnpAVBrowseRequest::ExternalizeL( RWriteStream& aStream ) const
       
    97     {    
       
    98     aStream.WriteInt16L( iCriteriaLength );    
       
    99     aStream << *iId;
       
   100     aStream << *iSearchCriteria;
       
   101     aStream << *iFilter;
       
   102     aStream.WriteInt16L( (TInt)iBrowseFlag );
       
   103     aStream.WriteInt16L( iStartIndex );
       
   104     aStream.WriteInt16L( iRequestedCount );
       
   105     aStream << *iSortCriteria;   
       
   106     }
       
   107     
       
   108 // --------------------------------------------------------------------------
       
   109 // CUpnpAVBrowseRequest::InternalizeL
       
   110 // Internalizes object
       
   111 // --------------------------------------------------------------------------
       
   112 inline void CUpnpAVBrowseRequest::InternalizeL( RReadStream& aStream )
       
   113     {
       
   114     iCriteriaLength = aStream.ReadInt16L();
       
   115     
       
   116     delete iId; iId = NULL;
       
   117     iId = HBufC8::NewL( aStream, KBrowseMaxStringLen );
       
   118 
       
   119     delete iSearchCriteria; iSearchCriteria = NULL;
       
   120     iSearchCriteria = HBufC8::NewL( aStream, iCriteriaLength );
       
   121 
       
   122     delete iFilter; iFilter = NULL;
       
   123     iFilter = HBufC8::NewL( aStream, KBrowseMaxStringLen );
       
   124     
       
   125     iBrowseFlag = (MUPnPAVBrowsingSession::TBrowseFlag)aStream.ReadInt16L();
       
   126     
       
   127     iStartIndex = aStream.ReadInt16L();
       
   128     
       
   129     iRequestedCount = aStream.ReadInt16L();
       
   130 
       
   131     delete iSortCriteria; iSortCriteria = NULL;
       
   132     iSortCriteria = HBufC8::NewL( aStream, KBrowseMaxStringLen );
       
   133     }
       
   134 
       
   135 // --------------------------------------------------------------------------
       
   136 // CUpnpAVBrowseRequest::ToDes8L
       
   137 // Externalizes object to a heap descriptor
       
   138 // --------------------------------------------------------------------------
       
   139 inline HBufC8* CUpnpAVBrowseRequest::ToDes8L() const
       
   140     {
       
   141     // serialize object
       
   142     CBufFlat* tempFlatBuf = CBufFlat::NewL( KBrowseBufferGranularity );
       
   143     CleanupStack::PushL( tempFlatBuf );
       
   144 
       
   145     RBufWriteStream stream( *tempFlatBuf );
       
   146     CleanupClosePushL( stream );
       
   147     
       
   148     stream << *this;
       
   149     
       
   150     // create heap descriptor
       
   151     HBufC8* tempBuf = HBufC8::NewLC( tempFlatBuf->Size() );
       
   152     TPtr8 ptr( tempBuf->Des() );
       
   153     tempFlatBuf->Read( 0, ptr, tempFlatBuf->Size() );
       
   154     
       
   155     // clean up
       
   156     CleanupStack::Pop( tempBuf );
       
   157     CleanupStack::PopAndDestroy( &stream );
       
   158     CleanupStack::PopAndDestroy( tempFlatBuf );
       
   159     
       
   160     return tempBuf;
       
   161     }
       
   162 
       
   163 
       
   164 // --------------------------------------------------------------------------
       
   165 // CUpnpAVBrowseRequest::SetIdL
       
   166 // Sets id
       
   167 // --------------------------------------------------------------------------
       
   168 inline void CUpnpAVBrowseRequest::SetIdL( const TDesC8& aId )
       
   169     {
       
   170     HBufC8* tempBuf = aId.AllocL();
       
   171     delete iId;
       
   172     iId = tempBuf;
       
   173     }
       
   174     
       
   175 // --------------------------------------------------------------------------
       
   176 // CUpnpAVBrowseRequest::Id
       
   177 // Returns id
       
   178 // --------------------------------------------------------------------------
       
   179 inline const TDesC8& CUpnpAVBrowseRequest::Id()
       
   180     {
       
   181     if( iId )
       
   182         {
       
   183         return *iId;
       
   184         }
       
   185     else
       
   186         {
       
   187         return KNullDesC8;
       
   188         }    
       
   189     }
       
   190   
       
   191 // --------------------------------------------------------------------------
       
   192 // CUpnpAVBrowseRequest::SetSearchCriteriaL
       
   193 // Sets search criteria
       
   194 // --------------------------------------------------------------------------
       
   195 inline void CUpnpAVBrowseRequest::SetSearchCriteriaL(
       
   196     const TDesC8& aSearchCriteria )
       
   197     {
       
   198     HBufC8* tempBuf = aSearchCriteria.AllocL();
       
   199 	iCriteriaLength = tempBuf->Length();
       
   200 	delete iSearchCriteria;
       
   201 	iSearchCriteria = tempBuf;
       
   202     }
       
   203 
       
   204 // --------------------------------------------------------------------------
       
   205 // CUpnpAVBrowseRequest::SearchCriteria
       
   206 // Returns search criteria
       
   207 // --------------------------------------------------------------------------
       
   208 inline const TDesC8& CUpnpAVBrowseRequest::SearchCriteria()
       
   209     {
       
   210     if( iSearchCriteria )
       
   211         {
       
   212         return *iSearchCriteria;
       
   213         }
       
   214     else
       
   215         {
       
   216         return KNullDesC8;
       
   217         }        
       
   218     }
       
   219 
       
   220 // --------------------------------------------------------------------------
       
   221 // CUpnpAVBrowseRequest::SetFilterL
       
   222 // Sets filter
       
   223 // --------------------------------------------------------------------------
       
   224 inline void CUpnpAVBrowseRequest::SetFilterL( const TDesC8& aFilter )
       
   225     {
       
   226     HBufC8* tempBuf = aFilter.AllocL();
       
   227     delete iFilter;
       
   228     iFilter = tempBuf;    
       
   229     }
       
   230     
       
   231 // --------------------------------------------------------------------------
       
   232 // CUpnpAVBrowseRequest::Filter
       
   233 // Returns filter
       
   234 // --------------------------------------------------------------------------
       
   235 inline const TDesC8& CUpnpAVBrowseRequest::Filter()
       
   236     {    
       
   237     if( iFilter )
       
   238         {
       
   239         return *iFilter;
       
   240         }
       
   241     else
       
   242         {
       
   243         return KNullDesC8;
       
   244         }        
       
   245     }
       
   246     
       
   247 // --------------------------------------------------------------------------
       
   248 // CUpnpAVBrowseRequest::SetBrowseFlag
       
   249 // Sets browse flag
       
   250 // --------------------------------------------------------------------------
       
   251 inline void CUpnpAVBrowseRequest::SetBrowseFlag(
       
   252     MUPnPAVBrowsingSession::TBrowseFlag aBrowseFlag )
       
   253     {
       
   254     iBrowseFlag = aBrowseFlag;
       
   255     }
       
   256     
       
   257 // --------------------------------------------------------------------------
       
   258 // CUpnpAVBrowseRequest::BrowseFlag
       
   259 // Returns browse flag
       
   260 // --------------------------------------------------------------------------
       
   261 inline MUPnPAVBrowsingSession::TBrowseFlag CUpnpAVBrowseRequest::BrowseFlag()
       
   262     {
       
   263     return iBrowseFlag;
       
   264     }
       
   265     
       
   266 // --------------------------------------------------------------------------
       
   267 // CUpnpAVBrowseRequest::SetStartIndex
       
   268 // Sets start index
       
   269 // --------------------------------------------------------------------------
       
   270 inline void CUpnpAVBrowseRequest::SetStartIndex( TInt aStartIndex )
       
   271     {
       
   272     iStartIndex = aStartIndex;
       
   273     }
       
   274     
       
   275 // --------------------------------------------------------------------------
       
   276 // CUpnpAVBrowseRequest::StartIndex
       
   277 // Returns start index
       
   278 // --------------------------------------------------------------------------
       
   279 inline TInt CUpnpAVBrowseRequest::StartIndex()
       
   280     {
       
   281     return iStartIndex;
       
   282     }
       
   283 
       
   284 // --------------------------------------------------------------------------
       
   285 // CUpnpAVBrowseRequest::SetRequestedCount
       
   286 // Sets requested count
       
   287 // --------------------------------------------------------------------------
       
   288 inline void CUpnpAVBrowseRequest::SetRequestedCount( TInt aRequestedCount )
       
   289     {
       
   290     iRequestedCount = aRequestedCount;
       
   291     }
       
   292 
       
   293 // --------------------------------------------------------------------------
       
   294 // CUpnpAVBrowseRequest::RequestedCount
       
   295 // Returns requested count
       
   296 // --------------------------------------------------------------------------
       
   297 inline TInt CUpnpAVBrowseRequest::RequestedCount()
       
   298     {
       
   299     return iRequestedCount;
       
   300     }
       
   301 
       
   302 // --------------------------------------------------------------------------
       
   303 // CUpnpAVBrowseRequest::SetSortCriteriaL
       
   304 // Sets sort criteria
       
   305 // --------------------------------------------------------------------------
       
   306 inline void CUpnpAVBrowseRequest::SetSortCriteriaL(
       
   307     const TDesC8& aSortCriteria )
       
   308     {
       
   309     HBufC8* tempBuf = aSortCriteria.AllocL();
       
   310     delete iSortCriteria;
       
   311     iSortCriteria = tempBuf;    
       
   312     }
       
   313     
       
   314 // --------------------------------------------------------------------------
       
   315 // CUpnpAVBrowseRequest::SortCriteria
       
   316 // Returns sort criteria
       
   317 // --------------------------------------------------------------------------
       
   318 inline const TDesC8& CUpnpAVBrowseRequest::SortCriteria()
       
   319     {
       
   320     if( iSortCriteria )
       
   321         {
       
   322         return *iSortCriteria;
       
   323         }
       
   324     else
       
   325         {
       
   326         return KNullDesC8;
       
   327         }
       
   328     }
       
   329 
       
   330 // End of File
       
   331