browsercore/core/network/WebNetworkConnectionManager.cpp
author hgs
Fri, 06 Aug 2010 17:23:08 -0400
changeset 9 b39122337a00
parent 3 0954f5dd2cd0
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
*
3
hgs
parents: 0
diff changeset
     5
* This program is free software: you can redistribute it and/or modify
hgs
parents: 0
diff changeset
     6
* it under the terms of the GNU Lesser General Public License as published by
hgs
parents: 0
diff changeset
     7
* the Free Software Foundation, version 2.1 of the License.
hgs
parents: 0
diff changeset
     8
* 
hgs
parents: 0
diff changeset
     9
* This program is distributed in the hope that it will be useful,
hgs
parents: 0
diff changeset
    10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
hgs
parents: 0
diff changeset
    11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
hgs
parents: 0
diff changeset
    12
* GNU Lesser General Public License for more details.
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
3
hgs
parents: 0
diff changeset
    14
* You should have received a copy of the GNU Lesser General Public License
hgs
parents: 0
diff changeset
    15
* along with this program.  If not, 
hgs
parents: 0
diff changeset
    16
* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*
3
hgs
parents: 0
diff changeset
    18
* Description:
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
*
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
*/
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include "WebNetworkConnectionManager.h"
3
hgs
parents: 0
diff changeset
    22
#include "WebNetworkSession.h"
9
hgs
parents: 3
diff changeset
    23
#include "webpagecontroller.h"
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
namespace WRT {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
3
hgs
parents: 0
diff changeset
    27
/*!
hgs
parents: 0
diff changeset
    28
    Constructs a WebNetworkConfigurationManager with the given \a parent.
hgs
parents: 0
diff changeset
    29
*/
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
WebNetworkConnectionManager::WebNetworkConnectionManager(QObject *parent)
9
hgs
parents: 3
diff changeset
    31
    : QObject(parent), m_WebNetworkSession(0), m_offlined(false), m_roamingRejected(false)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
{ 
3
hgs
parents: 0
diff changeset
    33
    // set up handlers for Network Configuration Manager signals
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
    connect(&m_NetworkConfigurationManager, SIGNAL(updateCompleted()), 
3
hgs
parents: 0
diff changeset
    35
            this, SLOT(handleConfigurationUpdateCompleted()));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
    connect(&m_NetworkConfigurationManager, SIGNAL(configurationAdded(const QNetworkConfiguration&)),
3
hgs
parents: 0
diff changeset
    37
            this, SLOT(handleConfigurationAdded(const QNetworkConfiguration&)));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
    connect(&m_NetworkConfigurationManager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)),
3
hgs
parents: 0
diff changeset
    39
            this, SLOT(handleConfigurationRemoved(const QNetworkConfiguration&)));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
    connect(&m_NetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)), 
3
hgs
parents: 0
diff changeset
    41
            this, SLOT(handleOnlineStateChanged(bool)));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
    connect(&m_NetworkConfigurationManager, SIGNAL(configurationChanged(const QNetworkConfiguration&)),
3
hgs
parents: 0
diff changeset
    43
            this, SLOT(handleConfigurationChanged(const QNetworkConfiguration&)));
9
hgs
parents: 3
diff changeset
    44
            
hgs
parents: 3
diff changeset
    45
    // listen to the signal when the secure page is no longer secure
hgs
parents: 3
diff changeset
    46
    connect(WebPageController::getSingleton(), SIGNAL(hideSecureIcon()),
hgs
parents: 3
diff changeset
    47
    	      this, SLOT(handleHideSecureIcon()));
3
hgs
parents: 0
diff changeset
    48
hgs
parents: 0
diff changeset
    49
#ifdef QT_MOBILITY_SYSINFO 
hgs
parents: 0
diff changeset
    50
    // initialize the mapping between network mode string and SystemNetworkInfo::NetworkMode
hgs
parents: 0
diff changeset
    51
    initializeMapString();
hgs
parents: 0
diff changeset
    52
#endif // QT_MOBILITY_SYSINFO
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
3
hgs
parents: 0
diff changeset
    55
/*!
hgs
parents: 0
diff changeset
    56
    Frees the resources associated with the WebNetworkConfigurationManager object.
hgs
parents: 0
diff changeset
    57
*/
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
WebNetworkConnectionManager::~WebNetworkConnectionManager()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
    if (m_WebNetworkSession)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
        deleteSession();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
3
hgs
parents: 0
diff changeset
    64
/*!
hgs
parents: 0
diff changeset
    65
    Initiates an update of all configurations. This may be used to initiate WLAN scans or other
hgs
parents: 0
diff changeset
    66
    time consuming updates which may be required to obtain the correct state for configurations.
hgs
parents: 0
diff changeset
    67
hgs
parents: 0
diff changeset
    68
    This call is asynchronous. On completion of this update the updateCompleted() signal is
hgs
parents: 0
diff changeset
    69
    emitted. If new configurations are discovered or old ones were removed or changed the update
hgs
parents: 0
diff changeset
    70
    process may trigger the emission of one or multiple configurationAdded(),
hgs
parents: 0
diff changeset
    71
    configurationRemoved() and configurationChanged() signals.
hgs
parents: 0
diff changeset
    72
hgs
parents: 0
diff changeset
    73
    If a configuration state changes as a result of this update all existing QNetworkConfiguration
hgs
parents: 0
diff changeset
    74
    instances are updated automatically.
hgs
parents: 0
diff changeset
    75
*/
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
void WebNetworkConnectionManager::updateConfigurations()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    m_NetworkConfigurationManager.updateConfigurations();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
3
hgs
parents: 0
diff changeset
    81
/*!
hgs
parents: 0
diff changeset
    82
    Returns the default configuration to be used. This function always returns a discovered
hgs
parents: 0
diff changeset
    83
    configuration; otherwise an invalid configuration. Only configuration type SNAP is handled.
hgs
parents: 0
diff changeset
    84
hgs
parents: 0
diff changeset
    85
    In some cases it may be required to call updateConfigurations() and wait for the
hgs
parents: 0
diff changeset
    86
    updateCompleted() signal before calling this function.
hgs
parents: 0
diff changeset
    87
*/
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
QNetworkConfiguration WebNetworkConnectionManager::defaultConfiguration() const
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
    const bool canStartIAP = (m_NetworkConfigurationManager.capabilities() 
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
                              & QNetworkConfigurationManager::CanStartAndStopInterfaces);
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    QNetworkConfiguration config = m_NetworkConfigurationManager.defaultConfiguration();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    if (!config.isValid() || !canStartIAP)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
        return config;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
        
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
    switch(config.type()) {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
        case QNetworkConfiguration::InternetAccessPoint:
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
            // no user interaction -> system starts IAP immediately
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
            qDebug() << "IAP";
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
            break;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
        case QNetworkConfiguration::ServiceNetwork:
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
            // no user interaction -> system determines best IAP in group and starts it
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
            qDebug() << "SNAP";
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
            break;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
        case QNetworkConfiguration::UserChoice:
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
            // IAP resolved by asking user as part of QNetworkSession::open()
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
            qDebug() << "User Choice";
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
            break;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    return config;
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
3
hgs
parents: 0
diff changeset
   114
/*! 
hgs
parents: 0
diff changeset
   115
    Create a Web Network Session using a QNetworkConfiguration and connect to its signals.
hgs
parents: 0
diff changeset
   116
    
hgs
parents: 0
diff changeset
   117
*/
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
void WebNetworkConnectionManager::createSession(QNetworkConfiguration config)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
{   
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    m_WebNetworkSession = new WebNetworkSession(config);
3
hgs
parents: 0
diff changeset
   121
hgs
parents: 0
diff changeset
   122
    // set up handlers for the WebNetworkSession signals
hgs
parents: 0
diff changeset
   123
    connect(m_WebNetworkSession, SIGNAL(sessionConfigurationChanged(const QNetworkConfiguration &)),
hgs
parents: 0
diff changeset
   124
            this, SLOT(handleSessionConfigurationChanged(const QNetworkConfiguration &)));
9
hgs
parents: 3
diff changeset
   125
    connect(m_WebNetworkSession, SIGNAL(sessionRoamingRejected(void)), 
hgs
parents: 3
diff changeset
   126
            this, SLOT(handleSessionRoamingRejected(void)));
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
3
hgs
parents: 0
diff changeset
   129
/*! 
hgs
parents: 0
diff changeset
   130
    Delete a Web Network Session.
hgs
parents: 0
diff changeset
   131
    
hgs
parents: 0
diff changeset
   132
*/
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
void WebNetworkConnectionManager::deleteSession(void)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
{   
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
    delete m_WebNetworkSession;
3
hgs
parents: 0
diff changeset
   136
    m_WebNetworkSession = 0;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
3
hgs
parents: 0
diff changeset
   139
/*!
hgs
parents: 0
diff changeset
   140
    Handle the updateCompleted signal from Network Configuration Manager.
hgs
parents: 0
diff changeset
   141
    
hgs
parents: 0
diff changeset
   142
    It creates a Web Network Session using the default configuration.
hgs
parents: 0
diff changeset
   143
*/
hgs
parents: 0
diff changeset
   144
void WebNetworkConnectionManager::handleConfigurationUpdateCompleted()
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
{
9
hgs
parents: 3
diff changeset
   146
	  qDebug() << "configurationUpdateCompleted:";
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
	  if (m_WebNetworkSession)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
	  {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
	  	  qDebug() << "Delete old network connection session";
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
	  	  deleteSession();
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
	  }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
	  
9
hgs
parents: 3
diff changeset
   153
	  qDebug() << "Create new network connection session";
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    createSession(defaultConfiguration());
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
3
hgs
parents: 0
diff changeset
   157
/*! 
hgs
parents: 0
diff changeset
   158
    Handle the configurationAdded signal from Network Configuration Manager.
hgs
parents: 0
diff changeset
   159
*/
hgs
parents: 0
diff changeset
   160
void WebNetworkConnectionManager::handleConfigurationAdded(const QNetworkConfiguration& config)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    qDebug() << "Configuration" << config.name() << "Added";    
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
3
hgs
parents: 0
diff changeset
   165
/*! 
hgs
parents: 0
diff changeset
   166
    Handle the configurationRemoved signal from Network Configuration Manager
hgs
parents: 0
diff changeset
   167
*/
hgs
parents: 0
diff changeset
   168
void WebNetworkConnectionManager::handleConfigurationRemoved(const QNetworkConfiguration& config)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
{
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
    qDebug() << "Configuration" << config.name() << "Removed";
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
3
hgs
parents: 0
diff changeset
   173
/*! 
hgs
parents: 0
diff changeset
   174
    Handle the onlineStateChanged signal from Network Configuration Manager.
hgs
parents: 0
diff changeset
   175
*/
hgs
parents: 0
diff changeset
   176
void WebNetworkConnectionManager::handleOnlineStateChanged(bool isOnline)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
{
3
hgs
parents: 0
diff changeset
   178
    emit networkOnlineStateChanged(isOnline);
hgs
parents: 0
diff changeset
   179
    
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
    if (!isOnline)
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
        qDebug() << "offline";
3
hgs
parents: 0
diff changeset
   183
        m_offlined = true;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
    else
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
    {
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
        qDebug() << "online";
3
hgs
parents: 0
diff changeset
   188
        m_offlined = false;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    }
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
    // flash icon to indicate the online state change with "online" and "offline".
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
}
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
3
hgs
parents: 0
diff changeset
   193
/*! 
hgs
parents: 0
diff changeset
   194
    Handle the configurationChanged signal from Network Configuration Manager.
hgs
parents: 0
diff changeset
   195
*/
hgs
parents: 0
diff changeset
   196
void WebNetworkConnectionManager::handleConfigurationChanged(const QNetworkConfiguration &config)
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
{
3
hgs
parents: 0
diff changeset
   198
    qDebug() << "Configuration" << config.name() << "Changed";
hgs
parents: 0
diff changeset
   199
    qDebug() << "bearername:" << config.bearerName() << "type:" << config.type() << "state:" << config.state() << "purpose:" << config.purpose();
hgs
parents: 0
diff changeset
   200
    
hgs
parents: 0
diff changeset
   201
    /* The QNetworkSession is closed becuase of previous offline condition. Re-open the session if 
hgs
parents: 0
diff changeset
   202
       the configuration matches the configurations hold by the QNetworkSession */
hgs
parents: 0
diff changeset
   203
#ifdef NO_OFFLINED_BUG
hgs
parents: 0
diff changeset
   204
    if (isOfflined())
hgs
parents: 0
diff changeset
   205
    {
hgs
parents: 0
diff changeset
   206
#endif // NO_OFFLINED_BUG
hgs
parents: 0
diff changeset
   207
        if (m_WebNetworkSession && !m_WebNetworkSession->isOpen())
hgs
parents: 0
diff changeset
   208
        {
hgs
parents: 0
diff changeset
   209
            QNetworkConfiguration sessionConfig = m_WebNetworkSession->configuration();
hgs
parents: 0
diff changeset
   210
            QList<QNetworkConfiguration> children = sessionConfig.children();
hgs
parents: 0
diff changeset
   211
        	  switch(sessionConfig.type())
hgs
parents: 0
diff changeset
   212
            {
hgs
parents: 0
diff changeset
   213
                case QNetworkConfiguration::ServiceNetwork:        
hgs
parents: 0
diff changeset
   214
                    /* Traverse all configuration to find the matching configuration */
hgs
parents: 0
diff changeset
   215
                    foreach(QNetworkConfiguration tmpConfig, children)
hgs
parents: 0
diff changeset
   216
                    {
hgs
parents: 0
diff changeset
   217
        	              if (config == tmpConfig)
hgs
parents: 0
diff changeset
   218
        	              {
hgs
parents: 0
diff changeset
   219
        	              	  if ((config.state() == QNetworkConfiguration::Discovered) ||
hgs
parents: 0
diff changeset
   220
        	              	  	   (config.state() == QNetworkConfiguration::Active))
hgs
parents: 0
diff changeset
   221
        	                      m_WebNetworkSession->open();
hgs
parents: 0
diff changeset
   222
            	              break;
hgs
parents: 0
diff changeset
   223
            	          }
hgs
parents: 0
diff changeset
   224
            	      }
hgs
parents: 0
diff changeset
   225
                    break;  
hgs
parents: 0
diff changeset
   226
               case QNetworkConfiguration::InternetAccessPoint:
hgs
parents: 0
diff changeset
   227
        	          qDebug() << "InternetAccessPoint";
hgs
parents: 0
diff changeset
   228
                    break;
hgs
parents: 0
diff changeset
   229
               case QNetworkConfiguration::UserChoice:
hgs
parents: 0
diff changeset
   230
        	          qDebug() << "UserChoice";
hgs
parents: 0
diff changeset
   231
        	          break;
hgs
parents: 0
diff changeset
   232
               default:
hgs
parents: 0
diff changeset
   233
        	         break;
hgs
parents: 0
diff changeset
   234
            } 	  
hgs
parents: 0
diff changeset
   235
        }
hgs
parents: 0
diff changeset
   236
#ifdef NO_OFFLINED_BUG
hgs
parents: 0
diff changeset
   237
    }
hgs
parents: 0
diff changeset
   238
#endif // NO_OFFLINED_BUG
hgs
parents: 0
diff changeset
   239
} 
hgs
parents: 0
diff changeset
   240
hgs
parents: 0
diff changeset
   241
/*! 
hgs
parents: 0
diff changeset
   242
    Handle the networkNameChanged signal from Network Configuration Manager and translate 
hgs
parents: 0
diff changeset
   243
    sessionConfiguration signal to networknameChanged.
hgs
parents: 0
diff changeset
   244
    
hgs
parents: 0
diff changeset
   245
    It a\ emits networkNameChanged signal for no cellular network connetion.
hgs
parents: 0
diff changeset
   246
*/
hgs
parents: 0
diff changeset
   247
void WebNetworkConnectionManager::handleSessionConfigurationChanged(const QNetworkConfiguration &config)
hgs
parents: 0
diff changeset
   248
{  
hgs
parents: 0
diff changeset
   249
    qDebug() << "handleSessionConfigurationChanged" << "bearername:" << config.bearerName();
hgs
parents: 0
diff changeset
   250
hgs
parents: 0
diff changeset
   251
#ifdef QT_MOBILITY_SYSINFO  
hgs
parents: 0
diff changeset
   252
    QSystemNetworkInfo::NetworkMode mode;
hgs
parents: 0
diff changeset
   253
    mode = m_mapStringNetworkMode[config.bearerName()];
hgs
parents: 0
diff changeset
   254
hgs
parents: 0
diff changeset
   255
    emit networkSessionNameChanged(mode, config.name());
hgs
parents: 0
diff changeset
   256
#endif // QT_MOBILITY_SYSINFO
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
}
3
hgs
parents: 0
diff changeset
   258
9
hgs
parents: 3
diff changeset
   259
void WebNetworkConnectionManager::handleSessionRoamingRejected(void)
hgs
parents: 3
diff changeset
   260
{
hgs
parents: 3
diff changeset
   261
	  qDebug() << "roaming is rejected";
hgs
parents: 3
diff changeset
   262
	  m_roamingRejected = true;
hgs
parents: 3
diff changeset
   263
}
hgs
parents: 3
diff changeset
   264
hgs
parents: 3
diff changeset
   265
void WebNetworkConnectionManager::handleHideSecureIcon(void)
hgs
parents: 3
diff changeset
   266
{
hgs
parents: 3
diff changeset
   267
	  qDebug() << "Switch to non-secure page";
hgs
parents: 3
diff changeset
   268
	  // Update the configuration and restart session if the roaming has been
hgs
parents: 3
diff changeset
   269
	  // rejected and the page become unsecure.
hgs
parents: 3
diff changeset
   270
	  if (m_roamingRejected)
hgs
parents: 3
diff changeset
   271
	  {
hgs
parents: 3
diff changeset
   272
	  	  m_NetworkConfigurationManager.updateConfigurations();
hgs
parents: 3
diff changeset
   273
	  	  m_roamingRejected = false;
hgs
parents: 3
diff changeset
   274
	  }
hgs
parents: 3
diff changeset
   275
}
hgs
parents: 3
diff changeset
   276
3
hgs
parents: 0
diff changeset
   277
#ifdef QT_MOBILITY_SYSINFO
hgs
parents: 0
diff changeset
   278
void WebNetworkConnectionManager::initializeMapString(void)
hgs
parents: 0
diff changeset
   279
{
hgs
parents: 0
diff changeset
   280
	  m_mapStringNetworkMode["Ethernet"] = QSystemNetworkInfo::EthernetMode;
hgs
parents: 0
diff changeset
   281
	  m_mapStringNetworkMode["WLAN"] = QSystemNetworkInfo::WlanMode;
hgs
parents: 0
diff changeset
   282
	  m_mapStringNetworkMode["2G"] = QSystemNetworkInfo::GsmMode;
hgs
parents: 0
diff changeset
   283
	  m_mapStringNetworkMode["CDMA2000"] = QSystemNetworkInfo::CdmaMode;
hgs
parents: 0
diff changeset
   284
	  m_mapStringNetworkMode["WCDMA"] = QSystemNetworkInfo::WcdmaMode;
hgs
parents: 0
diff changeset
   285
	  m_mapStringNetworkMode["HSPA"] = QSystemNetworkInfo::UnknownMode;
hgs
parents: 0
diff changeset
   286
	  m_mapStringNetworkMode["Bluetooth"] = QSystemNetworkInfo::BluetoothMode;
hgs
parents: 0
diff changeset
   287
	  m_mapStringNetworkMode["WiMAX"] = QSystemNetworkInfo::WimaxMode;
hgs
parents: 0
diff changeset
   288
	  m_mapStringNetworkMode[""] = QSystemNetworkInfo::UnknownMode;
0
1450b09d0cfd Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
}
3
hgs
parents: 0
diff changeset
   290
#endif // QT_MOBILITY_SYSINFO
hgs
parents: 0
diff changeset
   291
hgs
parents: 0
diff changeset
   292
} // WRT
hgs
parents: 0
diff changeset
   293