localconnectivityservice/dun/utils/inc/DunDataWaiter.h
branchRCL_3
changeset 19 0aa8cc770c8a
equal deleted inserted replaced
18:453dfc402455 19:0aa8cc770c8a
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Monitors for new data in RComm local media side
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CDUNDATAWAITER_H
       
    20 #define C_CDUNDATAWAITER_H
       
    21 
       
    22 #include "DunChanMan.h"
       
    23 
       
    24 /**
       
    25  *  Class to monitor for new data in RComm local media side
       
    26  *  This class is needed to avoid unnecessary resource allocation of Dataport
       
    27  *  side when number of supported Dataport ports for DUN is less than the
       
    28  *  number of local media side plugins that use RComm
       
    29  *
       
    30  *  @lib dunutils.lib
       
    31  *  @since S60 v3.2
       
    32  */
       
    33 NONSHARABLE_CLASS( CDunDataWaiter ) : public CActive
       
    34     {
       
    35 
       
    36 public:
       
    37 
       
    38     /**
       
    39      * Two-phased constructor.
       
    40      * @param aChannelCallback Callback to call when notification via
       
    41      *                         MDunChannelAllocator to be made
       
    42      * @return Instance of self
       
    43      */
       
    44 	static CDunDataWaiter* NewL( MDunChannelAllocator* aChannelCallback );
       
    45 
       
    46     /**
       
    47     * Destructor.
       
    48     */
       
    49     virtual ~CDunDataWaiter();
       
    50 
       
    51     /**
       
    52      * Resets data to initial values
       
    53      *
       
    54      * @since S60 3.2
       
    55      * @return None
       
    56      */
       
    57     void ResetData();
       
    58 
       
    59     /**
       
    60      * Adds callback for RunL error controlling
       
    61      * The callback will be called when error is detected in asynchronous
       
    62      * operation
       
    63      *
       
    64      * @since S60 3.2
       
    65      * @param aCallback Callback to call when line status changes
       
    66      * @return Symbian error code on error, KErrNone otherwise
       
    67      */
       
    68     TInt AddCallback( MDunConnMon* aCallback );
       
    69 
       
    70     /**
       
    71      * Sets media to use for this endpoint
       
    72      *
       
    73      * @since S60 3.2
       
    74      * @param aComm RComm pointer to use as the endpoint
       
    75      * @return Symbian error code on error, KErrNone otherwise
       
    76      */
       
    77     TInt SetMedia( RComm* aComm );
       
    78 
       
    79     /**
       
    80      * Issues request to start waiting for new data in RComm
       
    81      *
       
    82      * @since S60 3.2
       
    83      * @return Symbian error code on error, KErrNone otherwise
       
    84      */
       
    85     TInt IssueRequest();
       
    86 
       
    87     /**
       
    88      * Stops monitoring for new data
       
    89      *
       
    90      * @since S60 3.2
       
    91      * @return Symbian error code on error, KErrNone otherwise
       
    92      */
       
    93     TInt Stop();
       
    94 
       
    95 private:
       
    96 
       
    97     CDunDataWaiter( MDunChannelAllocator* aChannelCallback );
       
    98 
       
    99     void ConstructL();
       
   100 
       
   101     /**
       
   102      * Initializes this class
       
   103      *
       
   104      * @since S60 3.2
       
   105      * @return None
       
   106      */
       
   107     void Initialize();
       
   108 
       
   109 // from base class CActive
       
   110 
       
   111     /**
       
   112      * From CActive.
       
   113      * Gets called when new data in RComm object
       
   114      *
       
   115      * @since S60 3.2
       
   116      * @return None
       
   117      */
       
   118     void RunL();
       
   119 
       
   120     /**
       
   121      * From CActive.
       
   122      * Gets called on cancel
       
   123      *
       
   124      * @since S60 3.2
       
   125      * @return None
       
   126      */
       
   127     void DoCancel();
       
   128 
       
   129 private:  // data
       
   130 
       
   131     /**
       
   132      * Callback(s) to call when notification(s) via MDunConnMon to be made
       
   133      * Normally contains only one callback
       
   134      */
       
   135     RPointerArray<MDunConnMon> iCallbacks;
       
   136 
       
   137     /**
       
   138      * Callback to call when notification via MDunChannelAllocator to be made
       
   139      * Not own.
       
   140      */
       
   141     MDunChannelAllocator* iChannelCallback;
       
   142 
       
   143     /**
       
   144      * Current state of data monitoring: active or inactive
       
   145      */
       
   146     TDunState iDataWaiterState;
       
   147 
       
   148     /**
       
   149      * RComm object of local media side
       
   150      * Not own.
       
   151      */
       
   152     RComm* iComm;
       
   153 
       
   154     };
       
   155 
       
   156 #endif  // C_CDUNDATAWAITER_H