phoneengine/networkhandlingstarter/src/cnetworklistener.cpp
changeset 56 5bcb308bd24d
parent 45 6b911d05207e
child 60 1eef62f5c541
equal deleted inserted replaced
46:bc5a64e5bc3c 56:5bcb308bd24d
     1 /*
     1 /*
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14  * Description:  
    14  * Description:  
    15  *
    15  *
    16  */
    16  */
    17 #include <networkhandlingproxy.h>
    17 #include <networkhandlingproxy.h>
    18 #include <cnwsession.h>
    18 #include <cnwsession.h>
    19 #include <e32property.h>
       
    20 #include <centralrepository.h>
       
    21 #include <ProfileEngineSDKCRKeys.h>
       
    22 #include <BTSapDomainPSKeys.h>
    19 #include <BTSapDomainPSKeys.h>
    23 #include <startupdomainpskeys.h>
    20 #include <startupdomainpskeys.h>
    24 
    21 
    25 #include "cnetworklistener.h"
    22 #include "cnetworklistener.h"
    26 #include "mnetworklistenerobserver.h"
    23 #include "mnetworklistenerobserver.h"
    29 // Constants
    26 // Constants
    30 
    27 
    31 // 1-minute timeout before showing soft notification
    28 // 1-minute timeout before showing soft notification
    32 const TInt KNetworkLostTimeout = 60*1000000;
    29 const TInt KNetworkLostTimeout = 60*1000000;
    33 
    30 
    34 // Offline profile, from ProfileEngineSDKCRKeys.h
       
    35 const TInt KOfflineProfileId = 5;
       
    36 
       
    37 
       
    38 // ======== MEMBER FUNCTIONS ========
    31 // ======== MEMBER FUNCTIONS ========
    39 
    32 
    40 /*!
    33 /*!
    41     Constructor of CNetworkListener.
    34     Constructor of CNetworkListener.
    42  */
    35  */
    43 CNetworkListener::CNetworkListener(MNetworkListenerObserver& aObserver) : 
    36 CNetworkListener::CNetworkListener( MNetworkListenerObserver& aObserver )
       
    37     :
    44     iRegistered(ETrue),
    38     iRegistered(ETrue),
    45     iObserver(aObserver)
    39     iObserver(aObserver)
    46 {
    40 {
    47     DPRINT << ": IN";
    41     DPRINT << ": IN";
    48     
    42     
    57     DPRINT << ": IN";
    51     DPRINT << ": IN";
    58     
    52     
    59     //Create network handling engine session.
    53     //Create network handling engine session.
    60     iSession = CreateL(*this, iInfo);
    54     iSession = CreateL(*this, iInfo);
    61     iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
    55     iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
    62     iProfileApi = CRepository::NewL(KCRUidProfileEngine);
    56     QT_TRYCATCH_LEAVING(iDeviceInfo = new QSystemDeviceInfo())
    63     
    57     
    64     DPRINT << ": OUT";
    58     DPRINT << ": OUT";
    65 }
    59 }
    66 
    60 
    67 /*!
    61 /*!
    68     Constructor of CNetworkListener.
    62     Constructor of CNetworkListener.
    69  */
    63  */
    70 CNetworkListener* CNetworkListener::NewL(MNetworkListenerObserver& aObserver)
    64 CNetworkListener* CNetworkListener::NewL( MNetworkListenerObserver& aObserver )
    71 {
    65 {
    72     DPRINT << ": IN";
    66     DPRINT << ": IN";
    73     
    67     
    74     CNetworkListener* self = new(ELeave) CNetworkListener(aObserver);
    68     CNetworkListener* self = new(ELeave) CNetworkListener(aObserver);
    75     CleanupStack::PushL( self );
    69     CleanupStack::PushL( self );
    87 {
    81 {
    88     DPRINT << ": IN";
    82     DPRINT << ": IN";
    89     
    83     
    90     delete iSession;
    84     delete iSession;
    91     delete iTimer;
    85     delete iTimer;
    92     delete iProfileApi;
    86     delete iDeviceInfo;
    93     
    87     
    94     DPRINT << ": OUT";
    88     DPRINT << ": OUT";
    95 }
    89 }
    96 
    90 
    97 /*!
    91 /*!
   208  */
   202  */
   209 TBool CNetworkListener::IsOffLineMode() const
   203 TBool CNetworkListener::IsOffLineMode() const
   210 {
   204 {
   211     DPRINT << ": IN";
   205     DPRINT << ": IN";
   212     
   206     
   213     TInt profileId;
   207     TInt result = KErrNone;
   214     TInt err = iProfileApi->Get(KProEngActiveProfile, profileId);
   208     TBool isOffLineMode = EFalse;
   215     
   209     QT_TRYCATCH_ERROR(result, isOffLineMode =
   216     DPRINT << ": OUT";
   210         QSystemDeviceInfo::OfflineProfile == iDeviceInfo->currentProfile())
   217     
   211     
   218     return profileId == KOfflineProfileId && err == KErrNone;
   212     DPRINT << ": OUT, result: " << result;
       
   213     return (isOffLineMode && (KErrNone == result));
   219     }
   214     }
   220     
   215     
   221 /*!
   216 /*!
   222     CNetworkListener::IsBluetoothSAPConnected
   217     CNetworkListener::IsBluetoothSAPConnected
   223  */
   218  */