OSDN Git Service

[tracking] Add Q_OBJECT, sanitize API
authorAdriaan de Groot <groot@kde.org>
Wed, 8 Sep 2021 11:30:32 +0000 (13:30 +0200)
committerAdriaan de Groot <groot@kde.org>
Wed, 8 Sep 2021 11:31:17 +0000 (13:31 +0200)
src/modules/tracking/TrackingJobs.cpp
src/modules/tracking/TrackingJobs.h

index dba6000..5e3cd12 100644 (file)
 
 #include <KMacroExpander>
 
-#include <QSemaphore>
-#include <QTimer>
-
 #include <chrono>
 
+
+// Namespace keeps all the actual jobs anonymous, the
+// public API is the addJob() functions below the namespace.
+namespace
+{
+
+/** @brief Install-tracking job (gets a URL)
+ *
+ * The install-tracking job (there is only one kind) does a GET
+ * on a configured URL with some additional information about
+ * the machine (if configured into the URL).
+ *
+ * No persistent tracking is done.
+ */
+class TrackingInstallJob : public Calamares::Job
+{
+    Q_OBJECT
+public:
+    TrackingInstallJob( const QString& url );
+    ~TrackingInstallJob() override;
+
+    QString prettyName() const override;
+    QString prettyStatusMessage() const override;
+    Calamares::JobResult exec() override;
+
+private:
+    const QString m_url;
+};
+
+/** @brief Tracking machines, update-manager style
+ *
+ * The machine has a machine-id, and this is sed(1)'ed into the
+ * update-manager configuration, to report the machine-id back
+ * to distro servers.
+ */
+class TrackingMachineUpdateManagerJob : public Calamares::Job
+{
+    Q_OBJECT
+public:
+    ~TrackingMachineUpdateManagerJob() override;
+
+    QString prettyName() const override;
+    QString prettyStatusMessage() const override;
+    Calamares::JobResult exec() override;
+};
+
+/** @brief Turn on KUserFeedback in target system
+ *
+ * This writes suitable files for turning on KUserFeedback for the
+ * normal user configured in Calamares. The feedback can be reconfigured
+ * by the user through Plasma's user-feedback dialog.
+ */
+class TrackingKUserFeedbackJob : public Calamares::Job
+{
+    Q_OBJECT
+public:
+    TrackingKUserFeedbackJob( const QString& username, const QStringList& areas );
+    ~TrackingKUserFeedbackJob() override;
+
+    QString prettyName() const override;
+    QString prettyStatusMessage() const override;
+    Calamares::JobResult exec() override;
+
+private:
+    QString m_username;
+    QStringList m_areas;
+};
+
 TrackingInstallJob::TrackingInstallJob( const QString& url )
     : m_url( url )
 {
@@ -161,6 +226,8 @@ FeedbackLevel=16
     return Calamares::JobResult::ok();
 }
 
+} // namespace
+
 void
 addJob( Calamares::JobList& list, InstallTrackingConfig* config )
 {
@@ -223,3 +290,7 @@ addJob( Calamares::JobList& list, UserTrackingConfig* config )
         }
     }
 }
+
+#include "utils/moc-warnings.h"
+
+#include "TrackingJobs.moc"
index b58880f..4a6e90c 100644 (file)
@@ -16,79 +16,19 @@ class InstallTrackingConfig;
 class MachineTrackingConfig;
 class UserTrackingConfig;
 
-class QSemaphore;
-
 /** @section Tracking Jobs
  *
  * The tracking jobs do the actual work of configuring tracking on the
  * target machine. Tracking jobs may have *styles*, variations depending
  * on the distro or environment of the target system. At the root of
  * each family of tracking jobs (installation, machine, user) there is
- * a class with static method `addJob()` that takes the configuration
+ * free function `addJob()` that takes the configuration
  * information from the relevant Config sub-object and optionally
  * adds the right job (subclass!) to the list of jobs.
- */
-
-/** @brief Install-tracking job (gets a URL)
- *
- * The install-tracking job (there is only one kind) does a GET
- * on a configured URL with some additional information about
- * the machine (if configured into the URL).
  *
- * No persistent tracking is done.
+ * There are no job-classes defined here because you need to be using the
+ * `addJob()` interface instead.
  */
-class TrackingInstallJob : public Calamares::Job
-{
-    Q_OBJECT
-public:
-    TrackingInstallJob( const QString& url );
-    ~TrackingInstallJob() override;
-
-    QString prettyName() const override;
-    QString prettyStatusMessage() const override;
-    Calamares::JobResult exec() override;
-
-private:
-    const QString m_url;
-};
-
-/** @brief Tracking machines, update-manager style
- *
- * The machine has a machine-id, and this is sed(1)'ed into the
- * update-manager configuration, to report the machine-id back
- * to distro servers.
- */
-class TrackingMachineUpdateManagerJob : public Calamares::Job
-{
-    Q_OBJECT
-public:
-    ~TrackingMachineUpdateManagerJob() override;
-
-    QString prettyName() const override;
-    QString prettyStatusMessage() const override;
-    Calamares::JobResult exec() override;
-};
-
-/** @brief Turn on KUserFeedback in target system
- *
- * This writes suitable files for turning on KUserFeedback for the
- * normal user configured in Calamares. The feedback can be reconfigured
- * by the user through Plasma's user-feedback dialog.
- */
-class TrackingKUserFeedbackJob : public Calamares::Job
-{
-public:
-    TrackingKUserFeedbackJob( const QString& username, const QStringList& areas );
-    ~TrackingKUserFeedbackJob() override;
-
-    QString prettyName() const override;
-    QString prettyStatusMessage() const override;
-    Calamares::JobResult exec() override;
-
-private:
-    QString m_username;
-    QStringList m_areas;
-};
 
 void addJob( Calamares::JobList& list, InstallTrackingConfig* config );
 void addJob( Calamares::JobList& list, MachineTrackingConfig* config );