locationtriggering/ltclientlib/src/lbtclientrequester.cpp
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 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:  location triggering server client interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32base.h>
       
    21 #include <s32strm.h>
       
    22 #include <s32mem.h>
       
    23 #include <lbt.h>
       
    24 
       
    25 #include "lbtclientrequester.h"
       
    26 #include "lbttriggerinfo.h"
       
    27 
       
    28 
       
    29 
       
    30 
       
    31 
       
    32 // ================= LOCAL FUNCTIONS ========================
       
    33  
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 
       
    36 // ---------------------------------------------------------
       
    37 // CLbtClientRequester::CLbtClientRequester
       
    38 //
       
    39 // Default constructor
       
    40 // ---------------------------------------------------------
       
    41 //
       
    42 CLbtClientRequester::CLbtClientRequester( RLbt& aLbt ):
       
    43                     CActive(EPriorityStandard),iLbt(aLbt),
       
    44                     iClientStatus(NULL)
       
    45    
       
    46     {
       
    47     CActiveScheduler::Add(this);
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CLbtClientRequester::ConstructL()
       
    52 // Symbian 2nd phase constructor can leave.
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void CLbtClientRequester::ConstructL()
       
    56     {
       
    57 
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CLbtClientRequester::NewL()
       
    62 //
       
    63 // (other items were commented in a header).
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CLbtClientRequester* CLbtClientRequester::NewL( RLbt& aLbt )
       
    67     {
       
    68     CLbtClientRequester* self = new (ELeave) CLbtClientRequester( aLbt );
       
    69     CleanupStack::PushL(self);
       
    70     self->ConstructL();
       
    71     CleanupStack::Pop(self);
       
    72     return self;
       
    73     }
       
    74    
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // CLbtClientRequester::~CLbtClientRequester()
       
    78 // Destructor
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 CLbtClientRequester::~CLbtClientRequester()
       
    82     {
       
    83     if (IsActive())      
       
    84       	Cancel();
       
    85     iClientBuf.Close();
       
    86     }
       
    87 
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // CLbtTriggerChangeEventNotifier::Start
       
    91 //
       
    92 // (other items were commented in a header).
       
    93 // ---------------------------------------------------------
       
    94 //
       
    95 void CLbtClientRequester::Start()
       
    96     {
       
    97  	iType = EOpOther;
       
    98  	SetActive();
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CLbtTriggerChangeEventNotifier::Start
       
   103 //
       
   104 // (other items were commented in a header).
       
   105 // ---------------------------------------------------------
       
   106 //    
       
   107 void CLbtClientRequester::Start(TAsyncReqType aType)
       
   108     {
       
   109     iType = aType;
       
   110     SetActive();
       
   111     }
       
   112  
       
   113 
       
   114 // ---------------------------------------------------------
       
   115 // CLbtTriggerChangeEventNotifier::Status
       
   116 //
       
   117 // (other items were commented in a header).
       
   118 // ---------------------------------------------------------
       
   119 // 
       
   120  TRequestStatus& CLbtClientRequester::Status()
       
   121     {
       
   122     return *iClientStatus;	
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------
       
   126 // CLbtTriggerChangeEventNotifier::SetStatus
       
   127 //
       
   128 // (other items were commented in a header).
       
   129 // ---------------------------------------------------------
       
   130 // 
       
   131 void CLbtClientRequester::SetStatus(TRequestStatus& aStatus)
       
   132     {
       
   133 	iClientStatus=&aStatus;
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------
       
   137 // CLbtTriggerChangeEventNotifier::SetBuffer
       
   138 //
       
   139 // (other items were commented in a header).
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 void CLbtClientRequester::SetBuffer(CBufFlat* aBuf )
       
   143     {
       
   144 	iClientBuf.Reset();
       
   145 	iClientBuf.Append(aBuf);
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------
       
   149 // CLbtTriggerChangeEventNotifier::SetListTriggerIdData
       
   150 //
       
   151 // (other items were commented in a header).
       
   152 // ---------------------------------------------------------
       
   153 //
       
   154 void CLbtClientRequester::SetListTriggerIdData(RArray < TLbtTriggerId >* aTriggerIdArray)
       
   155     {
       
   156     iTriggerIdArray = aTriggerIdArray;
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------
       
   160 // CLbtTriggerChangeEventNotifier::SetListTriggerIdData
       
   161 //
       
   162 // (other items were commented in a header).
       
   163 // ---------------------------------------------------------
       
   164 //
       
   165 RArray < TLbtTriggerId >* CLbtClientRequester::ListTriggerIdData()
       
   166     {
       
   167     return iTriggerIdArray;
       
   168     }
       
   169     
       
   170 // ---------------------------------------------------------
       
   171 // CLbtTriggerChangeEventNotifier::SetListTriggerData
       
   172 //
       
   173 // (other items were commented in a header).
       
   174 // ---------------------------------------------------------
       
   175 //    
       
   176 void CLbtClientRequester::SetListTriggerData(RPointerArray < CLbtTriggerInfo >* aTriggerInfoList)
       
   177     {
       
   178     iTriggerInfoList = aTriggerInfoList;
       
   179     }
       
   180 
       
   181 // ---------------------------------------------------------
       
   182 // CLbtTriggerChangeEventNotifier::ListTriggerData
       
   183 //
       
   184 // (other items were commented in a header).
       
   185 // ---------------------------------------------------------
       
   186 //    
       
   187 RPointerArray < CLbtTriggerInfo >* CLbtClientRequester::ListTriggerData()
       
   188     {
       
   189     return iTriggerInfoList;
       
   190     }
       
   191     
       
   192 // ---------------------------------------------------------
       
   193 // CLbtClientRequester::RunL
       
   194 //
       
   195 // (other items were commented in a header).
       
   196 // ---------------------------------------------------------
       
   197 //
       
   198 void CLbtClientRequester::RunL()
       
   199     {
       
   200     TInt bufCount=iClientBuf.Count();
       
   201     TInt i=0;
       
   202     while(i<bufCount)
       
   203         {
       
   204         delete iClientBuf[i];
       
   205         iClientBuf[i]=NULL;
       
   206         i++;
       
   207         }
       
   208 
       
   209     switch(iType)
       
   210         {
       
   211         case EOpOther: 
       
   212         	{
       
   213         	break;
       
   214         	}
       
   215         case EListTriggerIdsCount:
       
   216             {
       
   217             TRAPD(error,iLbt.HandleListTriggerIdsL());
       
   218             if( error != KErrNone )
       
   219                 {
       
   220                 User::RequestComplete(iClientStatus,error);
       
   221                 return;
       
   222                 }
       
   223             break;
       
   224             }
       
   225         case EListTriggersCount:
       
   226             {
       
   227             TRAPD(error,iLbt.HandleGetTriggersL());
       
   228             if( error != KErrNone )
       
   229                 {
       
   230                 User::RequestComplete(iClientStatus,error);
       
   231                 return;
       
   232                 }
       
   233             break;
       
   234             }
       
   235         }
       
   236    
       
   237    TInt error=iStatus.Int();
       
   238    User::RequestComplete(iClientStatus,error);
       
   239    }
       
   240 
       
   241 
       
   242 // ---------------------------------------------------------
       
   243 // CLbtClientRequester::RunError
       
   244 //
       
   245 // (other items were commented in a header).
       
   246 // ---------------------------------------------------------
       
   247 //
       
   248 TInt CLbtClientRequester::RunError(TInt /*aError*/)
       
   249     {
       
   250     return KErrNone;
       
   251     }
       
   252 
       
   253 // ---------------------------------------------------------
       
   254 // CLbtClientRequester::DoCancel
       
   255 //
       
   256 // (other items were commented in a header).
       
   257 // ---------------------------------------------------------
       
   258 //
       
   259 void CLbtClientRequester::DoCancel()
       
   260     {    
       
   261     User::RequestComplete(iClientStatus, iStatus.Int());
       
   262     }
       
   263 
       
   264 // ---------------------------------------------------------
       
   265 // CLbtClientRequester::ListTriggersSize
       
   266 //
       
   267 // (other items were commented in a header).
       
   268 // ---------------------------------------------------------
       
   269 //
       
   270 TInt& CLbtClientRequester::ListTriggersSize()
       
   271     {
       
   272     return iListTriggersSize;   
       
   273     }
       
   274     
       
   275 //  End of File
       
   276 
       
   277