wvuing/IMPSConnectionUI/ServiceSrc/CCnUiSignaller.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003 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:  Connection UI interprocess signaller.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <e32std.h>
       
    20 #include "CCnUiSignaller.h"
       
    21 
       
    22 
       
    23 // ================= GLOBAL FUNCTIONS ====================
       
    24 // -----------------------------------------------------------------------------
       
    25 // CreateConnUiSignallerL()
       
    26 // -----------------------------------------------------------------------------
       
    27 //
       
    28 GLREF_C MCnUiSignaller* CreateConnUiSignallerL()
       
    29     {
       
    30     return CCnUiSignaller::NewL();
       
    31     }
       
    32 
       
    33 GLREF_C MCnUiSignaller* CreateConnUiSignallerLC()
       
    34     {
       
    35     CCnUiSignaller* self = CCnUiSignaller::NewL();
       
    36     CleanupStack::PushL( self );
       
    37     return self;
       
    38     }
       
    39 
       
    40 
       
    41 
       
    42 // ================= MEMBER FUNCTIONS =======================
       
    43 // Two-phased constructor.
       
    44 CCnUiSignaller* CCnUiSignaller::NewL()
       
    45     {
       
    46     CCnUiSignaller* self = new ( ELeave ) CCnUiSignaller();
       
    47     CleanupStack::PushL( self );
       
    48     self->ConstructL();
       
    49     CleanupStack::Pop( self ); //self
       
    50     return self;
       
    51     }
       
    52 
       
    53 
       
    54 // Destructor
       
    55 CCnUiSignaller::~CCnUiSignaller()
       
    56     {
       
    57     //no need to explicitly to cancel the
       
    58     //signal ==> closing will do it automaticly
       
    59     delete iOperationSignalChannel;
       
    60     }
       
    61 
       
    62 // C++ default constructor can NOT contain any code, that
       
    63 // might leave.
       
    64 //
       
    65 CCnUiSignaller::CCnUiSignaller()
       
    66         : iOperationSignalRequested( EFalse )
       
    67     {
       
    68     }
       
    69 
       
    70 
       
    71 // Symbian OS default constructor can leave.
       
    72 void CCnUiSignaller::ConstructL()
       
    73     {
       
    74     iOperationSignalChannel = CCnUiGroupChannel::NewL( ECnUiGlobalGroup,
       
    75                                                        ECnUiGlobalOperationSignalChannel );
       
    76     }
       
    77 
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CCnUiSignaller::SignalOperationL()
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 TInt CCnUiSignaller::SignalOperationL( const TDesC& aDetailDesc )
       
    84     {
       
    85     if ( OperationRunning() )
       
    86         {
       
    87         return KErrInUse;
       
    88         }
       
    89 
       
    90     //construct objects
       
    91     iOperationSignalChannel->SignalL( aDetailDesc );
       
    92     iOperationSignalRequested = ETrue;
       
    93     return KErrNone;
       
    94     }
       
    95 
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CCnUiSignaller::CancelOperationSignal()
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void CCnUiSignaller::CancelOperationSignal()
       
   102     {
       
   103     if ( iOperationSignalRequested )
       
   104         {
       
   105         iOperationSignalChannel->CancelSignal();
       
   106         iOperationSignalRequested = EFalse;
       
   107         }
       
   108     }
       
   109 
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CCnUiSignaller::OperationRunning()
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 TBool CCnUiSignaller::OperationRunning()
       
   116     {
       
   117     TInt signalCount = 0;
       
   118     iOperationSignalChannel->Read( signalCount );
       
   119 
       
   120     return ( signalCount > 0 );
       
   121     }
       
   122 
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CCnUiSignaller::OperationDetailsL()
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CCnUiSignaller::OperationDetailsL( HBufC*& aDetailDesc )
       
   129     {
       
   130     if ( !OperationRunning() )
       
   131         {
       
   132         //if the operation isn't running
       
   133         //values are defaulted to empty buffer and 0
       
   134         aDetailDesc = KNullDesC().AllocL();
       
   135         }
       
   136 
       
   137     else
       
   138         {
       
   139         iOperationSignalChannel->ReadL( aDetailDesc );
       
   140         }
       
   141     }
       
   142 
       
   143 
       
   144 //  End of File