javamanager/javacaptain/extensionplugins/javacertstore/src.linux/metadatafilehandler.cpp
branchRCL_3
changeset 14 04becd199f91
child 17 0fd27995241b
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2007-2007 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "metadatafilehandler.h"
       
    20 
       
    21 namespace java
       
    22 {
       
    23 namespace security
       
    24 {
       
    25 
       
    26 bool JavaCertStoreMetadataFileHandler::writeState(std::string aFilePath, int aState)
       
    27 {
       
    28     FILE * stateFile = fopen(aFilePath.c_str(), "w+");
       
    29     if (stateFile != NULL)
       
    30     {
       
    31         fprintf(stateFile, "%d\n", aState);
       
    32         fclose(stateFile);
       
    33         return true;
       
    34     }
       
    35     return false;
       
    36 }
       
    37 
       
    38 int JavaCertStoreMetadataFileHandler::readState(std::string aFilePath)
       
    39 {
       
    40     int state = STATE_UNDEFINED;
       
    41     FILE * stateFile = fopen(aFilePath.c_str(), "r");
       
    42     if (stateFile != NULL)
       
    43     {
       
    44         int tmp = getc(stateFile);
       
    45         switch (tmp - 48)
       
    46         {
       
    47         case STATE_ENABLED:
       
    48         case STATE_DISABLED:
       
    49         case STATE_DELETED:
       
    50             state = tmp - 48;
       
    51             break;
       
    52         }
       
    53     }
       
    54     return state;
       
    55 }
       
    56 
       
    57 } //end namespace security
       
    58 } //end namespace java