javatools/usersettingsconfigurator/src.s60/storagehandler.h
branchRCL_3
changeset 18 9ac0a0a7da70
parent 17 0fd27995241b
child 19 71c436fe3ce0
equal deleted inserted replaced
17:0fd27995241b 18:9ac0a0a7da70
     1 /*
       
     2 * Copyright (c) 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:
       
    15 *
       
    16 */
       
    17 #ifndef STORAGEHANDLER_H
       
    18 #define STORAGEHANDLER_H
       
    19 
       
    20 #include <vector>
       
    21 #include <string>
       
    22 #include <e32base.h>
       
    23 #include <d32dbms.h>
       
    24 #include "javastorage.h"
       
    25 #include "javacommonutils.h"
       
    26 #include "j2me/midp2/security/MSecurityPolicyV2.h"
       
    27 
       
    28 using namespace java::util;
       
    29 using namespace java::storage;
       
    30 
       
    31 namespace java
       
    32 {
       
    33 namespace tools
       
    34 {
       
    35 namespace usersettingsconfigurator
       
    36 {
       
    37 
       
    38 class SecuritySettings
       
    39 {
       
    40 public:
       
    41     SecuritySettings(const std::wstring& aSettingsName,
       
    42                      const std::wstring& aCurrentInteractionMode);
       
    43 
       
    44     SecuritySettings &operator=(const SecuritySettings&);
       
    45     SecuritySettings();
       
    46 
       
    47     std::wstring iName;
       
    48     std::wstring iCurrentInteractionMode;
       
    49 };
       
    50 
       
    51 class CustomAttribute
       
    52 {
       
    53 public:
       
    54     CustomAttribute(const std::wstring& aAttributeName,
       
    55                     const std::wstring& aAttributeValue);
       
    56 
       
    57     CustomAttribute &operator=(const CustomAttribute&);
       
    58     CustomAttribute();
       
    59 
       
    60     std::wstring iName;
       
    61     std::wstring iValue;
       
    62 };
       
    63 
       
    64 class MidletSuiteCustomAttributes
       
    65 {
       
    66 public:
       
    67     MidletSuiteCustomAttributes(const TUint32& aMidletSuiteUid);
       
    68 
       
    69     TUint32 iUid;
       
    70     std::vector<CustomAttribute*> iCustomAttributes;
       
    71 };
       
    72 
       
    73 
       
    74 class MidletSuiteSecuritySettings
       
    75 {
       
    76 public:
       
    77     MidletSuiteSecuritySettings(const TUint32& aMidletSuiteUid,
       
    78                                 const std::wstring& aMidletSuiteName,
       
    79                                 const std::wstring& aMidletSuiteVendor,
       
    80                                 const std::wstring& aMidletSuiteVersion);
       
    81     TUint32 iUid;
       
    82     std::wstring iName;
       
    83     std::wstring iVendor;
       
    84     std::wstring iVersion;
       
    85     std::vector<SecuritySettings*> iSecuritySettings;
       
    86 };
       
    87 
       
    88 class StorageHandler: public CBase
       
    89 {
       
    90 public:
       
    91     static StorageHandler* NewL();
       
    92     void readMidletSuitesPropertiesL(std::vector<MidletSuiteSecuritySettings*>& aMidletSuitesSecuritySettings, std::vector<MidletSuiteCustomAttributes*>& aMidletSuitesCustomAttributes);
       
    93     void writeMidletSuitePropertiesL(const std::vector<MidletSuiteSecuritySettings*>& aMidletSuitesSecuritySettings, const std::vector<MidletSuiteCustomAttributes*>& aMidletSuitesCustomAttributes);
       
    94     void convertAPNSettingsL() const;
       
    95     virtual ~StorageHandler();
       
    96 private:
       
    97     void ConstructL();
       
    98     StorageHandler();
       
    99     void DecodeSecuritySettingsL(const TDesC& aProtectionDomain, const std::string& aEncodedSecuritySettings, std::vector<SecuritySettings*>& aSecuritySettings);
       
   100     void ReadSecuritySettingsL(std::vector<MidletSuiteSecuritySettings*>& aMidletSuitesSecuritySettings);
       
   101     void ReadCustomAttributesL(std::vector<MidletSuiteCustomAttributes*>& aMidletSuitesCustomAttributes);
       
   102     void WriteSecuritySettingsL(const std::vector<MidletSuiteSecuritySettings*>& aMidletSuitesSecuritySettings);
       
   103     void WriteCustomAttributesL(const std::vector<MidletSuiteCustomAttributes*>& aMidletSuitesCustomAttributes);
       
   104     bool IsInteractionModeAllowed(const std::wstring& aInteractionMode, const std::wstring& aAllowedInteractionModes);
       
   105     void findEntry(const JavaStorageApplicationList_t&, const std::wstring&, std::wstring& eValue);
       
   106 
       
   107 private:
       
   108     RDbs iDbs;
       
   109     RDbNamedDatabase iUserDb;
       
   110     RDbTable  iSecurityPreferencesTable;
       
   111     RDbTable  iCustomAttributesTable;
       
   112     // security preferences columns
       
   113     TInt iSPNameColId;
       
   114     TInt iSPVendorColId;
       
   115     TInt iSPVersionColId;
       
   116     TInt iSPDomainColId;
       
   117     TInt iSPPreferencesColId;
       
   118     TInt iSPIdColId;
       
   119     // custom attributes columns
       
   120     TInt iCAIdColId;
       
   121     TInt iCAValueColId;
       
   122     JavaStorage* iStorage;
       
   123     MIDP::MSecurityPolicyV2* iSecurityPolicy;
       
   124 };
       
   125 
       
   126 } //end namespace usersettingsconfigurator
       
   127 } //end namespace tools
       
   128 } // end namespace java
       
   129 #endif // STORAGEHANDLER_H
       
   130