Esempio n. 1
0
static TInt MainL()
{
    RDebug::Print(_L("Main() - Starting!"));

    RFs theFs;

    TInt r = theFs.Connect();
    if (r != KErrNone)
    {
        RDebug::Print(_L("Main() - Failed to connect to the fs. Error = %d"), r);
        return r;
    }

    RDebug::Print(_L("Main() - Connected to file server"));

    r = StartC32();
    if (r!=KErrNone && r !=KErrAlreadyExists)
    {
        RDebug::Print(_L("Main() - Failed to start C32. Error = %d"), r);
        return r;
    }

    RDebug::Print(_L("E32Main: Started c32"));

    RUsb usb;
    TInt err = usb.Connect();
    if (err != KErrNone)
    {
        RDebug::Print(_L("MainL() - Unable to Connect to USB server"));
        theFs.Close();
        return err;
    }
    RDebug::Print(_L("MainL() - Connected to USB server"));

    TUsbServiceState state;

    err = usb.GetCurrentState(state);
    if (err != KErrNone)
    {
        RDebug::Print(_L("MainL() - Failed to fetch service state from usbman, error %d"), err);
    }
    else
    {
        RDebug::Print(_L("MainL() - Usb service state = 0x%x"), state);
    }

    TRequestStatus status;
    usb.Start(status);
    User::WaitForRequest(status);

    RDebug::Print(_L("Start completed with status %d"), status.Int());

    theFs.Close();
    RDebug::Print(_L("MainL() - Exiting normally"));
    return KErrNone;
}
Esempio n. 2
0
CBatteryCommonInfo::CBatteryCommonInfo() : iBatteryStatus(NULL), iBatteryChargingStatus(NULL), iCapacityBars(NULL), iUsbConnected(EFalse),iChargingON(EFalse)
{
#ifdef SYMBIAN_3_PLATFORM
    iBatteryStatus = CPubSubKeyHandler::New(KPSUidHWRMPowerState, KHWRMBatteryStatus,*this );
    iBatteryChargingStatus = CPubSubKeyHandler::New(KPSUidHWRMPowerState, KHWRMChargingStatus,*this);
    iCapacityBars = CPubSubKeyHandler::New(KPSUidHWRMPowerState, KHWRMBatteryLevel,*this );
    iBatteryStatData=iRemainingCapacityBars=-1; //Assigning each to error code
    if (iBatteryChargingStatus)
    {
        TInt chargingState = iBatteryChargingStatus->GetValue();
        switch(chargingState)
        {
        case EChargingStatusCharging:
        case EChargingStatusAlmostComplete:
        case EChargingStatusChargingContinued:
            iChargingON = ETrue;
            break ;
        case EChargingStatusNotConnected:
        case EChargingStatusChargingComplete:
        case EChargingStatusNotCharging:
        default :
            iChargingON = EFalse;
            break;
        }

        if ( iChargingON )
        {
            RUsb usbMan;
            if ( KErrNone == usbMan.Connect() )
            {
                TUsbDeviceState deviceState (EUsbDeviceStateUndefined );
                usbMan.GetDeviceState(deviceState);
                if ( EUsbDeviceStateConfigured == deviceState )
                    iUsbConnected = ETrue;
            }
        }
    }
    if (iBatteryStatus)
        iBatteryStatData = iBatteryStatus->GetValue();
    if (iCapacityBars)
        iRemainingCapacityBars = iCapacityBars->GetValue();
#else
    iRemainingCapacityBars = -1;
    iPreviousUsbConnected = EFalse;
    iBatteryStatData = -1;
#endif
}
void UsbUiSettingModel::initializeModelData( int aModeId )
{
    myDebug() << ">>> UsbUiSettingModel::initializeModelData aModeId="
            << aModeId;
    RUsb usbMan;
    if ( usbMan.Connect() == KErrNone ) {
        RArray<TInt> personalityIds;
        mPersonalityIds.clear();
        if ( usbMan.GetPersonalityIds( personalityIds ) == KErrNone ) {
            for ( int i = 0; i < personalityIds.Count(); i++ ) {
                myDebug() << ">>> UsbUiSettingModel::initializeModelData personality ID ="
                    << personalityIds[i];
                if ( !isPersonalityHidden(usbMan, personalityIds[i]) ) {
                    mPersonalityIds.append( personalityIds[i] );                    
                    QString friendlyName = getFriendlyName(usbMan, personalityIds[i]);
                    
                    QStringList displayList;
                    //text-1 mode name
                    displayList.append( modeName( friendlyName ) );
                    
                    //text-2 description
                    QString textId = TextIdPrefix + friendlyName + DescriptionIdPostfix;
                    displayList.append( hbTrId(textId.toAscii()) );
                    
                    QMap< int, QVariant > dataRow;
                    dataRow[ Qt::DisplayRole ] = QVariant( displayList );
                    
                    //icon-1
                    QString iconName = ModeIconNamePrefix + friendlyName;
                    HbIcon icon(iconName);
                    QList<QVariant> icons;
                    icons << icon;                    
                    dataRow[ Qt::DecorationRole ] = QVariant( icons );
                    
                    mSettingsList << dataRow;
                }
            }
        }
        personalityIds.Close();
        usbMan.Close();
    }
    myDebug() << "<<< UsbUiSettingModel::initializeModelData";
}
Esempio n. 4
0
void CBatteryCommonInfo::CommanSignalHandler( const TUid aCategory, const TUint aKey )
{
#ifdef SYMBIAN_3_PLATFORM
    if ( KPSUidHWRMPowerState == aCategory )
    {
        switch ( aKey )
        {
        case KHWRMBatteryStatus :
            if (iBatteryStatus)
            {
                iBatteryStatData = iBatteryStatus->GetValue();
                foreach (MBatteryInfoObserver *observer, iObservers)
                {
                    observer->changedBatteryStatus();
                }
            }
            break;
        case KHWRMChargingStatus :
            //Get Charge Status
            if (iBatteryChargingStatus)
            {
                TInt chargeStatus = iBatteryChargingStatus->GetValue();
                switch (chargeStatus)
                {
                case EChargingStatusCharging:
                case EChargingStatusAlmostComplete:
                case EChargingStatusChargingContinued:
                    iChargingON = ETrue;
                    break ;
                case EChargingStatusNotConnected:
                case EChargingStatusChargingComplete:
                case EChargingStatusNotCharging:
                default :
                    iChargingON = EFalse;
                    break;
                }
                //  Get Charger Type
                RUsb usbMan;
                if ( KErrNone == usbMan.Connect() )
                {
                    TUsbDeviceState deviceState (EUsbDeviceStateUndefined );
                    usbMan.GetDeviceState(deviceState);
                    if ( EUsbDeviceStateConfigured == deviceState )
                        iUsbConnected = ETrue;
                    else
                        iUsbConnected =  EFalse;
                }

                foreach (MBatteryInfoObserver *observer, iObservers)
                {
                    observer->changedChargingState();
                    observer->changedChargerType();
                }
            }
            break;
        case KHWRMBatteryLevel :
            if (iCapacityBars)
            {
                iRemainingCapacityBars = iCapacityBars->GetValue();
                foreach (MBatteryInfoObserver *observer, iObservers)
                {
                    observer->changedRemainingCapacityBars();
                }
            }
            break;
        default :
            break ; //do Nothing
        }
    }