messagingfw/wappushfw/MiscPushMsgUtils/src/Cmultipartpushmsgentry.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <push/cmultipartpushmsgentry.h>
       
    17 
       
    18 GLDEF_C TPtrC16 LimitStringSize(const TPtrC16& aString, TInt aMaxSize)
       
    19 	{
       
    20 	if (aString.Length() < aMaxSize)
       
    21 		return aString;
       
    22 	else
       
    23 		return aString.Left(aMaxSize);
       
    24 	}
       
    25 
       
    26 
       
    27 /** 
       
    28 Allocates and constructs a new multipart WAP Push message object.
       
    29 
       
    30 @return 
       
    31 New multipart WAP Push message object.
       
    32 */
       
    33 EXPORT_C CMultiPartPushMsgEntry* CMultiPartPushMsgEntry::NewL()
       
    34 	{
       
    35 	CMultiPartPushMsgEntry* self = new (ELeave) CMultiPartPushMsgEntry();
       
    36 	CleanupStack::PushL(self);
       
    37 	self->ConstructL();
       
    38 	CleanupStack::Pop();
       
    39 	return self;
       
    40 	}
       
    41 
       
    42 
       
    43 /** 
       
    44 Allocates and constructs a new multipart WAP Push message object,
       
    45 specifying the AppURI as a string.
       
    46 
       
    47 @param aAppURI
       
    48 AppURI value as a string.
       
    49 
       
    50 @return 
       
    51 New multipart WAP Push message object.
       
    52 */
       
    53 EXPORT_C CMultiPartPushMsgEntry* CMultiPartPushMsgEntry::NewL(const TPtrC8& aAppURI)
       
    54 	{
       
    55 	CMultiPartPushMsgEntry* self = new (ELeave) CMultiPartPushMsgEntry();
       
    56 	CleanupStack::PushL(self);
       
    57 	self->ConstructL(aAppURI);
       
    58 	CleanupStack::Pop();
       
    59 	return self;
       
    60 	}
       
    61 
       
    62 
       
    63 /** 
       
    64 Allocates and constructs a new multipart WAP Push message object, 
       
    65 specifying the AppId as a number.
       
    66 
       
    67 @param aAppID
       
    68 AppId value as a number.
       
    69 
       
    70 @return
       
    71 New multipart WAP Push message object.
       
    72 */
       
    73 EXPORT_C CMultiPartPushMsgEntry* CMultiPartPushMsgEntry::NewL(TInt& aAppID)
       
    74 	{
       
    75 	CMultiPartPushMsgEntry* self = new (ELeave) CMultiPartPushMsgEntry();
       
    76 	CleanupStack::PushL(self);
       
    77 	self->ConstructL(aAppID);
       
    78 	CleanupStack::Pop();
       
    79 	return self;
       
    80 	}
       
    81 
       
    82 
       
    83 /** 
       
    84 Destructor. 
       
    85 */
       
    86 EXPORT_C CMultiPartPushMsgEntry::~CMultiPartPushMsgEntry()
       
    87 	{
       
    88 	delete iContentType;
       
    89 	}
       
    90 
       
    91 
       
    92 /** 
       
    93 Sets the Content Type of the message.
       
    94 
       
    95 @param aContentType 
       
    96 The Content Type of the message.
       
    97 */
       
    98 EXPORT_C void CMultiPartPushMsgEntry::SetContentTypeL(const TDesC& aContentType)
       
    99 	{
       
   100 	HBufC* tempBuf = aContentType.AllocL();
       
   101 
       
   102 	delete iContentType;
       
   103 	iContentType  = tempBuf;
       
   104 	}
       
   105 
       
   106 
       
   107 /**
       
   108 Constructor.
       
   109 */
       
   110 CMultiPartPushMsgEntry::CMultiPartPushMsgEntry()
       
   111 		{
       
   112 		}
       
   113 
       
   114 
       
   115 /** 
       
   116 Gets the push message type.
       
   117 
       
   118 For this class, the message type UID is KUidWapPushMsgMultiPart.
       
   119 
       
   120 @return 
       
   121 Push message type.
       
   122 */
       
   123 TInt32 CMultiPartPushMsgEntry::PushMsgType() const
       
   124 	{
       
   125 	return KUidWapPushMsgMultiPart.iUid;
       
   126 	}
       
   127 
       
   128 
       
   129 /**
       
   130 Sets the push message type UID. 
       
   131 
       
   132 For this class, the message type UID is KUidWapPushMsgMultiPart.
       
   133 */
       
   134 void CMultiPartPushMsgEntry::SetPushMsgType()
       
   135 	{
       
   136 	iEntry.iBioType = KUidWapPushMsgMultiPart.iUid;	
       
   137 	}
       
   138 
       
   139 
       
   140 /**
       
   141 Externalises Push message data to a write stream.
       
   142 
       
   143 Apart from the data stored by the base class, other data stored are Content Type and Time Sent.
       
   144 
       
   145 @param	aStream	
       
   146 The stream to which the data should be externalised.
       
   147 
       
   148 @see	CPushMsgEntryBase::ExternalizeL()
       
   149 */	
       
   150 void CMultiPartPushMsgEntry::ExternalizeL(RMsvWriteStream& aStream)
       
   151 	{	
       
   152 	CPushMsgEntryBase::ExternalizeL(aStream);
       
   153 
       
   154 	aStream<<LimitStringSize(ContentType(), KLongestStringAllowed);
       
   155 	aStream << iTimeSent.Int64();
       
   156 	}
       
   157 
       
   158 
       
   159 /** 
       
   160 Internalises Push message data from a read stream.
       
   161 
       
   162 Apart from the data read by the base class, other data read are Content Type and Time Sent.
       
   163 
       
   164 @param	aStream	
       
   165 The stream from which the data should be internalised.
       
   166 
       
   167 @leave HBufC::NewL
       
   168 @leave CPushMsgEntryBase::InternalizeL
       
   169 
       
   170 @see	CPushMsgEntryBase::InternalizeL()
       
   171 */	
       
   172 void CMultiPartPushMsgEntry::InternalizeL(RMsvReadStream& aStream)
       
   173 	{
       
   174 	CPushMsgEntryBase::InternalizeL(aStream);
       
   175 
       
   176 	delete iContentType;
       
   177 	iContentType = NULL;
       
   178 	iContentType = HBufC::NewL(aStream, KLongestStringAllowed);
       
   179 
       
   180 	TInt64 timeSent;
       
   181 	aStream >> timeSent;
       
   182 	iTimeSent = timeSent;
       
   183 	}