browserutilities/favouritesengine/ClientServer/src/FavouritesSession.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: 
       
    15 *      Implementation of class RFavouritesSession
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "FavouritesSession.h"
       
    24 #include "FavouritesSrv.h"
       
    25 #include "FavouritesVersion.h"
       
    26 #include "FavouritesDef.h"
       
    27 #include "FavouritesMsg.h"
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =======================
       
    30 
       
    31 // ---------------------------------------------------------
       
    32 // RFavouritesSession::Version
       
    33 // ---------------------------------------------------------
       
    34 //
       
    35 EXPORT_C TVersion RFavouritesSession::Version()
       
    36     {
       
    37     return TVersion
       
    38         ( KFavouritesMajorVersion, KFavouritesMinorVersion, KFavouritesBuild );
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------
       
    42 // RFavouritesSession::Connect
       
    43 // ---------------------------------------------------------
       
    44 //
       
    45 EXPORT_C TInt RFavouritesSession::Connect()
       
    46     {
       
    47     TInt err = DoConnect();
       
    48     if ( err == KErrNotFound )
       
    49         {
       
    50         err = FavouritesSrv::Start();
       
    51         if ( err != KErrNone && err != KErrAlreadyExists )
       
    52             {
       
    53             ;
       
    54             }
       
    55         else
       
    56             {
       
    57             // Deal with race conditions.
       
    58             err = DoConnect();
       
    59             }
       
    60         }
       
    61     return err;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------
       
    65 // RFavouritesSession::ResourceMark
       
    66 // ---------------------------------------------------------
       
    67 //
       
    68 EXPORT_C void RFavouritesSession::ResourceMark()
       
    69     {
       
    70     (void)SendReceive( TFavouritesMsg( 0, EFavengResourceMarkStart ) );
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------
       
    74 // RFavouritesSession::ResourceCheck
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 EXPORT_C void RFavouritesSession::ResourceCheck()
       
    78     {
       
    79     (void)SendReceive( TFavouritesMsg( 0, EFavengResourceMarkEnd ) );
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // RFavouritesSession::ResourceCount
       
    84 // ---------------------------------------------------------
       
    85 //
       
    86 EXPORT_C TInt RFavouritesSession::ResourceCount()
       
    87     {
       
    88     return SendReceive( TFavouritesMsg( 0, EFavengResourceCount ) );
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------
       
    92 // RFavouritesSession::DeleteDatabase
       
    93 // ---------------------------------------------------------
       
    94 //
       
    95 EXPORT_C TInt RFavouritesSession::DeleteDatabase( const TDesC& aName )
       
    96     {
       
    97     return SendReceive( TFavouritesMsg( 0, EFavengDeleteDatabase ),
       
    98         TIpcArgs( &aName ));
       
    99     }
       
   100 
       
   101 #ifdef _DEBUG
       
   102 
       
   103 // ---------------------------------------------------------
       
   104 // RFavouritesSession::__DbgSetAllocFail
       
   105 // ---------------------------------------------------------
       
   106 //
       
   107 EXPORT_C void RFavouritesSession::__DbgSetAllocFail
       
   108 ( RAllocator::TAllocFail aType, TInt aRate )
       
   109     {
       
   110     TInt type = STATIC_CAST( TInt, aType );
       
   111     (void) SendReceive( TFavouritesMsg( 0, EFavengSetHeapFailure ),
       
   112         TIpcArgs( type, aRate ) );
       
   113     }
       
   114 
       
   115 #else /* not _DEBUG */
       
   116 
       
   117 // ---------------------------------------------------------
       
   118 // RFavouritesSession::__DbgSetAllocFail
       
   119 // ---------------------------------------------------------
       
   120 //
       
   121 EXPORT_C void RFavouritesSession::__DbgSetAllocFail
       
   122 ( RAllocator::TAllocFail /*aType*/, TInt /*aRate*/ )
       
   123     {
       
   124     }
       
   125 
       
   126 #endif /* def _DEBUG */
       
   127 
       
   128 // ---------------------------------------------------------
       
   129 // RFavouritesSession::DoConnect
       
   130 // ---------------------------------------------------------
       
   131 //
       
   132 TInt RFavouritesSession::DoConnect()
       
   133     {
       
   134     return CreateSession( KFavouritesSrvName, Version() );
       
   135     }
       
   136 
       
   137 //  End of File