dosservices/dosserver/src/saepubsubnotifier.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     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 // INCLUDE FILES
       
    20 #include "saepubsubnotifier.h"
       
    21 #include "saeetelobserver.h"
       
    22 
       
    23 #include "SaeSignalStrengthObserver.h"
       
    24 #include "sae_debug.h"
       
    25 
       
    26 #include <e32std.h>
       
    27 #include <e32cons.h>
       
    28 #include <e32svr.h>
       
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
       
    31 
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 //
       
    35 CSaePubSubNotifier::CSaePubSubNotifier() : iCfStatusInitialised( EFalse )
       
    36     {
       
    37     }
       
    38 
       
    39 // EPOC default constructor can leave.
       
    40 void CSaePubSubNotifier::ConstructL()
       
    41     {
       
    42 
       
    43 	TInt err(KErrNone);
       
    44 	// Define Publish and Suvscribe properties
       
    45 	DefineProperties();
       
    46 
       
    47 	// Create the ETel observers.
       
    48 	iEtelObserver = CSaeEtelObserver::NewL( this );
       
    49 	// Create GPRS session and observers, and start listening for events.
       
    50 	// If not succesfull ETEL messages are missed, but DosObserver still works
       
    51 	// and messages are delelgated to SA.
       
    52 	TRAP(err, iEtelObserver->StartListeningL());
       
    53 	COM_TRACE_1( "SAE: CSaeSysAgentNotifier::ConstructL(): iEtelObserver->StartListeningL() return value: %d", err );
       
    54     
       
    55 	if (err != KErrNone) 
       
    56 		{
       
    57 		COM_TRACE_( "SAE: CSaeSysAgentNotifier::ConstructL(): deleting iEtelObserver..." );
       
    58 		delete iEtelObserver;
       
    59 		iEtelObserver = 0;
       
    60 		COM_TRACE_( "SAE: CSaeSysAgentNotifier::ConstructL(): iEtelObserver deleted - GPRS states not handled by etelObs." );
       
    61 		}
       
    62 
       
    63     // Start polling network signal strength
       
    64     iSignalObserver = CSaeSignalStrengthObserver::NewL( this );
       
    65     iSignalObserver->Receive();
       
    66 	
       
    67 	}
       
    68 
       
    69 // Two-phased constructor.
       
    70 CSaePubSubNotifier* CSaePubSubNotifier::NewL()
       
    71     {
       
    72     CSaePubSubNotifier* self = new ( ELeave ) CSaePubSubNotifier();
       
    73     
       
    74     CleanupStack::PushL( self );
       
    75     self->ConstructL();
       
    76     CleanupStack::Pop();
       
    77 
       
    78     return self;
       
    79     }
       
    80 
       
    81     
       
    82 // Destructor
       
    83 CSaePubSubNotifier::~CSaePubSubNotifier()
       
    84     {
       
    85 	// Disallocate reserved resources...
       
    86 	delete iEtelObserver;
       
    87 	delete iSignalObserver;
       
    88 	}
       
    89 
       
    90 void CSaePubSubNotifier::DefineProperties()
       
    91     {
       
    92 	};
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // CSaeSysAgentNotifier::NotifySystemAgent
       
    96 // ?implementation_description
       
    97 // (other items were commented in a header).
       
    98 // ---------------------------------------------------------
       
    99 //
       
   100 TInt CSaePubSubNotifier::NotifyPubSub( const TUid aVariable, const TInt aState )
       
   101 	{
       
   102 #ifdef _DEBUG
       
   103 	TInt variable = aVariable.iUid;
       
   104     COM_TRACE_3( "SAE: CSaePubSubNotifier::NotifyPubSub : aVariable Dec:%d, aVariable Hex:%x, aState: %d", variable, variable, aState );
       
   105 #endif
       
   106 
       
   107 	TInt returnValue = 	iSAProperty.Set(KUidSystemCategory, aVariable.iUid, aState);
       
   108 	
       
   109     COM_TRACE_1( "SAE: CSaePubSubNotifier::NotifyPubSub : returnValue == %d", returnValue );
       
   110     
       
   111     return returnValue;                        	
       
   112 	}
       
   113 //  End of File