Exemplo n.º 1
0
bool Path::copy( const QString & src, const QString & dest )
{
	Path srcp( src ), destp( dest );
	if( !srcp.fileExists() || !destp.dir().dirExists() )
		return false;
#ifdef Q_OS_WIN
	bool s_unc = false, d_unc = false;
	
	QString srcw( srcp.path() );
	srcw = srcw.replace( "/", "\\" );
	QString destw( destp.path() );
	destw = destw.replace( "/", "\\" );
	
	if( srcw[0] == '\\' && srcw[1] == '\\' ) s_unc = true;
	if( destw[0] == '\\' && destw[1] == '\\' ) d_unc = true;
	srcw.replace( "\\\\", "\\" );
	if( s_unc ) srcw = "\\" + srcw;
	destw.replace( "\\\\", "\\" );
	if( d_unc ) destw = "\\" + destw;
	
	bool ret = CopyFileA( srcw.toLatin1(), destw.toLatin1(), false ) != 0;
	if( !ret ) {
		DWORD err = GetLastError();
		LOG_1( "Copy failed with error: " + QString::number(err) );
		LOG_1( "Src: " + srcw +  "Dest: " + destw );
	}
	return ret;
#else
	system( QString( "cp " + srcp.path() + " " + destp.path() ).toLatin1() );
	return true;
#endif
}
Exemplo n.º 2
0
// ---------------------------------------------------------------------------
// CLingerConnection::StartLinger
// ---------------------------------------------------------------------------
//
TInt CLingerConnection::StartLinger()
    {
    LOG_1( _L("CLingerConnection::StartLinger") );
    
    if ( !iAttached )
        {    
        // Read settings    
        ReadSettings();
         
        if ( iLingerInterval != 0 )
            {
            TInt err = OpenAndAttach();

            if ( err != KErrNone )
                {
                // Write to log
                LOG_2( _L("OpenAndAttach: err: %d"), err );    
                return( err );
                }
        
            if ( iLingerInterval > 0 )
                {
                // Start timer
                StartTimer( KDataInactivityInterval );
            
                LOG_1( _L("Linger timer started OK") );    
                }
            
            }
        }
        
    return KErrNone;                  
    }
Exemplo n.º 3
0
// ---------------------------------------------------------------------------
// CVpnSipObserver::RunL
// ---------------------------------------------------------------------------
//             
void CVpnSipObserver::RunL()
    {
    LOG_1( "CVpnSipObserver::RunL iStatus = %d", iStatus.Int());
    if ( iStatus == KErrNone ) 
        {
        TInt val = 0;
        // SIP Profile Server notified completion of SIP deregistration.
        TInt err = iSIPProperty.Get( KPSVpnSipUid, KVpnSipState, val );        
        if ( err == KErrNone && val == ESipDeregisterCompleted )
            {
            // If SIP is deregistered, let the VPN Connection Agent to 
            // proceed VPN session start.
            LOG_( "CVpnSipObserver::RunL SIP is deregistered. VPN Connection Agent continue with VPN start." );
            iAgent.ProceedServiceStart();            
            }
        else
            {
            // Keep monitoring.
            Subscribe();
            }
        }
    // Check if observer can be restarted.
    else if ( iStatus != KErrCancel 
           && iStatus != KErrServerTerminated
           && iStatus != KErrNotSupported )
        {
        // Keep monitoring.
        Subscribe();
        }
    else
        {
        // Error.
        LOG_1( "CVpnSipObserver::RunL Unknown error situation, iStatus = %d", iStatus.Int() );
        }
    }
// -----------------------------------------------------------------------------
// CSilenceAction::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSilenceAction::ConstructL( )
    {
    LOG_1( _L("->CSilenceAction::ConstructL: START") );     

    iPhoneClient = CPhCltCommandHandler::NewL();

    LOG_1( _L("<-CSilenceAction::ConstructL: END") );
    }
Exemplo n.º 5
0
JobBurner::JobBurner( const JobAssignment & jobAssignment, Slave * slave, int options )
: QObject( slave )
, mSlave( slave )
, mCmd( 0 )
, mJobAssignment( jobAssignment )
, mJob( jobAssignment.job() )
, mLoaded( false )
, mOutputTimer( 0 )
, mMemTimer( 0 )
, mLogFlushTimer( 0 )
, mCheckupTimer( 0 )
, mState( StateNew )
, mOptions( Options(options) )
, mCurrentCopy( 0 )
, mLogFilesReady( false )
, mLogFile( 0 )
, mLogStream( 0 )
, mCmdPid( 0 )
{
	mOutputTimer = new QTimer( this );
	connect( mOutputTimer, SIGNAL( timeout() ), SLOT( updateOutput() ) );

	mMemTimer = new QTimer( this );
	connect( mMemTimer, SIGNAL( timeout() ), SLOT( checkMemory() ) );

	mCheckupTimer = new QTimer( this );
	connect( mCheckupTimer, SIGNAL( timeout() ), SLOT( checkup() ) );
    mCheckupTimer->start(30000);
	
	/* Ensure we are actually assigned some tasks to work on */
	mTaskAssignments = mJobAssignment.jobTaskAssignments();
	if( mTaskAssignments.isEmpty() ) {
		jobErrored( QString("JobAssignment has no assigned tasks, Job Assignment key: %1").arg(mJobAssignment.key()) );
		return;
	}

	// Double check that we are still assigned
	mJobAssignment.reload();
	if( mJobAssignment.jobAssignmentStatus().status() != "ready" ) {
		LOG_1( "JobAssignment no longer ready, cancelling the burn" );
		cancel();
		return;
	}

	/* Make sure each of the tasks are still valid, some could have already been unassigned or cancelled */
	/* Also verify that the jobtask record matches the assignment */
	mTasks = JobTask::table()->records( mTaskAssignments.keys( JobTaskAssignment::schema()->field("fkeyjobtask")->pos() ), /*select=*/true, /*useCache=*/false );
	foreach( JobTaskAssignment jta, mTaskAssignments ) {
		JobTask task = jta.jobTask();
		if( jta.jobAssignmentStatus().status() != "ready" || task.status() != "assigned" || task.host() != Host::currentHost() ) {
			LOG_1( QString("JobTask no longer assigned, discarding. keyJobTask: %1  keyJobTaskAssignment: %2  jobtask status: %3 jobtaskassignment status: %4")
				.arg(task.key()).arg(jta.key()).arg(task.status()).arg(jta.jobAssignmentStatus().status()) );
			mTaskAssignments -= jta;
			mTasks -= task;
		}
	}
//-----------------------------------------------------------------------------
// CSilenceAction::ActionMuteRingingToneL
//-----------------------------------------------------------------------------
// 
void CSilenceAction::ActionMuteRingingTone( )
    {
    LOG_1( _L("->CSilenceAction::ActionMuteRingingTone: START") );
    if ( !IsActive() ) 
        {
        iPhoneClient->MuteRingingTone(iStatus);
        SetActive();
        }
    LOG_1( _L("<-CSilenceAction::ActionMuteRingingTone: END") );
    }
Exemplo n.º 7
0
// ---------------------------------------------------------------------------
// CLingerConnection::StopLinger
// ---------------------------------------------------------------------------
//
void CLingerConnection::StopLinger()
    {
    LOG_1( _L("CLingerConnection::StopLinger") );
    
    if ( iAttached )
        {    
        CancelTimer();
        CloseConnection();           
        iLingering = EFalse;
        
        LOG_1( _L("Linger timer stopped") );
        }      
    }
Exemplo n.º 8
0
void CPKCS12Handler::SaveCertificatesToDiskL() 
    {
    LOG_("-> CPKCS12Handler::SaveCertificatesToDiskL()");

    TInt certCount(0);

    // first the CAs (if any; not required necessarily)
    if (iCACerts) 
        {
        certCount = iCACerts->Count();
        LOG_1(" Saving %d CA Certificates", certCount);

        for (TInt i = 0; i < certCount; i++)
            {
            CX509Certificate* cert = iCACerts->At(i);

            // Generate filename with running identifier
            // Use TFileName, because the function isn't stack
            // critical
            TFileName fn;
            fn.Format(KCAFileNameStem(), i+1);

            WriteToFileL(cert->Encoding(), fn);
            }
        }
    LOG(else LOG_(" No CA Certs found!"));

    // Then the user certs
    if (iUserCerts)
        {
        certCount = iUserCerts->Count();
        LOG_1(" Saving %d User Certificates", certCount);

        for (TInt i = 0; i < certCount; i++) 
            {
            CX509Certificate* cert = iUserCerts->At(i);

            TFileName fn;
            fn.Format(KUserCertFileNameStem(), i+1);

            WriteToFileL(cert->Encoding(), fn);
            }
        }

    LOG(else LOG_(" No User Certs found!"));

    LOG_("<- CPKCS12Handler::SaveCertificatesToDiskL()");
    }
// ---------------------------------------------------------------------------
// CAORAUManagerImpl::RAUEventSubscribeIssueRequest
// ---------------------------------------------------------------------------
//
void CAORAUManagerImpl::RAUEventSubscribeIssueRequest(
    TRequestStatus& aStatus )
    {
    LOG_1( _L("CAORAUManagerImpl::RAUEventSubscribeIssueRequest") );
    
    iRAUEventProperty.Subscribe( aStatus );
    }
Exemplo n.º 10
0
// ---------------------------------------------------------------------------
// CAOTimer::StartRetryTimer
// ---------------------------------------------------------------------------
//
void CAOTimer::StartRetryTimer()
    {
    LOG_1( _L("CAOTimer::StartRetryTimer") );
    
    __ASSERT_DEBUG( !iRetryTimer->IsActive(),
        Panic( ERetryTimerAlreadyActive ) );
        
    iRetryTimerCount = 0;
    
    // First check if the current retry timer value is more than 30 minutes
    iCurrentRetryTimerInterval = 0;
    if( iSettings.RetryTimerValue() > KMaxTimerInSeconds )
        {
        // First interval is 30 minutes
        iCurrentRetryTimerInterval = KMaxTimerInSeconds * KSecondsToMicro;
        }
    else
        {
        // use current value
        iCurrentRetryTimerInterval =
            iSettings.RetryTimerValue() * KSecondsToMicro;
        }
    
    TCallBack cb( RetryTimerCallBack, this );
    iRetryTimer->Start(
        iCurrentRetryTimerInterval, iCurrentRetryTimerInterval, cb );
    }
Exemplo n.º 11
0
void CPKCS12Handler::AttachCertificateL(CX509Certificate* aCert, 
                                        const TPKIKeyIdentifier& aKeyId)
    {

    LOG_("-> CPKCS12Handler::AttachCertificateL()");

    TRequestStatus requestStatus;
    TAny* resArray(NULL);

    // Perform asynchronous PKI operation synchronously
    iPkiService->AttachCertificateL(aKeyId, DEFAULT_KEY_LEN, EPKIRSA, 
                                    aCert->Encoding(), &resArray, 
                                    requestStatus);

    User::WaitForRequest(requestStatus);
    iPkiService->Finalize(resArray);

    // Check for operation status    
    TInt status = requestStatus.Int();
    if (status != KErrNone)
        {
        LOG_1("<- CPKCS12Handler::AttachCertificateL() LEAVE: %d", status);
        User::Leave(status);
        }

    LOG_("<- CPKCS12Handler::AttachCertificateL() OK");
    }
Exemplo n.º 12
0
EXPORT_C void CPKCS12Handler::SaveSecurityObjectsToDiskL(const TDesC8& aData,
                                                         const TDesC& aPwd,
                                                         const TDesC& aDir) 
    {
    LOG_("-> CPKCS12Handler::SaveSecurityObjectsToDiskL()");

    if (iOutputDir) 
        {
        delete iOutputDir;
        iOutputDir = NULL;
        }

    // Output dir needs to end with backslash
    iOutputDir = aDir.AllocL();

    LOG_1(" Using output dir: '%S'", iOutputDir);

    ExtractSecurityObjectsL(aData, aPwd);

    // Save CA/user certificates to disk
    SaveCertificatesToDiskL();

    // Save private keys to disk
    SaveKeysToDiskL();

    LOG_("<- CPKCS12Handler::SaveSecurityObjectsToDiskL()");
    }
Exemplo n.º 13
0
// --------------------------------------------------------------------------
// TAOState::HandleResetFactorySettingsL
// --------------------------------------------------------------------------
//
TAOState* TAOState::HandleResetFactorySettingsL( TBool aReset )
{
    LOG_1( _L("TAOState::HandleResetFactorySettingsL") );

    TAOState* newState = NULL;
    if ( aReset )
    {
        // Close connection
        CancelAll();

        // Respond to Rfs that connection has been torn down and rfs sequence
        // can continue
        RProperty::Set(
            KPDPContextManager2,
            KPDPContextManagerFactorySettingsReset,
            EPDPContextManagerFactorySettingsResetStartReply );

        newState = iStatePool.ChangeState( EStateResetFactorySettings );
    }
    else
    {
        newState = DoActivatePDPContextL();
    }
    return newState;
}
Exemplo n.º 14
0
// ---------------------------------------------------------------------------
// CAOGpds::ConstructL
// ---------------------------------------------------------------------------
//
void CAOGpds::ConstructL()
    {
    LOG_1( _L("CAOGpds::ConstructL") );
    
    // Create active schduler wiat for synchronizing async operations    
    iWait = new( ELeave ) CActiveSchedulerWait;
    }
Exemplo n.º 15
0
void exploreFile( QString path )
{
	QFileInfo fi(path);
	QStringList args;
	QString dirPath = QFileInfo( path ).path();

	QString cmd;
	#ifdef Q_OS_WIN
	cmd = "explorer.exe";
	if( fi.isFile() && fi.exists() ) {
		args << "/select,";
		args << path.replace("/","\\");
	} else
		args << dirPath.replace("/", "\\");
	#endif
	#ifdef Q_OS_LINUX
	args << dirPath.replace('\\', '/');
	cmd = "thunar";
	#endif
	#ifdef Q_OS_MAC
	args << dirPath.replace('\\', '/');
	cmd = "open";
	#endif
	if( !QProcess::startDetached( cmd, args ) ) {
		LOG_1( "Unable to start " + cmd );
	}
}
Exemplo n.º 16
0
// ---------------------------------------------------------------------------
// CAOSettings::LingerTimerValue
// ---------------------------------------------------------------------------
//
TInt CAOSettings::LingerTimerValue( const TUint aIapId ) const
{
    LOG_1( _L("CAOSettings::LingerTimerValue") );

    for ( TInt j=0; j < iLingerSettings.Count(); j++ )
    {
        if ( iLingerSettings[ j ].iIap == aIapId )
        {
            LOG_3( _L("Linger setting found >> iap: %d, interval: %d"),
                   aIapId,
                   iLingerSettings[ j ].iInterval);

            if ( iLingerSettings[ j ].iInterval == 0 )
            {
                return KLingerForEver;
            }
            else
            {
                return ( iLingerSettings[ j ].iInterval );
            }
        }
    }

    LOG_2( _L("LingerTimerValue() not found >> iap: %d"),
           aIapId );

    return KLingerOff; // Linger is off
}
Exemplo n.º 17
0
// ---------------------------------------------------------------------------
// TAOState::HandleExternalConnectionCreatedL
// ---------------------------------------------------------------------------
//
TAOState* TAOState::HandleExternalConnectionCreatedL()
{
    LOG_1( _L("TAOState::HandleExternalConnectionCreatedL") );

    CancelAll();
    return iStatePool.ChangeState( TAOState::EStateExternalConnection );
}
Exemplo n.º 18
0
bool IniConfig::writeToFile( const QString & fileName )
{
	QString filePath = fileName;
	if( filePath.isEmpty() )
		filePath = mFile;

	QFile file(filePath);
	if( !file.open(QIODevice::WriteOnly) ) {
		LOG_1( "Unable to open config file for writing at: " + filePath );
		return false;
	}
	QTextStream out(&file);
	QMap<QString, QMap<QString,QString> >::Iterator it;
	for(it = mValMap.begin(); it != mValMap.end(); ++it)
	{
		if( !it.value().isEmpty() ){
			out << '[' << (it.key().isEmpty() ? QString("NO_SECTION") : it.key()) << ']' << '\n';
			for( QMap<QString,QString>::Iterator valit = it.value().begin(); valit!=it.value().end(); ++valit )
				out << valit.key() << '=' << valit.value() << '\n';
			out << "\n";
		}
	}
	LOG_3( "Wrote config file to: " + filePath );
	return true;
}
Exemplo n.º 19
0
// ---------------------------------------------------------------------------
// CLingerConnection::ConstructL
// ---------------------------------------------------------------------------
//
void CLingerConnection::ConstructL()
    {
    LOG_1( _L("CLingerConnection::ConstructL") );         
    
    // Create timer
    iTimer = CPeriodic::NewL( CActive::EPriorityStandard );
    }
Exemplo n.º 20
0
// ---------------------------------------------------------------------------
// CLingerConnection::StartTimer()
// ---------------------------------------------------------------------------
//
void CLingerConnection::StartTimer( TInt aTimerInterval, TBool aReset )
    {
    LOG_1( _L("CLingerConnection::StartTimer") );
    
    if ( aReset )
        {
        iLingerTimerCount = 0;
        }
    
    TCallBack cb( TimerCallBack, this );

    // if linger timer is negative we should not start timer but linger forever...
    if ( iLingerInterval > 0 )
        {
        LOG_2( _L("iTimer->Start: aTimerInterval: %d"), aTimerInterval );
        
        if( aTimerInterval > KMaxTimerInSeconds )
            {
            // Maximum allowed interval is 30 minutes.
            // This restriction comes from TTimeIntervalMicroSeconds32
            iCurrentTimerInterval = KMaxTimerInSeconds;
            }
        else
            {
            // use current value
            iCurrentTimerInterval = aTimerInterval;
            }    
    
        LOG_2( _L("iTimer->Start: iCurrentTimerInterval: %d"), iCurrentTimerInterval );
        CancelTimer();
        iTimer->Start( ( iCurrentTimerInterval * KSecondsToMicro ), 
                       ( iCurrentTimerInterval * KSecondsToMicro ), 
                       cb );    
        }
    }
Exemplo n.º 21
0
// ---------------------------------------------------------------------------
// CLingerConnection::OpenAndAttach
// ---------------------------------------------------------------------------
//
TInt CLingerConnection::OpenAndAttach()
    {
    LOG_1( _L("CLingerConnection::OpenAndAttach") );
    
    if ( !iAttached )
        {        
        // Open
        TInt err = iConnection.Open( *iSocketServ, KAfInet );

        if ( err != KErrNone )
            {
            return ( err );
            }
    
        // Attach to keep the connection open
        err = iConnection.Attach( TPckg< TConnectionInfo >( iConnectionInfo ), 
                                  RConnection::EAttachTypeNormal );
                              
        if ( err != KErrNone )
            {
            iConnection.Close();
            return ( err );
            }
        
        iAttached = ETrue;    
        }
            
    return KErrNone;    
    }
Exemplo n.º 22
0
void write( QString & input,  QString output )
{
	if( readFile( output ) != input ) {
		if( !writeFullFile( output, input ) )
			LOG_1( "Couldn't open " + output + " for writing" );
	}
}
Exemplo n.º 23
0
// --------------------------------------------------------------------------
// TAOState::HandleSwitchFromDisconnectedL
// --------------------------------------------------------------------------
//
TAOState* TAOState::HandleSwitchFromDisconnectedL(
    MAOConnectionManager::TFailureReason /*aReason*/ )
{
    LOG_1( _L("TAOState::HandleSwitchFromDisconnectedL") );

    return NULL;
}
// ---------------------------------------------------------------------------
// CAOConnectionImpl::DoCancel
// ---------------------------------------------------------------------------
//
void CAOConnectionImpl::DoCancel()
    {
    LOG_1( _L("CAOConnectionImpl::DoCancel") );
    
    ChangeState( EDisconnected );
    CompleteSelf( iStatus, KErrCancel );
    }
// ---------------------------------------------------------------------------
// CAOConnectionImpl::PDPContextDisconnectionIssueRequest
// ---------------------------------------------------------------------------
//
void CAOConnectionImpl::PDPContextDisconnectionIssueRequest(
    TRequestStatus& aStatus )
    {
    LOG_1( _L("CAOConnectionImpl::PDPContextDisconnectionIssueRequest") );
    
    iPDPContextDisconnectionProperty.Subscribe( aStatus );
    }
// ---------------------------------------------------------------------------
// CAOConnectionImpl::HandleConnectionCallBackL
// ---------------------------------------------------------------------------
//
void CAOConnectionImpl::HandleConnectionCallBackL()
    {
    LOG_1( _L("CAOConnectionImpl::HandleConnectionCallBackL") );
    
    iConnectionTimer->Cancel();
    CompleteSelf( iStatus, iActivationError );
    }
Exemplo n.º 27
0
// --------------------------------------------------------------------------
// Constructor
// --------------------------------------------------------------------------
//
TAOState::TAOState( MAOStateContext& aStateContext,
                    MAOStatePool& aStatePool ):
    iStateContext( aStateContext ),
    iStatePool( aStatePool ),
    iFlags( 0 )
{
    LOG_1( _L("TAOState::TAOState") );
}
Exemplo n.º 28
0
// ---------------------------------------------------------------------------
// CAOGpds::CAOGpds
// ---------------------------------------------------------------------------
//
CAOGpds::CAOGpds( RMmCustomAPI& aCustomAPI ):
    CActive( EPriorityStandard ),
    iCustomAPI( aCustomAPI )
    {
    LOG_1( _L("CAOGpds::CAOGpds") );
    
    CActiveScheduler::Add( this );
    }
Exemplo n.º 29
0
// ---------------------------------------------------------------------------
// CAOTimer::RetryTimerCallBack
// ---------------------------------------------------------------------------
//
TInt CAOTimer::RetryTimerCallBack( TAny* aSelf )
    {
    LOG_1( _L("CAOTimer::RetryTimerCallBack") );
    
    CAOTimer* self = static_cast<CAOTimer*>( aSelf );
    TRAPD( err, self->HandleRetryTimerCallBackL() );
    return err;
    }
Exemplo n.º 30
0
// ---------------------------------------------------------------------------
// CAOTimer::~CAOTimer
// ---------------------------------------------------------------------------
//
CAOTimer::~CAOTimer()
    {
    LOG_1( _L("CAOTimer::~CAOTimer") );
    
    delete iUnconnectTimer;
    delete iConnectionTimer;
    delete iRetryTimer;
    }