Hi,
I am using a RConnection to open a WLan connection. Below is the code
Header file
Source fileCode:class CConnectionMaker : public CActive { public: static CConnectionMaker* NewL(); static CConnectionMaker* NewLC(); ~CConnectionMaker(); public: void ConnectL(TUint32 aIapId); void Disconnect(); protected: void DoCancel(); void RunL(); TInt RunError(TInt aError); static TInt TimeoutCallback(TAny* aAny); private: CConnectionMaker(); void ConstructL(); private: RSocketServ iSocketServer; RConnection iConnection; CPeriodic* iPeriodic; public: };
Now when I am trying to connect to a access point for the first time I am able to connect to it.Code:CConnectionMaker * CConnectionMaker::NewL() { CConnectionMaker* self = NewLC (); CleanupStack::Pop (self); return self; } CConnectionMaker* CConnectionMaker::NewLC() { CConnectionMaker* self = new (ELeave) CConnectionMaker(); CleanupStack::PushL (self); self->ConstructL (); return self; } CConnectionMaker::~CConnectionMaker() { Deque(); delete iPeriodic; iConnection.Close (); iSocketServer.Close (); } CConnectionMaker::CConnectionMaker() : CActive(CActive::EPriorityStandard) { } void CConnectionMaker::ConstructL() { User :: LeaveIfError (iSocketServer.Connect (KESockDefaultMessageSlots)); /** create the timeout timer */ iPeriodic = CPeriodic::NewL (EPriorityStandard); /** Add to active scheduler */ CActiveScheduler::Add (this); } void CConnectionMaker::DoCancel() { iPeriodic->Cancel (); iConnection.Close(); } void CConnectionMaker::RunL() { User::LeaveIfError(iStatus.Int()); iPeriodic->Cancel (); // some notification code ........ } TInt CConnectionMaker::RunError(TInt aError) { iPeriodic->Cancel (); // some notification code ........ return KErrNone; } void CConnectionMaker::ConnectL(TUint32 aIapId) { Cancel (); iConnection.Close (); User :: LeaveIfError (iConnection.Open (iSocketServer)); TCommDbConnPref prefs; prefs.SetDialogPreference (ECommDbDialogPrefDoNotPrompt); prefs.SetDirection (ECommDbConnectionDirectionOutgoing); prefs.SetIapId (aIapId); iConnection.Start (prefs, iStatus); SetActive (); iPeriodic->Start (250000000, 250000000, TCallBack (CConnectionMaker::TimeoutCallback, this)); } void CConnectionMaker::Disconnect() { iConnection.Close(); } TInt CConnectionMaker::TimeoutCallback(TAny* aAny) { CConnectionMaker* parent = static_cast<CConnectionMaker*>(aAny); parent->iConnection.Stop(); return KErrNone; }
When I forcefully disconnect it with "Conn. Mgr." it get disconnected (the icon vanish). When I try to connect it second time it cannot start connection and my Timer expires. This connection is in midway as my RunL is not called for very long time. So I call iConnection->Stop(); My RunL is called after but this Connection is not closed (even if i closed my application). I still see icon and connecting status in "Conn. mgr.".
I have to explectly delete it with "Conn. mgr."
Can some one help me in figuring out the problem
Also how "conn. mgr." achive this functionality of disconnection. I could even use that to release the connection.
Regards
Ashfaq Ghori




