upnp/upnpstack/upnpconnectionmanagersession/src/upnpconnectionmanagersession.cpp
changeset 0 f5a58ecadc66
equal deleted inserted replaced
-1:000000000000 0:f5a58ecadc66
       
     1 /** @file
       
     2 * Copyright (c) 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 "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:  upnpconnectionmanager / client side
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32math.h>
       
    19 #include "upnpconnmanagercommon.h"
       
    20 #include "upnpconnectionmanagersession.h"
       
    21 #include "upnpcustomlog.h"
       
    22 
       
    23 const TInt KServerMessageSlots = 1; //Number of message slots available per session.
       
    24 const TInt KServerRetryCount = 2;
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // RUpnpConnectionManagerSession::RUpnpConnectionManagerSession
       
    28 // C++ default constructor can NOT contain any code, that
       
    29 // might leave.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 RUpnpConnectionManagerSession::RUpnpConnectionManagerSession() :
       
    33     RUpnpSessionBase(), iParameter0( NULL, 0, 0 ), iNetworkEventParameter( NULL, 0, 0 )
       
    34     {
       
    35     // No implementation required
       
    36     }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // RUpnpConnectionManagerSession::Connect
       
    40 // Establish connection to server.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 TInt RUpnpConnectionManagerSession::Connect()
       
    44     {
       
    45     return RUpnpSessionBase::Connect( KUpnpConnectionManagerName,
       
    46              TVersion( KUpnpConnectionManagerMajorVersionNumber,
       
    47                        KUpnpConnectionManagerMinorVersionNumber,
       
    48                        KUpnpConnectionManagerBuildVersionNumber ),
       
    49              KServerMessageSlots,
       
    50              KServerRetryCount,
       
    51              KUpnpConnectionManagerFilename,
       
    52              KServerUid3 );
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // RUpnpConnectionManagerSession::RequestEnsureStartRConnection
       
    57 // Client requests server to ensure RConnection is started.
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 TInt RUpnpConnectionManagerSession::RequestEnsureStartRConnection(
       
    61     TInt& aAccessPoint )
       
    62     {
       
    63     LOG_FUNC_NAME;
       
    64     iParameter0.Set( reinterpret_cast<TUint8*>( &aAccessPoint ),
       
    65                      sizeof( TInt ),
       
    66                      sizeof( TInt ) );
       
    67 
       
    68     return SendReceive( EEnsureStartRConnection, TIpcArgs( &iParameter0 ) );
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // RUpnpConnectionManagerSession::RequestIsRConnectionStarted
       
    73 // Client requests server whether RConnection has been started.
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void RUpnpConnectionManagerSession::RequestIsRConnectionStarted(
       
    77     TBool& aResult )
       
    78     {
       
    79     LOG_FUNC_NAME;
       
    80     iParameter0.Set( reinterpret_cast<TUint8*>( &aResult ), 
       
    81                      sizeof( TBool ),
       
    82                      sizeof( TBool ) );
       
    83 
       
    84     SendReceive( EIsRConnectionStarted, TIpcArgs( &iParameter0 ) );
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // RUpnpConnectionManagerSession::RequestActiveIap
       
    89 // Client requests server for active Iap
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 TInt RUpnpConnectionManagerSession::RequestActiveIap()
       
    93     {
       
    94     LOG_FUNC_NAME;
       
    95     
       
    96     TInt ret = KErrNotFound;
       
    97     
       
    98     iParameter0.Set( reinterpret_cast<TUint8*>( &ret ), 
       
    99                      sizeof( TInt ),
       
   100                      sizeof( TInt ) );
       
   101 
       
   102     SendReceive( ECmActiveIap, TIpcArgs( &iParameter0 ) );
       
   103     
       
   104     return ret;
       
   105     }
       
   106 // -----------------------------------------------------------------------------
       
   107 // RUpnpConnectionManagerSession::RequestLocalAddress
       
   108 // Client requests server for active Iap
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 TInetAddr RUpnpConnectionManagerSession::RequestLocalAddress()
       
   112     {
       
   113     LOG_FUNC_NAME;
       
   114     
       
   115     TInetAddr address = INET_ADDR( 0,0,0,0 );
       
   116     
       
   117     iParameter0.Set( reinterpret_cast<TUint8*>( &address ), 
       
   118                      sizeof( TInetAddr ),
       
   119                      sizeof( TInetAddr ) );
       
   120 
       
   121     SendReceive( ECmGetAddress, TIpcArgs( &iParameter0 ) );
       
   122     
       
   123     return address;
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // RUpnpConnectionManagerSession::RequestSubscribeToNetworkEvents
       
   128 // Client requests subscribe to network events.
       
   129 // -----------------------------------------------------------------------------
       
   130 //    
       
   131 void RUpnpConnectionManagerSession::RequestSubscribeToNetworkEvents( TRequestStatus& aStatus,
       
   132                                             TUpnpConnectionManagerNetworkEvent &aNetworkEvent )
       
   133     {
       
   134     LOG_FUNC_NAME;
       
   135 
       
   136     iNetworkEventParameter.Set( reinterpret_cast<TUint8*>( &aNetworkEvent ),
       
   137                                 sizeof( TUpnpConnectionManagerNetworkEvent ),
       
   138                                 sizeof( TUpnpConnectionManagerNetworkEvent ) );
       
   139     SendReceive( EEventSubscribe, TIpcArgs( &iNetworkEventParameter ), aStatus );
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // RUpnpConnectionManagerSession::RequestCancelSubscribeToNetworkEvents
       
   144 // Client requests cancel subscribe to network events.
       
   145 // -----------------------------------------------------------------------------
       
   146 //  
       
   147 void RUpnpConnectionManagerSession::RequestCancelSubscribeToNetworkEvents()
       
   148     {
       
   149     LOG_FUNC_NAME;
       
   150     SendReceive( ECancelEventSubscribe ); //ignoring returned value
       
   151     }
       
   152     
       
   153 // End of file