webservices/wsutils/src/senattribute.cpp
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2004 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 
       
    22 
       
    23 
       
    24 #include "senattribute.h"
       
    25 
       
    26 #include "senlogger.h"
       
    27 
       
    28 
       
    29 //#ifdef _SENDEBUG
       
    30 // // CONSTATS for file logging
       
    31 //namespace
       
    32 //    {
       
    33 //    _LIT(KLogFileDir, "SenUtils");
       
    34 //    _LIT(KLogFileName, "SenAttribute.log"); 
       
    35 //    }
       
    36 //#endif // _SENDEBUG
       
    37 
       
    38 EXPORT_C CSenAttribute* CSenAttribute::NewL(const TDesC8& aName,
       
    39                                             const TDesC8& aType,
       
    40                                             const TDesC8& aValue,
       
    41                                             const TDesC8& aFriendlyName)
       
    42     {
       
    43     CSenAttribute* pNew = new (ELeave) CSenAttribute;
       
    44     CleanupStack::PushL(pNew);
       
    45     pNew->ConstructL(aName, aType, aValue, aFriendlyName);
       
    46     CleanupStack::Pop(); // pNew;
       
    47     return pNew;
       
    48     }
       
    49 
       
    50 EXPORT_C CSenAttribute* CSenAttribute::NewL(const TDesC8& aName,
       
    51                                             const TDesC8& aType,
       
    52                                             const TDesC8& aValue)
       
    53     {
       
    54     CSenAttribute* pNew = new (ELeave) CSenAttribute;
       
    55     CleanupStack::PushL(pNew);
       
    56     pNew->ConstructL(aName, aType, aValue, KNullDesC8());
       
    57     CleanupStack::Pop(); // pNew;
       
    58     return pNew;
       
    59     }
       
    60 
       
    61 EXPORT_C CSenAttribute::~CSenAttribute()
       
    62     {
       
    63     delete ipName;
       
    64     delete ipType;
       
    65     delete ipFriendlyName;
       
    66     iValues.ResetAndDestroy();
       
    67 
       
    68 //    // Close the log file and the connection to the server.
       
    69 //    LOG_WRITE((_L("Log file closed.")));
       
    70 //    LOG_CLOSELOG;
       
    71 //    LOG_CLOSE;
       
    72     }
       
    73 
       
    74 EXPORT_C CSenAttribute::CSenAttribute()
       
    75     {
       
    76     }
       
    77 
       
    78 
       
    79 EXPORT_C void CSenAttribute::ConstructL(const TDesC8& aName,
       
    80                                         const TDesC8& aType,
       
    81                                         const TDesC8& aValue,
       
    82                                         const TDesC8& aFriendlyName)
       
    83     {
       
    84 //    LOG_CONNECT;
       
    85 //    LOG_CREATELOG((KLogFileDir, KLogFileName, EFileLoggingModeOverwrite));
       
    86 //    LOG_WRITE(( _L8("CSenAttribute::ConstructL(): Log opened") ));
       
    87     TLSLOG_L(KSenUtilsLogChannel, KMinLogLevel, "CSenAttribute::ConstructL(): Start");
       
    88     ipName = aName.AllocL() ;
       
    89     ipType = aType.AllocL() ;
       
    90     iValues.Append(aValue.AllocL());
       
    91     // If the friendly nameparam isn't set, then don't set the owned value
       
    92     ipFriendlyName = aFriendlyName.AllocL() ;
       
    93     TLSLOG_L(KSenUtilsLogChannel, KMinLogLevel, "CSenAttribute::ConstructL(): End");
       
    94     }
       
    95 
       
    96 
       
    97 EXPORT_C TPtrC8 CSenAttribute::Name() const
       
    98     {
       
    99     if ( ipName == NULL )
       
   100         {
       
   101         return KNullDesC8();
       
   102         } else
       
   103         {
       
   104         return *ipName;
       
   105         }
       
   106     }
       
   107 
       
   108 
       
   109 EXPORT_C TPtrC8 CSenAttribute::Value() const
       
   110     {
       
   111     if ( 0 == iValues.Count() )
       
   112         {
       
   113         return KNullDesC8();
       
   114         } else
       
   115         {
       
   116         return *iValues[0];
       
   117         }
       
   118     }
       
   119 
       
   120 
       
   121 EXPORT_C TPtrC8 CSenAttribute::Type() const
       
   122     {
       
   123     if ( ipType == NULL )
       
   124         {
       
   125         return KNullDesC8();
       
   126         } else
       
   127         {
       
   128         return *ipType;
       
   129         }
       
   130     }
       
   131 
       
   132 
       
   133 EXPORT_C TPtrC8 CSenAttribute::FriendlyName() const
       
   134     {
       
   135     if ( ipFriendlyName == NULL )
       
   136         {
       
   137         return KNullDesC8();
       
   138         } else
       
   139         {
       
   140         return *ipFriendlyName;
       
   141         }
       
   142     }
       
   143 
       
   144 
       
   145 EXPORT_C void CSenAttribute::SetValueL(const TDesC8& aValue)	//codescannerwarnings
       
   146     {
       
   147     iValues.ResetAndDestroy();
       
   148     iValues.Append(aValue.AllocL());
       
   149     }
       
   150 
       
   151 
       
   152 EXPORT_C void CSenAttribute::AddValueL(const TDesC8& aValue)	//codescannerwarnings
       
   153     {
       
   154     iValues.Append(aValue.AllocL());
       
   155     }
       
   156 
       
   157 
       
   158 EXPORT_C const RAttrValueArray CSenAttribute::GetValues() const
       
   159     {
       
   160     return iValues;
       
   161     }
       
   162 
       
   163 
       
   164 EXPORT_C TInt CSenAttribute::NumValues() const
       
   165     {
       
   166     return iValues.Count();
       
   167     }
       
   168 
       
   169 
       
   170 EXPORT_C TBool CSenAttribute::Equals(const CSenAttribute& aAttr) const
       
   171     {
       
   172     if ( 0 != aAttr.Name().Compare(*ipName) ) return EFalse;
       
   173     if ( 0 != aAttr.Type().Compare(*ipType) ) return EFalse;
       
   174     if ( 0 != aAttr.FriendlyName().Compare(*ipFriendlyName) ) return EFalse;
       
   175 
       
   176     TInt count = iValues.Count();
       
   177     if ( count != aAttr.NumValues() ) return EFalse;
       
   178 
       
   179     RAttrValueArray thatValues = aAttr.GetValues();
       
   180     TBool ret = ETrue;
       
   181     for ( TInt i = 0; i < count; i++ )
       
   182         {
       
   183         if ( EFalse == ret ) break;
       
   184         ret = EFalse;
       
   185         for ( TInt ii = 0; ii < count; ii++ )
       
   186             {
       
   187             if ( 0 == iValues[i]->Compare(*thatValues[ii]) )
       
   188                 {
       
   189                 ret = ETrue;
       
   190                 break;
       
   191                 }
       
   192             }
       
   193         }
       
   194     return ret;
       
   195     }
       
   196 
       
   197 
       
   198 //RFileLogger* CSenAttribute::Log() const
       
   199 //    {
       
   200 //    return(RFileLogger*) &iLog;
       
   201 //    }
       
   202 
       
   203