browserutilities/favouritesengine/ClientServer/src/FavouritesHandle.cpp
changeset 0 dd21522fd290
child 25 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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 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:  Implementation of class RFavouritesHandle
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "FavouritesHandle.h"
       
    22 #include "FavouritesMsg.h"
       
    23 #include "FavouritesPanic.h"
       
    24 #include "FavouritesLogger.h" 
       
    25 
       
    26 // ================= MEMBER FUNCTIONS =======================
       
    27 
       
    28 // ---------------------------------------------------------
       
    29 // RFavouritesHandle::Close
       
    30 // ---------------------------------------------------------
       
    31 //
       
    32 EXPORT_C void RFavouritesHandle::Close()
       
    33     {
       
    34     if ( iHandle )
       
    35         {
       
    36         (void) SendReceive( EFavengClose );
       
    37         }
       
    38     iSess.SetHandle( 0 );
       
    39     iHandle = 0;
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------
       
    43 // RFavouritesHandle::Open
       
    44 // ---------------------------------------------------------
       
    45 //
       
    46 TInt RFavouritesHandle::Open
       
    47 ( RFavouritesSession& aSess, TInt aFunction, const TIpcArgs& aArgs )
       
    48     {
       
    49     __ASSERT_DEBUG( !iHandle, FavouritesPanic( EFavouritesAlreadyOpen ) );
       
    50     TInt ret = aSess.SendReceive( aFunction, aArgs );
       
    51     __ASSERT_DEBUG( ret, FavouritesPanic( EFavouritesInternal ) );
       
    52     // Positive value -> handle returned.
       
    53     // Negative value -> error returned.
       
    54     if ( ret > 0 )
       
    55         {
       
    56         iSess = aSess;
       
    57         iHandle = ret;
       
    58         ret = KErrNone;
       
    59         }
       
    60     return ret;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------
       
    64 // RFavouritesHandle::Open
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 TInt RFavouritesHandle::Open
       
    68 ( RFavouritesHandle& aHandle, TInt aFunction, const TIpcArgs& aArgs )
       
    69     {
       
    70     __ASSERT_DEBUG( !iHandle, FavouritesPanic( EFavouritesAlreadyOpen ) );
       
    71 //    FLOG(( _L("RFavouritesHandle::Open before SendReceive") ));
       
    72     TInt ret = aHandle.SendReceive( aFunction, aArgs );
       
    73 //    FLOG(( _L("RFavouritesHandle::Open after SendReceive") ));
       
    74     __ASSERT_DEBUG( ret, FavouritesPanic( EFavouritesInternal ) );
       
    75     // Positive value -> handle returned.
       
    76     // Negative value -> error returned.
       
    77     if ( ret > 0 )
       
    78         {
       
    79         FLOG(( _L("RFavouritesHandle::Open() ret>0") ));
       
    80         iSess = aHandle.iSess;
       
    81         iHandle = ret;
       
    82         ret = KErrNone;
       
    83         }
       
    84     return ret;
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 // RFavouritesHandle::SendReceive
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 void RFavouritesHandle::SendReceive
       
    92 ( TInt aFunction, const TIpcArgs& aArgs, TRequestStatus& aStatus ) const
       
    93     {
       
    94     __ASSERT_DEBUG( iHandle, FavouritesPanic( EFavouritesNotReady ) );
       
    95     iSess.SendReceive( TFavouritesMsg( iHandle, aFunction ), aArgs, aStatus );
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // RFavouritesHandle::SendReceive
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 TInt RFavouritesHandle::SendReceive
       
   103 ( TInt aFunction, const TIpcArgs& aArgs ) const
       
   104     {
       
   105     __ASSERT_DEBUG( iHandle, FavouritesPanic( EFavouritesNotReady ) );
       
   106     return iSess.SendReceive( TFavouritesMsg( iHandle, aFunction ), aArgs );
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------
       
   110 // RFavouritesHandle::SendReceive
       
   111 // ---------------------------------------------------------
       
   112 //
       
   113 TInt RFavouritesHandle::SendReceive( TInt aFunction ) const
       
   114     {
       
   115     __ASSERT_DEBUG( iHandle, FavouritesPanic( EFavouritesNotReady ) );
       
   116     return iSess.SendReceive( TFavouritesMsg( iHandle, aFunction ) );
       
   117     }
       
   118 
       
   119 // End of file