wlanutilities/wlanqtutilities/wrapper/src/wlanqtutilsesockwrapper_s60.cpp
branchGCC_SURGE
changeset 47 b3d8f88532b7
parent 34 30a5f517c615
parent 46 2fbd1d709fe7
equal deleted inserted replaced
34:30a5f517c615 47:b3d8f88532b7
     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 "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 // INCLUDE FILES
       
    19 #include <e32base.h>
       
    20 #include <es_sock.h>
       
    21 #include <in_sock.h>
       
    22 #include <commdbconnpref.h>
       
    23 #include "wlanqtutilsesockwrapper.h"
       
    24 #include "wlanqtutilsesockwrapper_s60_p.h"
       
    25 
       
    26 #ifdef WLANQTUTILS_NO_OST_TRACES_FLAG
       
    27 #include <opensystemtrace.h>
       
    28 #else
       
    29 #include "OstTraceDefinitions.h"
       
    30 #endif
       
    31 #ifdef OST_TRACE_COMPILER_IN_USE
       
    32 #include "wlanqtutilsesockwrapper_s60Traces.h"
       
    33 #endif
       
    34 
       
    35 
       
    36 // =========== PRIVATE CLASS MEMBER FUNCTIONS ===============
       
    37 //
       
    38 // ---------------------------------------------------------
       
    39 // EsockWrapperPrivate::EsockWrapperPrivate()
       
    40 // Constructor
       
    41 // ---------------------------------------------------------
       
    42 //
       
    43 EsockWrapperPrivate::EsockWrapperPrivate(EsockWrapper *aWrapper)
       
    44 : CActive(EPriorityStandard), q_ptr(aWrapper)
       
    45     {
       
    46     OstTraceFunctionEntryExt( ESOCKWRAPPERPRIVATE_ESOCKWRAPPERPRIVATE_ENTRY, this );
       
    47     
       
    48     CActiveScheduler::Add(this);
       
    49     
       
    50     iSocketServer.Connect();
       
    51     
       
    52     OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_ESOCKWRAPPERPRIVATE_EXIT, this );
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------
       
    56 // EsockWrapperPrivate::EsockWrapperPrivate()
       
    57 // Destructor
       
    58 // ---------------------------------------------------------
       
    59 //
       
    60 EsockWrapperPrivate::~EsockWrapperPrivate()
       
    61     {
       
    62     OstTraceFunctionEntry1( ESOCKWRAPPERPRIVATE_ESOCKWRAPPERPRIVATEDESTR_ENTRY, this );
       
    63     
       
    64     Cancel();
       
    65     // Closing active RConnection is not mandatory, but is recommended.
       
    66     // ==> add checking here when implementing cancel/error cases.
       
    67     iSocketServer.Close();
       
    68     
       
    69     OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_ESOCKWRAPPERPRIVATEDESTR_EXIT, this );
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------
       
    73 // EsockWrapperPrivate::connectIap()
       
    74 // Start connection creation to given IAP.
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 void EsockWrapperPrivate::connectIap(int aIapId)
       
    78     {
       
    79     OstTraceFunctionEntryExt( ESOCKWRAPPERPRIVATE_CONNECTIAP_ENTRY, this );
       
    80     
       
    81     // Open an RConnection object.
       
    82     iConnection.Open(iSocketServer);
       
    83     
       
    84     // Create overrides to force opening of the given IAP without any user prompts.
       
    85     TCommDbConnPref prefs;
       
    86     prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
       
    87     prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
       
    88     prefs.SetIapId(aIapId);
       
    89     
       
    90     // Start the Connection with overrides
       
    91     iConnection.Start(prefs, iStatus);
       
    92     
       
    93     // TODO: Currently SetActive Panics when connecting "furiously" in Visual view...
       
    94     // Panicking line in SetActive was this:
       
    95     // __ASSERT_ALWAYS(!(iStatus.iFlags&TRequestStatus::EActive),Panic(EReqAlreadyActive));
       
    96     SetActive();
       
    97     
       
    98     OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_CONNECTIAP_EXIT, this );
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // EsockWrapperPrivate::disconnectIap()
       
   103 // Stop connection.
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 void EsockWrapperPrivate::disconnectIap()
       
   107     {      
       
   108     OstTraceFunctionEntry1( ESOCKWRAPPERPRIVATE_DISCONNECTIAP_ENTRY, this );
       
   109     
       
   110     // TODO: Error checking
       
   111     iConnection.Close();
       
   112     
       
   113     OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_DISCONNECTIAP_EXIT, this );
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // EsockWrapperPrivate::RunL()
       
   118 // Called when connection creation has finished.
       
   119 // ---------------------------------------------------------
       
   120 //
       
   121 void EsockWrapperPrivate::RunL()
       
   122     {
       
   123     OstTraceFunctionEntry1( ESOCKWRAPPERPRIVATE_RUNL_ENTRY, this );
       
   124     OstTrace1( TRACE_NORMAL, ESOCKWRAPPERPRIVATE_RUNL, "EsockWrapperPrivate::RunL;iStatus.Int()=%d", iStatus.Int() );
       
   125     
       
   126     bool success = false;
       
   127     
       
   128     if (iStatus == KErrNone)
       
   129         {
       
   130         success = true;
       
   131         }
       
   132     
       
   133     q_ptr->updateConnection(success);
       
   134     
       
   135     OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_RUNL_EXIT, this );
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------
       
   139 // EsockWrapperPrivate::DoCancel()
       
   140 // 
       
   141 // ---------------------------------------------------------
       
   142 //
       
   143 void EsockWrapperPrivate::DoCancel()
       
   144     {
       
   145     OstTraceFunctionEntry1( ESOCKWRAPPERPRIVATE_DOCANCEL_ENTRY, this );
       
   146     OstTraceFunctionExit1( ESOCKWRAPPERPRIVATE_DOCANCEL_EXIT, this );
       
   147     }
       
   148 
       
   149 //end of file