wlanutilities/wlanlogin/wlanloginapp/src/wlanloginnetworkaccessmanager.cpp
branchRCL_3
changeset 25 f28ada11abbf
parent 24 63be7eb3fc78
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
     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 * Wlan Login network access manager class implementation
       
    16 * 
       
    17 */
       
    18 
       
    19 
       
    20 // System includes
       
    21 #include <QObject>
       
    22 #include <QSslConfiguration>
       
    23 #include <QSslSocket>
       
    24 #include <QNetworkReply>
       
    25 
       
    26 //User includes
       
    27 #include "wlanloginnetworkaccessmanager.h"
       
    28 
       
    29 #include "OstTraceDefinitions.h"
       
    30 #ifdef OST_TRACE_COMPILER_IN_USE
       
    31 #include "wlanloginnetworkaccessmanagerTraces.h"
       
    32 #endif
       
    33 
       
    34 /*!
       
    35     \class WlanLoginNetworkAccessManager
       
    36     \brief WLAN Login network access manager class implementation.
       
    37 */
       
    38 
       
    39 // External function prototypes
       
    40 
       
    41 // Local constants
       
    42 
       
    43 // ======== LOCAL FUNCTIONS ========
       
    44 
       
    45 // ======== MEMBER FUNCTIONS ========
       
    46 
       
    47 WlanLoginNetworkAccessManager::WlanLoginNetworkAccessManager(QObject *parent): 
       
    48     QNetworkAccessManager(parent)
       
    49 {
       
    50     OstTraceFunctionEntry0(WLANLOGINNETWORKACCESSMANAGER_WLANLOGINNETWORKACCESSMANAGER_ENTRY);
       
    51 
       
    52     QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
       
    53     sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone);    
       
    54     QSslConfiguration::setDefaultConfiguration(sslConfig);
       
    55       
       
    56     bool connectStatus = connect(
       
    57         this,
       
    58         SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
       
    59         SLOT(handleSslErrors(QNetworkReply*, const QList<QSslError>&))
       
    60         );
       
    61     Q_ASSERT(connectStatus == true);
       
    62     
       
    63     connectStatus = connect(
       
    64         this,
       
    65         SIGNAL(finished(QNetworkReply*)), 
       
    66         this,
       
    67         SLOT(handleNetworkRequestFinished(QNetworkReply*))
       
    68         );
       
    69     Q_ASSERT(connectStatus == true);
       
    70     
       
    71     OstTraceFunctionExit0(WLANLOGINNETWORKACCESSMANAGER_WLANLOGINNETWORKACCESSMANAGER_EXIT);
       
    72 
       
    73 }
       
    74 
       
    75 WlanLoginNetworkAccessManager::~WlanLoginNetworkAccessManager()
       
    76 {
       
    77     OstTraceFunctionEntry0( WLANLOGINNETWORKACCESSMANAGER_DESTRUCTOR_ENTRY );
       
    78     
       
    79     OstTraceFunctionExit0( WLANLOGINNETWORKACCESSMANAGER_DESTRUCTOR_EXIT );
       
    80 }
       
    81 
       
    82 /*!
       
    83     This function handles sslError signal from QNetworkAccessManager
       
    84         
       
    85  */
       
    86 void WlanLoginNetworkAccessManager::handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
       
    87 {
       
    88     OstTraceFunctionEntry0(WLANLOGINNETWORKACCESSMANAGER_HANDLESSLERRORS_ENTRY);
       
    89     
       
    90 #ifdef OST_TRACE_COMPILER_IN_USE    
       
    91     for (int i=0; i<errors.count(); i++) {
       
    92                   
       
    93         OstTrace1(
       
    94             TRACE_NORMAL,
       
    95             WLANLOGINNETWORKACCESSMANAGER_HANDLESSLERRORS_ERROR_CODE_TRACE,
       
    96             "WlanLoginView::handleSslErrors;SSL error code=%d",
       
    97             errors[i].error()
       
    98             );
       
    99         
       
   100         QString string = errors[i].errorString();
       
   101         TPtrC tmp(string.utf16(),string.length() );
       
   102         
       
   103         OstTraceExt1(TRACE_NORMAL,
       
   104             WLANLOGINNETWORKACCESSMANAGER_HANDLESSLERRORS_ERROR_STRING_TRACE, 
       
   105             "WlanLoginNetworkAccessManager::handleSslErrors;SSL error string=%S",
       
   106             tmp
       
   107             );  
       
   108        }
       
   109 #endif //OST_TRACE_COMPILER_IN_USE
       
   110     
       
   111     reply->ignoreSslErrors();
       
   112 
       
   113     OstTraceFunctionExit0( WLANLOGINNETWORKACCESSMANAGER_HANDLESSLERRORS_EXIT );
       
   114 }
       
   115 
       
   116 /*!
       
   117     This function handles finished signal from QNetworkAccessManager
       
   118         
       
   119  */
       
   120 void WlanLoginNetworkAccessManager::handleNetworkRequestFinished(QNetworkReply* reply)
       
   121 {
       
   122     OstTraceFunctionEntry0(WLANLOGINNETWORKACCESSMANAGER_HANDLENETWORKREQUESTFINISHED_ENTRY);
       
   123     
       
   124     OstTrace1(
       
   125         TRACE_NORMAL, WLANLOGINNETWORKACCESSMANAGER_HANDLENETWORKREQUESTFINISHED_ERROR_CODE_TRACE, 
       
   126         "WlanLoginNetworkAccessManager::handleNetworkRequestFinished;QNetworkReply error code=%d",
       
   127         reply->error()
       
   128         );
       
   129     
       
   130 #ifdef OST_TRACE_COMPILER_IN_USE 
       
   131     QString string = reply->errorString();
       
   132     TPtrC tmp(string.utf16(),string.length() );
       
   133             
       
   134     OstTraceExt1( TRACE_NORMAL, WLANLOGINNETWORKACCESSMANAGER_HANDLENETWORKREQUESTFINISHED_ERROR_STRING_TRACE, 
       
   135             "WlanLoginNetworkAccessManager::handleNetworkRequestFinished;QNetworkReply error string=%S", tmp );
       
   136 #endif //OST_TRACE_COMPILER_IN_USE
       
   137     
       
   138     OstTraceFunctionExit0( WLANLOGINNETWORKACCESSMANAGER_HANDLENETWORKREQUESTFINISHED_EXIT );   
       
   139 }