upnpsharing/upnpsecurity/inc/server/upnpsecuritymanagerengine.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /** @file
       
     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:  CUpnpSecurityManagerEngine
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef C_CUPNPSECURITYMANAGERENGINE_H
       
    19 #define C_CUPNPSECURITYMANAGERENGINE_H
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 #include "upnpsecuritymanagerclientsession.h"
       
    24 
       
    25 // ENUMS
       
    26 // Properties keys
       
    27 enum TUPnPSecurityManagerProperties
       
    28     {
       
    29     EUPnPSecManFirstRun
       
    30     };
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CUpnpSecurityDbConnection;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38  * 
       
    39  */
       
    40 class CUpnpSecurityManagerEngine : public CBase
       
    41     {
       
    42 public:
       
    43 
       
    44     /**
       
    45      * A two-phased constructor function.
       
    46      * @result A new instance of CUpnpSecurityManagerEngine
       
    47      */
       
    48     static CUpnpSecurityManagerEngine* NewL();
       
    49 
       
    50     /**
       
    51      * Destructor function.
       
    52      */
       
    53     virtual ~CUpnpSecurityManagerEngine();
       
    54 
       
    55 public:
       
    56     /**
       
    57      * Adds new file to allowed file array, if not existing yet.
       
    58      * @param aFileName (const TDesC&) file path+name to new allowed file
       
    59      */
       
    60     void AddNewFileL( const TDesC& aFileName );
       
    61 
       
    62     /**
       
    63      * Removes file from allowed array.
       
    64      * @param aFileName (const TDesC&) File path+name to file to be removed
       
    65      */
       
    66     void RemoveFileL( const TDesC& aFileName );
       
    67 
       
    68     /**
       
    69      * Adds new address to allowed address array, if not existing yet.
       
    70      * @param aIpAddress (const TInetAddr&) containing IP Address of the
       
    71      *        remote party
       
    72      */
       
    73     void AddNewAddressL( const TInetAddr& aIpAddress );
       
    74 
       
    75     /**
       
    76      * Removes address from allowed array.
       
    77      * @param (const TInetAddr&) aIpAddress containing IP Address to be
       
    78      *        removed
       
    79      */
       
    80     void RemoveAddressL( const TInetAddr& aIpAddress );
       
    81 
       
    82     /**
       
    83      * Remove all files from allowed array
       
    84      */
       
    85     void ResetFileListL();
       
    86 
       
    87     /**
       
    88      * Remove all addresses from allowed array
       
    89      */
       
    90     void ResetAddressListL();
       
    91 
       
    92     /**
       
    93      * Check if ipaddress and filename is on allowed list
       
    94      */
       
    95     TAccessType CheckAuthorization( const TInetAddr& aIpAddress,
       
    96         const TDesC& aFileName );
       
    97 
       
    98     /**
       
    99      * Shows authorisation query to end user, and add address to allowed list
       
   100      * if user accepted it
       
   101      */
       
   102     TAccessType ShowAuthorisationQueryL( const TInetAddr& aIpAdress );
       
   103 
       
   104 private:
       
   105     /**
       
   106      * Default constructor.
       
   107      */
       
   108     CUpnpSecurityManagerEngine();
       
   109 
       
   110     /**
       
   111      * 2nd phase constructor.
       
   112      */
       
   113     void ConstructL();
       
   114 
       
   115     /**
       
   116      * 
       
   117      */
       
   118     void ResetListsOnFirstRunL();
       
   119 
       
   120 private:
       
   121 
       
   122     /**
       
   123      * Finds file from allowed array
       
   124      * @param (const TDesC&) aFileName File path+name to file to search
       
   125      * @return TInt, index to array. KErrNotFound, if file cannot be found.
       
   126      */
       
   127     TInt FindFileFromArray( const TDesC& aFileName );
       
   128 
       
   129     /**
       
   130      * Finds address from array
       
   131      * @param aIpAddress (const TInetAddr&) containing IP Address to be
       
   132      *        searched
       
   133      * @return TInt, index to array. KErrNotFound, if file cannot be found.
       
   134      */
       
   135     TInt FindAddressFromArray( const TInetAddr& aIpAddress );
       
   136 
       
   137 private:
       
   138     // Member variables
       
   139 
       
   140     // Array for allowed files. Owned.
       
   141     RPointerArray<HBufC> iAllowedFiles;
       
   142 
       
   143     // Array for allowed IP addresses. Owned.
       
   144     RArray<TInetAddr> iAllowedAddresses;
       
   145 
       
   146     // Sqlite connection wrapper.
       
   147     CUpnpSecurityDbConnection* iDbConnection;
       
   148     };
       
   149 
       
   150 #endif // C_CUPNPSECURITYMANAGERENGINE_H
       
   151 // End of File