title: C++: How do I load a PulseAudio module via DBUS API?
body: <p>The PulseAudio <a href="http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/DBus/" rel="nofollow">DBUS API page</a> says that the arguments to LoadModule are </p>
  
  <p>Arguments: name : String, arguments : {String -> String}</p>
  
  <p>It also states that {String -> String} is a dictionary with a String key and String value.</p>
  
  <p>How do I send this via the c++ API?  Normally I would do something like this:</p>
  
  <pre><code>msg = dbus_message_new_method_call(
              "org.PulseAudio1",              //Destination
              "/org/pulseaudio/core1",                    //Object path to call on
              interfaceStr,                               //Interface to call on
              method);                                    //Method
  </code></pre>
  
  <p>Then create a msg iterator:</p>
  
  <pre><code>//append arguments to the LoadModule() method. (String, {String-&gt;String})
  dbus_message_iter_init_append(msg, &amp;msgIter);
  
  dbus_message_iter_append_basic(&amp;msgIter, DBUS_TYPE_STRING,&amp;moduleName);
  
  //dict entries
  dbus_message_iter_open_container(&amp;msgIter, DBUS_TYPE_DICT_ENTRY, NULL, &amp;subIter);
  dbus_message_iter_append_basic(&amp;subIter, DBUS_TYPE_STRING, &amp;sourceStr);
  dbus_message_iter_append_basic(&amp;subIter, DBUS_TYPE_STRING, &amp;sourcePath);
  dbus_message_iter_close_container(&amp;msgIter, &amp;subIter);
  
  dbus_message_iter_open_container(&amp;msgIter, DBUS_TYPE_DICT_ENTRY, NULL, &amp;subIter);
  dbus_message_iter_append_basic(&amp;subIter, DBUS_TYPE_STRING, &amp;sinkStr);
  dbus_message_iter_append_basic(&amp;subIter, DBUS_TYPE_STRING, &amp;sinkPath);
  dbus_message_iter_close_container(&amp;msgIter, &amp;subIter);
  </code></pre>
  
  <p>This creates a parameter list like this, I think: LoadModule(String, {String->String}, {String->String})</p>
  
  <p>However, the function does not give a reply.  I don't think I'm creating the parameters correctly.  In fact, I'm pretty sure I'm not.  I've seen others use arrays for different methods, but it does not specify that here.  Is there a way to specifically state that something is a key/value?</p>
  
  <p>UPDATE:</p>
  
  <p>I found this line: <em>A dictionary entry must be element of an array, and it must contain only a key-value pair of two elements, with a basic D-Bus type key.</em> on the <a href="http://www.gnu.org/software/emacs/manual/html_mono/dbus.html" rel="nofollow">GNU Using of D-Bus Page,</a> in case it helps.  I'll try that and post the results.</p>