示例#1
0
文件: flext.cpp 项目: IcaroL2ORK/pd
void flext_base::AddMessageMethods(t_class *c,bool dsp,bool dspin)
{
    add_loadbang(c,cb_loadbang);

#if FLEXT_SYS == FLEXT_SYS_PD
    class_addmethod(c,(t_method)cb_click,gensym(const_cast<char *>("click")),A_FLOAT,A_FLOAT,A_FLOAT,A_FLOAT,A_FLOAT,A_NULL);
#elif FLEXT_SYS == FLEXT_SYS_MAX
    add_assist(c,cb_assist);
    add_dblclick(c,cb_click);
#endif

    SetProxies(c,dsp);
    StartQueue();
    
    if(dsp) {
#if FLEXT_SYS == FLEXT_SYS_MAX
        add_dsp(c,cb_dsp);
        dsp_initclass();
#elif FLEXT_SYS == FLEXT_SYS_PD
        if(dspin)
            CLASS_MAINSIGNALIN(c,flext_hdr,defsig); // float messages going into the left inlet are converted to signal
        add_dsp(c,cb_dsp);
#else
#error Platform not supported!
#endif
    }
}
// m_LoopRef needs to be set before this is called
void InputHandler_MacOSX_HID::StartDevices()
{
	int n = 0;

	ASSERT( m_LoopRef );
	FOREACH( HIDDevice *, m_vDevices, i )
		(*i)->StartQueue( m_LoopRef, InputHandler_MacOSX_HID::QueueCallback, this, n++ );

	CFRunLoopSourceRef runLoopSource = IONotificationPortGetRunLoopSource( m_NotifyPort );

	CFRunLoopAddSource( m_LoopRef, runLoopSource, kCFRunLoopDefaultMode );
}
// -----------------------------------------------------------------------------
// CSConTaskQueue::AddNewTask( CSConTask*& aNewTask, TInt aTaskId )
// Adds a new task to queue
// -----------------------------------------------------------------------------
//
TInt CSConTaskQueue::AddNewTask( CSConTask*& aNewTask, TInt aTaskId )
    {
    TInt ret( KErrNone );
    
    aNewTask->iTaskId = aTaskId;
    
    //Set progress value "task accepted for execution"
    aNewTask->SetProgressValue( KSConCodeTaskCreated );
    aNewTask->SetCompleteValue( EFalse );
    
    if ( iQueue.Count() == 0 )
        {
        StartQueue();
        }
    ret = iQueue.InsertInOrder( aNewTask, CSConTaskQueue::Compare );
    return ret;
    }
// -----------------------------------------------------------------------------
// CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
// Set the task to completed -mode
// -----------------------------------------------------------------------------
//
TInt CSConTaskQueue::CompleteTask( TInt aTask, TInt aError )
    {
    LOGGER_WRITE_1( "CSConTaskQueue::CompleteTask aError: %d", aError );
    TInt ret(KErrNone);
    TInt index( KErrNotFound );
    
    CSConTask* temp = new CSConTask();
    if (!temp)
        return KErrNoMemory;
    
    temp->iTaskId = aTask;
    index = iQueue.Find( temp, CSConTaskQueue::Match );
    delete temp;
    
    if ( index != KErrNotFound )
        {
        TBool complete( ETrue );
        TBool notComplete( EFalse );
        TInt progress( KSConCodeTaskCompleted );        
        
        switch( aError )
            {
            case KErrNone :
                iQueue[index]->SetCompleteValue( complete );
                progress =  KSConCodeTaskCompleted;
                break;
            case KErrNotFound :
                iQueue[index]->SetCompleteValue( complete );
                progress =  KSConCodeNotFound;
                break;
            case KErrCompletion :
                iQueue[index]->SetCompleteValue( notComplete );
                progress = KSConCodeTaskPartiallyCompleted;
                break;

            // installer specific errors
            case SwiUI::KSWInstErrUserCancel:
            	LOGGER_WRITE("User cancelled the operation");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrUserCancel;
            	break;
            case SwiUI::KSWInstErrFileCorrupted:
            case KErrSifCorruptedPackage:
            	LOGGER_WRITE("File is corrupted");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrFileCorrupted;
            	break;
            case SwiUI::KSWInstErrInsufficientMemory:
            case KErrSifNotEnoughSpace:
            	LOGGER_WRITE("Insufficient free memory in the drive to perform the operation");
	            iQueue[index]->SetCompleteValue( complete );
	            progress = KSConCodeInstErrInsufficientMemory;	
	            break;
            case SwiUI::KSWInstErrPackageNotSupported:
            case KErrSifUnsupportedSoftwareType:
            	LOGGER_WRITE("Installation of the package is not supported");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrPackageNotSupported;
            	break;
            case SwiUI::KSWInstErrSecurityFailure:
            	LOGGER_WRITE("Package cannot be installed due to security error");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrSecurityFailure;
            	break;
            case SwiUI::KSWInstErrMissingDependency:
            case KErrSifMissingDependencies:
            	LOGGER_WRITE("Package cannot be installed due to missing dependency");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrMissingDependency;
            	break;
            case SwiUI::KSWInstErrFileInUse:
            	LOGGER_WRITE("Mandatory file is in use and prevents the operation");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrFileInUse;
            	break;
            case SwiUI::KSWInstErrGeneralError:
            case KErrSifUnknown:
            	LOGGER_WRITE("Unknown error");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrGeneralError;
            	break;
            case SwiUI::KSWInstErrNoRights:
            	LOGGER_WRITE("The package has no rights to perform the operation");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrNoRights;
            	break;
            case SwiUI::KSWInstErrNetworkFailure:
            	LOGGER_WRITE("Indicates that network failure aborted the operation");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrNetworkFailure;
            	break;
            case SwiUI::KSWInstErrBusy:
            	LOGGER_WRITE("Installer is busy doing some other operation");
            	iQueue[index]->SetCompleteValue( complete );
        		progress = KSConCodeInstErrBusy;
            	break;
            case SwiUI::KSWInstErrAccessDenied:
            	LOGGER_WRITE("Target location of package is not accessible");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstErrAccessDenied;
            	break;
            case SwiUI::KSWInstUpgradeError:
            	LOGGER_WRITE("The package is an invalid upgrade");
            	iQueue[index]->SetCompleteValue( complete );
            	progress = KSConCodeInstUpgradeError;
            	break;
            	
            case KErrSifMissingBasePackage:
                LOGGER_WRITE("KErrSifMissingBasePackage");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifMissingBasePackage;
                break;
            case KErrSifOverflow:
                LOGGER_WRITE("KErrSifOverflow");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifOverflow;
                break;
            case KErrSifSameVersionAlreadyInstalled:
                LOGGER_WRITE("KErrSifSameVersionAlreadyInstalled");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifSameVersionAlreadyInstalled;
                break;
            case KErrSifNewerVersionAlreadyInstalled:
                LOGGER_WRITE("KErrSifNewerVersionAlreadyInstalled");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifNewerVersionAlreadyInstalled;
                break;
            case KErrSifAlreadyActivated:
                LOGGER_WRITE("KErrSifAlreadyActivated");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifAlreadyActivated;
                break;
            case KErrSifAlreadyDeactivated:
                LOGGER_WRITE("KErrSifAlreadyDeactivated");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifAlreadyDeactivated;
                break;
            case KErrSifBadComponentId:
                LOGGER_WRITE("KErrSifBadComponentId");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifBadComponentId;
                break;
            case KErrSifBadInstallerConfiguration:
                LOGGER_WRITE("KErrSifBadInstallerConfiguration");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifBadInstallerConfiguration;
                break;
            case KErrSifPackageCannotBeInstalledOnThisDevice:
                LOGGER_WRITE("KErrSifPackageCannotBeInstalledOnThisDevice");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifPackageCannotBeInstalledOnThisDevice;
                break;
            case KErrSifUnsupportedLanguage:
                LOGGER_WRITE("KErrSifUnsupportedLanguage");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrSifUnsupportedLanguage;
                break;
            case KErrScrWriteOperationInProgress:
                LOGGER_WRITE("KErrScrWriteOperationInProgress");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrScrWriteOperationInProgress;
                break;
            case KErrScrReadOperationInProgress:
                LOGGER_WRITE("KErrScrReadOperationInProgress");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrScrReadOperationInProgress;
                break;
            case KErrScrNoActiveTransaction:
                LOGGER_WRITE("KErrScrNoActiveTransaction");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrScrNoActiveTransaction;
                break;
            case KErrScrUnsupportedLocale:
                LOGGER_WRITE("KErrScrUnsupportedLocale");
                iQueue[index]->SetCompleteValue( complete );
                progress = KSConCodeInstErrScrUnsupportedLocale;
                break;
            
            default :
                iQueue[index]->SetCompleteValue( complete );
                if ( aError < KErrNone && aError >= KErrCorruptSurrogateFound )
                    {
                    // aError is always negative
                    //  -> returned errorcode is from KSConCodeFirstSymbianErr...n
                    progress = KSConCodeFirstSymbianErr - aError;
                    }
                else
                    {
                    progress = KSConCodeConflict;
                    }
                
                break;
            }
            
        iQueue[index]->SetProgressValue( progress );
        }
    else
        {
        ret = KErrNotFound;
        }
    StartQueue();
    return ret;
    }