upnpsharing/upnpsecurity/src/client/upnpsecuritymanagerclientsession.cpp
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:  upnpsecuritymanager / client side
       
    15  *
       
    16  */
       
    17 
       
    18 // INCLUDES
       
    19 #include <e32base.h>
       
    20 #include "upnpsecuritymanagerclientservercommon.h"
       
    21 #include "upnpsecuritymanagerclientsession.h"
       
    22 
       
    23 // CONSTANTS
       
    24 const TInt KServerMessageSlots = 1; //Number of message slots available per session.
       
    25 const TInt KServerRetryCount = 2;
       
    26 
       
    27 // ============================= MEMBER FUNCTIONS ==============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // RUpnpSecurityManagerClientSession::RUpnpSecurityManagerClientSession
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 EXPORT_C RUpnpSecurityManagerClientSession::RUpnpSecurityManagerClientSession() :
       
    36 RUpnpSessionBase()
       
    37     {
       
    38     // No implementation required
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // RUpnpSecurityManagerClientSession::Connect
       
    43 // Establish connection to server.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 EXPORT_C TInt RUpnpSecurityManagerClientSession::Connect()
       
    47     {
       
    48     return RUpnpSessionBase::Connect( KUpnpSecurityManagerName, TVersion(
       
    49                     KUpnpSecurityManagerMajorVersionNumber,
       
    50                     KUpnpSecurityManagerMinorVersionNumber,
       
    51                     KUpnpSecurityManagerBuildVersionNumber ), KServerMessageSlots,
       
    52             KServerRetryCount, KUpnpSecurityManagerFilename, KServerUid3 );
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // RUpnpSecurityManagerClientSession::AddFileL
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C void RUpnpSecurityManagerClientSession::AddFileL(
       
    60         const TDesC& aFileName )
       
    61     {
       
    62     User::LeaveIfError( SendReceive( EAddFile, TIpcArgs( &aFileName ) ) );
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // RUpnpSecurityManagerClientSession::RemoveFileL
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C void RUpnpSecurityManagerClientSession::RemoveFileL(
       
    70         const TDesC& aFileName )
       
    71     {
       
    72     User::LeaveIfError( SendReceive( ERemoveFile, TIpcArgs( &aFileName ) ) );
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // RUpnpSecurityManagerClientSession::AddAddressL
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C void RUpnpSecurityManagerClientSession::AddAddressL(
       
    80         const TInetAddr& aIpAddress )
       
    81     {
       
    82     TPckg<TInetAddr> addressPck( aIpAddress );
       
    83     User::LeaveIfError( SendReceive( EAddAddress, TIpcArgs( &addressPck ) ) );
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // RUpnpSecurityManagerClientSession::RemoveAddressL
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 EXPORT_C void RUpnpSecurityManagerClientSession::RemoveAddressL(
       
    91         const TInetAddr& aIpAddress )
       
    92     {
       
    93     TPckg<TInetAddr> addressPck( aIpAddress );
       
    94     User::LeaveIfError( SendReceive( ERemoveAddress, TIpcArgs( &addressPck ) ) );
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // RUpnpSecurityManagerClientSession::ResetFileListL
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 EXPORT_C void RUpnpSecurityManagerClientSession::ResetFileListL()
       
   102     {
       
   103     User::LeaveIfError( SendReceive( EResetFileList ) );
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // RUpnpSecurityManagerClientSession::ResetAddressListL
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 
       
   111 EXPORT_C void RUpnpSecurityManagerClientSession::ResetAddressListL()
       
   112     {
       
   113     User::LeaveIfError( SendReceive( EResetAddressList ) );
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // RUpnpSecurityManagerClientSession::CheckAuthorizationL
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 EXPORT_C TAccessType RUpnpSecurityManagerClientSession::CheckAuthorizationL(
       
   121         const TInetAddr& aIpAddress, const TDesC& aFileName )
       
   122     {
       
   123     TAccessType accessType = ENoneAllowed;
       
   124     TPckg<TAccessType> accessTypeBuf( accessType );
       
   125     TPckg<TInetAddr> addressPck( aIpAddress );
       
   126     User::LeaveIfError( SendReceive( ECheckAuthorization, TIpcArgs( &addressPck,
       
   127                             &aFileName, &accessTypeBuf ) ) );
       
   128 
       
   129     return accessType;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // RUpnpSecurityManagerClientSession::QueryAuthorisationL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C TAccessType RUpnpSecurityManagerClientSession::QueryAuthorisationL(
       
   137         const TInetAddr& aIpAddress )
       
   138     {
       
   139     TAccessType accessType = ENoneAllowed;
       
   140     TPckg<TAccessType> accessTypeBuf(accessType);
       
   141     TPckg<TInetAddr> addressPck( aIpAddress );
       
   142     User::LeaveIfError( SendReceive( EQueryAuthorisation, TIpcArgs( &addressPck,
       
   143                             &accessTypeBuf ) ) );
       
   144 
       
   145     if ( accessType == ENoneAllowed )
       
   146         {
       
   147         User::Leave( KErrAccessDenied );
       
   148         }
       
   149 
       
   150     return accessType;
       
   151     }
       
   152 
       
   153 //  End of File