qtinternetradio/irqnetworkcontroller/src/irqnetworkcontrollerbody.cpp
changeset 14 896e9dbc5f19
parent 12 608f67c22514
child 15 065198191975
equal deleted inserted replaced
12:608f67c22514 14:896e9dbc5f19
     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 #include <QStringList>
       
    18 #include "irqnetworkcontrollerbody.h"
       
    19 
       
    20 // ---------------------------------------------------------------------------
       
    21 // IRQNetworkControllerBody::~IRQNetworkControllerBody()
       
    22 // Destructor
       
    23 //
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 IRQNetworkControllerBody::~IRQNetworkControllerBody()
       
    27 {
       
    28     if (iNetworkController)
       
    29     {
       
    30         iNetworkController->Close();
       
    31     }
       
    32 }
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // IRQNetworkControllerBody::GetNetworkStatus()
       
    36 // Returns the variable which indicates if connection is active or not
       
    37 // @return bool
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 bool IRQNetworkControllerBody::getNetworkStatus() const
       
    41 {
       
    42     return (bool)iNetworkController->GetNetworkStatus();
       
    43 }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // IRQNetworkControllerBody::getIAPId()
       
    47 // Gets the IAP Id of the chosen IAP
       
    48 // @return IRQError
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 IRQError IRQNetworkControllerBody::getIAPId(unsigned long& aIapId) const
       
    52 {
       
    53     IRQError retval = EIRQErrorNone;
       
    54 
       
    55     if (KErrNotFound == iNetworkController->GetIAPId(aIapId))
       
    56     {
       
    57         retval = EIRQErrorNotFound;
       
    58     }
       
    59 
       
    60     return retval;
       
    61 }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // IRQNetworkControllerBody::chooseAccessPoint()
       
    65 // Configures the Access Point which is used by all the components for network
       
    66 // connectivity
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void  IRQNetworkControllerBody::chooseAccessPoint()
       
    70 {
       
    71     TRAPD(error, iNetworkController->ChooseAccessPointL());
       
    72     if (KErrNone != error)
       
    73     {
       
    74         emit errorOccured(EIRQErrorGeneral);
       
    75     }
       
    76 }
       
    77 
       
    78 /*
       
    79  * Cancel configuring access point
       
    80  */
       
    81 void IRQNetworkControllerBody::cancelConnecting()
       
    82 {
       
    83     iNetworkController->CancelConnecting();
       
    84 }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // IRQNetworkControllerBody::isOfflineMode()
       
    88 // Indicates if the phone is in offline mode
       
    89 // @return True if the phone is in offline mode else False
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 bool IRQNetworkControllerBody::isOfflineMode()
       
    93 {
       
    94     return (bool)iNetworkController->IsOfflineMode();
       
    95 }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // IRQNetworkControllerBody::isWlanSupported()
       
    99 // Indicates if the phone supports WLan usage
       
   100 // @return True if the phone supports else False
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 bool IRQNetworkControllerBody::isWlanSupported() const
       
   104 {
       
   105     return (bool)iNetworkController->IsWlanSupported();
       
   106 }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // IRQNetworkControllerBody::resetConnectionStatus()
       
   110 // Resets the connection status to Disconnected state
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void IRQNetworkControllerBody::resetConnectionStatus()
       
   114 {
       
   115     iNetworkController->ResetConnectionStatus();
       
   116 }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // IRQNetworkControllerBody::identifyConnectionType()
       
   120 // Indicates the type of connection
       
   121 // @return enum describing the type of connection ( GPRS/3G/WiFi )
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 IRQConnectionType IRQNetworkControllerBody::identifyConnectionType() const
       
   125 {
       
   126     return (IRQConnectionType)iNetworkController->IdentifyConnectionType();
       
   127 }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // IRQNetworkControllerBody::notifyActiveNetworkObservers()
       
   131 // Notifies all observers whose network request is active to reissue the request
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 void IRQNetworkControllerBody::notifyActiveNetworkObservers(IRQNetworkEvent aEvent)
       
   135 {
       
   136     TRAPD(error, iNetworkController->NotifyActiveNetworkObserversL((TIRNetworkEvent)aEvent));
       
   137     if (KErrNone != error)
       
   138     {
       
   139         emit errorOccured(EIRQErrorGeneral);
       
   140     }
       
   141 }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // IRQNetworkControllerBody::isHandlingOverConnection()
       
   145 // Indicates if the hand over of network connection has happened
       
   146 // @return bool
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 bool IRQNetworkControllerBody::isHandlingOverConnection()
       
   150 {
       
   151     return (bool)iNetworkController->IsHandingOverConnection();
       
   152 }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // IRQNetworkControllerBody::isConnectRequestIssued()
       
   156 // Indicates if chooseAccessPoint is called
       
   157 // @return bool
       
   158 // ---------------------------------------------------------------------------
       
   159 //
       
   160 bool IRQNetworkControllerBody::isConnectRequestIssued() const
       
   161 {
       
   162     return (bool)iNetworkController->iIsConnectRequestIssued;
       
   163 }
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // MIRActiveNetworkObserver::NotifyActiveNetworkObserversL()
       
   167 // Callback which notifies all observers whose network request is active to reissue the request
       
   168 // @param aEvent Indicates the type of network event that occurred
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 void IRQNetworkControllerBody::NotifyActiveNetworkObserversL(TIRNetworkEvent aEvent)
       
   172 {
       
   173     emit networkRequestNotified((IRQNetworkEvent)aEvent);
       
   174 }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // MIRActiveNetworkObserver::ResetPendingRequests()
       
   178 // Callback which notifies all observers whose network request is active to
       
   179 // reset the pending request status
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 void IRQNetworkControllerBody::ResetPendingRequests(TBool aValue)
       
   183 {
       
   184     emit pendingRequestsReset((bool)aValue);
       
   185 }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // MIRNetworkController::IRNetworkEventL()
       
   189 // @param aEvent Indicates the type of network event that occurred
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 void IRQNetworkControllerBody::IRNetworkEventL(TIRNetworkEvent aEvent)
       
   193 {
       
   194     emit networkEventNotified((IRQNetworkEvent)aEvent);
       
   195 }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // IRQNetworkControllerBody::initL()
       
   199 // Create resources
       
   200 //
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 void IRQNetworkControllerBody::initL()
       
   204 {
       
   205     // Get singleton instance
       
   206     iNetworkController = CIRNetworkController::OpenL(this);
       
   207     iNetworkController->RegisterActiveNetworkObserverL(*this);
       
   208 }