realtimenetprots/sipfw/ProfileAgent/ProxyResolver/src/CProxyConnectionContainer.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name          : CProxyConnectionContainer.cpp
       
    15 // Part of       : ProxyResolver
       
    16 // Implementation
       
    17 // Version       : SIP/4.0
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 #include "CProxyConnectionContainer.h"
       
    23 #include "MConnObserver.h"
       
    24 
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CProxyConnectionContainer::NewL
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CProxyConnectionContainer* 
       
    31 CProxyConnectionContainer::NewL( MConnObserver& aObserver,
       
    32                                  TUint32 aIapId, 
       
    33                                  RSocketServ& aServer )
       
    34     {
       
    35     CProxyConnectionContainer* self = NewLC( aObserver, aIapId, aServer );
       
    36     CleanupStack::Pop(self);
       
    37     return self;
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CProxyConnectionContainer::NewLC
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CProxyConnectionContainer* 
       
    45 CProxyConnectionContainer::NewLC( MConnObserver& aObserver,
       
    46                                   TUint32 aIapId, 
       
    47                                   RSocketServ& aServer )
       
    48     {
       
    49     CProxyConnectionContainer* self = 
       
    50         new( ELeave )CProxyConnectionContainer( aObserver, aIapId, aServer );
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     return self;
       
    54     }
       
    55     
       
    56 // -----------------------------------------------------------------------------
       
    57 // CProxyConnectionContainer::CProxyConnectionContainer
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CProxyConnectionContainer::CProxyConnectionContainer( MConnObserver& aObserver,
       
    61                                                       TUint32 aIapId, 
       
    62                                                       RSocketServ& aServer)
       
    63     : CActive( EPriorityStandard ),
       
    64       iObserver( aObserver ),
       
    65       iIapId(aIapId),
       
    66       iServer(aServer)
       
    67     {
       
    68     CActiveScheduler::Add( this );
       
    69     }    
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CProxyConnectionContainer::ConstructL
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CProxyConnectionContainer::ConstructL()
       
    76     {
       
    77     // open connection
       
    78     User::LeaveIfError( iConnection.Open( iServer ) );
       
    79         
       
    80     // Set connection preferences
       
    81     iPrefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
       
    82     iPrefs.SetDirection( ECommDbConnectionDirectionOutgoing );
       
    83     iPrefs.SetIapId( iIapId );
       
    84 
       
    85     // Start connecting
       
    86     iConnection.Start( iPrefs, iStatus );
       
    87     SetActive();
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CProxyConnectionContainer::~CProxyConnectionContainer
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 CProxyConnectionContainer::~CProxyConnectionContainer()
       
    95     {
       
    96     Cancel();
       
    97     iConnection.Close();
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CProxyConnectionContainer::Connection
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 RConnection& CProxyConnectionContainer::Connection() 
       
   105     {  
       
   106     return iConnection; 
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CProxyConnectionContainer::RunL
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CProxyConnectionContainer::RunL()
       
   114     {
       
   115     TInt err = iStatus.Int();
       
   116     switch( err )
       
   117         {   
       
   118         case KErrNone: // if there is no error, Get the Dhcp options, 
       
   119                        // parse it and send it to proxy resolver owner
       
   120             {
       
   121             iObserver.ConnectionReady();
       
   122             }
       
   123             break;
       
   124         
       
   125         default: // other than KErrNone, KErrCancel, 
       
   126                  //send the err to proxy resolver owner
       
   127             {
       
   128             iObserver.ErrorOccured(err);
       
   129             }
       
   130             break;
       
   131         }   
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CProxyConnectionContainer::DoCancel
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CProxyConnectionContainer::DoCancel()
       
   139     {
       
   140     iConnection.Close();   
       
   141     }