Add RequestRemoveNetworkService and RequestNetworkServiceDisconnect

BUG=chromium-os:18186
TEST=ensure libcros and chrome compile

Change-Id: I71356b1179e400beef52c638f7c821c07025c40a
Reviewed-on: http://gerrit.chromium.org/gerrit/6963
Tested-by: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Satoru Takabayashi <satorux@chromium.org>
diff --git a/chromeos_cros_api.h b/chromeos_cros_api.h
index 15b4385..1a5188b 100644
--- a/chromeos_cros_api.h
+++ b/chromeos_cros_api.h
@@ -272,12 +272,13 @@
 // 165: Removed SetTouchpadSensitivity and SetTouchpadTapToClick.
 // 166: Replace base::Value parameters with glib GValue in NetworkLibrary.
 //      Old calls stil exist, labeled 'deprecated.'
+// 167: Added RequestRemoveNetworkService and RequestNetworkServiceDisconnect.
 
 namespace chromeos {  // NOLINT
 
 enum CrosAPIVersion {
   kCrosAPIMinVersion = 161,
-  kCrosAPIVersion = 166
+  kCrosAPIVersion = 167
 };
 
 // Default path to pass to LoadCros: "/opt/google/chrome/chromeos/libcros.so"
diff --git a/chromeos_network.cc b/chromeos_network.cc
index 20b408c..d4ff1ad 100644
--- a/chromeos_network.cc
+++ b/chromeos_network.cc
@@ -559,19 +559,7 @@
   return true;
 }
 
-namespace {
-// TODO(stevenjb): This should soon be part of chromeos_network_deprecated.cc
-
-class ScopedPtrGStrFreeV {
- public:
-  inline void operator()(char** x) const {
-    g_strfreev(x);
-  }
-};
-
-}  // namespace
-
-
+// Deprecated
 extern "C"
 bool ChromeOSDisconnectFromNetwork(const char* service_path) {
   dbus::Proxy service_proxy(dbus::GetSystemBusConnection(),
@@ -1281,6 +1269,40 @@
 }
 
 extern "C"
+void ChromeOSRequestNetworkServiceDisconnect(const char* service_path) {
+  FlimflamCallbackData* cb_data =
+      new FlimflamCallbackData(kFlimflamServiceInterface, service_path);
+  DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call(
+      cb_data->proxy->gproxy(),
+      kDisconnectFunction,
+      &FlimflamNotifyHandleError,
+      cb_data,
+      &DeleteFlimflamCallbackData,
+      G_TYPE_INVALID);
+  if (!call_id) {
+    LOG(ERROR) << "NULL call_id for: " << kDisconnectFunction;
+    delete cb_data;
+  }
+}
+
+extern "C"
+void ChromeOSRequestRemoveNetworkService(const char* service_path) {
+  FlimflamCallbackData* cb_data =
+      new FlimflamCallbackData(kFlimflamServiceInterface, service_path);
+  DBusGProxyCall* call_id = ::dbus_g_proxy_begin_call(
+      cb_data->proxy->gproxy(),
+      kRemoveServiceFunction,
+      &FlimflamNotifyHandleError,
+      cb_data,
+      &DeleteFlimflamCallbackData,
+      G_TYPE_INVALID);
+  if (!call_id) {
+    LOG(ERROR) << "NULL call_id for: " << kRemoveServiceFunction;
+    delete cb_data;
+  }
+}
+
+extern "C"
 void ChromeOSRequestNetworkScan(const char* network_type) {
   FlimflamCallbackData* cb_data =
       new FlimflamCallbackData(kFlimflamManagerInterface, "/");
diff --git a/chromeos_network.h b/chromeos_network.h
index 3f3d125..2af5aa4 100644
--- a/chromeos_network.h
+++ b/chromeos_network.h
@@ -331,6 +331,12 @@
     NetworkPropertiesGValueCallback callback,
     void* object);
 
+// Asynchronous disconnect from network service.
+extern void (*RequestNetworkServiceDisconnect)(const char* service_path);
+
+// Remove an exisiting network service (e.g. after forgetting a VPN).
+extern void (*RequestRemoveNetworkService)(const char* service_path);
+
 // Requests a scan of services of |type|.
 // |type| should be is a string recognized by flimflam's Manager API.
 extern void (*RequestNetworkScan)(const char* network_type);
diff --git a/load.cc b/load.cc
index c3b82c1..354d116 100644
--- a/load.cc
+++ b/load.cc
@@ -194,6 +194,8 @@
             NetworkPropertiesGValueCallback, void*);
 DECL_FUNC_5(RequestVirtualNetworkProperties, void, const char*, const char*,
             const char*, NetworkPropertiesGValueCallback, void*);
+DECL_FUNC_1(RequestRemoveNetworkService, void, const char*);
+DECL_FUNC_1(RequestNetworkServiceDisconnect, void, const char*);
 DECL_FUNC_1(RequestNetworkScan, void, const char*);
 DECL_FUNC_2(RequestNetworkDeviceEnable, void, const char*, bool);
 DECL_FUNC_5(RequestRequirePin, void, const char*, const char*, bool,
@@ -503,6 +505,8 @@
   INIT_FUNC(RequestNetworkProfileEntryProperties);
   INIT_FUNC(RequestHiddenWifiNetworkProperties);
   INIT_FUNC(RequestVirtualNetworkProperties);
+  INIT_FUNC(RequestRemoveNetworkService);
+  INIT_FUNC(RequestNetworkServiceDisconnect);
   INIT_FUNC(RequestNetworkScan);
   INIT_FUNC(RequestNetworkDeviceEnable);
   INIT_FUNC(RequestRequirePin);