wlan_bearer/wlanengine/wlan_symbian/wlanengine_symbian_3.1/src/wlmsession.cpp
changeset 0 c40eb8fe8501
child 3 6524e815f76f
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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 the License "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:  Session class is required by the client/server framework
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 23 %
       
    20 */
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "wlmsession.h"
       
    24 #include "genscanlist.h"
       
    25 #include "wlmserver.h"
       
    26 #include "am_debug.h"
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CWlmSession::CWlmSession
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CWlmSession::CWlmSession(
       
    37     CWlmServer& aServer ) :
       
    38     iId( 0 ),
       
    39     iWlmServer( aServer ),
       
    40     iIsNotificationRequestPending( EFalse ),
       
    41     iNotificationHandle( NULL )
       
    42     {
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CWlmSession::ConstructL
       
    47 // Symbian 2nd phase constructor can leave.
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 void CWlmSession::ConstructL()
       
    51     {
       
    52     iPendingNotifications.Reset();
       
    53     iId = iWlmServer.NotifySessionCreated();
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CWlmSession::NewL
       
    58 // Two-phased constructor.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CWlmSession* CWlmSession::NewL(
       
    62     CWlmServer& aServer )
       
    63     {
       
    64     CWlmSession* self = new( ELeave ) CWlmSession( aServer );
       
    65     CleanupStack::PushL( self );
       
    66     self->ConstructL();
       
    67     CleanupStack::Pop( self );
       
    68     return self;
       
    69     }
       
    70     
       
    71 // Destructor
       
    72 CWlmSession::~CWlmSession()
       
    73     {
       
    74     iPendingNotifications.Close();
       
    75 
       
    76     if( iNotificationHandle )
       
    77         {
       
    78         iWlmServer.NotifyRemove( *iNotificationHandle );
       
    79         delete iNotificationHandle;
       
    80         }
       
    81     iWlmServer.NotifySessionClosed( iId );
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // CWlmSession::ServiceL
       
    86 // ---------------------------------------------------------
       
    87 //
       
    88 void CWlmSession::ServiceL(
       
    89     const RMessage2& aMessage )
       
    90     {    
       
    91     DEBUG1( "CWlmSession: Function %d received", aMessage.Function() );
       
    92 #ifdef _DEBUG    
       
    93     TInt totalAllocated = 0;
       
    94     TInt cellCount = User::AllocSize( totalAllocated );
       
    95     DEBUG2("WLMSERVER MEMORYINFO: mem allocated == %d, cellcount == %d",
       
    96         totalAllocated, cellCount );
       
    97 #endif // _DEBUG
       
    98 
       
    99     TInt cmd = aMessage.Function();
       
   100     switch ( cmd )
       
   101         {
       
   102         case EOrderNotifications:
       
   103             HandleOrderNotifications( aMessage );
       
   104             break;
       
   105         // --------------------------------------------------------------------
       
   106         case ECancelNotifications:
       
   107             HandleCancelNotifications( aMessage );
       
   108             break;
       
   109         // --------------------------------------------------------------------
       
   110         case EGetScanResults:
       
   111             iWlmServer.GetScanResult( iId, aMessage );
       
   112             break;
       
   113         // --------------------------------------------------------------------
       
   114         case ECancelGetScanResults:
       
   115             iWlmServer.CancelGetScanResult( iId, aMessage );
       
   116             break;
       
   117         // --------------------------------------------------------------------
       
   118         case EJoinByProfileId:
       
   119             // Joining/creating network requires capabilities
       
   120             aMessage.HasCapabilityL( ECapabilityNetworkServices );
       
   121             iWlmServer.Connect( iId, aMessage );
       
   122             break;
       
   123         // --------------------------------------------------------------------
       
   124         case ECancelJoin:
       
   125             iWlmServer.CancelConnect( iId, aMessage );
       
   126             break;
       
   127         // --------------------------------------------------------------------
       
   128         case EReset:
       
   129             // Releasing network connections requires capabilities
       
   130             aMessage.HasCapabilityL( ECapabilityNetworkServices );
       
   131             iWlmServer.ReleaseComplete( iId, aMessage );
       
   132             break;
       
   133         // --------------------------------------------------------------------
       
   134         case EGetAvailableIaps:
       
   135             iWlmServer.GetAvailableIaps( iId, aMessage );
       
   136             break;
       
   137         // --------------------------------------------------------------------
       
   138         case ECancelGetAvailableIaps:
       
   139             iWlmServer.CancelGetAvailableIaps( iId, aMessage );
       
   140             break;
       
   141         // --------------------------------------------------------------------
       
   142         case EGetCurrentState:
       
   143             iWlmServer.GetConnectionState( iId, aMessage );
       
   144             break;
       
   145         // --------------------------------------------------------------------
       
   146         case EGetCurrentRSSI:
       
   147             iWlmServer.GetCurrentRCPI( iId, aMessage );
       
   148             break;
       
   149         // --------------------------------------------------------------------
       
   150         case EGetMacAddress:
       
   151             iWlmServer.GetCurrentBSSID( iId, aMessage );
       
   152             break;
       
   153         // --------------------------------------------------------------------
       
   154         case EGetNetworkName:
       
   155             iWlmServer.GetCurrentSSID( iId, aMessage );
       
   156             break;
       
   157         // --------------------------------------------------------------------
       
   158         case EGetSecurityMode:
       
   159             iWlmServer.GetCurrentSecurityMode( iId, aMessage );
       
   160             break;
       
   161         // --------------------------------------------------------------------
       
   162         case EGetSystemMode:
       
   163             iWlmServer.GetCurrentSystemMode( iId, aMessage );
       
   164             break;
       
   165         // --------------------------------------------------------------------
       
   166         case ENotifyChangedSettings:
       
   167             iWlmServer.NotifyChangedSettings( iId, aMessage );
       
   168             break;        
       
   169         // --------------------------------------------------------------------
       
   170         case EAddBssidToRoguelist:
       
   171             iWlmServer.AddBssidToRoguelist( iId, aMessage );
       
   172             break;        
       
   173         // --------------------------------------------------------------------
       
   174         case EUpdateRcpNotificationBoundaries:
       
   175             iWlmServer.UpdateRcpNotificationBoundary( iId, aMessage );
       
   176             break;        
       
   177         // --------------------------------------------------------------------
       
   178         case EConfigureMulticastGroup:
       
   179             iWlmServer.ConfigureMulticastGroup( iId, aMessage );
       
   180             break;        
       
   181         // --------------------------------------------------------------------
       
   182         case EGetPacketStatistics:
       
   183             iWlmServer.GetPacketStatistics( iId, aMessage );
       
   184             break;        
       
   185         // --------------------------------------------------------------------
       
   186         case EClearPacketStatistics:
       
   187             iWlmServer.ClearPacketStatistics( iId, aMessage );
       
   188             break;        
       
   189         // --------------------------------------------------------------------
       
   190         case EGetUapsdSettings:
       
   191             iWlmServer.GetUapsdSettings( iId, aMessage );
       
   192             break;        
       
   193         // --------------------------------------------------------------------
       
   194         case ESetUapsdSettings:
       
   195             iWlmServer.SetUapsdSettings( iId, aMessage );
       
   196             break;
       
   197         // --------------------------------------------------------------------
       
   198         case EGetPowerSaveSettings:
       
   199             iWlmServer.GetPowerSaveSettings( iId, aMessage );
       
   200             break;
       
   201         // --------------------------------------------------------------------
       
   202         case ESetPowerSaveSettings:
       
   203             iWlmServer.SetPowerSaveSettings( iId, aMessage );
       
   204             break;
       
   205         // --------------------------------------------------------------------
       
   206         case ERunProtectedSetup:
       
   207             iWlmServer.RunProtectedSetup( iId, aMessage );
       
   208             break;
       
   209         // --------------------------------------------------------------------
       
   210         case ECancelProtectedSetup:
       
   211             iWlmServer.CancelProtectedSetup( iId, aMessage );
       
   212             break;
       
   213         // --------------------------------------------------------------------
       
   214         case ECreateTrafficStream:
       
   215             iWlmServer.CreateTrafficStream( iId, aMessage );
       
   216             break;
       
   217         // --------------------------------------------------------------------
       
   218         case ECancelCreateTrafficStream:
       
   219             iWlmServer.CancelCreateTrafficStream( iId, aMessage );
       
   220             break;
       
   221         // --------------------------------------------------------------------
       
   222         case EDeleteTrafficStream:
       
   223             iWlmServer.DeleteTrafficStream( iId, aMessage );
       
   224             break;
       
   225         // --------------------------------------------------------------------
       
   226         case ECancelDeleteTrafficStream:
       
   227             iWlmServer.CancelDeleteTrafficStream( iId, aMessage );
       
   228             break;
       
   229         // --------------------------------------------------------------------
       
   230         case EGetAccessPointInfo:
       
   231             iWlmServer.GetAccessPointInfo( iId, aMessage );
       
   232             break;
       
   233         // --------------------------------------------------------------------
       
   234         case EGetRoamMetrics:
       
   235             iWlmServer.GetRoamMetrics( iId, aMessage );
       
   236             break;
       
   237         // --------------------------------------------------------------------
       
   238         case EGetRogueList:
       
   239             iWlmServer.GetRogueList( iId, aMessage );
       
   240             break;
       
   241             // --------------------------------------------------------------------
       
   242         case EGetRegulatoryDomain:
       
   243             iWlmServer.GetRegulatoryDomain( iId, aMessage );
       
   244             break;
       
   245         // --------------------------------------------------------------------
       
   246         case EGetPowerSaveMode:
       
   247             iWlmServer.GetPowerSaveMode( iId, aMessage );
       
   248             break;
       
   249         // --------------------------------------------------------------------
       
   250         case EAddIapSsidList:
       
   251             iWlmServer.AddIapSsidListL( iId, aMessage );
       
   252             break;
       
   253         // --------------------------------------------------------------------
       
   254         case ERemoveIapSsidList:
       
   255             iWlmServer.RemoveIapSsidListL( iId, aMessage );
       
   256             break;      
       
   257         // --------------------------------------------------------------------
       
   258         case ESetPowerSaveMode:
       
   259             iWlmServer.SetPowerSaveMode( iId, aMessage );
       
   260             break;
       
   261         // --------------------------------------------------------------------
       
   262         case ENotifyChangedPsmSrvMode:
       
   263             iWlmServer.NotifyChangedPsmSrvMode( iId, aMessage );
       
   264             break;
       
   265         // --------------------------------------------------------------------
       
   266         case EGetAcTrafficStatus:
       
   267             iWlmServer.GetAcTrafficStatus( iId, aMessage );
       
   268             break;                
       
   269         // --------------------------------------------------------------------
       
   270         case EDirectedRoam:
       
   271             iWlmServer.DirectedRoam( iId, aMessage );
       
   272             break;
       
   273         // --------------------------------------------------------------------
       
   274         case ECancelDirectedRoam:
       
   275             iWlmServer.CancelDirectedRoam( iId, aMessage );
       
   276             break;        
       
   277         // --------------------------------------------------------------------
       
   278         default:
       
   279             aMessage.Complete( KErrNotSupported );
       
   280         }
       
   281     }
       
   282 
       
   283 // ---------------------------------------------------------
       
   284 // CWlmSession::HandleOrderNotifications
       
   285 // ---------------------------------------------------------
       
   286 //
       
   287 void CWlmSession::HandleOrderNotifications(
       
   288     const RMessage2& aMessage )
       
   289     {
       
   290     iPendingNotificationRequest = aMessage;
       
   291     iIsNotificationRequestPending = ETrue;
       
   292     if( !iNotificationHandle ) // == NULL i.e. is not activated
       
   293         {
       
   294         TRAPD( err, iNotificationHandle =
       
   295             CSessionNotification::NewL( *this, aMessage.Int1() ) );
       
   296         if ( err == KErrNone )
       
   297             {
       
   298             iWlmServer.NotifyAdd( *iNotificationHandle );
       
   299             }
       
   300         else
       
   301             {
       
   302             iIsNotificationRequestPending = EFalse;
       
   303             aMessage.Complete( err );
       
   304             return;
       
   305             }
       
   306         }
       
   307     HandleNotification(); // check is there any unsent notifications
       
   308     }
       
   309 
       
   310 // ---------------------------------------------------------
       
   311 // CWlmSession::HandleCancelNotifications
       
   312 // ---------------------------------------------------------
       
   313 //
       
   314 void CWlmSession::HandleCancelNotifications(
       
   315     const RMessage2& aMessage )
       
   316     {
       
   317     if( iIsNotificationRequestPending )
       
   318         {
       
   319         iPendingNotificationRequest.Complete( EWlmNotifyNotificationsCancelled );
       
   320         iIsNotificationRequestPending = EFalse;
       
   321         iPendingNotifications.Reset();
       
   322         }
       
   323     if( iNotificationHandle )
       
   324         {
       
   325         iWlmServer.NotifyRemove( *iNotificationHandle );
       
   326         delete iNotificationHandle;
       
   327         iNotificationHandle = NULL;
       
   328         }
       
   329     aMessage.Complete( KErrNone );
       
   330     }
       
   331         
       
   332 // ---------------------------------------------------------
       
   333 // CWlmSession::AddNotification
       
   334 // ---------------------------------------------------------
       
   335 //
       
   336 void CWlmSession::AddNotification(
       
   337     TInt aNotification,
       
   338     const TDesC8& aData )
       
   339     {
       
   340     DEBUG( "CWlmSession::AddNotification" );
       
   341 
       
   342     TNotification notif;
       
   343     notif.id = aNotification;
       
   344     notif.data = aData;
       
   345 
       
   346     iPendingNotifications.Append( notif );
       
   347     HandleNotification(); // check is there client waiting for notification
       
   348     }
       
   349 
       
   350 // ---------------------------------------------------------
       
   351 // CWlmSession::HandleNotification
       
   352 // ---------------------------------------------------------
       
   353 //
       
   354 void CWlmSession::HandleNotification()
       
   355     {
       
   356     DEBUG( "CWlmSession::HandleNotification" );
       
   357 
       
   358     // Check is there message to wait notification and 
       
   359     // notification that is not sent.
       
   360     if ( iIsNotificationRequestPending && iPendingNotifications.Count() != 0 )
       
   361         {
       
   362         DEBUG( "CWlmSession::HandleNotification - sending response..." );
       
   363         iIsNotificationRequestPending = EFalse;
       
   364 
       
   365         TPckgBuf<TWlmNotifyData> pckg;
       
   366         pckg().data = iPendingNotifications[0].data;
       
   367         TInt ret( iPendingNotificationRequest.Write( 0, pckg ) );
       
   368         if ( ret != KErrNone )
       
   369             {
       
   370             iPendingNotificationRequest.Complete( ret );
       
   371             return;
       
   372             }
       
   373         iPendingNotificationRequest.Complete( iPendingNotifications[0].id );
       
   374         iPendingNotifications.Remove( 0 );
       
   375         }
       
   376     }
       
   377 
       
   378 //  End of File