Changeset View
Changeset View
Standalone View
Standalone View
plugins/battery/batteryplugin.cpp
Show All 37 Lines | 37 | { | |||
---|---|---|---|---|---|
38 | 38 | | |||
39 | //TODO: Add battery reporting, could be based on: | 39 | //TODO: Add battery reporting, could be based on: | ||
40 | // http://kde-apps.org/content/show.php/battery+plasmoid+with+remaining+time?content=120309 | 40 | // http://kde-apps.org/content/show.php/battery+plasmoid+with+remaining+time?content=120309 | ||
41 | 41 | | |||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | void BatteryPlugin::connected() | 44 | void BatteryPlugin::connected() | ||
45 | { | 45 | { | ||
46 | NetworkPackage np(PACKAGE_TYPE_BATTERY_REQUEST, {{"request",true}}); | 46 | NetworkPacket np(PACKET_TYPE_BATTERY_REQUEST, {{"request",true}}); | ||
47 | sendPackage(np); | 47 | sendPacket(np); | ||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | BatteryPlugin::~BatteryPlugin() | 50 | BatteryPlugin::~BatteryPlugin() | ||
51 | { | 51 | { | ||
52 | //FIXME: Qt dbus does not allow to remove an adaptor! (it causes a crash in | 52 | //FIXME: Qt dbus does not allow to remove an adaptor! (it causes a crash in | ||
53 | // the next dbus access to its parent). The implication of not deleting this | 53 | // the next dbus access to its parent). The implication of not deleting this | ||
54 | // is that disabling the plugin does not remove the interface (that will | 54 | // is that disabling the plugin does not remove the interface (that will | ||
55 | // return outdated values) and that enabling it again instantiates a second | 55 | // return outdated values) and that enabling it again instantiates a second | ||
56 | // adaptor. This is also a memory leak until the entire device is destroyed. | 56 | // adaptor. This is also a memory leak until the entire device is destroyed. | ||
57 | 57 | | |||
58 | //batteryDbusInterface->deleteLater(); | 58 | //batteryDbusInterface->deleteLater(); | ||
59 | } | 59 | } | ||
60 | 60 | | |||
61 | bool BatteryPlugin::receivePackage(const NetworkPackage& np) | 61 | bool BatteryPlugin::receivePacket(const NetworkPacket& np) | ||
62 | { | 62 | { | ||
63 | bool isCharging = np.get<bool>(QStringLiteral("isCharging"), false); | 63 | bool isCharging = np.get<bool>(QStringLiteral("isCharging"), false); | ||
64 | int currentCharge = np.get<int>(QStringLiteral("currentCharge"), -1); | 64 | int currentCharge = np.get<int>(QStringLiteral("currentCharge"), -1); | ||
65 | int thresholdEvent = np.get<int>(QStringLiteral("thresholdEvent"), (int)ThresholdNone); | 65 | int thresholdEvent = np.get<int>(QStringLiteral("thresholdEvent"), (int)ThresholdNone); | ||
66 | 66 | | |||
67 | if (batteryDbusInterface->charge() != currentCharge | 67 | if (batteryDbusInterface->charge() != currentCharge | ||
68 | || batteryDbusInterface->isCharging() != isCharging | 68 | || batteryDbusInterface->isCharging() != isCharging | ||
69 | ) { | 69 | ) { | ||
Show All 17 Lines |