예제 #1
0
// -----------------------------------------------------------------------------
// CNSmlHTTP::~CNSmlHTTP()
// desctructor
// -----------------------------------------------------------------------------
//
CNSmlHTTP::~CNSmlHTTP() 
	{
DBG_FILE(_S8("CNSmlHTTP::~CNSmlHTTP() BEGIN"));
if(FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
{
	DeleteCertificate(); 
}

	Cancel();
	delete iData;
	delete iReqBodySubmitBuffer;
	delete iURI;
	delete iMimeType;
	delete iHTTPusername;	
	delete iHTTPpassword;	
	delete iShutdown;
	iShutdown = NULL;
	if(iNetworkStatusEngine)
	{
		delete iNetworkStatusEngine;
		iNetworkStatusEngine = NULL;
	}
	iSess.Close();
	delete iTransObs;
	delete iDialUpAgent;
    delete iIAPidArray;
    FeatureManager::UnInitializeLib();
    DBG_FILE(_S8("CNSmlHTTP::~CNSmlHTTP() END"));
	}
// -----------------------------------------------------------------------------
// CPluginServiceTimer::ConstructL()
// -----------------------------------------------------------------------------
//
void CPluginServiceTimer::ConstructL()
	{
	DBG_FILE( _S8( "CPluginServiceTimer::ConstructL()" ) );
	// create a thread-relative timer
	User::LeaveIfError( iTimer.CreateLocal() );
	DBG_FILE( _S8( "CPluginServiceTimer::ConstructL() : end" ) );
	}
// -----------------------------------------------------------------------------
// CPluginServiceTimer::StopTimer()
// -----------------------------------------------------------------------------
//
void CPluginServiceTimer::StopTimer()
	{
	DBG_FILE( _S8( "CPluginServiceTimer::StopTimer()" ) );
	iEngine->iSessionActive = ETrue;	
	DBG_FILE( _S8( "iSessiActive = ETrue" ) );
	DBG_FILE( _S8( "CPluginServiceTimer::StopTimer() : end" ) );
	}
예제 #4
0
// -----------------------------------------------------------------------------
// CNSmlHTTP::DoCancel()
// DoCancel() from CActive
// -----------------------------------------------------------------------------
//
void CNSmlHTTP::DoCancel() 
	{DBG_FILE(_S8("CNSmlHTTP::DoCancel() BEGIN"));
	iEngineState = ExptIdle;
	TInt cancelReason;
	
	iShutdown->Cancel();
	iDialUpAgent->Cancel();
	iSess.Close();

	if( iTimeOut )
		{DBG_FILE(_S8("CNSmlHTTP::DoCancel() timing out"));
		cancelReason = TNSmlHTTPErrCode::ENSmlHTTPErr_RequestTimeout;
		}
	else
		{
		cancelReason = KErrCancel;
		}
	// signal current (engine) thread request semaphore that this AO's 
	// request has completed
	TRequestStatus* status = &iStatus;		
	User::RequestComplete( status, cancelReason );
	// signal agent
	TRequestStatus* agentStatus = iAgentStatus;
	User::RequestComplete( agentStatus, cancelReason );
	DBG_FILE(_S8("CNSmlHTTP::DoCancel() END"));
	}
void CNsmlNetworkStatusEngine::ConstructL( )
{
	DBG_FILE(_S8("CNsmlNetworkStatusEngine::ConstructL, BEGIN "));
	iTimerOn = EFalse;
	iConnectionMonitor.ConnectL();
	iTimedExecuteStopSession = NULL;
	DBG_FILE(_S8("CNsmlNetworkStatusEngine::ConstructL, END "));	 
}
// -----------------------------------------------------------------------------
// CNsmlNetworkStatusEngine::StopDMSession()
// Stops DM session by calling http cancel 
// -----------------------------------------------------------------------------
//	
void CNsmlNetworkStatusEngine::StopDMSession()
	{
	DBG_FILE(_S8("CNsmlNetworkStatusEngine::StopDMSession STARTS   "));
	iTimerOn = EFalse;
	DBG_FILE(_S8("CNsmlNetworkStatusEngine::StopDMSession calling http->Cancel"));
	iAgent->iTimeOut =ETrue; //added for showing timeout note
	iAgent->Cancel();
	DBG_FILE(_S8("CNsmlNetworkStatusEngine::StopDMSession ENDS    "));
	}
// -----------------------------------------------------------------------------
// CPluginServiceTimer::RunL()
// -----------------------------------------------------------------------------
//
void CPluginServiceTimer::RunL()
	{
	DBG_FILE( _S8( "CPluginServiceTimer::RunL()" ) );
	iEngine->iSessionActive = EFalse;
	DBG_FILE( _S8( "iSessionActive = EFalse" ) );
	iEngine->iStartTimer = EFalse;
	DBG_FILE( _S8( "iStartTimer = EFalse" ) );
	DBG_FILE( _S8( "CPluginServiceTimer::RunL() : end" ) );
	}
void CNsmlNetworkStatusEngine::NotifyL()
{
	DBG_FILE(_S8("CNsmlNetworkStatusEngine::NotifyL Begin  "));
	iConnectionMonitor.NotifyEventL( *this );
	DBG_FILE(_S8("CNsmlNetworkStatusEngine::NotifyL, after registering  "));
   // Threholds
	TInt    err = iConnectionMonitor.SetUintAttribute( EBearerIdGPRS, 
                                               0, 
                                               KSignalStrengthThreshold, 
                                               1 );    
	DBG_FILE(_S8("CNsmlNetworkStatusEngine::NotifyL : END "));
                                                                                          
}
CNsmlNetworkStatusEngine::~CNsmlNetworkStatusEngine( )
{
	DBG_FILE(_S8("~CNsmlNetworkStatusEngine Destructor starts  "));
	StopNotify();
	iConnectionMonitor.Close();
	if ( iTimedExecuteStopSession ) 
    {
     iTimedExecuteStopSession->Cancel();
     delete iTimedExecuteStopSession;
     iTimedExecuteStopSession = NULL;
     }
    DBG_FILE(_S8("~CNsmlNetworkStatusEngine Destructor ENDs  "));     
            
}
// -----------------------------------------------------------------------------
// CPluginServiceTimer::StartTimer()
// -----------------------------------------------------------------------------
//
void CPluginServiceTimer::StartTimer()
	{
	DBG_FILE( _S8( "CPluginServiceTimer::StartTimer()" ) );
	if( !IsActive() )
		{
		DBG_FILE( _S8( "!IsActive()" ) );
		iTimer.After( iStatus, TTimeIntervalMicroSeconds32( iValue ) );
		iEngine->iSessionActive = ETrue;
		SetActive();
		DBG_FILE( _S8( "SetActive()" ) );
		}

	DBG_FILE( _S8( "CPluginServiceTimer::StartTimer() : end" ) );
	}
static TInt StaticDoStopDMSession(TAny *aPtr)
    {

    DBG_FILE(_S8("StaticDoStopDMSession start "));
               
    CNsmlNetworkStatusEngine* srv = (CNsmlNetworkStatusEngine*) aPtr;
    TRAPD( err,  srv->StopDMSession() );
    if(err) 
        {
       	DBG_FILE_CODE(err,_S8("StaticDoStopDMSession err after calling StopDMSession"));
        }

    DBG_FILE(_S8(" StaticDoStopDMSession ENDS "));
    return err;
    }
예제 #12
0
// -----------------------------------------------------------------------------
// CNSmlHTTP::CompleteRequest()
// called when asynchronous request should be completed with a purpose
// -----------------------------------------------------------------------------
//
void CNSmlHTTP::CompleteRequest()
{
	DBG_FILE(_S8("CNSmlHTTP::CompleteRequest BEGIN"));
		
		if(IsActive())
		{
		DBG_FILE(_S8("CNSmlHTTP::CompleteRequest iTrans.Cancel();"));
		iTrans.Cancel();
		DBG_FILE(_S8("CNSmlHTTP::CompleteRequest iTrans.Close();"));
		iTrans.Close();
		DBG_FILE(_S8("CNSmlHTTP::CompleteRequest isActive returned TRUE  "));
		iPreemptRequest++;
		DBG_FILE_CODE( iPreemptRequest, _S8("Increasing value of iPreemptRequest ") );
				TRequestStatus* status = &iStatus;
		User::RequestComplete( status, KErrTimedOut );
		}

	DBG_FILE(_S8("CNSmlHTTP::CompleteRequest ENDS "));
}
예제 #13
0
// ---------------------------------------------------------
// CNSmlDSAlert::StartSync( const TDesC8& aSyncMLMessage, TInt aTransport, TBTDevAddr aBTAddress,
//    						const TDesC& aBTName, MNSmlAlertObexPluginContext* aPluginContext )
// Both standards supported (1.1 and 1.2)
// ---------------------------------------------------------
//
	TNSmlAlertResult CNSmlDSAlert::StartSyncL(
    const TDesC8& aSyncMLMessage,
    TInt aTransport,
    TBTDevAddr /* aBTAddress */,
    const TDesC& /* aBTName */,
    MNSmlAlertObexPluginContext* /* aPluginContext */)
 	{
	DBG_FILE(_S8("CNSmlDSAlert::StartSync begins"));
	// Handling 1.2 Notification package
	//==================================
	TSmlProtocolVersion protocol(ESmlVersion1_2);
		
	if ( ! Is12Package( aSyncMLMessage ) )
		{
		// Handling 1.1 Package0
		//======================
		TRAPD( parseErr, ParseMessageL( aSyncMLMessage ) );
		if ( ( parseErr != KErrNone ) || (iPacketShouldGoToMdo) )
			{
			// It may be MDO package
			return TNSmlAlertResult( ENSmlErrNotConsumed );
			}
		
		protocol = ESmlVersion1_1_2;
		
		}
	
	RNSmlPrivateAPI privateApi;
	TRAPD(openErr, privateApi.OpenL());
	
	if ( openErr != KErrNone )
		{
		return ENSmlErrUndefined;
		}
	
	const TUid transportId = { aTransport };
 	
	TRAPD(connErr, privateApi.SendL(aSyncMLMessage, ESmlDataSync, 
	        protocol, transportId ));
	
	if ( connErr != KErrNone )
		{
		privateApi.Close();
		return ENSmlErrUndefined;
		}
		
	privateApi.Close();
	
	return ENSmlErrNone;
	}
예제 #14
0
// CNSmlHTTP::RunL()
// Runl() from CActive
// called when asynchronous request completed
// -----------------------------------------------------------------------------
//
void CNSmlHTTP::RunL() 
	{
	DBG_FILE(_S8("CNSmlHTTP::RunL begins"));

	DBG_FILE_CODE( iEngineState, _S8("RunL iEgnineStatus is : ") );
	DBG_FILE_CODE( iStatus.Int(), _S8("RunL httpClient status is : ") );
	if(iEngineState == ExptOpenCommunication)
		{
		DBG_FILE(_S8("CNSmlHTTP::RunL before SetHttpConnectionInfoL"));
		DBG_FILE_CODE( iStatus.Int(), _S8("RunL HTTP client iStatus: ") );
		if( iStatus == KErrNone) 
			{  
			DBG_FILE(_S8("CNSmlHTTP::RunL Status was NO ERROR"));
			TRAPD( ret, SetHttpConnectionInfoL( EFalse ) );
			if ( ret != KErrNone )
				{
				DBG_FILE_CODE( ret, _S8("CNSmlHTTP::RunL SetHttpConnectionInfoL\
				 error:") );
				iShutdown->Cancel();
				TRequestStatus* status = iAgentStatus;
				User::RequestComplete( status, ret );
				iTimeOut = EFalse;
				return;
				}
void CNsmlNetworkStatusEngine::EventL( const CConnMonEventBase& aConnMonEvent )
{

	DBG_FILE(_S8("CNsmlNetworkStatusEngine::EventL, BEGIN"));
	DBG_ARGS8(_S8("CNsmlNetworkStatusEngine::EventL event is ==  %d"), aConnMonEvent.EventType()  );
	switch ( aConnMonEvent.EventType() )
	{
	case EConnMonNetworkStatusChange:
	{
	const CConnMonNetworkStatusChange* eventNetworkStatus;
    eventNetworkStatus = ( const CConnMonNetworkStatusChange* ) &aConnMonEvent;
    iNetwStatus   = eventNetworkStatus->NetworkStatus();
    DBG_ARGS8(_S8("CNsmlNetworkStatusEngine::EventL EConnMonNetworkStatusChange: Network status event is ==  %d"), iNetwStatus  );   	
    switch( eventNetworkStatus->NetworkStatus() )
	{
		case EConnMonStatusActive:
		DBG_FILE(_S8("Network status ACTIVE"));
	    if(iTimerOn)
	    {
			iTimerOn = EFalse;
		    iSuspendDuration.HomeTime();
		    TTimeIntervalSeconds duration;
		    iSuspendDuration.SecondsFrom(iSuspendedTime,duration);
		    DBG_FILE_CODE(duration.Int(), _S8("CNsmlNetworkStatusEngine::EventL suspendDuration is "));        	 
			if ( iTimedExecuteStopSession ) 
			{
				iTimedExecuteStopSession->Cancel();
				delete iTimedExecuteStopSession;
				iTimedExecuteStopSession = NULL;
			}
		    if(duration.Int() >= KDMMaxHttpAutoResumeDurationSec)
			{
				iAgent->CompleteRequest();
			}
	    } // if itimerOn
	           
        break;
        case EConnMonStatusSuspended:
        DBG_FILE(_S8("HTTP  Network status SUSPEND and Timer will be set ON "));
	   	if(!iTimerOn)
		{
	    	CRepository *rep = NULL;
			TRAPD( err1, rep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ))
			iDMSmlSessionTimeout = -1;
			if(err1 == KErrNone)
			{
				TInt dmsessionTimeout = -1;
				rep->Get( KDevManDMSessionTimeout, dmsessionTimeout );
				delete rep;
				DBG_FILE_CODE(dmsessionTimeout, _S8("CNsmlNetworkStatusEngine::EventL session timeout duration from cenrep is "));        	 
				if( dmsessionTimeout < KNSmlDMMinSessionTimeout  || dmsessionTimeout > KNSmlDMMaxSessionTimeout )
				{
					dmsessionTimeout = -1;
					iDMSmlSessionTimeout = -1;
				}
				else
				{
					iDMSmlSessionTimeout =  dmsessionTimeout * 60* 1000000;
					iTimerOn = ETrue;
	    			iSuspendedTime.HomeTime();
	 		    	iTimedExecuteStopSession = CPeriodic::NewL (EPriorityNormal) ;
					iTimedExecuteStopSession->Start (
		    		TTimeIntervalMicroSeconds32(iDMSmlSessionTimeout)
		    		, TTimeIntervalMicroSeconds32(iDMSmlSessionTimeout)
		    		, TCallBack(StaticDoStopDMSession,this) ) ;
				}
			
			} // if KErrnone
			
	    	
	    } //if !iTimerON
		break;   
	    default: //for eventNetworkStatus->NetworkStatus()
		break;
     }
    break;
    }

	default: // for EConnMonNetworkStatusChange
	    break;
	}
}
// -----------------------------------------------------------------------------
// CPluginServiceTimer::~CPluginServiceTimer()
// -----------------------------------------------------------------------------
//
CPluginServiceTimer::~CPluginServiceTimer()
	{
	DBG_FILE( _S8( "CPluginServiceTimer::~CPluginServiceTimer()" ) );
	iTimer.Close();
	DBG_FILE( _S8( "CPluginServiceTimer::~CPluginServiceTimer() : end" ) );
	}
예제 #17
0
// -----------------------------------------------------------------------------
// CNSmlHTTP::ConstructL()
// 2-phase constructor
// -----------------------------------------------------------------------------
//
void CNSmlHTTP::ConstructL() 
	{
	// construct shutdown timer
	DBG_FILE(_S8("CNSmlHTTP::ConstructL BEGIN"));
	FeatureManager::InitializeLibL();
	iShutdown = new (ELeave) CNSmlXptShutdownTimer( this );
	iShutdown->ConstructL();
	iNetworkStatusEngine = NULL;
	// do this only if session is DM 
	TInt session=0;    
    TInt r=RProperty::Get( KPSUidNSmlSOSServerKey, KNSmlSyncJobOngoing, session);                       
    DBG_FILE_CODE(session, _S8("CNSmlHTTP::ConstructL Current Session is (DM = 2, DS = 1) "));
    if( session == ESyncMLDMSession )//for dm session
       {
		TInt dmsessionTimeout = -1;
		CRepository *rep = NULL;
		TRAPD( err1, rep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ))
		DBG_FILE_CODE(err1, _S8("CNSmlHTTP::ConstructL cenrep read error code "));
		if(err1 == KErrNone)
		{
			rep->Get( KDevManDMSessionTimeout, dmsessionTimeout );
			delete rep;
			DBG_FILE_CODE(dmsessionTimeout, _S8("CNSmlHTTP::ContructL, DMSessiontimeout feature value from cenrep"));
			if( dmsessionTimeout > KNSmlDMMaxSessionTimeout || dmsessionTimeout < KNSmlDMMinSessionTimeout)
			{
			dmsessionTimeout = -1;
			}
			DBG_FILE_CODE(dmsessionTimeout, _S8("CNSmlHTTP::ContructL, DMSessiontimeout feature value "));
		}
		if(dmsessionTimeout != -1)
		{
			iNetworkStatusEngine = new (ELeave) CNsmlNetworkStatusEngine( this );
			iNetworkStatusEngine->ConstructL();
			iNetworkStatusEngine->NotifyL();
		}
       }
	
	iPreemptRequest = 0; 

	iServerContentEncoding = ExptNone;
	iServerAcceptEncoding = ExptNone;
	iSession = ESyncMLSessionUnknown;
    RProperty::Get( KPSUidNSmlSOSServerKey, KNSmlSyncJobOngoing, iSession);                       
	// construct dialup agent
	iDialUpAgent = new (ELeave) CNSmlDialUpAgent();
	iDialUpAgent->ConstructL();

	iEngineState = ExptIdle;
	iTimeOut = EFalse;
	iLastPart = EFalse;
	iAuthRetryCount=0;
	iAuthUsed=0;
	
	iTransObs = CHttpEventHandler::NewL();
	iTransObs->ConstructL( this );
	iMaxMsgSize = KNSmlDefaultWorkspaceSize;
		
    if( iSession == ESyncMLDSSession )
        {        
        TInt value(0);
        TRAPD( err, ReadRepositoryL( KNSmlMaxMsgSizeKey, value) );      
        if ( err == KErrNone )
            {
            iMaxMsgSize = value;
            }
        }
	}
// -----------------------------------------------------------------------------
// CPluginServiceTimer::DoCancel()
// -----------------------------------------------------------------------------
//
void CPluginServiceTimer::DoCancel()
	{
	DBG_FILE( _S8( "CPluginServiceTimer::DoCancel()" ) );
	iTimer.Cancel();
	DBG_FILE( _S8( "CPluginServiceTimer::DoCancel() : end" ) );
	}
예제 #19
0
void _cdecl main (SHORT argc, char *argv[])
{
//  bool ok = FALSE;
//  char test[5];       // test for trap 05 errors
ULONG ulTimes;          // need for Trap Ctrl-Break Signal

#ifdef TESTING
  if(!dout) {
    DosBeep(500,300);
  }
  if(!memout) {
    DosBeep(1000,300);
  }
#endif

#ifdef ERR_HAND
rc = set_int24();
  if(rc != 0) {
     err_exit("Error initializing error handler", 3);
  }

MYEXCEPTIONREGISTRATIONRECORD myExceptionRegRecord;
myExceptionRegRecord.prev_structure = NULL;
myExceptionRegRecord.ExceptionHandler = MyExceptionHandler;
DosSetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord);
DosSetSignalExceptionFocus(SIG_SETFOCUS, &ulTimes);

if(setjmp(myExceptionRegRecord.env))
   goto OnException;
#endif

  DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl);

filesys_init();
get_current_directory(cwd);               // init cur dir
Mem::vmem_setup();
strcpy(exe_dir, *argv);    // assume loaded via X:\subdir\KED.EXE

DBG_FILE(dout << "EXE_DIR =  " << exe_dir <<endl);
DBG_MEM(memout<< " main after except setup "<< checkmem2 << endl);

assure_windows_ready();

if(!thread_init()) {
   err_exit("Error creating initial threads", 5);
}
process_env_string ("EDITOR");  /* do parameters from environment string */
strcpy (progname,*argv);
argc--;                         /* don't count program name */
argv++;
while (argc--) {                /* process each parameter */
   process_arg (*argv);
   argv++;
   }
if (!*settings.help_path) {     /* help is usually in same dir as program */
    delta_filename (settings.help_path, progname, "*.HLP");
   }

//#ifdef TESTING
//if(!debug_on) {
//   dout.close();
//   memout.close();
//}
//#endif


  assure_1_view();
  DBG_INI(dout<<"edit.cpp line "<<__LINE__<<" shell_command.s = °"<<settings.shell_command.s<<"°"<<endl);
  DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl);
//  ok = load_keys();        //  Version 2.08 
//  if(!ok)
//    err_exit("Failed to load Keyboard driver", 10);

  edit_loop();
//  test[5000] = 'A';                    // test trap array bounds

  goto Ked_Exit;

OnException:
#ifdef ERR_HAND
DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord);
//  Screen.term_mess = "application trapped";
  err_exit(" application trapped", 20);
#endif

Ked_Exit:
#ifdef ERR_HAND
if(ORG_NUMLOCK) {
   DBG_NUML(dout<<" exit - setting NUMLOCK    on"<<endl);
   numlock_set(TRUE);
}
else {
   DBG_NUML(dout<<" exit - setting NUMLOCK    off"<<endl);
   numlock_set(FALSE);   
}
DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord);
#endif

DBG_MEM(memout<< " main after except setup "<< checkmem2 << endl);
DBG_BUGS(dout<<'\n'<<"    Normal Closedown in LOGFILE "<<endl);
}