Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: src/service.h

Issue 3576011: Cashew: track cellular service state. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git
Patch Set: Make debug logging less verbose Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/main.cc ('k') | src/service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/service.h
diff --git a/src/service.h b/src/service.h
new file mode 100644
index 0000000000000000000000000000000000000000..8edf6137e0b0587e0247053a406428c4064b746d
--- /dev/null
+++ b/src/service.h
@@ -0,0 +1,132 @@
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SRC_SERVICE_H_
+#define SRC_SERVICE_H_
+
+#include <map>
+#include <string>
+
+#include <base/basictypes.h> // NOLINT
+#include <dbus-c++/dbus.h> // NOLINT
+
+#include "src/data_plan.h"
+#include "src/flimflam_service_client_glue.h"
+
+namespace cashew {
+
+class Device;
+
+// map of key, value pairs representing service properties received via D-Bus
+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:
+ Service(DBus::Connection& connection, const DBus::Path& path); // NOLINT
+ virtual ~Service();
+
+ // get D-Bus path for this service
+ virtual const DBus::Path& GetPath() const;
+
+ // valid state values for this service
+ typedef enum {
+ kStateUnknown = 0,
+ kStateIdle,
+ kStateCarrier,
+ kStateAssociation,
+ kStateConfiguration,
+ kStateReady,
+ kStateDisconnect,
+ kStateFailure,
+ kStateActivationFailure,
+ } State;
+
+ // get state for this service
+ virtual State GetState() const;
+
+ // valid type values for this service
+ typedef enum {
+ kTypeUnknown = 0,
+ kTypeEthernet,
+ kTypeWifi,
+ kTypeWimax,
+ kTypeBluetooth,
+ kTypeCellular,
+ } Type;
+
+ // get type for this service
+ // NOTE: for now, should always be kTypeCellular
+ virtual Type GetType() const;
+
+ // get Device object for this service
+ // this can return NULL if we don't yet have Device info
+ virtual Device* GetDevice() const;
+
+ // get data plan info, formatted for D-Bus
+ virtual DBusDataPlanList GetDBusDataPlans() const;
+
+ // Flimflam Service D-Bus Proxy methods
+
+ // receive incoming PropertyChanged D-Bus signal from Flimflam service
+ virtual void PropertyChanged(const std::string& property_name,
+ const DBus::Variant& new_value);
+
+ private:
+ // D-Bus connection, owned by our creator
+ // shared with Device obj that we create
+ DBus::Connection& connection_;
+
+ // D-Bus path for Flimflam service that we represent
+ // this is our unique identifier
+ const DBus::Path path_;
+
+ // Service connection state
+ State state_;
+
+ // Service type
+ Type type_;
+
+ // Device corresponding to our service
+ Device *device_;
+
+ // cached data plan info
+ DataPlanList data_plans_;
+
+ // TODO(vlaviano): reference to back end carrier plugin
+ // TODO(vlaviano): refresh data plan info from carrier plugin
+
+ // convert state string to State enum value
+ State StateFromString(const std::string& state) const;
+
+ // convert type string to Type enum value
+ Type TypeFromString(const std::string& type) const;
+
+ // we've received updated Device info from Flimflam
+ void OnDeviceUpdate(const DBus::Path& device_path);
+
+ // we've received updated State info from Flimflam
+ void OnStateUpdate(const std::string& state);
+
+ // we've received updated Type info from Flimflam
+ void OnTypeUpdate(const std::string& type);
+
+ // get service properties from Flimflam
+ void GetServiceProperties();
+
+ // clear data_plans_ list and delete data plan objects
+ void DeleteDataPlans();
+
+ // create a hardcoded data plan and add it to data_plans_ list
+ // for debugging
+ void AddHardcodedDataPlan();
+
+ DISALLOW_COPY_AND_ASSIGN(Service);
+};
+
+} // namespace cashew
+
+#endif // SRC_SERVICE_H_
« no previous file with comments | « src/main.cc ('k') | src/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698