| Index: src/service.h
|
| diff --git a/src/service.h b/src/service.h
|
| index 8edf6137e0b0587e0247053a406428c4064b746d..a63434e35aa50c508f1982cf1046d4ac57fd2a81 100644
|
| --- a/src/service.h
|
| +++ b/src/service.h
|
| @@ -5,6 +5,8 @@
|
| #ifndef SRC_SERVICE_H_
|
| #define SRC_SERVICE_H_
|
|
|
| +#include <glib.h>
|
| +
|
| #include <map>
|
| #include <string>
|
|
|
| @@ -12,11 +14,14 @@
|
| #include <dbus-c++/dbus.h> // NOLINT
|
|
|
| #include "src/data_plan.h"
|
| +#include "src/data_plan_provider.h"
|
| #include "src/flimflam_service_client_glue.h"
|
|
|
| namespace cashew {
|
|
|
| class Device;
|
| +class Policy;
|
| +class ServiceManager;
|
|
|
| // map of key, value pairs representing service properties received via D-Bus
|
| typedef std::map<std::string, DBus::Variant> PropertyMap;
|
| @@ -24,9 +29,12 @@ typedef std::map<std::string, DBus::Variant> PropertyMap;
|
| // represents a cellular service and monitors Flimflam state for that service
|
| class Service : public org::chromium::flimflam::Service_proxy,
|
| public DBus::IntrospectableProxy,
|
| - public DBus::ObjectProxy {
|
| + public DBus::ObjectProxy,
|
| + public DataPlanProviderDelegate {
|
| public:
|
| - Service(DBus::Connection& connection, const DBus::Path& path); // NOLINT
|
| + Service(ServiceManager * const parent,
|
| + DBus::Connection& connection, // NOLINT
|
| + const DBus::Path& path);
|
| virtual ~Service();
|
|
|
| // get D-Bus path for this service
|
| @@ -75,7 +83,22 @@ class Service : public org::chromium::flimflam::Service_proxy,
|
| virtual void PropertyChanged(const std::string& property_name,
|
| const DBus::Variant& new_value);
|
|
|
| + // Device methods
|
| +
|
| + // we've received updated Cellular.Carrier info from our child Device
|
| + virtual void OnCarrierUpdate(const std::string& carrier);
|
| +
|
| + // DataPlanProviderDelegate methods
|
| +
|
| + // a request to our carrier usage API proxy has completed
|
| + virtual void OnRequestComplete(const DataPlanProvider *provider,
|
| + bool successful,
|
| + const Value *parsed_usage_update);
|
| +
|
| private:
|
| + // back pointer to our parent ServiceManager
|
| + ServiceManager * const parent_;
|
| +
|
| // D-Bus connection, owned by our creator
|
| // shared with Device obj that we create
|
| DBus::Connection& connection_;
|
| @@ -96,8 +119,21 @@ class Service : public org::chromium::flimflam::Service_proxy,
|
| // cached data plan info
|
| DataPlanList data_plans_;
|
|
|
| - // TODO(vlaviano): reference to back end carrier plugin
|
| - // TODO(vlaviano): refresh data plan info from carrier plugin
|
| + // carrier usage API proxy
|
| + DataPlanProvider *provider_;
|
| +
|
| + // carrier usage API URL
|
| + // empty string represents "unknown"
|
| + std::string usage_url_;
|
| +
|
| + // do we have an outstanding usage API request
|
| + bool request_in_progress_;
|
| +
|
| + // periodic update timeout
|
| + GSource *update_timeout_source_;
|
| +
|
| + // carrier policy
|
| + Policy *policy_;
|
|
|
| // convert state string to State enum value
|
| State StateFromString(const std::string& state) const;
|
| @@ -114,16 +150,46 @@ class Service : public org::chromium::flimflam::Service_proxy,
|
| // we've received updated Type info from Flimflam
|
| void OnTypeUpdate(const std::string& type);
|
|
|
| + // we've received updated Cellular.UsageUrl info from Flimflam
|
| + void OnUsageUrlUpdate(const std::string& usage_url);
|
| +
|
| // get service properties from Flimflam
|
| void GetServiceProperties();
|
|
|
| - // clear data_plans_ list and delete data plan objects
|
| - void DeleteDataPlans();
|
| + // clear a DataPlanList and delete its data plan objects
|
| + void DeleteDataPlans(DataPlanList *data_plans);
|
|
|
| // create a hardcoded data plan and add it to data_plans_ list
|
| // for debugging
|
| void AddHardcodedDataPlan();
|
|
|
| + // ask provider to request a usage update if it makes sense
|
| + void RequestUsageUpdate();
|
| +
|
| + // cancel any pending usage API requests that we have
|
| + void CancelPendingRequests();
|
| +
|
| + // update timeout callback
|
| + gboolean UpdateTimeoutCallback();
|
| +
|
| + // glib integration: static wrapper for UpdateTimeoutCallback
|
| + // takes object ptr as data and invokes object->UpdateTimeoutCallback()
|
| + static gboolean StaticUpdateTimeoutCallback(gpointer data);
|
| +
|
| + // create and start an update timer that fires periodically
|
| + // |provider_| and |policy_| must both be non-NULL
|
| + // the timer interval is retrieved from the current policy
|
| + // returns true on success and false on failure
|
| + bool CreateUpdateTimer();
|
| +
|
| + // stop and destroy the update timer if it exists
|
| + void DestroyUpdateTimer();
|
| +
|
| + // delete carrier usage API proxy and policy if they exist
|
| + // this also destroys the update timer and cancels pending requests
|
| + // NOTE: this does not delete usage url (it's considered service state)
|
| + void DeleteCarrierState();
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(Service);
|
| };
|
|
|
|
|