×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Bangalore,India
    Posts
    129

    Phone Flickering problem

    Hi,
    When my app is running in background the app will perform http connection.But for every connetcion app phone is flickering.
    Does this is becoz of opening session every time or cpening connection or code i have chosen to set up IAP for HTTP connection?

    Code:
    CBlueIdClientEngine* CBlueIdClientEngine::NewL(MBlueIdClientObserver& aObserver)
    	{
    	CBlueIdClientEngine* self = CBlueIdClientEngine::NewLC(aObserver);
    	CleanupStack::Pop(self);
    	return self;
    	}
    CBlueIdClientEngine* CBlueIdClientEngine::NewLC(
    		MBlueIdClientObserver& aObserver)
    	{
    	CBlueIdClientEngine* self = new (ELeave) CBlueIdClientEngine(aObserver);
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	return self;
    	}
    CBlueIdClientEngine::CBlueIdClientEngine(MBlueIdClientObserver& aObserver) :
    	iObserver(aObserver), iRunning(EFalse)
    	{
    	// no implementation required
    	}
    CBlueIdClientEngine::~CBlueIdClientEngine()
    	{
    	iSession.Close();
    	}
    void CBlueIdClientEngine::ConstructL()
    	{
    	}void CBlueIdClientEngine::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField,
    		const TDesC8& aHdrValue)
    	{
    	RStringF valStr = iSession.StringPool().OpenFStringL(aHdrValue);
    	CleanupClosePushL(valStr);
    	THTTPHdrVal val(valStr);
    	aHeaders.SetFieldL(iSession.StringPool().StringF(aHdrField,
    			RHTTPSession::GetTable()), val);
    	CleanupStack::PopAndDestroy(&valStr);
    	}
    
    void CBlueIdClientEngine::DumpRespHeadersL(RHTTPTransaction& aTransaction)
    	{
    	RHTTPResponse resp = aTransaction.Response();
    	RStringPool strP = aTransaction.Session().StringPool();
    	RHTTPHeaders hdr = resp.GetHeaderCollection();
    	THTTPHdrFieldIter it = hdr.Fields();
    
    	HBufC* headerField = HBufC::NewLC(KMaxHeaderNameLength
    			+ KMaxHeaderValueLength);
    	HBufC* fieldValBuf = HBufC::NewLC(KMaxHeaderValueLength);
    
    	while (it.AtEnd() == EFalse)
    		{
    		RStringTokenF fieldName = it();
    		RStringF fieldNameStr = strP.StringF(fieldName);
    		THTTPHdrVal fieldVal;
    		if (hdr.GetField(fieldNameStr, 0, fieldVal) == KErrNone)
    			{
    			const TDesC8& fieldNameDesC = fieldNameStr.DesC();
    			headerField->Des().Copy(fieldNameDesC.Left(KMaxHeaderNameLength));
    			fieldValBuf->Des().Zero();
    			switch (fieldVal.Type())
    				{
    				// the value is an integer
    				case THTTPHdrVal::KTIntVal:
    					fieldValBuf->Des().Num(fieldVal.Int());
    					break;
    					// the value is a case-insensitive string
    				case THTTPHdrVal::KStrFVal:
    					{
    					RStringF fieldValStr = strP.StringF(fieldVal.StrF());
    					const TDesC8& fieldValDesC = fieldValStr.DesC();
    					fieldValBuf->Des().Copy(fieldValDesC.Left(
    							KMaxHeaderValueLength));
    					}
    					break;
    					// the value is a case-sensitive string
    				case THTTPHdrVal::KStrVal:
    					{
    					RString fieldValStr = strP.String(fieldVal.Str());
    					const TDesC8& fieldValDesC = fieldValStr.DesC();
    					fieldValBuf->Des().Copy(fieldValDesC.Left(
    							KMaxHeaderValueLength));
    					}
    					break;
    					// the value is a date/time
    				case THTTPHdrVal::KDateVal:
    					{
    					TDateTime date = fieldVal.DateTime();
    					TBuf<KMaxDateTimeStringLength> dateTimeString;
    					TTime t(date);
    					t.FormatL(dateTimeString, KDateFormat);
    					fieldValBuf->Des().Copy(dateTimeString);
    					}
    					break;
    					// the value is type is unknown
    				default:
    					break;
    				}
    
    			// Display HTTP header field name and value
    			headerField->Des().Append(KColon);
    			headerField->Des().Append(*fieldValBuf);
    			iObserver.ClientHeaderReceived(*headerField);
    
    			// Display realm for WWW-Authenticate header
    			RStringF wwwAuth = strP.StringF(HTTP::EWWWAuthenticate,
    					RHTTPSession::GetTable());
    			if (fieldNameStr == wwwAuth)
    				{
    				// check the auth scheme is 'basic'
    				RStringF basic = strP.StringF(HTTP::EBasic,
    						RHTTPSession::GetTable());
    				RStringF realm = strP.StringF(HTTP::ERealm,
    						RHTTPSession::GetTable());
    				THTTPHdrVal realmVal;
    				if ((fieldVal.StrF() == basic) && (!hdr.GetParam(wwwAuth,
    						realm, realmVal)))
    					{
    					RStringF realmValStr = strP.StringF(realmVal.StrF());
    					fieldValBuf->Des().Copy(realmValStr.DesC());
    					headerField->Des().Copy(Krealm);
    					headerField->Des().Append(*fieldValBuf);
    					iObserver.ClientHeaderReceived(*headerField);
    					}
    				}
    			}
    		++it;
    		}
    	CleanupStack::PopAndDestroy(fieldValBuf);
    	CleanupStack::PopAndDestroy(headerField);
    	}

  2. #2
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Bangalore,India
    Posts
    129

    Re: Phone Flickering problem

    Code:
    void CBlueIdClientEngine::HandleRunErrorL(TInt aError)
    	{
    	// Load a string from the resource file and add the leave code to string
    	HBufC* textResource = StringLoader::LoadL(R_WEBCLIENT_MHFRUN_ERROR, aError);
    	// Notify about the error
    	iObserver.ClientEvent(*textResource);
    	CleanupStack::PopAndDestroy(textResource);
    
    	}
    void CBlueIdClientEngine::SetupConnectionL()
    	{
    	
    	iSession.OpenL();
    	User::LeaveIfError(iSockServ.Connect());
    	User::LeaveIfError(iConnection.Open(iSockServ));
    	CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
    	CleanupStack::PushL(commDB);
    	CCommsDbConnectionPrefTableView* commDBView =
    			commDB->OpenConnectionPrefTableInRankOrderLC(
    					ECommDbConnectionDirectionOutgoing);
    	User::LeaveIfError(commDBView->GotoFirstRecord());
    	CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
    	commDBView->ReadConnectionPreferenceL(pref);
    	TUint32 iapID = pref.iBearer.iIapId;
    	CleanupStack::PopAndDestroy(commDBView);
    	CleanupStack::PopAndDestroy(commDB);
    	TCommDbConnPref connectPref;
    	connectPref.SetIapId(iapID);
    	connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    	connectPref.SetDirection(ECommDbConnectionDirectionOutgoing);
    	connectPref.SetBearerSet(ECommDbBearerGPRS | ECommDbBearerCdma2000
    			| ECommDbBearerLAN | ECommDbBearerCSD);
    	TInt errConnect = iConnection.Start(connectPref);
    
    	RStringPool strP = iSession.StringPool();
    	RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
    	connInfo.SetPropertyL(strP.StringF(HTTP::EHttpSocketServ,
    			RHTTPSession::GetTable()),
    
    	THTTPHdrVal(iSockServ.Handle()));
    	TInt connPtr = REINTERPRET_CAST(TInt, &(iConnection));
    	connInfo.SetPropertyL(strP.StringF(HTTP::EHttpSocketConnection,
    			RHTTPSession::GetTable()), THTTPHdrVal(connPtr));
    	if (errConnect != KErrNone)
    		{
    
    		TBuf<100> errMsg;
    		errMsg.Copy(_L("Unable to connect to server."));
    		iObserver.ClientEvent(errMsg);
    		return;
    		}
    
    	iConnectionSetupDone = ETrue;
    	}
    void CBlueIdClientEngine::IssueHTTPGetL(const TDesC8& aUri)
    	{
    	SetupConnectionL();
    	TUriParser8 uri;
    	uri.Parse(aUri);
    	// Get request method string for HTTP GET
    	RStringF method = iSession.StringPool().StringF(HTTP::EGET,
    			RHTTPSession::GetTable());
    
    	// Open transaction with previous method and parsed uri. This class will
    	// receive transaction events in MHFRunL and MHFRunError.
    	iTransaction = iSession.OpenTransactionL(uri, *this, method);
    
    	// Set headers for request; user agent and accepted content type
    	RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
    	SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    	SetHeaderL(hdr, HTTP::EAccept, KAccept);
    
    	// Submit the transaction. After this the framework will give transaction
    	// events via MHFRunL and MHFRunError.
    	iTransaction.SubmitL();
    
    	iRunning = ETrue;
    
    	// Load a string from the resource file 
    	HBufC* textResource = StringLoader::LoadLC(R_WEBCLIENT_CONNECTING);
    	iObserver.ClientEvent(*textResource);
    	CleanupStack::PopAndDestroy(textResource);
    	}
    
    void CBlueIdClientEngine::SetCallBack(CResponseView* aCallBack)
    	{
    	iResponseView = aCallBack;
    	}
    void CBlueIdClientEngine::CancelTransactionL()
    	{
    	if (!iRunning)
    		return;
    
    	// Close() also cancels transaction (Cancel() can also be used but 
    	// resources allocated by transaction must be still freed with Close())
    	iTransaction.Close();
    
    	// Not running anymore
    	iRunning = EFalse;
    
    	// Load a string from the resource file 
    
    	HBufC* textResource = StringLoader::LoadLC(R_WEBCLIENT_TRANSACTION_CANCEL);
    	iObserver.ClientEvent(*textResource);
    	CleanupStack::PopAndDestroy(textResource);
    	}
    void CBlueIdClientEngine::MHFRunL(RHTTPTransaction aTransaction,
    		const THTTPEvent& aEvent)
    	{
    	
    	switch (aEvent.iStatus)
    		{
    		case THTTPEvent::EGotResponseHeaders:
    			{
    		RHTTPResponse resp = aTransaction.Response();
    			DumpRespHeadersL(aTransaction);
    
    			}
    			break;
    
    		case THTTPEvent::EGotResponseBodyData:
    			{
    			MHTTPDataSupplier* body = aTransaction.Response().Body();
    			TPtrC8 dataChunk;
    
    			TBool isLast = body->GetNextDataPart(dataChunk);
    			iObserver.ClientBodyReceived(dataChunk);
    
    			if (isLast)
    				{
    
    				}
    
    			body->ReleaseData();
    			}
    			break;
    
    		case THTTPEvent::EResponseComplete:
    			{
    			// Indicates that header & body of response is completely received.
    
    
    			}
    			break;
    
    		case THTTPEvent::ESucceeded:
    			{
    			// Indicates that transaction succeeded. 
    
    			// Transaction can be closed now. It's not needed anymore.
    			aTransaction.Close();
    			iRunning = EFalse;
    			}
    			break;
    
    		case THTTPEvent::EFailed:
    			{
    			// Transaction completed with failure. 
    
    
    			aTransaction.Close();
    			iRunning = EFalse;
    			}
    			break;
    
    		default:
    			{
    			CSlimActAppUi* iAppui =
    					(CSlimActAppUi*) (CEikonEnv::Static()->AppUi());
    			HBufC* textResource;
    			if (aEvent.iStatus < 0)
    				{
    				iAppui->iGPRSFailed = ETrue;
    				textResource = StringLoader::LoadLC(
    						R_WEBCLIENT_TRANSACTION_ERROR,
    						aEvent.iStatus);
    				// Just close the transaction on errors
    				aTransaction.Close();
    				iRunning = EFalse;
    				}
    			else
    				{
    				iAppui->iGPRSFailed = ETrue;
    				textResource = StringLoader::LoadLC(
    						R_WEBCLIENT_UNRECOGNISED_EVENT,
    						aEvent.iStatus);
    				// Other events are not errors (e.g. permanent and temporary redirections)
    
    				}
    			iObserver.ClientEvent(*textResource);
    			CleanupStack::PopAndDestroy(textResource);
    			}
    			break;
    		}
    	}
    TInt CBlueIdClientEngine::MHFRunError(TInt aError,
    		RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/)
    	{
    	// Handle error and return KErrNone.
    	TRAPD( err, HandleRunErrorL( aError ) );
    	if (err)
    		Panic(EClientEngine);
    	return KErrNone;
    	}

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    2

    Re: Phone Flickering problem

    AFAIK setting up connection or opening a connection shouldnt lead to flickering. Are you craeting any UI object like dilaog etc at the time of making connection.

    And one more infor, you are not requred to setup the connection again and again. You can setup the connection once and can use it for sending the requests.

  4. #4
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Bangalore,India
    Posts
    129

    Re: Phone Flickering problem

    Hi,
    I am checking whether response is 0 or 1.
    If 0 still the app in background
    but 1 app comes to foreground.

    as my request will always get 0 it will be kept on called for SendToBackGround().
    so

    if connection made response is 0 the app which is background will be still in background
    by calling SendToBackGround().
    Here what i think is il put a bool variable.
    if app is running in background no need to call SendToBackGround().

    is that fine?

    And i will try setting up connection once.

    kusuma

  5. #5
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: Phone Flickering problem

    Quote Originally Posted by kusumat View Post
    Hi,
    I am checking whether response is 0 or 1.
    If 0 still the app in background
    but 1 app comes to foreground.

    as my request will always get 0 it will be kept on called for SendToBackGround().
    so

    if connection made response is 0 the app which is background will be still in background
    by calling SendToBackGround().
    Here what i think is il put a bool variable.
    if app is running in background no need to call SendToBackGround().

    is that fine?

    And i will try setting up connection once.

    kusuma

    If app is already in background you need not call sendToBackground try doing this.
    Regards,
    Shafali

Similar Threads

  1. Phone build problem
    By tinka_83 in forum Symbian
    Replies: 2
    Last Post: 2008-05-22, 18:56
  2. Problem related to phone call
    By praveenp in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2008-05-14, 16:50
  3. Eclipse/eclipseME problem invalid file error on phone
    By abonasoft in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2007-11-29, 08:02
  4. PC-Bluetooth Modem problem and question:
    By wireaudio in forum Bluetooth Technology
    Replies: 4
    Last Post: 2007-10-13, 05:27
  5. Replies: 0
    Last Post: 2007-07-14, 13:35

Posting Permissions

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