--- a/engine/inc/ConnectionEngine.h Sat Oct 23 16:26:37 2010 +0100
+++ b/engine/inc/ConnectionEngine.h Sun Oct 24 01:27:31 2010 +0100
@@ -68,6 +68,8 @@
RConnection& Connection();
TConnectionState ConnectionState();
IMPORT_C void AddObserver(MConnectionObserver* aObserver);
+ IMPORT_C void RemoveObserver(MConnectionObserver* aObserver);
+
RSocketServ& SockServ();
void Stop();
private: // Methods
--- a/engine/inc/HttpClient.h Sat Oct 23 16:26:37 2010 +0100
+++ b/engine/inc/HttpClient.h Sun Oct 24 01:27:31 2010 +0100
@@ -54,7 +54,7 @@
void DoGetAfterConnectL();
private:
RHTTPSession iSession;
- TBool iWaitingForGet;
+ TBool iWaitingForGet; // whether to run the Get after successfull connect
TBool iIsActive;
RHTTPTransaction iTrans;
CHttpEventHandler* iHandler;
--- a/engine/src/ConnectionEngine.cpp Sat Oct 23 16:26:37 2010 +0100
+++ b/engine/src/ConnectionEngine.cpp Sun Oct 24 01:27:31 2010 +0100
@@ -55,16 +55,21 @@
}
void CConnectionEngine::RunL()
- {
- if ( iStatus.Int() == KErrNone )
- {
- delete iMobility;
- iMobility = NULL;
- iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this );
+ {
+ DP1("CConnectionEngine::RunL BEGIN, iStatus.Int()=%d", iStatus.Int());
+ if ( iStatus.Int() == KErrNone && iMobility == NULL)
+ {
+ TRAPD(err, iMobility = CActiveCommsMobilityApiExt::NewL( iConnection, *this ));
+
+ if (err != KErrNone)
+ {
+ DP1("Leave in CActiveCommsMobilityApiExt::NewL, err=%d", err);
+ }
}
iConnectionState = iStatus.Int() == KErrNone?CConnectionEngine::EConnected:CConnectionEngine::ENotConnected;
ReportConnectionL( iStatus.Int() );
+ DP("CConnectionEngine::RunL END");
}
void CConnectionEngine::DoCancel()
@@ -80,7 +85,8 @@
TAccessPointInfo /*aNewAPInfo*/,
TBool aIsUpgrade,
TBool aIsSeamless )
- {
+ {
+ DP("CConnectionEngine::PreferredCarrierAvailable");
if ( aIsUpgrade )
{
}
@@ -103,6 +109,7 @@
void CConnectionEngine::NewCarrierActive( TAccessPointInfo /*aNewAPInfo*/, TBool aIsSeamless )
{
+ DP("CConnectionEngine::NewCarrierActive");
if ( aIsSeamless )
{
// in S60 3.2, this situation cannot occur.
@@ -124,6 +131,7 @@
TBool CConnectionEngine::ConnectionSettingL()
{
+ DP("CConnectionEngine::ConnectionSettingL");
TBool selected( EFalse );
CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
@@ -147,7 +155,7 @@
void CConnectionEngine::StartL(TConnectionType aConnectionType)
{
- DP1("CConnectionEngine::StartL, aConnectionType=%d", aConnectionType);
+ DP1("CConnectionEngine::StartL BEGIN, aConnectionType=%d", aConnectionType);
iConnection.Close();
User::LeaveIfError( iConnection.Open( iSocketServer ) );
@@ -206,6 +214,7 @@
iConnectionType = aConnectionType;
iConnectionState = CConnectionEngine::EConnecting;
+ DP1("CConnectionEngine::StartL END, iConnectionState=%d", iConnectionState);
}
void CConnectionEngine::Stop()
@@ -223,6 +232,7 @@
CConnectionEngine::TConnectionState CConnectionEngine::ConnectionState()
{
+ DP("CConnectionEngine::ConnectionState BEGIN");
TInt selectedConn = (TInt) iSnapPreference.Snap();
TInt specIAPSNAP = iPodcastModel.SettingsEngine().SpecificIAP();
// If we have IAP preference then get that from our current connection and mask out the selected iap
@@ -266,14 +276,29 @@
}
}
+ DP("CConnectionEngine::ConnectionState END");
return iConnectionState;
}
EXPORT_C void CConnectionEngine::AddObserver(MConnectionObserver* aObserver)
{
+ DP("CConnectionEngine::AddObserver");
iObserverArray.Append(aObserver);
}
+EXPORT_C void CConnectionEngine::RemoveObserver(MConnectionObserver* aObserver)
+ {
+ DP("CConnectionEngine::RemoveObserver");
+ for (int i=0;i<iObserverArray.Count();i++)
+ {
+ if (iObserverArray[i] == aObserver)
+ {
+ iObserverArray.Remove(i);
+ }
+
+ }
+ }
+
RSocketServ& CConnectionEngine::SockServ()
{
return iSocketServer;
@@ -282,10 +307,13 @@
void CConnectionEngine::ReportConnectionL(TInt aError)
{
+ DP1("CConnectionEngine::ReportConnectionL, aError=%d", aError);
TInt noObservers = iObserverArray.Count();
+ DP1(" noObservers=%d", noObservers);
while(noObservers)
{
noObservers--;
+ DP(" calling callback");
iObserverArray[noObservers]->ConnectCompleteL(aError);
}
}
--- a/engine/src/HttpClient.cpp Sat Oct 23 16:26:37 2010 +0100
+++ b/engine/src/HttpClient.cpp Sun Oct 24 01:27:31 2010 +0100
@@ -20,6 +20,9 @@
CHttpClient::~CHttpClient()
{
+
+ iPodcastModel.ConnectionEngine().RemoveObserver(this);
+
if (iHandler)
{
iHandler->CloseSaveFile();
@@ -111,29 +114,38 @@
void CHttpClient::ConnectCompleteL(TInt aErrorCode)
{
+ DP1("CHttpClient::ConnectCompleteL BEGIN, aErrorCode=%d", aErrorCode);
+ DP1(" iWaitingForGet=%d", iWaitingForGet);
if(iWaitingForGet)
{
iWaitingForGet = EFalse;
if( aErrorCode == KErrNone)
{
+ TRAP_IGNORE(iSession.OpenL());
+ DP(" one");
RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
+ DP(" one point five");
RStringPool pool = iSession.StringPool();
// Attach to socket server
+ DP(" two");
connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(iPodcastModel.ConnectionEngine().SockServ().Handle()));
// Attach to connection
+ DP(" three");
TInt connPtr = REINTERPRET_CAST(TInt, &iPodcastModel.ConnectionEngine().Connection());
connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(connPtr));
-
+ DP(" four");
iPodcastModel.SetProxyUsageIfNeededL(iSession);
- DoGetAfterConnectL();
+ DoGetAfterConnectL();
+ //iWaitingForGet = EFalse; // set to true by DoGetAfterConnectL
}
else
{
ClientRequestCompleteL(KErrCouldNotConnect);
iSession.Close();
}
- }
+ }
+ DP("CHttpClient::ConnectCompleteL END");
}
void CHttpClient::Disconnected()
@@ -144,6 +156,7 @@
void CHttpClient::DoGetAfterConnectL()
{
+ DP("CHttpClient::DoGetAfterConnectL BEGIN");
// since nothing should be downloading now. Delete the handler
if (iHandler)
{
@@ -158,7 +171,7 @@
TBuf8<KTempBufferSize> rangeText;
if (iResumeEnabled && iPodcastModel.FsSession().Entry(iCurrentFileName, entry) == KErrNone) {
- DP1("Found file, with size=%d", entry.iSize);
+ DP1(" Found file, with size=%d", entry.iSize);
// file exists, so we should probably resume
rangeText.Format(_L8("bytes=%d-"), (entry.iSize-KByteOverlap > 0 ? entry.iSize-KByteOverlap : 0));
iHandler->SetSaveFileName(iCurrentFileName, ETrue);
@@ -179,7 +192,7 @@
SetHeaderL(hdr, HTTP::EAccept, KAccept);
TBuf<KTempBufferSize> range16;
range16.Copy(rangeText);
- DP1("range text: %S", &range16);
+ DP1(" range text: %S", &range16);
if (rangeText.Length() > 0) {
SetHeaderL(hdr, HTTP::ERange, rangeText);
}
@@ -187,7 +200,7 @@
// submit the transaction
iTrans.SubmitL();
iIsActive = ETrue;
- DP("CHttpClient::Get END");
+ DP("CHttpClient::DoGetAfterConnectL END");
}
TBool CHttpClient::GetL(const TDesC& aUrl, const TDesC& aFileName, TBool aSilent) {
@@ -215,17 +228,18 @@
iSilentGet = aSilent;
iCurrentFileName.Copy(aFileName);
- iWaitingForGet = ETrue;
if (iTransactionCount == 0)
{
DP("CHttpClient::GetL\t*** Opening HTTP session ***");
iSession.Close();
iSession.OpenL();
+ iWaitingForGet = ETrue;
ConnectHttpSessionL();
}
else
{
+ iWaitingForGet = EFalse;
DoGetAfterConnectL();
}
return ETrue;
@@ -257,9 +271,10 @@
}
void CHttpClient::ClientRequestCompleteL(TInt aErrorCode) {
+ DP1("CHttpClient::ClientRequestCompleteL, aErrorCode=%d", aErrorCode);
iIsActive = EFalse;
iObserver.CompleteL(this, aErrorCode);
- DP("CHttpClient::ClientRequestCompleteL");
+ DP1(" iTransactionCount=%d", iTransactionCount);
if(iTransactionCount>0)
{
iTransactionCount--;
--- a/engine/src/HttpEventHandler.cpp Sat Oct 23 16:26:37 2010 +0100
+++ b/engine/src/HttpEventHandler.cpp Sun Oct 24 01:27:31 2010 +0100
@@ -61,6 +61,7 @@
void CHttpEventHandler::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
{
+ DP1("CHttpEventHandler::MHFRunL, aEvent.iStatus=%d", aEvent.iStatus);
switch (aEvent.iStatus)
{
case THTTPEvent::EGotResponseHeaders:
@@ -431,6 +432,7 @@
void CHttpEventHandler::CloseSaveFile()
{
+ DP("CHttpEventHandler::CloseSaveFile BEGIN");
if(iRespBody != NULL)
{
if(iRespBodyFile.SubSessionHandle() != 0)
@@ -441,5 +443,6 @@
iRespBodyFile.Close();
}
}
+ DP("CHttpEventHandler::CloseSaveFile BEGIN");
}