hotspotfw/hsclient/src/hsssrvnotifications.cpp
changeset 0 56b72877c1cb
equal deleted inserted replaced
-1:000000000000 0:56b72877c1cb
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:   Notification class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "e32std.h"
       
    20 #include "hssinterface.h"
       
    21 #include "hsssrvnotifications.h"
       
    22 #include "am_debug.h"
       
    23 #include "hotspotclientserver.h"
       
    24 
       
    25 // ================= MEMBER FUNCTIONS =======================
       
    26 
       
    27 // ---------------------------------------------------------
       
    28 // CHssSrvNotifications::ConstructL
       
    29 // ---------------------------------------------------------
       
    30 //
       
    31 void CHssSrvNotifications::ConstructL()
       
    32     {
       
    33     DEBUG( "CHssSrvNotifications::ConstructL()" );
       
    34     CActiveScheduler::Add( this );
       
    35     WaitForNotifications();   
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------
       
    39 // CHssSrvNotifications::CHssSrvNotifications
       
    40 // ---------------------------------------------------------
       
    41 // 
       
    42 CHssSrvNotifications::CHssSrvNotifications(
       
    43     MHssSrvNotifications& aCallback,
       
    44     RHssInterface& aServer):
       
    45     CActive( CActive::EPriorityStandard ), 
       
    46     iCallback( &aCallback ),
       
    47     iServer( aServer ),
       
    48     iReturnData(),
       
    49     iDataPckg( iReturnData ),
       
    50     iCancelRequested( EFalse ),
       
    51     iIapId( 0 )
       
    52     {
       
    53     DEBUG( "CHssSrvNotifications::CHssSrvNotifications()" );
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------
       
    57 // CHssSrvNotifications::~CHssSrvNotifications
       
    58 // ---------------------------------------------------------
       
    59 //
       
    60 CHssSrvNotifications::~CHssSrvNotifications()
       
    61     {
       
    62     DEBUG( "CHssSrvNotifications::~CHssSrvNotifications()" );
       
    63     Cancel();
       
    64     }
       
    65         
       
    66 // ---------------------------------------------------------
       
    67 // CHssSrvNotifications::NewL
       
    68 // ---------------------------------------------------------
       
    69 //
       
    70 CHssSrvNotifications* CHssSrvNotifications::NewL(
       
    71     MHssSrvNotifications& aCallback,
       
    72     RHssInterface& aServer ) 
       
    73     {
       
    74     DEBUG( "CHssSrvNotifications::NewL()" );
       
    75     CHssSrvNotifications* self = new (ELeave) CHssSrvNotifications( aCallback, aServer );
       
    76     CleanupStack::PushL( self );
       
    77     self->ConstructL();
       
    78     CleanupStack::Pop(self);
       
    79     return self;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CHssSrvNotifications::RunL
       
    84 // ---------------------------------------------------------
       
    85 //
       
    86 void CHssSrvNotifications::RunL()
       
    87     {
       
    88     DEBUG1( "CHssSrvNotifications::RunL(), status == %d", iStatus.Int() );
       
    89 
       
    90     if( iStatus == KRequestPending )
       
    91         {
       
    92         DEBUG( "ERROR in CHssSrvNotifications::RunL(): request still pending!" );
       
    93         return;
       
    94         }
       
    95 
       
    96     if( iStatus == KErrServerTerminated )
       
    97         {
       
    98         DEBUG( "ERROR in CHssSrvNotifications::RunL(): server terminated" );
       
    99         return;
       
   100         }
       
   101 
       
   102     switch( iStatus.Int() )
       
   103         {
       
   104         case EHssNewNetworksDetected:
       
   105         	{
       
   106         	iCallback->NewNetworksDetected( iIapId );
       
   107         	break;
       
   108         	}
       
   109         case EHssOldNetworksLost:
       
   110         	{
       
   111         	iCallback->OldNetworksLost( iIapId );
       
   112         	break;
       
   113         	}
       
   114         default:
       
   115             DEBUG1( "ERROR in CHssSrvNotifications::RunL: unknown notification: %d", iStatus.Int() );
       
   116         }
       
   117         
       
   118     // Make a new notification request if allowed
       
   119     if( !iCancelRequested )
       
   120         {
       
   121         WaitForNotifications();
       
   122         }
       
   123       }
       
   124         
       
   125 // ---------------------------------------------------------
       
   126 // CHssSrvNotifications::DoCancel
       
   127 // ---------------------------------------------------------
       
   128 //  
       
   129 void CHssSrvNotifications::DoCancel()
       
   130     {
       
   131     DEBUG( "CHssSrvNotifications::DoCancel()" );
       
   132     iServer.CancelWaitForNotification();
       
   133     }
       
   134        
       
   135 // ---------------------------------------------------------
       
   136 // CHssSrvNotifications::WaitForNotifications
       
   137 // ---------------------------------------------------------
       
   138 //  
       
   139 void CHssSrvNotifications::WaitForNotifications()
       
   140     {
       
   141     DEBUG( "CHssSrvNotifications::WaitForNotifications()" );
       
   142     iServer.WaitForNotification( iStatus, iDataPckg );    
       
   143     SetActive();
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------
       
   147 // CHssSrvNotifications::Activate
       
   148 // ---------------------------------------------------------
       
   149 //  
       
   150 void CHssSrvNotifications::Activate( MHssSrvNotifications& aCallback )
       
   151     {
       
   152     DEBUG( "CHssSrvNotifications::Activate()" );
       
   153     iCallback = &aCallback;
       
   154     iCancelRequested = EFalse;
       
   155     WaitForNotifications();
       
   156     }
       
   157         
       
   158 // ---------------------------------------------------------
       
   159 // CHssSrvNotifications::SetCancelled
       
   160 // ---------------------------------------------------------
       
   161 //  
       
   162 void CHssSrvNotifications::SetCancelled()
       
   163      {
       
   164      iCancelRequested = ETrue;
       
   165      }