multimediacommsengine/mmceshared/src/mcecommsrpsource.cpp
branchrcs
changeset 49 64c62431ac08
child 50 1d8943dd8be6
equal deleted inserted replaced
44:fb024d5e35fa 49:64c62431ac08
       
     1 /*
       
     2 * Copyright (c) 2005 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "mcecommsrpsource.h"
       
    22 #include "mcecommediastream.h"
       
    23 #include "mcecomsession.h"
       
    24 #include "mcemsrpsource.h"
       
    25 #include "e32const.h"
       
    26 #include <e32std.h>
       
    27 #include "mceserial.h"
       
    28 #include "mceclilogs.h"
       
    29 
       
    30 #ifdef MCE_COMMON_SERVER_SIDE
       
    31 
       
    32 #include <mmccInterface.h>
       
    33 #include "mcesdpsession.h"
       
    34 #include "mcemediamanager.h"
       
    35 #include "mcesrvlogs.h"
       
    36 
       
    37 
       
    38 #endif//MCE_COMMON_SERVER_SIDE
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CMceComAvSink::NewL
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CMceComMsrpSource* CMceComMsrpSource::NewL()
       
    49     {
       
    50     CMceComMsrpSource* self = NewLC();
       
    51     CleanupStack::Pop( self );
       
    52     return self;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CMceComMsrpSource::NewLC
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CMceComMsrpSource* CMceComMsrpSource::NewLC()
       
    60     {
       
    61     CMceComMsrpSource* self = new (ELeave) CMceComMsrpSource();
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     return self;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CMceComMsrpSource::~CMceComMsrpSource
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 CMceComMsrpSource::~CMceComMsrpSource()
       
    72     { 
       
    73     iPath.ResetAndDestroy();
       
    74     delete iFileName;
       
    75     delete iSessInfo;
       
    76     delete iFileType;
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CMceComMsrpSource::CMceComMsrpSource
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CMceComMsrpSource::CMceComMsrpSource()
       
    84   :CMceComMediaSource( KMceMSRPSource ),
       
    85   iPath(KMceArrayGranularity),
       
    86   iSessInfo(NULL),
       
    87   iAcceptTypes(KMceArrayGranularity),
       
    88   iAcceptWrappedTypes (KMceAcceptWrappedTypes),
       
    89   iWrappedTypes(EFalse),
       
    90   iFileShare(EFalse),
       
    91   iFileName(NULL)
       
    92     {
       
    93     }
       
    94 
       
    95 void CMceComMsrpSource::ConstructL(CMceComMsrpSource& aSource )
       
    96     {    
       
    97     iPath.ResetAndDestroy();
       
    98     for(int i=0;i<aSource.iPath.Count();i++)
       
    99         {       
       
   100         TUriParser8* parser = new (ELeave) TUriParser8;
       
   101         parser->Parse(aSource.iPath[i]->UriDes());
       
   102          CleanupStack::PushL(parser);
       
   103          iPath.AppendL(parser);
       
   104          CleanupStack::Pop(parser);
       
   105           }
       
   106    
       
   107     if (iSessInfo !=NULL)
       
   108         {
       
   109         delete iSessInfo;
       
   110         iSessInfo = NULL;
       
   111         }
       
   112     if (aSource.iSessInfo!=NULL)
       
   113         {
       
   114         iSessInfo = aSource.iSessInfo->Des().AllocL();
       
   115         }
       
   116         
       
   117     iAcceptTypes.Reset();  
       
   118     for(int i=0; i<aSource.iAcceptTypes.MdcaCount();i++)
       
   119         {
       
   120         iAcceptTypes.AppendL(aSource.iAcceptTypes.MdcaPoint(i) ); 
       
   121         }
       
   122      iAcceptWrappedTypes = aSource.iAcceptWrappedTypes;
       
   123      iWrappedTypes = aSource.iWrappedTypes;
       
   124      iFileShare = aSource.iFileShare;
       
   125      
       
   126      if (iFileName!=NULL)
       
   127          {
       
   128          delete iFileName;
       
   129          iFileName = NULL;
       
   130          }
       
   131      if (aSource.iFileName!=NULL)
       
   132          {
       
   133          iFileName = aSource.iFileName->Des().AllocL();
       
   134          }
       
   135      iFileSize = aSource.iFileSize;
       
   136      iFileTransferid = aSource.iFileTransferid;
       
   137      iDispositionValue = aSource.iDispositionValue;
       
   138      iSecureConnection = aSource.iSecureConnection;
       
   139      if (iFileType!=NULL)
       
   140          {
       
   141          delete iFileType;
       
   142          iFileType = NULL;
       
   143          }
       
   144      if (aSource.iFileType!=NULL)
       
   145          {
       
   146          iFileType = aSource.iFileType->Des().AllocL();
       
   147          }
       
   148      iFTProgressNotification = aSource.iFTProgressNotification;
       
   149     }
       
   150         
       
   151     
       
   152 void CMceComMsrpSource::ConstructL()
       
   153     {
       
   154     iFTProgressNotification = ETrue;
       
   155     }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // CMceComMsrpSource::CloneL
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 CMceComMediaSource* CMceComMsrpSource::CloneL()
       
   162     {
       
   163     CMceComMsrpSource* copy = CMceComMsrpSource::NewLC();
       
   164     copy->ConstructL(*this);
       
   165     CleanupStack::Pop(copy);
       
   166     return copy;        
       
   167     }
       
   168 
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CMceComMsrpSource::InternalizeFlatL
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 void CMceComMsrpSource::InternalizeFlatL( RReadStream& aReadStream )
       
   175     {
       
   176     CMceComMediaSource::InternalizeFlatL( aReadStream );
       
   177     MceSerial::DecodeL(this->iPath, aReadStream);
       
   178     MceSerial::DecodeL(this->iSessInfo, aReadStream);
       
   179     CDesC8Array* array = NULL;
       
   180     MceSerial::DecodeL(array, aReadStream);
       
   181     if (array)
       
   182         {
       
   183         this->iAcceptTypes.Reset();
       
   184         for (TInt i=0;i<array->MdcaCount();i++)
       
   185             {
       
   186             this->iAcceptTypes.AppendL(array->MdcaPoint(i)); 
       
   187             }
       
   188             delete array; // free up the memory
       
   189             }    
       
   190     MceSerial::DecodeL(this->iAcceptWrappedTypes, aReadStream);
       
   191     this->iWrappedTypes = aReadStream.ReadInt8L();
       
   192     
       
   193 #ifdef MCE_COMMON_SERVER_SIDE
       
   194     MCESRV_DEBUG_SVALUE( "CMceComMsrpSource::InternalizeFlatL: accept-wrapped-types:",  this->iAcceptWrappedTypes)
       
   195     MCESRV_DEBUG_DVALUE("CMceComMsrpSource::InternalizeFlatL: wrappedTypes", this->iWrappedTypes)
       
   196     
       
   197 #else
       
   198     MCECLI_DEBUG_DVALUE("CMceComMsrpSource::InternalizeFlatL: wrappedTypes value", this->iWrappedTypes)
       
   199     MCECLI_DEBUG_SVALUE("CMceComMsrpSource::InternalizeFlatL: AcceptWrappedTypes", this->iAcceptWrappedTypes) 
       
   200     
       
   201 #endif
       
   202     this->iFileShare = aReadStream.ReadInt8L();
       
   203     MceSerial::DecodeL(this->iFileName, aReadStream);
       
   204     this->iFileSize = aReadStream.ReadUint32L();
       
   205     MceSerial::DecodeL(this->iFileType, aReadStream);
       
   206     MceSerial::DecodeL(this->iFileTransferid, aReadStream);
       
   207     MceSerial::DecodeL(this->iDispositionValue, aReadStream);
       
   208     this->iSecureConnection = aReadStream.ReadInt8L();  
       
   209     MceSerial::DecodeL(this->iFilePath, aReadStream);
       
   210     this->iFTProgressNotification = aReadStream.ReadInt8L();
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CMceComMsrpSource::ExternalizeFlatL
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void CMceComMsrpSource::ExternalizeFlatL( RWriteStream& aWriteStream )
       
   218     {
       
   219     CMceComMediaSource::ExternalizeFlatL( aWriteStream );
       
   220     MceSerial::EncodeL(this->iPath, aWriteStream);
       
   221     MceSerial::EncodeL(this->iSessInfo, aWriteStream);
       
   222     MceSerial::EncodeL(&(this->iAcceptTypes), aWriteStream);
       
   223     MceSerial::EncodeL(this->iAcceptWrappedTypes, aWriteStream);
       
   224     aWriteStream.WriteInt8L(this->iWrappedTypes);
       
   225     aWriteStream.WriteInt8L(this->iFileShare);
       
   226     MceSerial::EncodeL(this->iFileName, aWriteStream);
       
   227     aWriteStream.WriteUint32L(this->iFileSize);
       
   228     MceSerial::EncodeL(this->iFileType, aWriteStream);
       
   229     MceSerial::EncodeL(this->iFileTransferid, aWriteStream);
       
   230     MceSerial::EncodeL(this->iDispositionValue, aWriteStream);
       
   231     aWriteStream.WriteInt8L(this->iSecureConnection);
       
   232     MceSerial::EncodeL(this->iFilePath, aWriteStream);
       
   233     aWriteStream.WriteInt8L(this->iFTProgressNotification);
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CMceComMsrpSink::UpdateL
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 void CMceComMsrpSource::UpdateL( CMceComMediaSource& aUpdate )
       
   241     {
       
   242     CMceComMediaSource::UpdateL( aUpdate );
       
   243     CMceComMsrpSource& update = static_cast<CMceComMsrpSource&>( aUpdate );
       
   244     
       
   245     //Set MSRP path member
       
   246     
       
   247     if (update.iPath.Count() > 0)
       
   248         {
       
   249         iPath.ResetAndDestroy();
       
   250         for(int i=0;i<update.iPath.Count();i++)
       
   251             {        
       
   252             TUriParser8* parser = new (ELeave) TUriParser8;
       
   253             CleanupStack::PushL(parser);
       
   254             User::LeaveIfError(parser->Parse(update.iPath[i]->UriDes()) );
       
   255             iPath.AppendL(parser);        
       
   256             CleanupStack::Pop(parser);
       
   257             }
       
   258         }
       
   259         
       
   260     //Set Accept-types member
       
   261     if (update.iAcceptTypes.MdcaCount() > 0)
       
   262         {
       
   263         iAcceptTypes.Reset();
       
   264         for(int i=0; i<update.iAcceptTypes.MdcaCount();i++)
       
   265             {       
       
   266             iAcceptTypes.AppendL(update.iAcceptTypes.MdcaPoint(i));        
       
   267             }    
       
   268         }
       
   269         
       
   270     //Set secureconneciton member
       
   271     if (iSecureConnection != update.iSecureConnection)
       
   272         {
       
   273         iSecureConnection = update.iSecureConnection;
       
   274         }
       
   275     
       
   276     if (update.iAcceptWrappedTypes.Size())
       
   277         {
       
   278         iAcceptWrappedTypes = update.iAcceptWrappedTypes;
       
   279         iWrappedTypes = update.iWrappedTypes;
       
   280         }
       
   281     // look for the updaitons for file share attributes
       
   282     UpdateFileShareAttrL(update);
       
   283     if (update.iSessInfo != NULL )
       
   284         {
       
   285         if (iSessInfo!=NULL)
       
   286             {
       
   287             delete iSessInfo;
       
   288             iSessInfo = NULL;
       
   289             }
       
   290         iSessInfo =  update.iSessInfo->Des().AllocL() ;
       
   291         }
       
   292     
       
   293     iFTProgressNotification = update.iFTProgressNotification;
       
   294     }
       
   295 
       
   296 void CMceComMsrpSource::UpdateFileShareAttrL(CMceComMsrpSource& aUpdate )
       
   297     {
       
   298     //Set FileSharing Attributes
       
   299     if(aUpdate.iFileShare || aUpdate.iFileTransferid.Length() || aUpdate.iDispositionValue.Size() )
       
   300         {
       
   301         iFileShare = aUpdate.iFileShare;
       
   302         if (iFileName!=NULL )
       
   303             {
       
   304             delete iFileName;
       
   305             iFileName = NULL;
       
   306             }
       
   307     
       
   308         iFileName = aUpdate.iFileName->Des().AllocL();
       
   309         iFileSize = aUpdate.iFileSize;
       
   310         if (iFileType!=NULL )
       
   311             {
       
   312             delete iFileType;
       
   313             iFileType = NULL;
       
   314             }
       
   315             
       
   316         iFileType = aUpdate.iFileType->Des().AllocL();
       
   317         iFileTransferid = aUpdate.iFileTransferid;
       
   318         iDispositionValue = aUpdate.iDispositionValue;
       
   319         }
       
   320     }
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // CMceComMsrpSource::UseRTCP
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 TBool CMceComMsrpSource::UseRTCP()
       
   327     {
       
   328     return EFalse;
       
   329     }
       
   330 
       
   331 #ifdef MCE_COMMON_SERVER_SIDE
       
   332 
       
   333 // -----------------------------------------------------------------------------
       
   334 // CMceComMsrpSource::MccType
       
   335 // -----------------------------------------------------------------------------
       
   336 //
       
   337 const TUid CMceComMsrpSource::MccType()
       
   338     {
       
   339     return KUidMccMsrpSource;
       
   340     }
       
   341 
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // CMceComMsrpSource::PrepareL
       
   345 // -----------------------------------------------------------------------------
       
   346 //
       
   347 void CMceComMsrpSource::PrepareL()
       
   348     {
       
   349     //NOP  // Not required as the data path for message stream will be handled by applications
       
   350     }
       
   351    
       
   352 #endif//MCE_COMMON_SERVER_SIDE
       
   353