harvester/common/src/harvesterblacklist.cpp
changeset 0 c53acadfccc6
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  Keeps a list of files that should not be harvested.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <f32file.h>
       
    20 
       
    21 #include "harvesterlog.h"
       
    22 #include "harvesterblacklist.h"
       
    23 
       
    24 // CHarvesterBlacklist
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // Default constructor for first phase construction.
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CHarvesterBlacklist::CHarvesterBlacklist() 
       
    31     {
       
    32     }
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // Second phase construction
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 void CHarvesterBlacklist::ConstructL() // second-phase constructor
       
    39     {
       
    40     ConnectToBlackListServerL();
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // ConnectToBlackListServerL()
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 void CHarvesterBlacklist::ConnectToBlackListServerL()
       
    48     {
       
    49     User::LeaveIfError( iBlacklistClient.Connect() );
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // The usual NewL()
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CHarvesterBlacklist* CHarvesterBlacklist::NewL()
       
    57     {
       
    58     CHarvesterBlacklist* self = new (ELeave) CHarvesterBlacklist();
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL();
       
    61     CleanupStack::Pop( self );
       
    62     return self;
       
    63     }
       
    64 
       
    65     
       
    66 // ---------------------------------------------------------------------------
       
    67 // Destructor
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 EXPORT_C CHarvesterBlacklist::~CHarvesterBlacklist()
       
    71     {
       
    72     // close connection
       
    73     iBlacklistClient.Close();
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // Adds a file to blacklist with it's URI. Doesn't leave.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 EXPORT_C TInt CHarvesterBlacklist::AddFile( const TDesC& aUri, TUint32 aMediaId, TTime aLastModifiedTime )
       
    81     {
       
    82     TRAPD( err, iBlacklistClient.AddL( aUri, aMediaId, aLastModifiedTime ) );
       
    83     return err;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // Removes a file from the blacklist. Doesn't leave.
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 EXPORT_C TInt CHarvesterBlacklist::RemoveFile( const TDesC& aUri, TUint32 aMediaId )
       
    91     {
       
    92     TRAPD( err, iBlacklistClient.RemoveL( aUri, aMediaId ) );
       
    93     return err;
       
    94     }
       
    95 
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // Checks if a given file is blacklisted. And doesn't leave.
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 EXPORT_C TBool CHarvesterBlacklist::IsBlacklisted( const TDesC& aUri, TUint32 aMediaId, TTime aLastModifiedTime )
       
   102     {
       
   103     TBool isBlacklisted( EFalse );
       
   104     TRAP_IGNORE( isBlacklisted = iBlacklistClient.IsBlacklistedL( aUri, aMediaId, aLastModifiedTime ) );
       
   105     return isBlacklisted;
       
   106     }
       
   107  
       
   108 // ---------------------------------------------------------------------------
       
   109 // Closes database connection.
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 EXPORT_C void CHarvesterBlacklist::CloseDatabase()
       
   113     {
       
   114     TRAP_IGNORE( iBlacklistClient.CloseDBL() );
       
   115     }
       
   116     
       
   117 // ---------------------------------------------------------------------------
       
   118 // Closes database connection.
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 EXPORT_C void CHarvesterBlacklist::OpenDatabase()
       
   122     {
       
   123     TRAP_IGNORE( iBlacklistClient.LoadBlacklistL() );
       
   124     }
       
   125