File indexing completed on 2024-05-12 05:22:24

0001 /*
0002  * This file is part of LibKGAPI library
0003  *
0004  * SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #pragma once
0010 
0011 #include "fetchjob.h"
0012 #include "kgapilatitude_export.h"
0013 #include "latitude.h"
0014 
0015 namespace KGAPI2
0016 {
0017 
0018 /**
0019  * @brief A job to fetch current or a specific locations from user's account on
0020  *        Google Latitude
0021  *
0022  * @author Daniel Vrátil <dvratil@redhat.com>
0023  * @since 2.0
0024  */
0025 class KGAPILATITUDE_DEPRECATED_EXPORT LocationFetchJob : public KGAPI2::FetchJob
0026 {
0027     Q_OBJECT
0028 
0029     /**
0030      * @brief Granularity of the results
0031      *
0032      * Specifies how precise the results should be. By default, Latitude::City
0033      * granularity is used.
0034      *
0035      * This property can be modified only when the job is not running.
0036      *
0037      * @see setGranularity, granularity
0038      */
0039     Q_PROPERTY(Latitude::Granularity granularity READ granularity WRITE setGranularity)
0040 
0041 public:
0042     /**
0043      * @brief Constructs a job that will fetch users current locations from
0044      *        Google Latitude service
0045      *
0046      * @param account Account to authenticate the requests
0047      * @param parent
0048      */
0049     explicit LocationFetchJob(const AccountPtr &account, QObject *parent = nullptr);
0050 
0051     /**
0052      * @brief Constructs a job that will fetch specific past user's location from
0053      *        Google Latitude service
0054      *
0055      * @param timestamp Timestamp of the location to fetch
0056      * @param account Account to authenticate the requests
0057      * @param parent
0058      */
0059     explicit LocationFetchJob(qlonglong timestamp, const AccountPtr &account, QObject *parent = nullptr);
0060 
0061     /**
0062      * @brief Destructor
0063      */
0064     ~LocationFetchJob() override;
0065 
0066     /**
0067      * @brief Sets granularity of the requested result. By default it's City.
0068      *
0069      * @param granularity
0070      */
0071     void setGranularity(Latitude::Granularity granularity);
0072 
0073     /**
0074      * @brief Returns granularity of the requested location.
0075      */
0076     Latitude::Granularity granularity() const;
0077 
0078 protected:
0079     /**
0080      * @brief KGAPI2::Job::start implementation
0081      */
0082     void start() override;
0083 
0084     /**
0085      * @brief KGAPI2::FetchJob::handleReplyWithItems implementation
0086      *
0087      * @param reply
0088      * @param rawData
0089      */
0090     ObjectsList handleReplyWithItems(const QNetworkReply *reply, const QByteArray &rawData) override;
0091 
0092 private:
0093     class Private;
0094     Private *const d;
0095     friend class Private;
0096 };
0097 
0098 } // namespace KGAPI2