×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Nov 2006
    Location
    Rajkot
    Posts
    430

    How to get Network info using S60 3rd Edition 9.2??

    Hi

    Code:
    CMobInfo.h
    ------------
    
    
    #include <etel3rdparty.h> // CTelephony
    #include <e32base.h>  // CBase, link against euser.lib
    
    enum TNetworkInfoV1
    {
    	ENoCellInfoRequest = 0,
    	EGetIMSINo,
    	EGetIMEINo,
    	EGetCellInfoId,
    	EGetCurrentNW,
    	EGetHomeNW,
    	EGetNWAvailbility,
    	EGetBatteryChargeInfo,
    	EGetSignalLevel,
    	ELastCellInfoRequest
    };
    
    // Observer interface
    class MNetworkInfoObserver
    {
    public:
    	virtual void NetworkInfoRetrievedL(
    		const CTelephony::TNetworkInfoV1& aNetworkInfo) = 0;
    	virtual void HandleNetworkInfoError(TInt aError) = 0;
    };
    
    // Active object to get network info
    class CNetworkInfo : public CActive
    {
    public:
    	static CNetworkInfo* NewL();
    	~CNetworkInfo();
    
    	void GetNetworkInfoL(MNetworkInfoObserver* aObserver);
    
    protected:
    	// from CActive
    	void RunL();
    	TInt RunError(TInt aError);
    	void DoCancel();
    
    private:
    	CNetworkInfo();
    	void ConstructL();
    
    private:
    	CTelephony* iTelephony;
    	CTelephony::TNetworkInfoV1 iNwInfo;
    	CTelephony::TNetworkInfoV1Pckg iNwInfoPckg;
    	MNetworkInfoObserver* iObserver;
    
    	TNetworkInfoV1 iNetworkInfo;
    };
    
    
    
    cMobInfo.cpp
    ------------
    
    
    CNetworkInfo::CNetworkInfo()
    : CActive(EPriorityStandard),
    iNwInfoPckg(iNwInfo)//, 
    //iObserver(ENoCellInfoRequest)
    {
    	CActiveScheduler::Add(this);
    }
    
    CNetworkInfo* CNetworkInfo::NewL()
    {
    	CNetworkInfo* self = new (ELeave) CNetworkInfo;
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	CleanupStack::Pop();
    	return self;
    }
    
    
    void CNetworkInfo::ConstructL()
    {
    	iTelephony = CTelephony::NewL();
    }
    
    
    CNetworkInfo::~CNetworkInfo()
    {
    	Cancel();
    	delete iTelephony;
    }
    
    // This function is used by our class' users to start getting network info.
    void CNetworkInfo::GetNetworkInfoL(MNetworkInfoObserver* aObserver)
    {
    	__ASSERT_ALWAYS(!IsActive(), User::Leave(KErrInUse));
    	iObserver = aObserver;
    
    	// Start async call to receive current network information
    	iTelephony->GetCurrentNetworkInfo(iStatus, iNwInfoPckg);
    	SetActive();
    }
    
    void CNetworkInfo::DoCancel()
    {
    	iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
    ////	iObserver = ENoCellInfoRequest;
    }
    
    void CNetworkInfo::RunL()
    {
    	User::LeaveIfError(iStatus.Int());
    	// Request completed successfully.
    	// Now we can notify our observer.
    	if(iObserver)
    	{
    		iObserver->NetworkInfoRetrievedL(iNwInfoPckg());
    	}
    }
    
    TInt CNetworkInfo::RunError(TInt aError)
    {
    	// There was an error retrieving current network info.
    	// Let's inform our observer about the error so that it can analyze it
    	// and try to recover.
    	if(iObserver)
    	{
    		iObserver->HandleNetworkInfoError(aError);
    	}
    
    	return KErrNone;
    }

    My problem is how i can call GetNetworkInfoL function for get network information because i don't know that how i can pass argument of GetNetworkInfoL function.

    Code:
    AppUi.h
    --------
    
    class CMobInfoExampleAppUi : public CAknViewAppUi,  MNetworkInfoObserver
        {
         private: //Data
            CAknNavigationControlContainer* iNaviPane;
            CAknTabGroup*                   iTabGroup;
            CAknNavigationDecorator*        iDecoratedTabGroup;
    
    		CNetworkInfo* iMobInfo;
    		//MNetworkInfoObserver* iObserver;
        };
    
    AppUi.cpp
    ---------
    
    
    void CMobInfoExampleAppUi::HandleCommandL(TInt aCommand)
        {
        switch ( aCommand )
            {
            case EMobInfoExampleCmdNetworkInfo:	                                                                                        
    	     iMobInfo->GetNetworkInfoL(EGetCurrentNW);
    	     break;
    
           default:
                break; 
    	}
        }

    Please Help me

    Regards
    Tanya

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: How to get Network info using S60 3rd Edition 9.2??

    since your appui is derived from MNetworkInfoObserver, and you are using the CNetworkInfo in it, you can just pass the this-pointer directly. i.e. just call:

    iMobInf->GetNetworkInfoL(this);

  3. #3
    Regular Contributor
    Join Date
    Jan 2005
    Location
    Estonia
    Posts
    350

    Re: How to get Network info using S60 3rd Edition 9.2??

    In CNetworkInfo:
    in header:
    Code:
    	CTelephony::TNetworkNameV1Pckg* iPkg;
    	CTelephony::TNetworkNameV1 iV1;
    in construct
    Code:
    	iPkg = new (ELeave) CTelephony::TNetworkNameV1Pckg(iV1);
    then:
    Code:
    void CNetInfo::GetNetInfo(TRequestStatus& aStatus)
    {
    	aStatus=KRequestPending; 
    	iNetInfoStatus = &aStatus;
    	iTelephony->GetCurrentNetworkName(iStatus, *iPkg );
    	SetActive();
    	CActiveScheduler::Start();
    }
    When calling it
    Code:
    TBuf<50> CellName;
    NetInfo->GetNetName(status);
    User::WaitForRequest(status);
    CellName.Copy(NetInfo->iV2.iNetworkName);

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: How to get Network info using S60 3rd Edition 9.2??

    sorry rihoe, but I think it would be rather pointless to make it syncronous, as well as I think I answered the question in a way that the original should work just fine..

  5. #5
    Regular Contributor
    Join Date
    Nov 2006
    Location
    Rajkot
    Posts
    430

    Re: How to get Network info using S60 3rd Edition 9.2??

    Hi symbianyucca

    Thanks For Your Reply,
    But it give me an error like.

    error: illegal use of abstract class ('MNetworkInfoObserver::NetworkInfoRetrievedL(const CTelephony::TNetworkInfoV1 &)')

    Code:
    Appui.h
    ---------
    
    
    class CMobInfoExampleAppUi : public CAknViewAppUi, MAknTabObserver, public MNetworkInfoObserver
        {
        }
    
    
    Appui.cpp
    -----------
    
    void CMobInfoExampleAppUi::HandleCommandL(TInt aCommand)
        {
        switch ( aCommand )
            {
            case EEikCmdExit:
                {
                Exit();
                break;
                }
    	case EMobInfoExampleCmdNetworkInfo:
    	    {			
    	    iMobInfo->GetNetworkInfoL(this);
    	    break;
    	    }
            default:
                break;      
            }
        }
    Regards
    Tanya

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: How to get Network info using S60 3rd Edition 9.2??

    basically when you derive from a class which has functions that are defined virtual, then you need to implement them in your class. So just implement the NetworkInfoRetrievedL() function in your appui and it should compile.

  7. #7
    Regular Contributor
    Join Date
    Nov 2006
    Location
    Rajkot
    Posts
    430

    Re: How to get Network info using S60 3rd Edition 9.2??

    Hi

    i done but now also give me an error like:

    MobInfoExample : error PRJ0002 : error result returned from 'link.exe'.
    [/CODE]


    Code:
    mwldsym2.exe: Undefined symbol: 'void CMobInfoExampleAppUi::NetworkInfoRetrievedL(class CTelephony::TNetworkInfoV1 const &) (?NetworkInfoRetrievedL@CMobInfoExampleAppUi@@EAEXABVTNetworkInfoV1@CTelephony@@@Z)'
    
    mwldsym2.exe: referenced from 'const CMobInfoExampleAppUi::`vftable' (??_7CMobInfoExampleAppUi@@6B@~)' in MobInfoExampleAppUi.o
    
    mwldsym2.exe: referenced from '@148@?NetworkInfoRetrievedL@CMobInfoExampleAppUi@@EAEXABVTNetworkInfoV1@CTelephony@@@Z' in MobInfoExampleAppUi.o
    
    Errors caused tool to abort.
    
    MobInfoExample : error PRJ0002 : error result returned from 'link.exe'.

    Code:
    MobInfo.h
    ---------
    
    // Observer interface
    class MNetworkInfoObserver
    {
    public:
    	virtual void NetworkInfoRetrievedL(
    		const CTelephony::TNetworkInfoV1& aNetworkInfo) = 0;
    };
    
    
    AppUi.h
    -------
    
    class CMobInfoExampleAppUi : public CAknViewAppUi, MNetworkInfoObserver, MAknTabObserver
        {
        public: // // Constructors and destructor
    
            /**
            * EPOC default constructor.
            */      
            void ConstructL();
    
            /**
            * Destructor.
            */      
            ~CMobInfoExampleAppUi();
            
        public: // New functions
    
         void NetworkInfoRetrievedL(const CTelephony::TNetworkInfoV1& aNetworkInfo);
           
    
        public: // Functions from base classes
    		/**
            * From MAknTabObserver.
            * @param aIndex tab index
            */
    		void TabChangedL(TInt aIndex);
    
        private:
            // From MEikMenuObserver
            void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
    
    .
    .
    .
    };
    #endif

    Please Help me for this problem.
    Thank you in Advance.

    Regards
    Tanya
    Last edited by Tanya; 2007-11-16 at 09:34.

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: How to get Network info using S60 3rd Edition 9.2??

    You might try reading and understanding the error message, and/or the API itself.
    An observer (MNetworkInfoObserver) is supposed to get notifications about events of the observed object. The notifications are going to be provided via a method or methods.
    So you are going to be notified via your NetworkInfoRetrievedL method about successful information retrieval, or HandleNetworkInfoError if something has gone wrong.
    If you do not implement these methods, you will not get notified about anything, and your code will not even compile.
    After 300 posts, you can also consider learning C++. Sorry :-(

  9. #9
    Regular Contributor
    Join Date
    Nov 2006
    Location
    Rajkot
    Posts
    430

    Re: How to get Network info using S60 3rd Edition 9.2??

    Hi

    i am beginner in 3rd edition but i am confused in error because it gives me an error like error result returned from 'link.exe' that means some library file is missing.

    but in description give me Undefined symbol: 'void CMobInfoExampleAppUi::NetworkInfoRetrievedL(class CTelephony::TNetworkInfoV1 const &) (?NetworkInfoRetrievedL@CMobInfoExampleAppUi@@UAEXABVTNetworkInfoV1@CTelephony@@@Z)'

    But my problem is i include all header file and lib files than also why it give me an error like undefined symbol.

    This thing i don't understand.

    Regards
    Tanya

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: How to get Network info using S60 3rd Edition 9.2??

    You have declared NetworkInfoRetrievedL in AppUi.h:
    Quote Originally Posted by Tanya
    void NetworkInfoRetrievedL(const CTelephony::TNetworkInfoV1& aNetworkInfo);
    which is ok, but you have not defined it in the AppUi.cpp. That would be the place wher you get the notification, something like this:
    Code:
    void CMobInfoExampleAppUi::NetworkInfoRetrievedL(const CTelephony::TNetworkInfoV1& aNetworkInfo)
    {
       // I've got networkinfo!
       DoSomethingWithIt;
    }
    Also note that in your original post MNetworkInfoObserver contained HandleNetworkInfoError. If it was you who has removed it, consider putting it back, and implementing the method, otherwise the code is going to malfunction in a really weird way.

Similar Threads

  1. speech recognition in s60 3rd edition
    By fatema27 in forum Symbian
    Replies: 10
    Last Post: 2008-08-14, 06:06
  2. Replies: 7
    Last Post: 2007-11-30, 14:49
  3. Progress indicator in alert of S60 3rd edition
    By jini_1 in forum Mobile Java General
    Replies: 2
    Last Post: 2006-10-24, 07:37
  4. Carbide c++ and S60 3rd Edition Feature Pack 1 Working
    By jimgilmour1 in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2006-10-18, 20:39
  5. RTP stack on S60 3rd edition
    By kit_walker in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-09-28, 14:37

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×