Incremental commit.
authorOssama Othman <ossama.othman@intel.com>
Mon, 4 Nov 2013 06:05:34 +0000 (22:05 -0800)
committerOssama Othman <ossama.othman@intel.com>
Tue, 3 Dec 2013 21:46:52 +0000 (13:46 -0800)
Change-Id: I5d9ca6d8f36b69f11bdad9f1b2f28666f7a7fe96
Signed-off-by: Ossama Othman <ossama.othman@intel.com>
plugins/connman/agent.cpp
plugins/connman/agent.hpp

index cde53ab..6bccc37 100644 (file)
@@ -109,6 +109,13 @@ namespace
       if (i != data->info.end()) {
         auto & response = i->second.response;
         response.send_error(error);
+
+        /**
+         * @todo Make sure map element removal occurs if exception is
+         *       thrown above.
+         */
+        // Done with the connection data.
+        data->info.erase(i);
       }
     }
 
@@ -131,15 +138,60 @@ namespace
   bool
   on_handle_request_input(Agent * object,
                           GDBusMethodInvocation * invocation,
-                          gchar const * /* service */,
-                          GVariant * /* fields */,
-                          gpointer /* user_data */)
+                          gchar const * service,
+                          GVariant * fields,
+                          gpointer user_data)
   {
-    GVariant * response = nullptr;
+    using namespace ivi::settings;
+    typedef agent::user_data data_type;
+
+    data_type * const data = static_cast<data_type *>(user_data);
+
+    {
+      std::lock_guard<std::mutex> guard(data->lock);
+
+      auto const i = data->info.find(service);
+      if (i != data->info.end()) {
+        // Extract requested mandatory and alternate fields.
+        GVariantIter * vi = nullptr;
+        g_variant_get(fields, "(a{sv})", &vi);
+        unique_ptr<GVariantIter> const iter(vi);
+
+        gchar    * fname  = nullptr;
+        GVariant * fvalue = nullptr;
+
+        while (g_variant_iter_next(vi, "{sv}", &fname, &fvalue)) {
+          unique_ptr<gchar>    const name(fname);
+          unique_ptr<GVariant> const value(fvalue);
+
+
+        }
+
+
+        auto & response = i->second.response;
+
+        // Nothing to add to successful response.
+        response.send_response(
+          [](JsonBuilder * /* builder */) {});
+
+        /**
+         * @todo Make sure map element removal occurs if exception is
+         *       thrown above.
+         */
+        // Done with the connection data.
+        data->info.erase(i);
+      }
+    }
+
+
+
+    GVariant * dictionary = nullptr;
+
+
 
     // The method return value will contain a dictionary of the
     // requested input fields.
-    agent_complete_request_input(object, invocation, response);
+    agent_complete_request_input(object, invocation, dictionary);
 
     return true;
   }
index 4931942..32c35dd 100644 (file)
@@ -77,9 +77,20 @@ namespace ivi
        * @struct connect_data
        *
        * @brief Connman Service object-specific connect data.
+       *
+       * An instance of this structure will be created each time a
+       * Connman connection operation will be performed in case
+       * Connman needs additional information, such as a passphrase,
+       * to complete a connection.
        */
       struct connect_data
       {
+        /**
+         * Constructor.
+         *
+         * @note We bump the reference count on the @c JsonReader
+         *       object.
+         */
         connect_data(JsonReader * rd,
                      response_callback const & resp)
           : reader(static_cast<JsonReader *>(g_object_ref(rd)))
@@ -87,6 +98,7 @@ namespace ivi
         {
         }
 
+        /// Move constructor.
         connect_data(connect_data && other)
           : reader(std::move(other.reader))
           , response(other.response)
@@ -96,9 +108,19 @@ namespace ivi
           // Nothing to do with response field.
         }
 
+        /// Disallow copy construction.
         connect_data(connect_data const &) = delete;
 
+        /**
+         * Pointer to the @c JsonReader object containing the request
+         * information, including arguments.
+         */
         unique_ptr<JsonReader> reader;
+
+        /**
+         * The response callback through errors will be sent to the
+         * caller.
+         */
         response_callback response;
       };