os/mm/mmlibs/mmfw/src/ControllerFramework/MMFControllerFrameworkBase.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2002-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 "mmfcontrollerframeworkbase.h"
    17 
    18 
    19 // TMMFEvent
    20 EXPORT_C TMMFEvent::TMMFEvent(TUid aEventType, TInt aErrorCode)
    21 	: iEventType(aEventType), iErrorCode(aErrorCode)
    22 	{
    23 	}
    24 
    25 EXPORT_C TMMFEvent::TMMFEvent()
    26 	: iEventType(KNullUid), iErrorCode(KErrNone)
    27 	{
    28 	}
    29 
    30 
    31 // CMMFMetaDataEntry
    32 EXPORT_C CMMFMetaDataEntry* CMMFMetaDataEntry::NewL(const TDesC& aName, const TDesC& aValue)
    33 	{
    34 	CMMFMetaDataEntry* s = new(ELeave) CMMFMetaDataEntry;
    35 	CleanupStack::PushL(s);
    36 	s->ConstructL(aName, aValue);
    37 	CleanupStack::Pop(s);
    38 	return s;
    39 	}
    40 
    41 EXPORT_C CMMFMetaDataEntry* CMMFMetaDataEntry::NewL(const CMMFMetaDataEntry& aOther)
    42 	{
    43 	CMMFMetaDataEntry* s = new(ELeave) CMMFMetaDataEntry;
    44 	CleanupStack::PushL(s);
    45 	s->ConstructL(aOther.Name(), aOther.Value());
    46 	CleanupStack::Pop(s);
    47 	return s;
    48 	}
    49 
    50 EXPORT_C CMMFMetaDataEntry* CMMFMetaDataEntry::NewL()
    51 	{
    52 	CMMFMetaDataEntry* s = new(ELeave) CMMFMetaDataEntry;
    53 	CleanupStack::PushL(s);
    54 	s->ConstructL(KNullDesC, KNullDesC);
    55 	CleanupStack::Pop(s);
    56 	return s;
    57 	}
    58 
    59 CMMFMetaDataEntry::CMMFMetaDataEntry()
    60 	{
    61 	}
    62 
    63 void CMMFMetaDataEntry::ConstructL(const TDesC& aName, const TDesC& aValue)
    64 	{
    65 	iName = aName.AllocL();
    66 	iValue = aValue.AllocL();
    67 	}
    68 
    69 EXPORT_C CMMFMetaDataEntry::~CMMFMetaDataEntry()
    70 	{
    71 	delete iName;
    72 	delete iValue;
    73 	}
    74 
    75 EXPORT_C void CMMFMetaDataEntry::ExternalizeL(RWriteStream& aStream) const
    76 	{
    77 	aStream << *iName;
    78 	aStream << *iValue;
    79 	}
    80 
    81 EXPORT_C void CMMFMetaDataEntry::InternalizeL(RReadStream& aStream)
    82 	{
    83 	delete iName;
    84 	iName = NULL;
    85 	iName = HBufC::NewL(aStream, KMaxTInt);//Max length of HBuf is taken from stream - KMaxTInt just used as upper limit
    86 
    87 	delete iValue;
    88 	iValue = NULL;
    89 	iValue = HBufC::NewL(aStream, KMaxTInt);
    90 	}
    91 
    92 EXPORT_C void CMMFMetaDataEntry::SetNameL(const TDesC& aName)
    93 	{
    94 	delete iName;
    95 	iName = NULL;
    96 	iName = aName.AllocL();
    97 	}
    98 
    99 EXPORT_C void CMMFMetaDataEntry::SetValueL(const TDesC& aValue)
   100 	{
   101 	delete iValue;
   102 	iValue = NULL;
   103 	iValue = aValue.AllocL();
   104 	}
   105 
   106 EXPORT_C const TDesC& CMMFMetaDataEntry::Name() const
   107 	{
   108 	return *iName;
   109 	}
   110 
   111 EXPORT_C const TDesC& CMMFMetaDataEntry::Value() const
   112 	{
   113 	return *iValue;
   114 	}
   115 
   116 
   117 
   118 
   119 
   120 EXPORT_C CMMFUrlParams* CMMFUrlParams::NewL(const TDesC& aUrl, TInt aIAPId)
   121 	{
   122 	CMMFUrlParams* s = CMMFUrlParams::NewLC(aUrl, aIAPId);
   123 	CleanupStack::Pop(s);
   124 	return s;
   125 	}
   126 
   127 EXPORT_C CMMFUrlParams* CMMFUrlParams::NewLC(const TDesC& aUrl, TInt aIAPId)
   128 	{
   129 	CMMFUrlParams* s = new(ELeave) CMMFUrlParams;
   130 	CleanupStack::PushL(s);
   131 	s->ConstructL(aUrl, aIAPId);
   132 	return s;
   133 	}
   134 
   135 EXPORT_C CMMFUrlParams* CMMFUrlParams::NewLC(RReadStream& aStream)
   136 	{
   137 	CMMFUrlParams* s = new(ELeave) CMMFUrlParams;
   138 	CleanupStack::PushL(s);
   139 	s->ConstructL(aStream);
   140 	return s;
   141 	}
   142 
   143 EXPORT_C void CMMFUrlParams::ExternalizeL(RWriteStream& aStream) const
   144 	{
   145 	aStream.WriteInt16L(iUrl->Length());
   146 	aStream.WriteL(*iUrl);
   147 	aStream.WriteInt32L(iIAPId);
   148 	}
   149 
   150 EXPORT_C CBufFlat* CMMFUrlParams::ExternalizeToCBufFlatLC() const
   151 	{
   152 	CBufFlat* buffer = CBufFlat::NewL(32);
   153 	CleanupStack::PushL(buffer);
   154 	RBufWriteStream s;
   155 	s.Open(*buffer);
   156 	CleanupClosePushL(s);
   157 	ExternalizeL(s);
   158 	CleanupStack::PopAndDestroy();//s
   159 	// Leave buffer on the CleanupStack
   160 	return buffer;
   161 	}
   162 
   163 
   164 CMMFUrlParams::~CMMFUrlParams()
   165 	{
   166 	delete iUrl;
   167 	}
   168 
   169 CMMFUrlParams::CMMFUrlParams()
   170 	{
   171 	}
   172 
   173 void CMMFUrlParams::ConstructL(const TDesC& aUrl, TInt aIAPId)
   174 	{
   175 	iUrl = aUrl.AllocL();
   176 	iIAPId = aIAPId;
   177 	}
   178 
   179 void CMMFUrlParams::ConstructL(RReadStream& aStream)
   180 	{
   181 	TInt size = aStream.ReadInt16L();
   182 	iUrl = HBufC::NewL(size);
   183 	TPtr temp (iUrl->Des());
   184 	aStream.ReadL(temp, size);
   185 	iIAPId = aStream.ReadInt32L();
   186 	}
   187 
   188 EXPORT_C const TDesC& CMMFUrlParams::Url() const
   189 	{
   190 	return *iUrl;
   191 	}
   192 
   193 EXPORT_C TInt CMMFUrlParams::IAPId() const
   194 	{
   195 	return iIAPId;
   196 	}
   197 
   198 EXPORT_C TBool CMMFUrlParams::UseIAPId() const
   199 	{
   200 	return (iIAPId != KUseDefaultIap);
   201 	}
   202