supl/locationomasuplprotocolhandler/asnconverterpluginapi/src/epos_comasuplreport.cpp
changeset 0 667063e416a2
child 4 42de37ce7ce4
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Header file for supl report message
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "epos_comasuplreport.h"
       
    20 #include "epos_comasuplstartver2.h"
       
    21 #include "epos_suplconstants.h"
       
    22 #include "epos_comasuplresponse.h"
       
    23 #include "lbs/epos_eomasuplposerrors.h"
       
    24 
       
    25 const TInt KSessionListShift = 3;
       
    26 const TInt KSetCapsShift = 2;
       
    27 const TInt KRepDataShift = 1;
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // COMASuplPositionData::COMASuplPositionData 
       
    31 // (other items were commented in a header).
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 COMASuplPositionData::COMASuplPositionData()
       
    35     {   
       
    36     // No implementation required
       
    37     }
       
    38 // -----------------------------------------------------------------------------
       
    39 // COMASuplPositionData::~COMASuplPositionData
       
    40 // (other items were commented in a header).
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C COMASuplPositionData::~COMASuplPositionData()
       
    44     {
       
    45     if(iPosition)
       
    46         {
       
    47         delete iPosition;
       
    48         iPosition = NULL;
       
    49         }
       
    50     }
       
    51 // -----------------------------------------------------------------------------
       
    52 // COMASuplPositionData::NewLC()
       
    53 // (other items were commented in a header).
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C COMASuplPositionData* COMASuplPositionData::NewLC()
       
    57     {
       
    58     COMASuplPositionData* self = new (ELeave)COMASuplPositionData();
       
    59     CleanupStack::PushL(self);
       
    60     self->ConstructL();
       
    61     return self;
       
    62     }
       
    63 // -----------------------------------------------------------------------------
       
    64 // COMASuplPositionData::NewL()
       
    65 // (other items were commented in a header).
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C COMASuplPositionData* COMASuplPositionData::NewL()
       
    69     {
       
    70     COMASuplPositionData* self=COMASuplPositionData::NewLC();
       
    71     CleanupStack::Pop(self); // self;
       
    72     return self;
       
    73     }
       
    74 // -----------------------------------------------------------------------------
       
    75 // COMASuplPositionData::ConstructL()
       
    76 // (other items were commented in a header).
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 void COMASuplPositionData::ConstructL()
       
    80     {
       
    81 
       
    82     }
       
    83 // -----------------------------------------------------------------------------
       
    84 // COMASuplPositionData::SetPosition()
       
    85 // (other items were commented in a header).
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 EXPORT_C void COMASuplPositionData::SetPosition(COMASuplPosition* aPosition)
       
    89     {
       
    90     if(iPosition)
       
    91         {
       
    92         delete iPosition;
       
    93         iPosition = NULL;
       
    94         }
       
    95     iPosition = aPosition; 
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // COMASuplPositionData::SetPosMethod()
       
   100 // (other items were commented in a header).
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 EXPORT_C void COMASuplPositionData::SetPosMethod(const TOMASuplPosMethod aPosMethod)
       
   104     {
       
   105     iPosMethod = aPosMethod;
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // COMASuplPositionData::GetPosition()
       
   110 // (other items were commented in a header).
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 
       
   114 EXPORT_C void COMASuplPositionData::GetPosition(COMASuplPosition*& aPosition)const
       
   115     {
       
   116     aPosition = iPosition;
       
   117     }
       
   118 // -----------------------------------------------------------------------------
       
   119 // COMASuplPositionData::GetPosMethod()
       
   120 // (other items were commented in a header).
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 EXPORT_C void COMASuplPositionData::GetPosMethod(TOMASuplPosMethod& aPosMethod)const
       
   124     {
       
   125     aPosMethod = iPosMethod;
       
   126     }
       
   127 
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // COMASuplPositionData::CloneL()
       
   131 // (other items were commented in a header).
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C COMASuplPositionData* COMASuplPositionData::CloneL()
       
   135     {
       
   136     COMASuplPositionData* positionDataToRet = COMASuplPositionData::NewL();
       
   137     positionDataToRet->SetPosMethod(iPosMethod);
       
   138     positionDataToRet->SetPosition(static_cast<COMASuplPosition*> (iPosition->CloneL()));
       
   139 
       
   140     return positionDataToRet;
       
   141     }
       
   142 // -----------------------------------------------------------------------------
       
   143 // COMASuplReportData::~COMASuplReportData()
       
   144 // (other items were commented in a header).
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 EXPORT_C COMASuplReportData::~COMASuplReportData()
       
   148     {
       
   149     if(iPositionData)
       
   150         {
       
   151         delete iPositionData;
       
   152         iPositionData = NULL;
       
   153         }
       
   154     if(iMultipleLocIds)
       
   155         {
       
   156         delete iMultipleLocIds;
       
   157         iMultipleLocIds = NULL;
       
   158         }
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // COMASuplReportData::NewLC
       
   163 // (other items were commented in a header).
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C COMASuplReportData* COMASuplReportData::NewLC()
       
   167     {
       
   168     COMASuplReportData* self = new (ELeave)COMASuplReportData();
       
   169     CleanupStack::PushL(self);
       
   170     self->ConstructL();
       
   171     return self;
       
   172     }
       
   173 // -----------------------------------------------------------------------------
       
   174 // COMASuplReportData::NewL
       
   175 // (other items were commented in a header).
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C COMASuplReportData* COMASuplReportData::NewL()
       
   179     {
       
   180     COMASuplReportData* self=COMASuplReportData::NewLC();
       
   181     CleanupStack::Pop(self); // self;
       
   182     return self;
       
   183     }
       
   184 // -----------------------------------------------------------------------------
       
   185 // COMASuplReportData::ConstructL
       
   186 // (other items were commented in a header).
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 void COMASuplReportData::ConstructL()
       
   190     {
       
   191 
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // COMASuplReportData::COMASuplReportData
       
   196 // (other items were commented in a header).
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 COMASuplReportData::COMASuplReportData()
       
   200     {
       
   201     //no implementation
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // COMASuplReportData::SetPosData
       
   206 // (other items were commented in a header).
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C void COMASuplReportData::SetPosData(COMASuplPositionData* aPositionData)
       
   210     {
       
   211     if(iPositionData)
       
   212         {
       
   213         delete iPositionData;
       
   214         iPositionData = NULL;
       
   215         }
       
   216     iPositionData = aPositionData;
       
   217     }
       
   218 // -----------------------------------------------------------------------------
       
   219 // COMASuplReportData::SetTimeStamp
       
   220 // (other items were commented in a header).
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 EXPORT_C void COMASuplReportData::SetTimeStamp(const TOMASuplTimeStamp aTimeStamp)
       
   224     {
       
   225     iTimeStamp = aTimeStamp;
       
   226     }
       
   227 // -----------------------------------------------------------------------------
       
   228 // COMASuplReportData::SetResultCode
       
   229 // (other items were commented in a header).
       
   230 // -----------------------------------------------------------------------------
       
   231 //
       
   232 EXPORT_C void COMASuplReportData::SetResultCode(const TOMASuplReportDataResultCode aResultCode)
       
   233     {
       
   234     iResultCode = aResultCode;
       
   235     }
       
   236 // -----------------------------------------------------------------------------
       
   237 // COMASuplReportData::SetMutipleLocId
       
   238 // (other items were commented in a header).
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 EXPORT_C void COMASuplReportData::SetMutipleLocId(COMASuplMultipleLocIds* aMultipleLocIds)
       
   242     {
       
   243     if(iMultipleLocIds)
       
   244         {
       
   245         delete iMultipleLocIds;
       
   246         iMultipleLocIds = NULL;
       
   247         }
       
   248     iMultipleLocIds = aMultipleLocIds;
       
   249     }
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // COMASuplReportData::GetPosData
       
   253 // (other items were commented in a header).
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 EXPORT_C void COMASuplReportData::GetPosData(COMASuplPositionData*& aPositionData)const
       
   257     {
       
   258     aPositionData = iPositionData;
       
   259     }
       
   260     
       
   261 // -----------------------------------------------------------------------------
       
   262 // COMASuplReportData::GetTimeStamp
       
   263 // (other items were commented in a header).
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 EXPORT_C void COMASuplReportData::GetTimeStamp(TOMASuplTimeStamp& aTimeStamp)const
       
   267     {
       
   268     aTimeStamp = iTimeStamp;
       
   269     }
       
   270 // -----------------------------------------------------------------------------
       
   271 // COMASuplReportData::GetResultCode
       
   272 // (other items were commented in a header).
       
   273 // -----------------------------------------------------------------------------
       
   274 //
       
   275 EXPORT_C void COMASuplReportData::GetResultCode(COMASuplReportData::TOMASuplReportDataResultCode& aResultCode)const
       
   276     {
       
   277     aResultCode = iResultCode;
       
   278     }
       
   279 // -----------------------------------------------------------------------------
       
   280 // COMASuplReportData::GetMutipleLocId
       
   281 // (other items were commented in a header).
       
   282 // -----------------------------------------------------------------------------
       
   283 //
       
   284 EXPORT_C void COMASuplReportData::GetMutipleLocId(COMASuplMultipleLocIds*& aMultipleLocIds)const
       
   285     {
       
   286     aMultipleLocIds = iMultipleLocIds;
       
   287     }
       
   288 // -----------------------------------------------------------------------------
       
   289 // COMASuplReportData::CloneL
       
   290 // (other items were commented in a header).
       
   291 // -----------------------------------------------------------------------------
       
   292 //
       
   293 EXPORT_C COMASuplReportData* COMASuplReportData::CloneL()
       
   294     {
       
   295     COMASuplReportData* repDataToRet = COMASuplReportData::NewL();
       
   296     repDataToRet->SetMutipleLocId(iMultipleLocIds->CloneL());
       
   297     repDataToRet->SetResultCode(iResultCode);
       
   298     repDataToRet->SetTimeStamp(iTimeStamp);
       
   299     repDataToRet->SetPosData(iPositionData->CloneL());
       
   300     return repDataToRet;
       
   301     }
       
   302 // -----------------------------------------------------------------------------
       
   303 // COMASuplReport::COMASuplReport
       
   304 // (other items were commented in a header).
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 EXPORT_C COMASuplReport::COMASuplReport()
       
   308     {
       
   309     // No implementation required
       
   310     }
       
   311 // -----------------------------------------------------------------------------
       
   312 // COMASuplReport::~COMASuplReport
       
   313 // (other items were commented in a header).
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 EXPORT_C COMASuplReport::~COMASuplReport()
       
   317     {
       
   318        
       
   319     if(iSETCapabilities)
       
   320         {
       
   321         delete iSETCapabilities;
       
   322         iSETCapabilities = NULL;
       
   323         }
       
   324     iSessionList.ResetAndDestroy();
       
   325     iReportDataList.ResetAndDestroy();
       
   326     }
       
   327 // -----------------------------------------------------------------------------
       
   328 // COMASuplReport::NewLC()
       
   329 // (other items were commented in a header).
       
   330 // -----------------------------------------------------------------------------
       
   331 //
       
   332 EXPORT_C COMASuplReport* COMASuplReport::NewLC()
       
   333     {
       
   334     COMASuplReport* self = new (ELeave)COMASuplReport();
       
   335     CleanupStack::PushL(self);
       
   336     self->ConstructL();
       
   337     return self;
       
   338     }
       
   339 // -----------------------------------------------------------------------------
       
   340 // COMASuplReport::NewL()
       
   341 // (other items were commented in a header).
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 EXPORT_C COMASuplReport* COMASuplReport::NewL()
       
   345     {
       
   346     COMASuplReport* self=COMASuplReport::NewLC();
       
   347     CleanupStack::Pop(self); // self;
       
   348     return self;
       
   349     }
       
   350 
       
   351 // -----------------------------------------------------------------------------
       
   352 // COMASuplReport::ConstructL()
       
   353 // (other items were commented in a header).
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 void COMASuplReport::ConstructL()
       
   357     {
       
   358     iOptionalMask = 0;
       
   359        
       
   360     SetMessageType(COMASuplAsnMessageBase::ESUPL_REPORT);
       
   361     }
       
   362 
       
   363 // -----------------------------------------------------------------------------
       
   364 // COMASuplReport::Clone() 
       
   365 // (other items were commented in a header).
       
   366 // -----------------------------------------------------------------------------
       
   367 //              
       
   368 EXPORT_C void COMASuplReport::Clone(const COMASuplAsnMessageBase* aReport,TInt& aErrorCode)
       
   369     {
       
   370 
       
   371     TRAP(aErrorCode, CloneBaseL(aReport,aErrorCode));
       
   372     COMASuplReport* reportToClone = (COMASuplReport*)aReport;
       
   373     
       
   374     RPointerArray<COMASuplSessionID> sessionList;
       
   375     /* SetCapabilities*/
       
   376     COMASuplSETCapabilitiesVer2* sETCapabilities = NULL; 
       
   377     RPointerArray<COMASuplReportData> reportDataList;
       
   378     //ver field/ of Supl_end
       
   379     TBuf8<KVer> ver;
       
   380 
       
   381     reportToClone->GetReportDataList(reportDataList);
       
   382     
       
   383     for(TInt reportListIter = 0; reportListIter < reportDataList.Count();reportListIter++)
       
   384         {
       
   385         TRAP(aErrorCode,(iReportDataList.Append(reportDataList[reportListIter]->CloneL())));
       
   386         }
       
   387         
       
   388     //set the optional mask to indicate report data list is set
       
   389     iOptionalMask |= 1<<KRepDataShift;
       
   390     
       
   391     reportToClone->GetSetCapabilities(sETCapabilities);
       
   392     if(sETCapabilities) 
       
   393     	{
       
   394 		TRAP(aErrorCode,SetSetCapabilities(sETCapabilities->CloneL()));
       
   395     	}
       
   396     	
       
   397     reportToClone->GetVer(ver);
       
   398     SetVer(ver);
       
   399     
       
   400     reportToClone->GetSessionList(sessionList);
       
   401    
       
   402     for(TInt count = 0; count < sessionList.Count();count++)
       
   403         {
       
   404         TRAP(aErrorCode,iSessionList.Append(sessionList[count]->CloneL()));
       
   405         } 
       
   406         
       
   407     iOptionalMask |= KSessionListShift;
       
   408     
       
   409     }
       
   410 
       
   411 /*
       
   412  * Getter method for Session List
       
   413  */
       
   414 EXPORT_C TInt COMASuplReport::GetSessionList(RPointerArray<COMASuplSessionID>& aSessionList)const
       
   415     {
       
   416     if(iOptionalMask & (1<<KSessionListShift))
       
   417         {
       
   418         for(TInt count = 0; count < iSessionList.Count();count++)
       
   419             {
       
   420             aSessionList.Append(iSessionList[count]);
       
   421             }
       
   422         return KErrNone;
       
   423         }
       
   424     else
       
   425         return KErrOMASuplParamNotSet;
       
   426     }
       
   427 
       
   428 /*
       
   429  * Getter method for Session List
       
   430  */
       
   431 EXPORT_C TInt COMASuplReport::GetSetCapabilities(COMASuplSETCapabilitiesVer2*& aSETCapabilities)const
       
   432     {
       
   433     if(iOptionalMask & (1<<KSetCapsShift))
       
   434         {
       
   435         aSETCapabilities = iSETCapabilities;
       
   436         return KErrNone;
       
   437         }
       
   438     else
       
   439         return KErrOMASuplParamNotSet;
       
   440     }
       
   441 
       
   442 /*
       
   443  * Getter method for Session List
       
   444  */
       
   445 EXPORT_C TInt COMASuplReport::GetReportDataList(RPointerArray<COMASuplReportData>& aReportDataList)const
       
   446     {
       
   447     if(iOptionalMask & (1<<KRepDataShift))
       
   448         {
       
   449         for(TInt count = 0; count < iReportDataList.Count();count++)
       
   450             {
       
   451             aReportDataList.Append(iReportDataList[count]);
       
   452             }
       
   453         return KErrNone;
       
   454         }
       
   455     else
       
   456         return KErrOMASuplParamNotSet;
       
   457     }
       
   458 /*
       
   459  * getter method for version
       
   460  */
       
   461 EXPORT_C TInt COMASuplReport::GetVer(TDes8& aVer)const
       
   462     {
       
   463     if(iOptionalMask & (1))
       
   464         {
       
   465         if(aVer.MaxLength() >= iVer.Length())
       
   466             {
       
   467             aVer = iVer;
       
   468             return KErrNone;
       
   469             }
       
   470         return KErrArgument;
       
   471         }
       
   472     else
       
   473         return KErrOMASuplParamNotSet;
       
   474     }
       
   475 /*
       
   476  * Getter method for Session List
       
   477  */
       
   478 EXPORT_C void COMASuplReport::SetSessionList(const RPointerArray<COMASuplSessionID>& aSessionList)
       
   479     {
       
   480     iSessionList.Reset();
       
   481     iOptionalMask |= 1<<KSessionListShift;
       
   482     for(TInt count = 0; count < aSessionList.Count();count++)
       
   483         {
       
   484         iSessionList.Append(aSessionList[count]);
       
   485         }  
       
   486     }
       
   487 /*
       
   488  * Getter method for Set Capabilities
       
   489  */
       
   490 EXPORT_C void COMASuplReport::SetSetCapabilities(COMASuplSETCapabilitiesVer2* aSETCapabilities)
       
   491     {
       
   492     if(aSETCapabilities)
       
   493         {
       
   494         iOptionalMask |= 1<<KSetCapsShift;
       
   495         iSETCapabilities = aSETCapabilities;
       
   496         }
       
   497     }
       
   498 /*
       
   499  * Getter method for Report Data List
       
   500  */
       
   501 EXPORT_C void COMASuplReport::SetReportDataList(const RPointerArray<COMASuplReportData>& aReportDataList)
       
   502     {
       
   503     iReportDataList.Reset();
       
   504     iOptionalMask |= 1<<KRepDataShift;
       
   505     for(TInt count = 0; count < aReportDataList.Count();count++)
       
   506         {
       
   507         iReportDataList.Append(aReportDataList[count]);
       
   508         }        
       
   509     }
       
   510 
       
   511 /*
       
   512  * Getter method for Version
       
   513  */
       
   514 EXPORT_C void COMASuplReport::SetVer(const TDesC8& aVer)
       
   515     {
       
   516     if(aVer.Length() <= iVer.MaxLength())
       
   517         {
       
   518         iOptionalMask |= 1;
       
   519         iVer = aVer;
       
   520         }
       
   521     }