upnpharvester/common/cmlibrary/src/cmmediaserver.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
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:      Capsulating Media servers
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <s32mem.h>
       
    26 
       
    27 #include "cmmediaserver.h"
       
    28 #include "msdebug.h"
       
    29 
       
    30 
       
    31 // ======== LOCAL FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // NewL
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 EXPORT_C CCmMediaServer* CCmMediaServer::NewL()
       
    38     {
       
    39     CCmMediaServer* self = CCmMediaServer::NewLC();
       
    40     CleanupStack::Pop( self );
       
    41     return self;
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // NewLC
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C CCmMediaServer* CCmMediaServer::NewLC()
       
    49     {
       
    50     CCmMediaServer* self = new ( ELeave ) CCmMediaServer();
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // Destructor
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CCmMediaServer::~CCmMediaServer()
       
    61     {
       
    62     delete iUDN;
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Retrieve mediaserver info
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C const TDesC8& CCmMediaServer::MediaServer() const
       
    70     {
       
    71     return *iUDN;
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // Sets UDN of the media server
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 EXPORT_C void CCmMediaServer::SetUDNL( const TDesC8& aUDN )
       
    79     {
       
    80     delete iUDN;
       
    81     iUDN = NULL;
       
    82 
       
    83     if( &aUDN )
       
    84         {
       
    85         iUDN = aUDN.AllocL();
       
    86         }
       
    87     else
       
    88         {
       
    89         iUDN = KNullDesC8().AllocL();
       
    90         }
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // Sets database id of the media server
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 EXPORT_C TInt64 CCmMediaServer::DbId() const
       
    98     {
       
    99     return iDbId;
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // Returns SystemUpdateID
       
   104 // ---------------------------------------------------------------------------
       
   105 //
       
   106 EXPORT_C TInt CCmMediaServer::SystemUpdateID() const
       
   107     {
       
   108     return iSystemUpdateID;
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // Sets SystemUpdateID
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 EXPORT_C void CCmMediaServer::SetSystemUpdateID(
       
   116     const TInt aSystemUpdateID )
       
   117     {
       
   118     iSystemUpdateID = aSystemUpdateID;
       
   119     }
       
   120     
       
   121 // ---------------------------------------------------------------------------
       
   122 // Gets database id of the media server
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 EXPORT_C void CCmMediaServer::SetDbId( const TInt64 aDbId )
       
   126     {
       
   127     iDbId = aDbId;
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CCmMediaServer::ExternalizeL
       
   132 // C++ default constructor can NOT contain any code, that
       
   133 // might leave.
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 void CCmMediaServer::ExternalizeL( RWriteStream& aStream ) const
       
   137     {
       
   138     aStream.WriteInt32L( iUDN->Length() );
       
   139 
       
   140     if ( iUDN )
       
   141         {
       
   142         aStream << *iUDN;
       
   143         }
       
   144     else
       
   145         {
       
   146         aStream << KNullDesC8();
       
   147         }
       
   148     aStream.WriteUint32L( iDbId );
       
   149     aStream.WriteInt32L( iSystemUpdateID );
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // CCmMediaServer::InternalizeL
       
   154 // C++ default constructor can NOT contain any code, that
       
   155 // might leave.
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 void CCmMediaServer::InternalizeL( RReadStream& aStream )
       
   159     {
       
   160     if ( iUDN )
       
   161         {
       
   162         delete iUDN;
       
   163         iUDN = NULL;
       
   164         }
       
   165     TInt bufLength = aStream.ReadInt32L();
       
   166     iUDN = HBufC8::NewL( aStream, bufLength );
       
   167     iDbId = aStream.ReadUint32L();
       
   168     iSystemUpdateID = aStream.ReadInt32L();
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // Default constructor
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 CCmMediaServer::CCmMediaServer()
       
   176     {
       
   177     iSystemUpdateID = KErrNotFound;
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // ConstructL
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 void CCmMediaServer::ConstructL()
       
   185     {
       
   186     iUDN = KNullDesC8().AllocL();
       
   187     }
       
   188 
       
   189 // End of file
       
   190