commsconfig/commsdatabaseshim/commdbshim/SCDB/CommDbConnPref.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 //
       
    15 
       
    16 #include "CommDbConnPref.h"
       
    17 #include "Commsdat_Log.h"
       
    18 
       
    19 EXPORT_C TCommDbConnPref::TCommDbConnPref()
       
    20 : TConnPref(TConnPref::EConnPrefCommDb)
       
    21 /**
       
    22 Constructor
       
    23 */
       
    24 	{
       
    25 	SetIapId(0);
       
    26 	SetNetId(0);
       
    27 	SetDialogPreference(ECommDbDialogPrefUnknown);
       
    28 	SetDirection(ECommDbConnectionDirectionUnknown);
       
    29 	SetBearerSet(0);
       
    30 	}
       
    31 
       
    32 EXPORT_C TVersion TCommDbConnPref::Version()
       
    33 /**
       
    34 Returns the version number of this class
       
    35 
       
    36 @return The version information.
       
    37 */
       
    38 	{
       
    39 	__FLOG_STATIC3(KLogComponent, KCommDbShim, _L("TCommDbConnPref::Version -> Major=%d, Minor=%d, Build=%d"), KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
       
    40 	return TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
       
    41 	}
       
    42 
       
    43 EXPORT_C void TCommDbConnPref::SetIapId(TUint32 aIapId)
       
    44 /**
       
    45 Sets the CommDb ID of the IAP to use for this connection
       
    46 
       
    47 @param aIapId The IAP Id to be set
       
    48 */
       
    49 	{
       
    50 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::SetIapId -> IAP Id=%d"), aIapId);
       
    51 	PrefPtr()->iIapId = aIapId;
       
    52 	}
       
    53 
       
    54 EXPORT_C TUint32 TCommDbConnPref::IapId() const
       
    55 /**
       
    56 Retrieves the CommDb ID of the IAP to use in this connection
       
    57 
       
    58 @return CommDb ID of the IAP
       
    59 */
       
    60 	{
       
    61 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::IapId -> IAP Id=%d"), PrefPtr()->iIapId);
       
    62 	return PrefPtr()->iIapId;
       
    63 	}
       
    64 	
       
    65 EXPORT_C void TCommDbConnPref::SetNetId(TUint32 aNetId)
       
    66 /**
       
    67 Sets the CommDb ID of the Network Id to use in this connection
       
    68 
       
    69 @param aNetId Network Id to use in this connection
       
    70 */
       
    71 	{
       
    72 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::SetNetId -> NetId=%d"), aNetId);
       
    73 	PrefPtr()->iNetId = aNetId;
       
    74 	}
       
    75 
       
    76 EXPORT_C TUint32 TCommDbConnPref::NetId() const
       
    77 /**
       
    78 Retrieves the CommDb ID of the Network Id to use in this connection
       
    79 
       
    80 @return CommDb ID of the Network Id to use in this connection
       
    81 */
       
    82 	{
       
    83 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::NetId -> NetId=%d"), PrefPtr()->iNetId);
       
    84 	return PrefPtr()->iNetId;
       
    85 	}
       
    86 	
       
    87 EXPORT_C void TCommDbConnPref::SetDialogPreference(TCommDbDialogPref aDialogPref)
       
    88 /**
       
    89 Sets the dialog preference to use in this connection
       
    90 
       
    91 @param aDialogPref Dialog preference to use in this connection
       
    92 */
       
    93 	{
       
    94 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::SetDialogPreference -> DialogPreference=%d"), aDialogPref);
       
    95 	PrefPtr()->iDialogPref = aDialogPref;
       
    96 	}
       
    97 
       
    98 EXPORT_C TCommDbDialogPref TCommDbConnPref::DialogPreference() const
       
    99 /**
       
   100 Retrieves the dialog preference to use in this connection
       
   101 
       
   102 @return Dialog preference
       
   103 */
       
   104 	{
       
   105 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::DialogPreference -> DialogPreference=%d"), PrefPtr()->iDialogPref);
       
   106 	return PrefPtr()->iDialogPref;
       
   107 	}
       
   108 	
       
   109 EXPORT_C void TCommDbConnPref::SetDirection(TCommDbConnectionDirection aDirection)
       
   110 /**
       
   111 Sets the connection direction
       
   112 
       
   113 @param aDirection Connection direction
       
   114 */
       
   115 	{
       
   116 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::SetDirection -> Direction=%d"), aDirection);
       
   117 	PrefPtr()->iDirection = aDirection;
       
   118 	}
       
   119 
       
   120 EXPORT_C TCommDbConnectionDirection TCommDbConnPref::Direction() const
       
   121 /**
       
   122 Retrieves the connection direction
       
   123 
       
   124 @return Connection direction
       
   125 */
       
   126 	{
       
   127 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::Direction -> Direction=%d"), PrefPtr()->iDirection);
       
   128 	return PrefPtr()->iDirection;
       
   129 	}
       
   130 	
       
   131 EXPORT_C void TCommDbConnPref::SetBearerSet(TUint32 aBearerSet)
       
   132 /**
       
   133 Sets the bearer set applicable for the connection
       
   134 
       
   135 @param aBearerSet The bearer set applicable for the connection
       
   136 */
       
   137 	{
       
   138 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::SetBearerSet -> BearerSet=%d"), aBearerSet);
       
   139 	PrefPtr()->iBearerSet = aBearerSet;
       
   140 	}
       
   141 
       
   142 EXPORT_C TUint32 TCommDbConnPref::BearerSet() const
       
   143 /**
       
   144 Retrieves the bearer set applicable for the connection
       
   145 
       
   146 @return The bearer set 
       
   147 */
       
   148 	{
       
   149 	__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("TCommDbConnPref::BearerSet -> BearerSet=%d"), PrefPtr()->iBearerSet);
       
   150 	return PrefPtr()->iBearerSet;
       
   151 	}
       
   152 
       
   153 EXPORT_C TInt TCommDbConnPref::Compare(const TCommDbConnPref& aPref) const
       
   154 /**
       
   155 Compares two sets of connection preferences
       
   156 The returned value gives a measure of the differences between the preferences
       
   157 If either value has not been set then the comparison is not made
       
   158 
       
   159 @param aPref The connection preferences to compare
       
   160 @return The measure of the differences between the preferences
       
   161 */
       
   162 	{
       
   163 
       
   164 	TInt retVal(0);
       
   165 
       
   166 	if(BearerSet() != 0 && aPref.BearerSet() != 0 &&
       
   167 		aPref.BearerSet() != BearerSet())
       
   168 		{
       
   169 		--retVal;
       
   170 		}
       
   171 
       
   172 	if(DialogPreference() != ECommDbDialogPrefUnknown && aPref.DialogPreference() != ECommDbDialogPrefUnknown && 
       
   173 		aPref.DialogPreference() != DialogPreference())
       
   174 		{
       
   175 		--retVal;
       
   176 		}
       
   177 
       
   178 	if(Direction() != ECommDbConnectionDirectionUnknown && aPref.Direction() != ECommDbConnectionDirectionUnknown &&
       
   179 		aPref.Direction() != Direction())
       
   180 		{
       
   181 		--retVal;
       
   182 		}
       
   183 
       
   184 	if(IapId() != 0 && aPref.IapId() != 0 &&
       
   185 		aPref.IapId() != IapId())
       
   186 		{
       
   187 		--retVal;
       
   188 		}
       
   189 
       
   190 	if(NetId() != 0 && aPref.NetId() != 0 && 
       
   191 		aPref.NetId() != NetId())
       
   192 		{
       
   193 		--retVal;
       
   194 		}
       
   195 	
       
   196 	//__FLOG_STATIC1(KLogComponent, KCommDbShim, _L("Compare Dialog Preferences -> Result=%d"), retVal);
       
   197 	return retVal;
       
   198 	}
       
   199 
       
   200 EXPORT_C TCommDbMultiConnPref::TCommDbMultiConnPref()
       
   201 : TConnPref(TConnPref::EConnPrefCommDbMulti)
       
   202 /**
       
   203 Constructor
       
   204 */
       
   205 	{
       
   206 	SetConnectionAttempts(KMaxMultiConnPrefCount);
       
   207 	}
       
   208 
       
   209 EXPORT_C TVersion TCommDbMultiConnPref::Version()
       
   210 /**
       
   211 Returns the version number of this class
       
   212 
       
   213 @return The version information.
       
   214 */
       
   215 	{
       
   216 	__FLOG_STATIC3(KLogComponent, KCommDbShim, _L("TCommDbMultiConnPref::Version -> Major=%d, Minor=%d, Build=%d"), KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
       
   217 	return TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber);
       
   218 	}
       
   219 
       
   220 EXPORT_C TInt TCommDbMultiConnPref::SetPreference(TInt aIndex, const TCommDbConnPref& aPref)
       
   221 /**
       
   222 Sets a connection preference to the array
       
   223 
       
   224 @param aIndex Index of the array
       
   225 @param aPref Connection preference settings
       
   226 @return KErrNone if successful else KErrArgument
       
   227 */
       
   228 	{
       
   229 
       
   230 	if(aIndex<1 || aIndex>KMaxMultiConnPrefCount)
       
   231 		{
       
   232 		return KErrArgument;
       
   233 		}
       
   234 
       
   235 	PrefPtr()->iPrefs[aIndex-1] = *(aPref.PrefPtr());
       
   236 	return KErrNone;
       
   237 	}
       
   238 
       
   239 EXPORT_C TInt TCommDbMultiConnPref::GetPreference(TInt aIndex, TCommDbConnPref& aPref)
       
   240 /**
       
   241 Retrieves a connection preference from the array
       
   242 
       
   243 @param aIndex Index of the array
       
   244 @param aPref On return, the connection preferences
       
   245 @return KErrNone if successful else KErrArgument
       
   246 */
       
   247 	{
       
   248 
       
   249 	if(aIndex<1 || aIndex>KMaxMultiConnPrefCount)
       
   250 		{
       
   251 		return KErrArgument;
       
   252 		}
       
   253 
       
   254 	*(aPref.PrefPtr()) = PrefPtr()->iPrefs[aIndex-1];
       
   255 	return KErrNone;
       
   256 	}
       
   257 
       
   258 EXPORT_C void TCommDbMultiConnPref::SetConnectionAttempts(TInt aNumAttempts)
       
   259 /**
       
   260 Sets the number of times to attempt the connection
       
   261 
       
   262 @param aNumAttempts Number of attempts to be made for a connection
       
   263 */
       
   264 	{
       
   265 	if(aNumAttempts<1 || aNumAttempts>KMaxMultiConnPrefCount)
       
   266 		{
       
   267 		return;
       
   268 		}
       
   269 
       
   270 	PrefPtr()->iNumAttempts = aNumAttempts;
       
   271 	}
       
   272 
       
   273 EXPORT_C TInt TCommDbMultiConnPref::ConnectionAttempts()
       
   274 /**
       
   275 Retrieves the number of times to attempt the connection
       
   276 
       
   277 @internalTechnology
       
   278 @return Number of times to attempt the connection
       
   279 */
       
   280 	{
       
   281 
       
   282 	return PrefPtr()->iNumAttempts;
       
   283 	}