locationtriggering/ltclientlib/src/lbtlisttriggeroptions.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2009 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: Implementation of helper class used when listing 
       
    15 * entries from location triggering server.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "lbtlisttriggeroptions.h"
       
    21 #include "lbttriggerfilterbase.h"
       
    22 #include "lbttriggerfilterbyattribute.h"
       
    23 #include "lbttriggerfilterbyarea.h"
       
    24 #include "lbttriggerfiltercomposite.h"
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CLbtListTriggerOptions::NewL()
       
    28 //
       
    29 // (other items were commented in a header).
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 EXPORT_C  CLbtListTriggerOptions* CLbtListTriggerOptions::NewL()
       
    33     {
       
    34    	CLbtListTriggerOptions* self = new( ELeave ) CLbtListTriggerOptions;
       
    35     CleanupStack::PushL( self );
       
    36     self->ConstructL();
       
    37 	CleanupStack::Pop( self );  
       
    38 	return self;
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CLbtListTriggerOptions::NewLC()
       
    43 //
       
    44 // (other items were commented in a header).
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C  CLbtListTriggerOptions* CLbtListTriggerOptions::NewLC()
       
    48     {
       
    49     CLbtListTriggerOptions* self = new( ELeave ) CLbtListTriggerOptions;
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL();
       
    52     return self;
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CLbtListTriggerOptions::ConstructL()
       
    57 // Symbian 2nd phase constructor can leave.
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 void CLbtListTriggerOptions::ConstructL()
       
    61     {
       
    62  	iTriigerAttributeFieldsMask=KLbtTriggerAttributeFieldsAll;
       
    63  	iDynInfoFieldsMask=KLbtTriggerDynInfoFieldsAll;
       
    64  	iSorting=ELbtNoSorting;
       
    65  	iFilter=NULL;
       
    66     }
       
    67     
       
    68 // ---------------------------------------------------------------------------
       
    69 // CLbtListTriggerOptions::GetRetrievedFields( 
       
    70 //            TLbtTriggerAttributeFieldsMask &aEntryMask,
       
    71 //            TLbtTriggerDynamicInfoFieldsMask &aDynInfoMask ) 
       
    72 //
       
    73 // (other items were commented in a header).
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C void CLbtListTriggerOptions::GetRetrievedFields( 
       
    77             TLbtTriggerAttributeFieldsMask &aEntryMask,
       
    78             TLbtTriggerDynamicInfoFieldsMask &aDynInfoMask ) const
       
    79 
       
    80     {
       
    81     aDynInfoMask=iDynInfoFieldsMask;
       
    82     aEntryMask=iTriigerAttributeFieldsMask;
       
    83     }
       
    84     
       
    85 // ---------------------------------------------------------------------------
       
    86 // CLbtListTriggerOptions::SetRetrievedFields( 
       
    87 //            TLbtTriggerAttributeFieldsMask aEntryMask,
       
    88 //            TLbtTriggerDynamicInfoFieldsMask aDynInfoMask = KLbtTriggerDynInfoFieldsAll ) 
       
    89 //
       
    90 // (other items were commented in a header).
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 
       
    94 EXPORT_C void CLbtListTriggerOptions::SetRetrievedFields( 
       
    95             TLbtTriggerAttributeFieldsMask aEntryMask, /* check if the default param has to be mentioned here*/
       
    96            TLbtTriggerDynamicInfoFieldsMask aDynInfoMask )
       
    97     {
       
    98     iTriigerAttributeFieldsMask=aEntryMask;
       
    99     iDynInfoFieldsMask=aDynInfoMask;
       
   100     }
       
   101      
       
   102 // ---------------------------------------------------------------------------
       
   103 // CLbtListTriggerOptions::SortingOption()
       
   104 //
       
   105 // (other items were commented in a header).
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 EXPORT_C CLbtListTriggerOptions::TLbtListTriggerSorting CLbtListTriggerOptions::SortingOption() const
       
   109     {
       
   110     return iSorting;
       
   111     }
       
   112     
       
   113 // ---------------------------------------------------------------------------
       
   114 // CLbtListTriggerOptions::SetSortingOption()
       
   115 //
       
   116 // (other items were commented in a header).
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 EXPORT_C void CLbtListTriggerOptions::SetSortingOption( TLbtListTriggerSorting aOption )
       
   120     {
       
   121     iSorting=aOption;
       
   122     }
       
   123 
       
   124 // ---------------------------------------------------------------------------
       
   125 // CLbtListTriggerOptions::SetFilterL( CLbtTriggerFilterBase* aFilter )
       
   126 //
       
   127 // (other items were commented in a header).
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 EXPORT_C void CLbtListTriggerOptions::SetFilter( 
       
   131             CLbtTriggerFilterBase* aFilter )
       
   132     {
       
   133 	iFilter=aFilter;
       
   134     }	
       
   135     
       
   136 // ---------------------------------------------------------------------------
       
   137 // CLbtListTriggerOptions::Filter( )
       
   138 //
       
   139 // (other items were commented in a header).
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 EXPORT_C CLbtTriggerFilterBase* CLbtListTriggerOptions:: Filter() 
       
   143     {
       
   144 	return iFilter;
       
   145     }        
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // CLbtListTriggerOptions::InternalizeL( )
       
   149 //
       
   150 // (other items were commented in a header).
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 EXPORT_C void CLbtListTriggerOptions::InternalizeL( RReadStream& aStream )
       
   154     {
       
   155 	iTriigerAttributeFieldsMask=aStream.ReadUint32L();
       
   156 	iDynInfoFieldsMask=aStream.ReadUint32L();
       
   157 	TInt filterType;
       
   158 	filterType=aStream.ReadInt8L();
       
   159 	switch(filterType)
       
   160 	    {
       
   161 		case 1: iFilter=CLbtTriggerFilterByAttribute::NewL();
       
   162 				iFilter->InternalizeL(aStream);
       
   163 				break;
       
   164 		case 2: iFilter=CLbtTriggerFilterByArea::NewL();
       
   165 				iFilter->InternalizeL(aStream);
       
   166 				break;
       
   167 				
       
   168 		case 3: iFilter=CLbtTriggerFilterComposite::NewL();
       
   169 				iFilter->InternalizeL(aStream);
       
   170 				break;
       
   171 		}
       
   172 	TInt sortOption=aStream.ReadInt8L();
       
   173 	
       
   174 	switch(sortOption)
       
   175 	    {
       
   176 		case 1: iSorting= CLbtListTriggerOptions::ELbtNoSorting;
       
   177 													break;
       
   178 		case 2: iSorting= CLbtListTriggerOptions::ELbtTriggerNameAscending;
       
   179 																break;
       
   180 																
       
   181 		case 3: iSorting= CLbtListTriggerOptions::ELbtTriggerNameDescending ;
       
   182 																 break;
       
   183 																 
       
   184 		case 4: iSorting= CLbtListTriggerOptions::ELbtDistanceToLatestLocationAscending ;
       
   185 		}
       
   186     }
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // CLbtListTriggerOptions::ExternalizeL( )
       
   190 //
       
   191 // (other items were commented in a header).
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 EXPORT_C void CLbtListTriggerOptions::ExternalizeL( RWriteStream& aStream ) const
       
   195     {
       
   196 	aStream.WriteUint32L(iTriigerAttributeFieldsMask);
       
   197 	aStream.WriteUint32L(iDynInfoFieldsMask);
       
   198 	
       
   199 	if(iFilter)
       
   200 		{
       
   201 	    CLbtTriggerFilterBase::TFilterType filterType=iFilter->Type();
       
   202 	
       
   203 	    switch(filterType)
       
   204 	        {
       
   205 		    case CLbtTriggerFilterBase::EFilterByAttribute: aStream.WriteInt8L(1);
       
   206 														break;	
       
   207 		    case CLbtTriggerFilterBase::EFilterByArea: aStream.WriteInt8L(2);
       
   208 												   break;
       
   209 		    case CLbtTriggerFilterBase::EFilterComposite: aStream.WriteInt8L(3);
       
   210 													  break;
       
   211 	        default: aStream.WriteInt8L(0);
       
   212 	        }
       
   213 	    iFilter->ExternalizeL(aStream);    
       
   214 		}	
       
   215 	else
       
   216 	    {
       
   217 	    aStream.WriteInt8L(0);
       
   218 	    }		
       
   219 	
       
   220 	switch(iSorting)
       
   221 	    {
       
   222 		case CLbtListTriggerOptions::ELbtNoSorting: aStream.WriteInt8L(1);
       
   223 													break;
       
   224 		case CLbtListTriggerOptions::ELbtTriggerNameAscending : aStream.WriteInt8L(2);
       
   225 																break;
       
   226 																
       
   227 		case CLbtListTriggerOptions::ELbtTriggerNameDescending : aStream.WriteInt8L(3);
       
   228 																 break;
       
   229 																 
       
   230 		case CLbtListTriggerOptions::ELbtDistanceToLatestLocationAscending :aStream.WriteInt8L(4);
       
   231 		}
       
   232 	
       
   233 	aStream.WriteInt8L(iSorting);
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------------------------
       
   237 // CLbtListTriggerOptions::CLbtListTriggerOptions()
       
   238 // Default constructor
       
   239 // ---------------------------------------------------------------------------
       
   240 // 
       
   241 CLbtListTriggerOptions::CLbtListTriggerOptions()
       
   242     {
       
   243 	
       
   244     }
       
   245 
       
   246 // ---------------------------------------------------------------------------
       
   247 // CLbtListTriggerOptions::~CLbtListTriggerOptions()
       
   248 // Destructor
       
   249 // ---------------------------------------------------------------------------
       
   250 // 
       
   251 EXPORT_C CLbtListTriggerOptions::~CLbtListTriggerOptions()
       
   252     {
       
   253 	
       
   254     }
       
   255