mmserv/tms/tmsserver/src/tareventhandler.cpp
changeset 12 5a06f39ad45b
parent 0 71ca22bcf22a
child 14 80975da52420
equal deleted inserted replaced
0:71ca22bcf22a 12:5a06f39ad45b
     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: Telephony Multimedia Service
       
    15  *
       
    16  */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "tareventhandler.h"
       
    20 #include "tmsclientserver.h"
       
    21 #include "tmsutility.h"
       
    22 
       
    23 using namespace TMS;
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // CTarEventHandler::CTarEventHandler
       
    27 // C++ default constructor can NOT contain any code, that
       
    28 // might leave.
       
    29 // -----------------------------------------------------------------------------
       
    30 //
       
    31 CTarEventHandler::CTarEventHandler(TMSServer* aServer) :
       
    32     CActive(EPriorityStandard),
       
    33     iTMSSer(aServer)
       
    34     {
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CTarEventHandler::ConstructL
       
    39 // Symbian 2nd phase constructor can leave.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 void CTarEventHandler::ConstructL()
       
    43     {
       
    44     TRACE_PRN_FN_ENT;
       
    45     CActiveScheduler::Add(this);
       
    46     User::LeaveIfError(iProperty.Attach(KTMSPropertyCategory, ERoutingPs));
       
    47     iProperty.Subscribe(iStatus);
       
    48     SetActive();
       
    49     TRACE_PRN_FN_EXT;
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CTarEventHandler::NewL
       
    54 // Two-phased constructor.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CTarEventHandler* CTarEventHandler::NewL(TMSServer* aServer)
       
    58     {
       
    59     CTarEventHandler* self = new (ELeave) CTarEventHandler(aServer);
       
    60     CleanupStack::PushL(self);
       
    61     self->ConstructL();
       
    62     CleanupStack::Pop(self);
       
    63     return self;
       
    64     }
       
    65 
       
    66 // Destructor
       
    67 CTarEventHandler::~CTarEventHandler()
       
    68     {
       
    69     TRACE_PRN_FN_ENT;
       
    70     if (IsActive())
       
    71         {
       
    72         Cancel();
       
    73         }
       
    74     iProperty.Close();
       
    75     TRACE_PRN_FN_EXT;
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CTarEventHandler::DoCancel
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CTarEventHandler::DoCancel()
       
    83     {
       
    84     TRACE_PRN_FN_ENT;
       
    85     iProperty.Cancel();
       
    86     TRACE_PRN_FN_EXT;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CTarEventHandler::RunL
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 void CTarEventHandler::RunL()
       
    94     {
       
    95     TRACE_PRN_FN_ENT;
       
    96     // Subscribe immediately before analyzing the notification to ensure that we
       
    97     // don't miss further updates.
       
    98     if (iStatus.Int() == KErrNone)
       
    99         {
       
   100         iProperty.Subscribe(iStatus);
       
   101         SetActive();
       
   102         TRoutingMsgBufPckg routingpckg;
       
   103         iProperty.Get(routingpckg);
       
   104         iTMSSer->NotifyTarClients(routingpckg);
       
   105         }
       
   106     TRACE_PRN_FN_EXT;
       
   107     }
       
   108 
       
   109 //  End of File
       
   110