connectivitylayer/isce/p2papi_dll/inc/p2pif.h
changeset 0 63b37f68c1ce
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     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 the License "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 
       
    20 #ifndef __P2PIF_H__
       
    21 #define __P2PIF_H__
       
    22 
       
    23 #include <e32cmn.h>     // For RBusLogicalChannel
       
    24 #include <p2pdefs.h>    // For TP2PProtocol
       
    25 
       
    26 /**
       
    27 * An interface for transceiving point-to-point (P2P) data between
       
    28 * two end points according to used P2P protocol.
       
    29 * Interface is used from user side.
       
    30 */
       
    31 class RP2PIf : public RBusLogicalChannel
       
    32     {
       
    33 
       
    34     public:
       
    35 
       
    36         /*
       
    37         * C++ default constructor.
       
    38         */
       
    39         IMPORT_C RP2PIf();
       
    40 
       
    41         /*
       
    42         * Destructor
       
    43         */
       
    44         IMPORT_C ~RP2PIf();
       
    45 
       
    46         /*
       
    47         * Closes the interface and cancels any outstanding requests with KErrCancel.
       
    48         * If interface is not opened with RP2PIf::Open does nothing.
       
    49         * Automatically called in destructor.
       
    50         * Execution:    Synchronous
       
    51         * Re-entrant:   No
       
    52         * Blocking:     Yes
       
    53         * Panic mode:   User::Panic
       
    54         * SMP safe:     Yes
       
    55         * @post Calling thread not blocked
       
    56         */
       
    57         IMPORT_C void Close();
       
    58 
       
    59         /*
       
    60         * Notifies when connection to other point is lost.
       
    61         * Automatically cancelled in RP2PIf::Close.
       
    62         * All data received after connection is lost shall be discarded.
       
    63         * NOTE! If interface is not open panicked with User::Panic.
       
    64         * NOTE! After connection lost RP2PIf::Close shall be called.
       
    65         * Execution:    Asynchronous
       
    66         * Re-entrant:   No
       
    67         * Blocking:     Yes
       
    68         * Panic mode:   User::Panic
       
    69         * SMP safe:     Yes
       
    70         * @param aStatus, updated when connection is lost
       
    71         *                 KErrNotReady when connection is lost
       
    72         *                 KErrCancel when request is cancelled
       
    73         * @post Calling thread not blocked
       
    74         */
       
    75         IMPORT_C void ConnectionLost( TRequestStatus& aStatus );
       
    76 
       
    77         /*
       
    78         * Cancels the pending connection lost request with KErrCancel.
       
    79         * Automatically cancelled in RP2PIf::Close.
       
    80         * NOTE! If interface is not open panicked with User::Panic.
       
    81         * Execution:    Synchronous
       
    82         * Re-entrant:   No
       
    83         * Blocking:     Yes
       
    84         * Panic mode:   User::Panic
       
    85         * SMP safe:     Yes
       
    86         * @post Calling thread not blocked
       
    87         */
       
    88         IMPORT_C void ConnectionLostCancel();
       
    89 
       
    90         /**
       
    91         * Asynchronously opens a P2P protocol communication path from this point to another.
       
    92         * Open is not complited before the communication path is open.
       
    93         * When request is set to pending blocked calling thread is released.
       
    94         * Automatically cancelled in RP2PIf::Close.
       
    95         * Execution:    Asynchronous
       
    96         * Re-entrant:   No
       
    97         * Blocking:     Yes
       
    98         * Panic mode:   User::Panic
       
    99         * SMP safe:     Yes
       
   100         * @param aP2PProtocolId, unique identifier of the used point-to-point protocol
       
   101         * @param aStatus, KErrNone if ok
       
   102         *                 KErrNotSupported if protocol is not supported
       
   103         *                 KErrInUse if someone uses the same protocol id
       
   104         *                 KErrAlreadyExists same interface object is opened with other protocol id
       
   105         *                 KErrCancel if outstanding request is cancelled
       
   106         *                 KErrPermissionDenied if not enough capabilities
       
   107         * @param aHandleType, specifies whether the handle is owned by process or by thread.
       
   108         * @post Calling thread not blocked
       
   109         */
       
   110         IMPORT_C void Open( const TP2PProtocol aP2PProtocolId,
       
   111                             TRequestStatus& aStatus,
       
   112                             TOwnerType aHandleType = EOwnerThread );
       
   113 
       
   114         /**
       
   115         * Cancel asynchronous channel opening with KErrCancel.
       
   116         * Does nothing if request is not pending.
       
   117         * Automatically called in RP2PIf::Close.
       
   118         * NOTE! If interface is not open panicked with User::Panic.
       
   119         * Execution:    Synchronous
       
   120         * Re-entrant:   No
       
   121         * Blocking:     Yes
       
   122         * Panic mode:   User::Panic
       
   123         * SMP safe:     Yes
       
   124         * @post Calling thread not blocked
       
   125         */
       
   126         IMPORT_C void OpenCancel();
       
   127 
       
   128         /**
       
   129         * Receive data from other point.
       
   130         * Either receives data immediately or set the receive request pending.
       
   131         * When request is set to pending blocked calling thread is released.
       
   132         * Automatically cancelled in RP2PIf::Close.
       
   133         * NOTE! If interface is not open panicked with User::Panic.
       
   134         * NOTE! If interface is not opened when other point is sending data to it data shall
       
   135         * be deallocated.
       
   136         * Execution:    Asynchronous
       
   137         * Re-entrant:   No
       
   138         * Blocking:     Yes
       
   139         * Panic mode:   User::Panic
       
   140         * SMP safe:     Yes
       
   141         * @param aStatus, KErrNone if ok.
       
   142         *                 KErrBadDescriptor if receive buffer is invalid or too small.
       
   143         * @param aReceiveBuffer, buffer where to receive data from kernel
       
   144         */
       
   145         IMPORT_C void Receive( TRequestStatus& aStatus, TDes8& aReceiveBuffer );
       
   146 
       
   147         /**
       
   148         * Cancel asynchronous receive request with KErrCancel.
       
   149         * Does nothing if request is not pending.
       
   150         * Automatically called in RP2PIf::Close.
       
   151         * NOTE! If interface is not open panicked with User::Panic.
       
   152         * Execution:    Synchronous
       
   153         * Re-entrant:   No
       
   154         * Blocking:     Yes
       
   155         * Panic mode:   User::Panic
       
   156         * SMP safe:     Yes
       
   157         * @post Calling thread not blocked
       
   158         */
       
   159         IMPORT_C void ReceiveCancel();
       
   160 
       
   161         /**
       
   162         * Sends data to other point.
       
   163         * NOTE! If interface is not open panicked with User::Panic.
       
   164         * NOTE! Absolutely maximum send buffer size is 16-bit value.
       
   165         * Execution:    Synchronous
       
   166         * Re-entrant:   No
       
   167         * Blocking:     Yes
       
   168         * Panic mode:   User::Panic
       
   169         * SMP safe:     Yes
       
   170         * @param aSendBuffer, data to be send
       
   171         * @return KErrNone, is succesfull
       
   172         *                   KErrNoMemory buffer size is over the maximum size
       
   173         *                   KErrNotReady connection to other point lost, data lost
       
   174         *                   KErrBadDescriptor if send buffer is invalid
       
   175         * @post Calling thread not blocked
       
   176         */
       
   177         IMPORT_C TInt Send( const TDesC8& aSendBuffer );
       
   178 
       
   179     };
       
   180 
       
   181 #endif      // __P2PIF_H__
       
   182 
       
   183 // End of File