bearermanagement/mpm/src/rmpm.cpp
changeset 0 5a93021fdf25
child 12 ea6e024ea6f9
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2004-2006 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: MPM server client interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20 @file rmpm.cpp
       
    21 Mobility Policy Manager server client interface.
       
    22 */
       
    23 
       
    24 // INCLUDE FILES
       
    25 #include "rmpm.h"
       
    26 #include "mpmcommon.h"
       
    27 #include "mpmlauncher.h"
       
    28 #include "mpmlogger.h"
       
    29 
       
    30 // ============================= LOCAL FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // Panic 
       
    34 // Panics the client in case of programming error.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 void Panic( TInt aPanic )
       
    38     {
       
    39     User::Panic( KPanicCategory, aPanic );
       
    40     }
       
    41 
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // RMPM::LaunchServer
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 EXPORT_C TInt RMPM::LaunchServer()
       
    50     {
       
    51     return KErrNone;
       
    52     }
       
    53 
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // RMPM::Connect
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C TInt RMPM::Connect(  )
       
    60     {
       
    61     TRequestStatus status;
       
    62     Connect( status );
       
    63     User::WaitForRequest( status );
       
    64     TInt err = status.Int();
       
    65     if ( err != KErrNone )
       
    66         {
       
    67         iConnected = EFalse;
       
    68         MPMLOGSTRING2( "RMPM::Connect - Error <%i> in CreateSession", err )
       
    69         } 
       
    70     return err;
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // RMPM::Connect
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 EXPORT_C void RMPM::Connect( TRequestStatus& aStatus )
       
    78     {
       
    79     TInt err( KErrNone );
       
    80 
       
    81     if ( !iConnected )
       
    82         {
       
    83         MPMLOGSTRING( "RMPM::Connect: Client connecting to MPM Server" )
       
    84         err = CreateSession( 
       
    85                 KMPMServerName,
       
    86                 Version(),
       
    87                 KNumMessageSlots,
       
    88                 EIpcSession_Unsharable,
       
    89                 (TSecurityPolicy*)0,
       
    90                 &aStatus );
       
    91         if ( err != KErrNone )
       
    92             {
       
    93             //Connecting failed, probably because this is the first Connect() attempt.
       
    94             TVersion version = Version();
       
    95             MPMLOGSTRING3("Mobility Policy Manager version %d.%d", version.iMajor, 
       
    96                                                                    version.iMinor )
       
    97             err = MPMLauncher::LaunchServer( KMPMServerImg, 
       
    98                                              KServerUid2, 
       
    99                                              KServerUid3 );
       
   100             if ( err != KErrNone )
       
   101                 {
       
   102                 MPMLOGSTRING2( "RMPM::Connect - Error <%i> in LaunchServer", err )
       
   103                 }
       
   104             else
       
   105                 {
       
   106                 err = CreateSession( 
       
   107                     KMPMServerName,
       
   108                     Version(),
       
   109                     KNumMessageSlots,
       
   110                     EIpcSession_Unsharable,
       
   111                     (TSecurityPolicy*)0,
       
   112                     &aStatus );
       
   113 #ifdef _DEBUG
       
   114                 if (err != KErrNone)
       
   115                     MPMLOGSTRING2( "RMPM::Connect - Error <%i> in CreateSession", err )
       
   116 #endif
       
   117                 }
       
   118             }   
       
   119         
       
   120         //This can't be else, in case the inner CreateSession() succeeds.
       
   121         if (err == KErrNone)
       
   122            {
       
   123            // session ok but waiting for MPM startup.
       
   124            // We have to assume that it'll be ok.
       
   125            TPtr8 ptr( reinterpret_cast< TUint8* >( NULL ), 0 );
       
   126            TBool errFound = EFalse;
       
   127            for (TUint i=0; ( (i < KNumPtrs) && !errFound ); i++)
       
   128                {
       
   129                err = iPtrArray.Append( ptr );
       
   130                if ( err != KErrNone )
       
   131                    {
       
   132                    MPMLOGSTRING2(
       
   133                        "RMPM::Connect - Error <%i> in ptrArray Append", err )
       
   134                     errFound = ETrue;
       
   135                    }
       
   136                }
       
   137            // If everything is fine, set client connected to true.
       
   138            if ( err == KErrNone )
       
   139                {
       
   140                iConnected = ETrue;
       
   141                }
       
   142            // Else close the created session.
       
   143            else
       
   144                {
       
   145                Close();
       
   146                }
       
   147            }
       
   148         }
       
   149     else
       
   150         {
       
   151         MPMLOGSTRING( "RMPM::Connect: Already connected to MPM Server" )
       
   152         err = KErrNone;
       
   153         }
       
   154 
       
   155     // Finally, always complete the failing connects 
       
   156     if ( err != KErrNone )
       
   157         {
       
   158         TRequestStatus* status = &aStatus;
       
   159         User::RequestComplete( status, err );
       
   160         }
       
   161     }
       
   162 
       
   163 
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // RMPM::ChooseBestIAP
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 EXPORT_C void RMPM::ChooseBestIAP( TConnPref&           aConnPref,
       
   170                                    const TConnectionId  aConnId,
       
   171                                    const TUid           aAppUid,
       
   172                                    TConnPref&           aPolicyPref,
       
   173                                    TRequestStatus&      aStatus )
       
   174     {
       
   175     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   176     MPMLOGSTRING( "RMPM::ChooseBestIAP: Client asking iap" )
       
   177 
       
   178     SendReceive( EMPMServerChooseIap,
       
   179                  TIpcArgs( &aConnPref,
       
   180                            aConnId, 
       
   181                            aAppUid.iUid, 
       
   182                            &aPolicyPref ),
       
   183                  aStatus );
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // RMPM::ReselectBestIAP
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 EXPORT_C void RMPM::ReselectBestIAP( const TConnectionId    aConnId,
       
   191                                      TConnPref&             aPolicyPref,
       
   192                                      TRequestStatus&        aStatus ) 
       
   193     {
       
   194     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   195 
       
   196     MPMLOGSTRING( "RMPM::ReselectBestIAP: Client asking iap" )
       
   197 
       
   198     SendReceive( EMPMServerReselectIap,
       
   199                  TIpcArgs( aConnId, &aPolicyPref ),
       
   200                  aStatus );
       
   201     }
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 // RMPM::ApplicationLeavesConnection
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 EXPORT_C TInt RMPM::ApplicationLeavesConnection( const TUint32       aIapId,
       
   208                                                  const TConnectionId aConnId )
       
   209     {
       
   210     TRequestStatus status;
       
   211     ApplicationLeavesConnection( aIapId, aConnId, status );
       
   212     User::WaitForRequest( status );
       
   213     return status.Int();
       
   214     }
       
   215 
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // RMPM::IAPConnectionStopped
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 EXPORT_C TInt RMPM::IAPConnectionStopped( const TUint32         aIapId,
       
   222                                           const TConnectionId   aConnId )
       
   223     {
       
   224     TRequestStatus status;
       
   225     IAPConnectionStopped( aIapId, aConnId, status );
       
   226     User::WaitForRequest( status );
       
   227     return status.Int();
       
   228     }
       
   229 
       
   230 
       
   231 EXPORT_C void RMPM::IAPConnectionStopped( const TUint32         aIapId,
       
   232                                           const TConnectionId   aConnId,
       
   233                                           TRequestStatus&       aStatus )
       
   234     {
       
   235     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   236 
       
   237     TIpcArgs args( aIapId, aConnId );
       
   238 
       
   239     SendReceive( EMPMServerIapConnectionStopped, args, aStatus );
       
   240     }
       
   241 
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // RMPM::ProcessError
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 EXPORT_C void RMPM::ProcessError( TInt&                 aError,
       
   248                                   const TConnectionId   aConnId,
       
   249                                   TBMNeededAction&      aNeededAction,
       
   250                                   TRequestStatus&       aStatus )
       
   251     {
       
   252     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   253 
       
   254     TPtr8& pkg = NextPtr();
       
   255     pkg.Set( reinterpret_cast< TUint8* >( &aError ),
       
   256              sizeof( aError ),
       
   257              sizeof( aError ) );
       
   258 
       
   259     TPtr8& pkgAction = NextPtr();
       
   260     pkgAction.Set( reinterpret_cast< TUint8* >( &aNeededAction ),
       
   261                    sizeof( aNeededAction ),
       
   262                    sizeof( aNeededAction ) );
       
   263 
       
   264     TIpcArgs args( &pkg, aConnId, &pkgAction );
       
   265 
       
   266     SendReceive( EMPMServerProcessError, args, aStatus );
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // RMPM::ProcessError
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 EXPORT_C void RMPM::ProcessError( TConnPref&           /*aConnPref*/,
       
   274                                   TInt&                /*aError*/,
       
   275                                   const TConnectionId  /*aConnId*/,
       
   276                                   TBMNeededAction&     /*aNeededAction*/,
       
   277                                   TRequestStatus&      /*aStatus*/ )
       
   278     {
       
   279     __ASSERT_ALWAYS( EFalse, Panic( KErrNotSupported ) );
       
   280     //-jl- TODO remove this function from the API.
       
   281     }
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // RMPM::RegisterPrefIAPNotif
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 EXPORT_C TInt RMPM::RegisterPrefIAPNotif( const TConnectionId   aConnId )
       
   288     {
       
   289     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   290 
       
   291     TIpcArgs args( aConnId );
       
   292 
       
   293     // SendReceive used here. MPM first sends preferred iap notifs before 
       
   294     // completing this
       
   295     // 
       
   296     TRequestStatus status;
       
   297     RegisterPrefIAPNotif( aConnId, status );
       
   298     User::WaitForRequest( status );
       
   299     return status.Int();
       
   300     }
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // RMPM::RegisterPrefIAPNotif
       
   304 // -----------------------------------------------------------------------------
       
   305 //
       
   306 EXPORT_C void RMPM::RegisterPrefIAPNotif( const TConnectionId   aConnId,
       
   307                                           TRequestStatus&       aStatus )
       
   308     {
       
   309     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   310 
       
   311     TIpcArgs args( aConnId );
       
   312 
       
   313     // SendReceive used here. MPM first sends preferred iap notifs before 
       
   314     // completing this
       
   315     // 
       
   316     return SendReceive( EMPMServerRegisterPrefIAPNotif, args, aStatus );
       
   317     }
       
   318 
       
   319 // -----------------------------------------------------------------------------
       
   320 // RMPM::RegisterPrefIAPNotif
       
   321 // -----------------------------------------------------------------------------
       
   322 //
       
   323 EXPORT_C TInt RMPM::RegisterPrefIAPNotif( const TConnPref&     /*aConnPref*/,
       
   324                                           const TConnectionId  /*aConnId*/ )
       
   325     {
       
   326     __ASSERT_ALWAYS( EFalse, Panic( KErrNotSupported ) );
       
   327     //-jl- TODO remove this function from the API.
       
   328     return NULL;
       
   329     }
       
   330 
       
   331 
       
   332 // -----------------------------------------------------------------------------
       
   333 // RMPM::UnregisterPrefIAPNotif
       
   334 // -----------------------------------------------------------------------------
       
   335 //
       
   336 EXPORT_C void RMPM::UnregisterPrefIAPNotif( const TConnectionId aConnId )
       
   337     {
       
   338     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   339 
       
   340     TIpcArgs args( aConnId );
       
   341 
       
   342     // Server should update the connection state before function returns 
       
   343     // No time consuming activities are done.
       
   344     //
       
   345     TRequestStatus status;
       
   346     UnregisterPrefIAPNotif( aConnId, status );
       
   347     User::WaitForRequest( status );
       
   348     }
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // RMPM::UnregisterPrefIAPNotif
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 EXPORT_C void RMPM::UnregisterPrefIAPNotif( const TConnectionId aConnId,
       
   355                                             TRequestStatus&     aStatus )
       
   356     {
       
   357     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   358 
       
   359     TIpcArgs args( aConnId );
       
   360 
       
   361     // Server should update the connection state before function returns 
       
   362     // No time consuming activities are done.
       
   363     //
       
   364     SendReceive( EMPMServerUnregisterPrefIAPNotif, args, aStatus );
       
   365     }
       
   366 
       
   367 // -----------------------------------------------------------------------------
       
   368 // RMPM::WaitNotification
       
   369 // -----------------------------------------------------------------------------
       
   370 //
       
   371 EXPORT_C void RMPM::WaitNotification( TMPMMessageBuffer& aMpmNotification,
       
   372                                       TRequestStatus&    aStatus )
       
   373     {
       
   374     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   375 
       
   376     TIpcArgs args( &aMpmNotification );
       
   377 
       
   378     SendReceive( EMPMServerWaitNotification, args, aStatus );
       
   379     }
       
   380 
       
   381 
       
   382 // -----------------------------------------------------------------------------
       
   383 // RMPM::SortSNAP
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 EXPORT_C TInt RMPM::SortSNAP( const TUint32     aSNAP, 
       
   387                               TMpmSnapBuffer&   aSortedList )
       
   388     {
       
   389     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   390     TRequestStatus status;
       
   391     SortSNAP( aSNAP, aSortedList, status );
       
   392     User::WaitForRequest( status );
       
   393     return status.Int();
       
   394     }
       
   395 
       
   396 
       
   397 // -----------------------------------------------------------------------------
       
   398 // RMPM::ApplicationJoinsConnection
       
   399 // -----------------------------------------------------------------------------
       
   400 //
       
   401 EXPORT_C TInt RMPM::ApplicationJoinsConnection( const TUint32       aIapId,
       
   402                                                 const TConnectionId aConnId )
       
   403     {
       
   404     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   405     TRequestStatus status;
       
   406     ApplicationJoinsConnection( aIapId, aConnId, status );
       
   407     User::WaitForRequest( status );
       
   408     return status.Int();
       
   409     }
       
   410 
       
   411 // -----------------------------------------------------------------------------
       
   412 // RMPM::IAPConnectionActivated
       
   413 // -----------------------------------------------------------------------------
       
   414 //
       
   415 EXPORT_C TInt RMPM::IAPConnectionActivated( const TUint32       aIapId,
       
   416                                             const TConnectionId aConnId )
       
   417     {
       
   418     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   419 
       
   420     // Server response not necessary for the client, using Send
       
   421     //
       
   422     return Send( EMPMServerIapConnectionActivated, 
       
   423                  TIpcArgs( aIapId, 
       
   424                            aConnId ) );
       
   425     }
       
   426 
       
   427 
       
   428 // -----------------------------------------------------------------------------
       
   429 // RMPM::IAPConnectionStarted
       
   430 // -----------------------------------------------------------------------------
       
   431 //
       
   432 EXPORT_C TInt RMPM::IAPConnectionStarted( const TUint32         aIapId,
       
   433                                           const TConnectionId   aConnId )
       
   434     {
       
   435     TRequestStatus status;
       
   436     IAPConnectionStarted( aIapId, aConnId, status );
       
   437     User::WaitForRequest( status );
       
   438     return status.Int();
       
   439     }
       
   440 
       
   441 
       
   442 EXPORT_C void RMPM::IAPConnectionStarted( const TUint32         aIapId,
       
   443                                           const TConnectionId   aConnId,
       
   444                                           TRequestStatus&       aStatus )
       
   445     {
       
   446     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   447 
       
   448     // Server should update the connection state before function returns 
       
   449     // No time consuming activities are done.
       
   450     //
       
   451     return SendReceive( EMPMServerIapConnectionStarted, 
       
   452                         TIpcArgs( aIapId, aConnId ),
       
   453                         aStatus );
       
   454     }
       
   455 
       
   456 
       
   457 // -----------------------------------------------------------------------------
       
   458 // RMPM::ApplicationConnectionEnds
       
   459 // -----------------------------------------------------------------------------
       
   460 //
       
   461 EXPORT_C TInt RMPM::ApplicationConnectionEnds( const TConnectionId aConnId ) 
       
   462     {
       
   463     TRequestStatus status;
       
   464     ApplicationConnectionEnds( aConnId, status );
       
   465     User::WaitForRequest( status );
       
   466     return status.Int();
       
   467     }
       
   468 
       
   469 
       
   470 // -----------------------------------------------------------------------------
       
   471 // RMPM::ApplicationMigratesToCarrier
       
   472 // -----------------------------------------------------------------------------
       
   473 //
       
   474 EXPORT_C TInt RMPM::ApplicationMigratesToCarrier( 
       
   475     const TUint32         aIapId,
       
   476     const TConnectionId   aConnId )
       
   477     {
       
   478     TRequestStatus status;
       
   479     ApplicationMigratesToCarrier( aIapId, aConnId, status );
       
   480     User::WaitForRequest( status );
       
   481     return status.Int();
       
   482     }
       
   483 
       
   484 
       
   485 // -----------------------------------------------------------------------------
       
   486 // RMPM::ApplicationIgnoredTheCarrier
       
   487 // -----------------------------------------------------------------------------
       
   488 //
       
   489 EXPORT_C TInt RMPM::ApplicationIgnoredTheCarrier( 
       
   490     const TUint32         aIapId,
       
   491     const TConnectionId   aConnId )
       
   492     {
       
   493     TRequestStatus status;
       
   494     ApplicationIgnoredTheCarrier( aIapId, aConnId, status );
       
   495     User::WaitForRequest( status );
       
   496     return status.Int();
       
   497     }
       
   498 
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 // RMPM::ApplicationAcceptedTheCarrier
       
   502 // -----------------------------------------------------------------------------
       
   503 //
       
   504 EXPORT_C TInt RMPM::ApplicationAcceptedTheCarrier( 
       
   505     const TUint32        aIapId,
       
   506     const TConnectionId  aConnId )
       
   507     {
       
   508     TRequestStatus status;
       
   509     ApplicationAcceptedTheCarrier( aIapId, aConnId, status );
       
   510     User::WaitForRequest( status );
       
   511     return status.Int();
       
   512     }
       
   513 
       
   514 
       
   515 // -----------------------------------------------------------------------------
       
   516 // RMPM::ApplicationRejectedTheCarrier
       
   517 // -----------------------------------------------------------------------------
       
   518 //
       
   519 EXPORT_C TInt RMPM::ApplicationRejectedTheCarrier( 
       
   520     const TUint32        aIapId,
       
   521     const TConnectionId  aConnId )
       
   522     {
       
   523     TRequestStatus status;
       
   524     ApplicationRejectedTheCarrier( aIapId, aConnId, status );
       
   525     User::WaitForRequest( status );
       
   526     return status.Int();
       
   527     }
       
   528 
       
   529 
       
   530 // -----------------------------------------------------------------------------
       
   531 // RMPM::EasyWlanSsid
       
   532 // -----------------------------------------------------------------------------
       
   533 //
       
   534 EXPORT_C TInt RMPM::EasyWlanSsid( const TWlanSsid& aSSID )
       
   535     {
       
   536     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   537 
       
   538     return SendReceive( EMPMServerEasyWlanSsid, 
       
   539                         TIpcArgs( &aSSID ) );
       
   540     }
       
   541 
       
   542 
       
   543 // -----------------------------------------------------------------------------
       
   544 // RMPM::Version
       
   545 // -----------------------------------------------------------------------------
       
   546 //
       
   547 EXPORT_C TVersion RMPM::Version() const
       
   548     {
       
   549     return TVersion( KMPMServerMajorVersionNumber,
       
   550                      KMPMServerMinorVersionNumber,
       
   551                      KMPMServerBuildVersionNumber );
       
   552     }
       
   553 
       
   554 
       
   555 // -----------------------------------------------------------------------------
       
   556 // RMPM::Cancel
       
   557 // -----------------------------------------------------------------------------
       
   558 //
       
   559 EXPORT_C void RMPM::Cancel( TMpmAsynchCodes aReqToCancel ) const
       
   560     {
       
   561     __ASSERT_ALWAYS( iConnected, Panic(ERMPMPanicClientNotConnected) );
       
   562     MPMLOGSTRING("RMPM::Cancel: Client canceling the request")
       
   563     SendReceive( EMPMServerCancelRequest, TIpcArgs( aReqToCancel ) );
       
   564     }
       
   565 
       
   566 
       
   567 // -----------------------------------------------------------------------------
       
   568 // RMPM::Close
       
   569 // -----------------------------------------------------------------------------
       
   570 //
       
   571 EXPORT_C void RMPM::Close()
       
   572     {
       
   573     MPMLOGSTRING("RMPM::Close: Client closing connection")
       
   574 
       
   575     iPtrArray.Close() ;
       
   576     iConnected = EFalse;
       
   577 
       
   578     RSessionBase::Close();
       
   579     }
       
   580 
       
   581 
       
   582 // -----------------------------------------------------------------------------
       
   583 // RMPM::Connected
       
   584 // -----------------------------------------------------------------------------
       
   585 //
       
   586 EXPORT_C TBool RMPM::Connected()
       
   587     {
       
   588     return iConnected;
       
   589     }
       
   590 
       
   591 
       
   592 // -----------------------------------------------------------------------------
       
   593 // RMPM::ApplicationJoinsConnection
       
   594 // -----------------------------------------------------------------------------
       
   595 //
       
   596 EXPORT_C void RMPM::ApplicationJoinsConnection( const TUint32       aIapId,
       
   597                                                 const TConnectionId aConnId,
       
   598                                                 TRequestStatus&     aStatus )
       
   599     {
       
   600     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   601 
       
   602     // Server should update the connection state before function returns 
       
   603     // No time consuming activities are done.
       
   604     //
       
   605     return SendReceive( EMPMServerApplicationJoinsConnection, 
       
   606                         TIpcArgs( aIapId, aConnId ),
       
   607                         aStatus );
       
   608     }
       
   609 
       
   610 
       
   611 // -----------------------------------------------------------------------------
       
   612 // RMPM::ApplicationLeavesConnection
       
   613 // -----------------------------------------------------------------------------
       
   614 //
       
   615 EXPORT_C void RMPM::ApplicationLeavesConnection( const TUint32       aIapId,
       
   616                                                  const TConnectionId aConnId,
       
   617                                                  TRequestStatus&     aStatus )
       
   618     {
       
   619     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   620 
       
   621     TIpcArgs args( aIapId, aConnId );
       
   622 
       
   623     return SendReceive( EMPMServerApplicationLeavesConnection, args, aStatus );
       
   624     }
       
   625 
       
   626 
       
   627 // -----------------------------------------------------------------------------
       
   628 // RMPM::ApplicationConnectionEnds
       
   629 // -----------------------------------------------------------------------------
       
   630 //
       
   631 EXPORT_C void RMPM::ApplicationConnectionEnds( const TConnectionId aConnId,
       
   632                                                TRequestStatus&     aStatus ) 
       
   633     {
       
   634     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   635 
       
   636     // Server should update the connection state before function returns 
       
   637     // No time consuming activities are done.
       
   638     //
       
   639     return SendReceive( EMPMServerApplicationConnectionEnds, 
       
   640                         TIpcArgs( aConnId ), aStatus );
       
   641     }
       
   642 
       
   643 
       
   644 // -----------------------------------------------------------------------------
       
   645 // RMPM::SendCancelRequest
       
   646 // -----------------------------------------------------------------------------
       
   647 //
       
   648 EXPORT_C TInt RMPM::SendCancelRequest( TMpmAsynchCodes aReqToCancel ) const
       
   649     {
       
   650     __ASSERT_ALWAYS( iConnected, Panic(ERMPMPanicClientNotConnected) );
       
   651     MPMLOGSTRING("RMPM::SendCancelRequest: Client canceling the request")
       
   652     // There must always be one free slot.
       
   653     return Send( EMPMServerCancelRequest, TIpcArgs( aReqToCancel ) );
       
   654     }
       
   655 
       
   656 
       
   657 // -----------------------------------------------------------------------------
       
   658 // RMPM::ApplicationMigratesToCarrier
       
   659 // -----------------------------------------------------------------------------
       
   660 //
       
   661 EXPORT_C void RMPM::ApplicationMigratesToCarrier( const TUint32         aIapId,
       
   662                                                   const TConnectionId   aConnId,
       
   663                                                   TRequestStatus&       aStatus )
       
   664     {
       
   665     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   666 
       
   667     return SendReceive( EMPMServerApplicationMigratesToCarrier,  
       
   668                         TIpcArgs( aIapId, aConnId ), 
       
   669                         aStatus );
       
   670     }
       
   671 
       
   672 
       
   673 // -----------------------------------------------------------------------------
       
   674 // RMPM::ApplicationIgnoredTheCarrier
       
   675 // -----------------------------------------------------------------------------
       
   676 //
       
   677 EXPORT_C void RMPM::ApplicationIgnoredTheCarrier( const TUint32         aIapId,
       
   678                                                   const TConnectionId   aConnId,
       
   679                                                   TRequestStatus&       aStatus )
       
   680     {
       
   681     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   682 
       
   683     // SendReceive used here. MPM sends preferred iap or error notification 
       
   684     // before completing this
       
   685     // 
       
   686     return SendReceive( EMPMServerApplicationIgnoredTheCarrier,  
       
   687                         TIpcArgs( aIapId, aConnId ), 
       
   688                         aStatus );
       
   689     }
       
   690 
       
   691 
       
   692 // -----------------------------------------------------------------------------
       
   693 // RMPM::ApplicationAcceptedTheCarrier
       
   694 // -----------------------------------------------------------------------------
       
   695 //
       
   696 EXPORT_C void RMPM::ApplicationAcceptedTheCarrier( const TUint32        aIapId,
       
   697                                                    const TConnectionId  aConnId,
       
   698                                                    TRequestStatus&      aStatus )
       
   699     {
       
   700     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   701 
       
   702     // Server should update the connection state before function returns 
       
   703     // No time consuming activities are done.
       
   704     //
       
   705     return SendReceive( EMPMServerApplicationAcceptedTheCarrier, 
       
   706                         TIpcArgs( aIapId, aConnId ),
       
   707                         aStatus );
       
   708     }
       
   709 
       
   710 
       
   711 // -----------------------------------------------------------------------------
       
   712 // RMPM::ApplicationRejectedTheCarrier
       
   713 // -----------------------------------------------------------------------------
       
   714 //
       
   715 EXPORT_C void RMPM::ApplicationRejectedTheCarrier( const TUint32        aIapId,
       
   716                                                    const TConnectionId  aConnId,
       
   717                                                    TRequestStatus&      aStatus )
       
   718     {
       
   719     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   720 
       
   721     // SendReceive used here. MPM sends preferred iap or error notifications 
       
   722     // before completing this
       
   723     // 
       
   724     return SendReceive( EMPMServerApplicationRejectedTheCarrier, 
       
   725                         TIpcArgs( aIapId, aConnId ),
       
   726                         aStatus);
       
   727     }
       
   728 
       
   729 // -----------------------------------------------------------------------------
       
   730 // RMPM::SortSNAP
       
   731 // -----------------------------------------------------------------------------
       
   732 //
       
   733 EXPORT_C void RMPM::SortSNAP( const TUint32   aSNAP, 
       
   734                               TMpmSnapBuffer& aSortedList,
       
   735                               TRequestStatus& aStatus,
       
   736                               const TUint32   aMaxAgeSeconds )
       
   737     {
       
   738     __ASSERT_ALWAYS( iConnected, Panic( ERMPMPanicClientNotConnected ) );
       
   739 
       
   740     TPtr8 n( reinterpret_cast< TUint8* >( &aSortedList ), sizeof( aSortedList ) );
       
   741     TIpcArgs args( aSNAP, &n, aMaxAgeSeconds );
       
   742 
       
   743     // Server response is needed before returning from the call
       
   744     //
       
   745     return SendReceive( EMPMServerSortSNAP, args, aStatus );
       
   746     }
       
   747 
       
   748 // -----------------------------------------------------------------------------
       
   749 // RMPM::NextPtr
       
   750 // -----------------------------------------------------------------------------
       
   751 //
       
   752 TPtr8& RMPM::NextPtr()
       
   753     {
       
   754     __ASSERT_ALWAYS( iConnected, Panic(ERMPMPanicClientNotConnected) );
       
   755 
       
   756     if ( iIndex >= iPtrArray.Count() )
       
   757         {
       
   758         iIndex = 0;
       
   759         }
       
   760 
       
   761     return iPtrArray[ iIndex++ ];
       
   762     }
       
   763 
       
   764 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   765 
       
   766 //  End of File