コード例 #1
0
ファイル: ficgta01battery.cpp プロジェクト: GodFox/qtopia-ezx
Ficgta01Battery::Ficgta01Battery(QObject *parent)
: QObject(parent),
  ac(0),
  battery(0),
  charging(0),
  percentCharge(0),
  cableEnabled(0),
  vsUsbCable(0)
{

    qWarning()<<"Ficgta01Battery::Ficgta01Battery";

    ac = new QPowerSourceProvider(QPowerSource::Wall, "PrimaryAC", this);
    battery = new QPowerSourceProvider(QPowerSource::Battery, "Ficgta01Battery", this);


    vsUsbCable = new QValueSpaceItem("/Hardware/UsbGadget/cableConnected", this);
    connect( vsUsbCable, SIGNAL(contentsChanged()), SLOT(cableChanged()));

    battery->setAvailability(QPowerSource::Available);

    checkChargeState();

    startTimer(60 * 1000);

    QTimer::singleShot( 10 * 1000, this, SLOT(updateFicStatus()));
}
コード例 #2
0
ファイル: neobattery.cpp プロジェクト: FilipBE/qtextended
NeoBattery::NeoBattery(QObject *parent)
: QObject(parent),
  ac(0),
  battery(0),
  vsUsbCable(0),
  cableEnabled(0),
  charging(0),
  isSmartBattery(0),
  percentCharge(0)
{
    bool apm = APMEnabled();
    if(!apm) return;
    qWarning()<<"NeoBattery::NeoBattery";

    QtopiaServerApplication::taskValueSpaceSetAttribute("NeoBattery",
                                                        "APMAvailable", apm);

    ac = new QPowerSourceProvider(QPowerSource::Wall, "PrimaryAC", this);
    battery = new QPowerSourceProvider(QPowerSource::Battery, "NeoBattery", this);


    vsUsbCable = new QValueSpaceItem("/Hardware/UsbGadget/cableConnected", this);
    connect( vsUsbCable, SIGNAL(contentsChanged()), SLOT(cableChanged()));

    cableChanged();

    startTimer(60 * 1000);

    if ( QFileInfo("/sys/devices/platform/bq27000-battery.0/power_supply/bat/status").exists()) {
        QTimer::singleShot( 10 * 1000, this, SLOT(updateSysStatus()));
        isSmartBattery = true;
    } else {
// 1973 only has dumb battery and must use apm
        QTimer::singleShot( 10 * 1000, this, SLOT(updateDumbStatus()));
        isSmartBattery = false;
    }
}