Commit 62ab4206 authored by Lukáš Tinkl's avatar Lukáš Tinkl

docu improvements

while getting acquainted with the code
parent fe1ecf0e
......@@ -4,4 +4,4 @@ set(solid_LIB_SRCS
${solid_LIB_SRCS}
power/backends/freedesktop/fdacpluggedjob.cpp
power/backends/freedesktop/fdpowernotifier.cpp
)
\ No newline at end of file
)
......@@ -49,14 +49,14 @@ void FDAcPluggedJob::doStart()
<< QStringLiteral("OnBattery");
msg.setArguments(args);
QDBusConnection::systemBus().callWithCallback(msg, this, SLOT(slotDBusReply(QDBusMessage)), SLOT(slotDBusError(QDBusError)));
QDBusConnection::systemBus().callWithCallback(msg, this, SLOT(slotDBusReply(QVariant)), SLOT(slotDBusError(QDBusError)));
}
void FDAcPluggedJob::slotDBusReply(const QDBusMessage& msg)
void FDAcPluggedJob::slotDBusReply(const QVariant & reply)
{
Q_ASSERT(!msg.arguments().isEmpty());
Q_ASSERT(reply.isValid());
m_isPlugged = !msg.arguments().first().value<QDBusVariant>().variant().toBool();
m_isPlugged = !reply.toBool();
emitResult();
}
......
......@@ -28,7 +28,7 @@ class QDBusMessage;
class QDBusPendingCallWatcher;
namespace Solid
{
class FDAcPluggedJob : public AbstractAcPluggedJob
class FDAcPluggedJob : public AbstractAcPluggedJob
{
Q_OBJECT
public:
......@@ -38,7 +38,7 @@ public:
private Q_SLOTS:
virtual void doStart() Q_DECL_OVERRIDE;
void slotDBusReply(const QDBusMessage &msg);
void slotDBusReply(const QVariant &reply);
void slotDBusError(const QDBusError &error);
private:
......
......@@ -39,7 +39,6 @@ Solid::FDPowerNotifier::FDPowerNotifier(QObject* parent): PowerNotifier(parent)
void Solid::FDPowerNotifier::propertiesChanged(const QString &interface, const QVariantMap &changedProperties, const QStringList &invalidated)
{
if (interface != QStringLiteral("org.freedesktop.UPower")) {
return;
}
......
......@@ -37,4 +37,4 @@ public Q_SLOTS:
};
}
#endif //SOLID_FD_POWER_NOTIFIER_H
\ No newline at end of file
#endif //SOLID_FD_POWER_NOTIFIER_H
......@@ -29,11 +29,11 @@ class PowerNotifier : public QObject
{
Q_OBJECT
public:
explicit PowerNotifier(QObject* parent = 0) : QObject(parent) {};
explicit PowerNotifier(QObject* parent = 0) : QObject(parent) {}
Q_SIGNALS:
void acPluggedChanged(bool plugged);
};
}
#endif //SOLID_POWER_NOTIFIER_H
\ No newline at end of file
#endif //SOLID_POWER_NOTIFIER_H
......@@ -34,7 +34,7 @@ class AbstractInhibition;
* Holds an inhibition
*
* This object is returned by Power::InhibitionJob::inhibition and it
* hols a reference to the inhibition that has been performed.
* holds a reference to the inhibition that has been performed.
*
* When this object is deleted the inhibition will be released
*/
......@@ -50,10 +50,10 @@ public:
};
/**
* This is meant to be instantiate by backends only
* This is meant to be instantiated by backends only
*
* AbstractInhibition is not part of Solid public api so this
* constructor is thought to be used only by backends.
* AbstractInhibition is not part of Solid public API so this
* constructor is meant to be used only by backends.
*/
explicit Inhibition(AbstractInhibition *backend, QObject *parent=0);
virtual ~Inhibition();
......@@ -63,7 +63,7 @@ public:
*
* The initial value is Started since that is how InhibitionJob will
* return it. The state can be modified by calling stop() and start().
* Also stateChanged signal is available.
* Also stateChanged() signal is available.
*/
State state() const;
......@@ -72,16 +72,16 @@ public Q_SLOTS:
* Stops the inhibition
*
* In case the state() is Started, it will stop the inhibition.
* This happens asynchronously so connect to stateChanged signal to know
* This happens asynchronously so connect to stateChanged() signal to know
* when stop() has changed the state.
*/
void stop();
/*
/**
* Starts the inhibition
*
* In case state() is Stopped, it will resume the inhibition.
* This happens asynchronously so connect to stateChanged signal to
* This happens asynchronously so connect to stateChanged() signal to
* know when start() has changed the state.
*/
void start();
......
......@@ -45,8 +45,8 @@ public:
* Instance InhibitionJob
*
* When this job emits result(Solid::Job*) and in case no
* error has happened an Inhibition object will be
* return using inhibition(). Delete the returned object
* error has happened, an Inhibition object will be
* returned using inhibition(). Delete the returned object
* as soon as the inhibition should be released.
*
* At least one action to inhibit and description should be
......@@ -87,7 +87,7 @@ public:
* The result of this job is an object called Inhibition
* which should be kept as long as the inhibition is desired.
*
* If this method is called before result(Solid::Job*) is emitted
* If this method is called before result(Solid::Job*) is emitted,
* it will return nullptr.
*/
Inhibition* inhibition() const;
......
......@@ -30,7 +30,7 @@ namespace Solid
class JobPrivate;
/**
* This class represents an asynchronous job performed by Solid,
* it is usually not used directly but instead it is inherit by some
* it is usually not used directly but instead it is inherited by some
* other class, for example \See AcPluggedJob or \See StatesJob
*
* There are two ways of using this class, one is via exec() which will block
......@@ -59,9 +59,9 @@ public:
virtual ~Job();
enum Error {
/*** Indicates there is no error */
/** Indicates there is no error */
NoError = 0,
/*** Subclasses should define error codes starting at this value */
/** Subclasses should define error codes starting at this value */
UserDefinedError = 100
};
......@@ -77,7 +77,7 @@ public:
* called, which usually wreaks havoc.
*
* Note that the event loop started by this method does not process user input events, which means
* your user interface will effectivly be blocked. Other events like paint or network events are
* your user interface will effectively be blocked. Other events like paint or network events are
* still being processed. The advantage of not processing user input events is that the chance of
* accidental reentrancy is greatly reduced. Still you should avoid calling this function.
*
......@@ -100,7 +100,7 @@ public:
* Only call if error is not 0.
*
* This is usually some extra data associated with the error,
* such as a URL. Use errorString() to get a human-readable,
* such as a URL. Use errorString() to get a human-readable,
* translated message.
*
* @return a string to help understand the error
......@@ -124,7 +124,7 @@ private Q_SLOTS:
*
* This slot is always called in the next loop, triggered by start().
*
* When implementing this method is important to remember that jobs
* When implementing this method it is important to remember that jobs
* are not executed on a different thread (unless done that way), so any
* blocking task has to be done in a different thread or process.
*/
......
......@@ -36,12 +36,12 @@ class SOLID_EXPORT Power : public QObject
Q_FLAGS(States)
public:
/**
* List of states a device and be into
* List of states a device can be in
*
* This list of states can be used to either put the device
* running the code into a specific state (for example put a
* laptop to sleep) or to avoid (inhibit) that state to happen,
* for example to prevent the brightness to be modified automatically
* for example to prevent the brightness from being modified automatically
*/
enum State {
None = 0,
......@@ -51,7 +51,7 @@ public:
Screen = 1 << 3,
Brightness = 1 << 4
};
Q_DECLARE_FLAGS(States, State);
Q_DECLARE_FLAGS(States, State)
/**
* Returns an instance of Power
*
......@@ -59,9 +59,9 @@ public:
* in the power management system by connecting to its signals, like
* acPluggedChanged().
*
* If you are interested on Power during the entire live cycle of your
* application, then you want to use this singlethon. If instead you are
* only intested for a short period of time, consider instancing your own
* If you are interested in Power during the entire life cycle of your
* application, then you want to use this singleton. If instead you are
* only interested for a short period of time, consider instantiating your own
* Solid::Power so you can free the memory at any point.
*/
static Power* self();
......@@ -74,21 +74,30 @@ public:
*/
static AcPluggedJob* isAcPlugged(QObject *parent = 0);
/*
/**
* Returns an InhibitionJob
*
* The returned job is initialized with the given @inhibitions and @description
* The returned job is initialized with the given @p states and @p description
*/
static InhibitionJob* inhibit(Power::States states, const QString &description, QObject *parent = 0);
/**
* Query the supported states (like Sleep or Hibernation)
* @return a StatesJob
*/
static StatesJob* states(QObject *parent = 0);
/**
* Set the computer in a desired @p state (like Sleep or Hibernation)
* @return a RequestStateJob
*/
static RequestStateJob* requestState(Power::State state, QObject *parent = 0);
/**
* If you are not going to destroy this object for the entire
* application live cycle, you might want to use self() singlethon.
* application life cycle, you might want to use self() singleton.
*
* The only reason to instance your own Power object is for when an
* The only reason to instantiate your own Power object is for when an
* application is only interested in power management during a small
* period of time and you want to free the memory after using it.
*/
......@@ -102,5 +111,7 @@ private:
Private *d;
};
}
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Power::States);
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Power::States)
#endif //SOLID_POWER_H
......@@ -59,4 +59,4 @@ PowerNotifier* PowerBackendLoader::notifier()
return new FDPowerNotifier();
}
return new DummyPowerNotifier();
}
\ No newline at end of file
}
......@@ -39,6 +39,6 @@ public:
static AbstractRequestStateJob* requestState();
static PowerNotifier* notifier();
};
};
}
#endif //POWER_BACKEND_LOADER_H
\ No newline at end of file
#endif //POWER_BACKEND_LOADER_H
......@@ -30,7 +30,7 @@ namespace Solid
{
class RequestStateJobPrivate;
/**
* Tries to set the device under the state indicate via setState
* Tries to set the device under the state indicated via setState()
*
* On success this job will contain no error and the device will
* be set to the desired state (for example Sleep). On error
......
......@@ -29,7 +29,7 @@
namespace Solid
{
class StatesJobPrivate;
/*
/**
* Returns the states supported on the device
*
* Different devices and different operating systems support
......
......@@ -74,4 +74,4 @@ int main(int argc, char **argv)
} else {
sOut << "Not recognized command" << endl;
}
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment