commsconfig/commsdatabaseshim/commdbshim/SCDB/OVERRIDE.CPP
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2006-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 // Override settings
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @deprecated since v9.1. Functionality is replaced with commsdat.
       
    21 */
       
    22 
       
    23 #include "OVERRIDE.H"
       
    24 
       
    25 // CCommDbOverride
       
    26 
       
    27 CCommDbOverride::CCommDbOverride(CCommDbOverrideSettings::TValueType aType)
       
    28 	: iType(aType), iTableName(), iColumnName()
       
    29 /**
       
    30 Constructor
       
    31 
       
    32 @param aType The value types that may be stored in as overrides
       
    33 */
       
    34 	{}
       
    35 
       
    36 void CCommDbOverride::InternalizeL(RReadStream& aStream)
       
    37 /**
       
    38 Internalises the override settings from a stream
       
    39 
       
    40 @param aStream The stream to read from
       
    41 */
       
    42 	{
       
    43 	iType = (CCommDbOverrideSettings::TValueType) aStream.ReadUint32L();
       
    44 	aStream >> iTableName;
       
    45 	aStream >> iColumnName;
       
    46 	}
       
    47 
       
    48 void CCommDbOverride::ExternalizeL(RWriteStream& aStream) const
       
    49 /**
       
    50 Externalises override settings to a stream.
       
    51 
       
    52 @param aStream The stream to write to
       
    53 */
       
    54 	{
       
    55 	aStream.WriteUint32L(iType);
       
    56 	aStream << iTableName;
       
    57 	aStream << iColumnName;
       
    58 	}
       
    59 
       
    60 TBool CCommDbOverride::MatchOverrides(const CCommDbOverride& aFirst,
       
    61 									  const CCommDbOverride& aSecond)
       
    62 /**
       
    63 Checks if the iColumnName, iTableName fields in the passed objects of CCommDbOverride are equal.
       
    64 
       
    65 @param aFirst A reference to CCommDbOverride class
       
    66 @param aSecond A reference to CCommDbOverride class
       
    67 @return ETrue if Successful else EFalse
       
    68 */
       
    69 	{
       
    70 	return (aFirst.iColumnName == aSecond.iColumnName &&
       
    71 			aFirst.iTableName == aSecond.iTableName);
       
    72 	}
       
    73 
       
    74 // CCommDbIntOverride
       
    75 
       
    76 CCommDbIntOverride::CCommDbIntOverride(const TDesC& aTable, const TDesC& aColumn)
       
    77 	: CCommDbOverride(CCommDbOverrideSettings::EIntValue)
       
    78 /**
       
    79 Constructor
       
    80 
       
    81 @param aTable A reference to a descriptor containing the name Table
       
    82 @param aColumn A reference to a descriptor containing the name of a column in table aTableName.
       
    83 */
       
    84 	{
       
    85 	iTableName.Copy(aTable);
       
    86 	iColumnName.Copy(aColumn);
       
    87 	}
       
    88 
       
    89 void CCommDbIntOverride::InternalizeL(RReadStream& aStream)
       
    90 /**
       
    91 Internalises the override settings from a stream
       
    92 
       
    93 @param aStream The stream to read from
       
    94 */
       
    95 	{
       
    96 	iValue = aStream.ReadUint32L();
       
    97 	}
       
    98 
       
    99 void CCommDbIntOverride::ExternalizeL(RWriteStream& aStream) const
       
   100 /**
       
   101 Externalises override settings to a stream.
       
   102 
       
   103 @param aStream The stream to write to
       
   104 */
       
   105 	{
       
   106 	CCommDbOverride::ExternalizeL(aStream);
       
   107 	aStream.WriteUint32L(iValue);
       
   108 	}
       
   109 
       
   110 // CCommDbBoolOverride
       
   111 
       
   112 CCommDbBoolOverride::CCommDbBoolOverride(const TDesC& aTable, const TDesC& aColumn)
       
   113 	: CCommDbOverride(CCommDbOverrideSettings::EBoolValue)
       
   114 /**
       
   115 Constructor
       
   116 
       
   117 @param aTable A reference to a descriptor containing the name Table
       
   118 @param aColumn A reference to a descriptor containing the name of a column in table aTableName.
       
   119 */
       
   120 	{
       
   121 	iTableName.Copy(aTable);
       
   122 	iColumnName.Copy(aColumn);
       
   123 	}
       
   124 
       
   125 void CCommDbBoolOverride::InternalizeL(RReadStream& aStream)
       
   126 /**
       
   127 Internalises the override settings from a stream
       
   128 
       
   129 @param aStream The stream to read from
       
   130 */
       
   131 	{
       
   132 	iValue = (TBool)aStream.ReadUint32L();
       
   133 	}
       
   134 
       
   135 void CCommDbBoolOverride::ExternalizeL(RWriteStream& aStream) const
       
   136 /**
       
   137 Externalises override settings to a stream.
       
   138 
       
   139 @param aStream The stream to write to
       
   140 */
       
   141 	{
       
   142 	CCommDbOverride::ExternalizeL(aStream);
       
   143 	aStream.WriteUint32L((TBool)iValue);
       
   144 	}
       
   145 
       
   146 //CCommDbDes8Override
       
   147 
       
   148 CCommDbDes8Override::CCommDbDes8Override(const TDesC& aTable, const TDesC& aColumn)
       
   149 	: CCommDbOverride(CCommDbOverrideSettings::EDes8Value)
       
   150 /**
       
   151 Constructor
       
   152 
       
   153 @param aTable A reference to a descriptor containing the name Table
       
   154 @param aColumn A reference to a descriptor containing the name of a column in table aTableName.
       
   155 */
       
   156 	{
       
   157 	iTableName.Copy(aTable);
       
   158 	iColumnName.Copy(aColumn);
       
   159 	}
       
   160 
       
   161 void CCommDbDes8Override::InternalizeL(RReadStream& aStream)
       
   162 /**
       
   163 Internalises the override settings from a stream
       
   164 
       
   165 @param aStream The stream to read from
       
   166 */
       
   167 	{
       
   168 	aStream >> iValue;
       
   169 	}
       
   170 
       
   171 void CCommDbDes8Override::ExternalizeL(RWriteStream& aStream) const
       
   172 /**
       
   173 Externalises override settings to a stream.
       
   174 
       
   175 @param aStream The stream to write to
       
   176 */
       
   177 	{
       
   178 	CCommDbOverride::ExternalizeL(aStream);
       
   179 	aStream << iValue;
       
   180 	}
       
   181 
       
   182 //CCommDbDes16Override
       
   183 
       
   184 CCommDbDes16Override::CCommDbDes16Override(const TDesC& aTable, const TDesC& aColumn)
       
   185 	: CCommDbOverride(CCommDbOverrideSettings::EDes16Value)
       
   186 /**
       
   187 Constructor
       
   188 
       
   189 @param aTable A reference to a descriptor containing the name Table
       
   190 @param aColumn A reference to a descriptor containing the name of a column in table aTableName.
       
   191 */
       
   192 	{
       
   193 	iTableName.Copy(aTable);
       
   194 	iColumnName.Copy(aColumn);
       
   195 	}
       
   196 
       
   197 void CCommDbDes16Override::InternalizeL(RReadStream& aStream)
       
   198 /**
       
   199 Internalises the override settings from a stream
       
   200 
       
   201 @param aStream The stream to read from
       
   202 */
       
   203 	{
       
   204 	aStream >> iValue;
       
   205 	}
       
   206 
       
   207 void CCommDbDes16Override::ExternalizeL(RWriteStream& aStream) const
       
   208 /**
       
   209 Externalises override settings to a stream.
       
   210 
       
   211 @param aStream The stream to write to
       
   212 */
       
   213 	{
       
   214 	CCommDbOverride::ExternalizeL(aStream);
       
   215 	aStream << iValue;
       
   216 	}
       
   217 
       
   218 // CCommDbLongDesOverride
       
   219 
       
   220 CCommDbLongDesOverride* CCommDbLongDesOverride::NewL(const TDesC& aTable, const TDesC& aColumn)
       
   221 /**
       
   222 Allocates and constructs a new communications database override object on the heap.
       
   223 
       
   224 @param aTable A reference to a descriptor containing the name Table
       
   225 @param aColumn A reference to a descriptor containing the name of a column in table aTableName.
       
   226 @return A pointer to a communications database override object.
       
   227 */
       
   228 	{
       
   229 	CCommDbLongDesOverride* r = new(ELeave) CCommDbLongDesOverride(aTable,aColumn);
       
   230 	return r;
       
   231 	}
       
   232 
       
   233 CCommDbLongDesOverride* CCommDbLongDesOverride::NewL(const TDesC& aTable, const TDesC& aColumn, const TDesC& aValue)
       
   234 /**
       
   235 Allocates and constructs a new communications database override object on the heap.
       
   236 
       
   237 @param aTable A reference to a descriptor containing the name Table
       
   238 @param aColumn A reference to a descriptor containing the name of a column in table aTableName.
       
   239 @param aValue A reference to a descriptor passed by the caller.
       
   240 @return A pointer to a communications database override object.
       
   241 */
       
   242 	{
       
   243 	CCommDbLongDesOverride* r = new(ELeave) CCommDbLongDesOverride(aTable,aColumn);
       
   244 	CleanupStack::PushL(r);
       
   245 	r->ConstructL(aValue);
       
   246 	CleanupStack::Pop(r);
       
   247 	return r;
       
   248 	}
       
   249 
       
   250 CCommDbLongDesOverride::CCommDbLongDesOverride(const TDesC& aTable, const TDesC& aColumn)
       
   251 	: CCommDbOverride(CCommDbOverrideSettings::ELongDesValue)
       
   252 /**
       
   253 Constructor
       
   254 
       
   255 @param aTable A reference to a descriptor containing the name Table
       
   256 @param aColumn A reference to a descriptor containing the name of a column in table aTableName.
       
   257 */
       
   258 	{
       
   259 	iTableName.Copy(aTable);
       
   260 	iColumnName.Copy(aColumn);
       
   261 	}
       
   262 
       
   263 void CCommDbLongDesOverride::ConstructL(const TDesC& aValue)
       
   264 	{
       
   265 	iValue = aValue.AllocL();
       
   266 	}
       
   267 
       
   268 CCommDbLongDesOverride::~CCommDbLongDesOverride()
       
   269 /**
       
   270 Destructor
       
   271 */
       
   272 	{
       
   273 	delete iValue;
       
   274 	}
       
   275 
       
   276 // Would it be possible to stream iValue directly?
       
   277 void CCommDbLongDesOverride::InternalizeL(RReadStream& aStream)
       
   278 /**
       
   279 Internalises the override settings from a stream
       
   280 
       
   281 @param aStream The stream to read from
       
   282 */
       
   283 	{
       
   284 	TUint32 length=aStream.ReadUint32L();
       
   285 	if (iValue != NULL)
       
   286 		{
       
   287 		delete iValue;
       
   288 		}
       
   289 	iValue = HBufC::NewL(aStream, length);
       
   290 	}
       
   291 
       
   292 void CCommDbLongDesOverride::ExternalizeL(RWriteStream& aStream) const
       
   293 /**
       
   294 Externalises override settings to a stream.
       
   295 
       
   296 @param aStream The stream to write to
       
   297 */
       
   298 	{
       
   299 	CCommDbOverride::ExternalizeL(aStream);
       
   300 	aStream.WriteUint32L(iValue->Length());
       
   301 	aStream << iValue->Des();
       
   302 	}
       
   303 
       
   304 //TCommDbIapConnectionPrefOverride
       
   305 
       
   306 TCommDbIapConnectionPrefOverride::TCommDbIapConnectionPrefOverride() :
       
   307 /**
       
   308 Constructor
       
   309 */
       
   310 	iPref()
       
   311 	{}
       
   312 
       
   313 void TCommDbIapConnectionPrefOverride::InternalizeL(RReadStream& aStream)
       
   314 /**
       
   315 Internalises the override settings from a stream
       
   316 
       
   317 @param aStream The stream to read from
       
   318 */
       
   319 	{
       
   320 	iPref.iRanking = aStream.ReadUint32L();
       
   321 	iPref.iDirection = (TCommDbConnectionDirection)aStream.ReadUint32L();
       
   322 	iPref.iDialogPref = (TCommDbDialogPref)aStream.ReadUint32L();
       
   323 	iPref.iBearer.iBearerSet = aStream.ReadUint32L();
       
   324 	iPref.iBearer.iIapId = aStream.ReadUint32L();
       
   325 	}
       
   326 
       
   327 void TCommDbIapConnectionPrefOverride::ExternalizeL(RWriteStream& aStream) const
       
   328 /**
       
   329 Externalises override settings to a stream.
       
   330 
       
   331 @param aStream The stream to write to
       
   332 */
       
   333 	{
       
   334 	aStream.WriteUint32L(iPref.iRanking);
       
   335 	aStream.WriteUint32L(iPref.iDirection);
       
   336 	aStream.WriteUint32L(iPref.iDialogPref);
       
   337 	aStream.WriteUint32L(iPref.iBearer.iBearerSet);
       
   338 	aStream.WriteUint32L(iPref.iBearer.iIapId);
       
   339 	}