* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#include <gi18n.h>
+#ifdef G_OS_WIN32
+#include "glib/glib-private.h"
+#endif
+
/* ---------------------------------------------------------------------------------------------------- */
G_GNUC_UNUSED static void completion_debug (const gchar *format, ...);
}
g_variant_get (result, "(&s)", &xml_data);
- //g_printerr ("xml=`%s'", xml_data);
+ //g_printerr ("xml='%s'", xml_data);
error = NULL;
node = g_dbus_node_info_new_for_xml (xml_data, &error);
goto out;
}
- //g_printerr ("bar `%s'\n", path);
+ //g_printerr ("bar '%s'\n", path);
if (node->interfaces != NULL)
g_print ("%s \n", path);
{
gchar *s;
- //g_printerr ("foo `%s'\n", node->nodes[n].path);
+ //g_printerr ("foo '%s'\n", node->nodes[n].path);
if (g_strcmp0 (path, "/") == 0)
s = g_strdup_printf ("/%s", node->nodes[n]->path);
static gboolean opt_connection_system = FALSE;
static gboolean opt_connection_session = FALSE;
+static gboolean opt_connection_user = FALSE;
+static gboolean opt_connection_machine = FALSE;
static gchar *opt_connection_address = NULL;
static const GOptionEntry connection_entries[] =
{
{ "system", 'y', 0, G_OPTION_ARG_NONE, &opt_connection_system, N_("Connect to the system bus"), NULL},
{ "session", 'e', 0, G_OPTION_ARG_NONE, &opt_connection_session, N_("Connect to the session bus"), NULL},
+ { "machine", 'm', 0, G_OPTION_ARG_NONE, &opt_connection_machine, N_("Connect to the machine bus"), NULL},
+ { "user", 'u', 0, G_OPTION_ARG_NONE, &opt_connection_user, N_("Connect to the user bus"), NULL},
{ "address", 'a', 0, G_OPTION_ARG_STRING, &opt_connection_address, N_("Connect to given D-Bus address"), NULL},
{ NULL }
};
connection_get_dbus_connection (GError **error)
{
GDBusConnection *c;
+ guint count;
c = NULL;
+ count = !!opt_connection_system +
+ !!opt_connection_session +
+ !!opt_connection_machine +
+ !!opt_connection_user +
+ !!opt_connection_address;
+
/* First, ensure we have exactly one connect */
- if (!opt_connection_system && !opt_connection_session && opt_connection_address == NULL)
+ if (count == 0)
{
g_set_error (error,
G_IO_ERROR,
_("No connection endpoint specified"));
goto out;
}
- else if ((opt_connection_system && (opt_connection_session || opt_connection_address != NULL)) ||
- (opt_connection_session && (opt_connection_system || opt_connection_address != NULL)) ||
- (opt_connection_address != NULL && (opt_connection_system || opt_connection_session)))
+ else if (count > 1)
{
g_set_error (error,
G_IO_ERROR,
{
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
}
+ else if (opt_connection_machine)
+ {
+ c = g_bus_get_sync (G_BUS_TYPE_MACHINE, NULL, error);
+ }
+ else if (opt_connection_user)
+ {
+ c = g_bus_get_sync (G_BUS_TYPE_USER, NULL, error);
+ }
else if (opt_connection_address != NULL)
{
c = g_dbus_connection_new_for_address_sync (opt_connection_address,
if (interface_info == NULL)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Warning: According to introspection data, interface `%s' does not exist\n"),
+ _("Warning: According to introspection data, interface '%s' does not exist\n"),
interface_name);
goto out;
}
if (method_info == NULL)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Warning: According to introspection data, method `%s' does not exist on interface `%s'\n"),
+ _("Warning: According to introspection data, method '%s' does not exist on interface '%s'\n"),
method_name,
interface_name);
goto out;
}
else
{
- g_print ("--system \n--session \n--address \n");
+ g_print ("--system \n--session \n--machine \n--user \n--address \n");
}
}
else
g_printerr (_("Error: signal not specified.\n"));
goto out;
}
+
s = strrchr (opt_emit_signal, '.');
+ if (s == NULL)
+ {
+ g_printerr (_("Error: signal must be the fully-qualified name.\n"));
+ goto out;
+ }
signal_name = g_strdup (s + 1);
interface_name = g_strndup (opt_emit_signal, s - opt_emit_signal);
&error);
if (value == NULL)
{
+ gchar *context;
+
+ context = g_variant_parse_error_print_context (error, (*argv)[n]);
g_error_free (error);
error = NULL;
value = _g_variant_parse_me_harder (NULL, (*argv)[n], &error);
if (value == NULL)
{
+ /* Use the original non-"parse-me-harder" error */
g_printerr (_("Error parsing parameter %d: %s\n"),
n,
- error->message);
+ context);
g_error_free (error);
+ g_free (context);
g_variant_builder_clear (&builder);
goto out;
}
+ g_free (context);
}
g_variant_builder_add_value (&builder, value);
}
}
else
{
- g_print ("--system \n--session \n--address \n");
+ g_print ("--system \n--session \n--machine \n--user \n--address \n");
}
}
else
s = strrchr (opt_call_method, '.');
if (!request_completion && s == NULL)
{
- g_printerr (_("Error: Method name `%s' is invalid\n"), opt_call_method);
+ g_printerr (_("Error: Method name '%s' is invalid\n"), opt_call_method);
goto out;
}
method_name = g_strdup (s + 1);
&error);
if (value == NULL)
{
+ gchar *context;
+
+ context = g_variant_parse_error_print_context (error, (*argv)[n]);
g_error_free (error);
error = NULL;
value = _g_variant_parse_me_harder (type, (*argv)[n], &error);
if (type != NULL)
{
s = g_variant_type_dup_string (type);
- g_printerr (_("Error parsing parameter %d of type `%s': %s\n"),
+ g_printerr (_("Error parsing parameter %d of type '%s': %s\n"),
n,
s,
- error->message);
+ context);
g_free (s);
}
else
{
g_printerr (_("Error parsing parameter %d: %s\n"),
n,
- error->message);
+ context);
}
g_error_free (error);
g_variant_builder_clear (&builder);
+ g_free (context);
goto out;
}
+ g_free (context);
}
g_variant_builder_add_value (&builder, value);
}
&error);
if (result == NULL)
{
- g_printerr (_("Error: %s\n"), error->message);
- g_error_free (error);
+ if (error)
+ {
+ g_printerr (_("Error: %s\n"), error->message);
+ g_error_free (error);
+ }
if (in_signature_types != NULL)
{
GString *s;
g_variant_type_peek_string (type),
g_variant_type_get_string_length (type));
}
- g_printerr ("(According to introspection data, you need to pass `%s')\n", s->str);
+ g_printerr ("(According to introspection data, you need to pass '%s')\n", s->str);
g_string_free (s, TRUE);
}
goto out;
}
else
{
- g_print ("--system \n--session \n--address \n");
+ g_print ("--system \n--session \n--machine \n--user \n--address \n");
}
}
else
gchar *s;
GError *error;
GDBusConnection *c;
- GVariant *result;
- GDBusNodeInfo *node;
gboolean complete_names;
gboolean complete_paths;
GMainLoop *loop;
ret = FALSE;
c = NULL;
- node = NULL;
- result = NULL;
modify_argv0_for_command (argc, argv, "monitor");
}
else
{
- g_print ("--system \n--session \n--address \n");
+ g_print ("--system \n--session \n--machine \n--user \n--address \n");
}
}
else
ret = TRUE;
out:
- if (node != NULL)
- g_dbus_node_info_unref (node);
- if (result != NULL)
- g_variant_unref (result);
if (c != NULL)
g_object_unref (c);
g_option_context_free (o);
gboolean request_completion;
gchar *completion_cur;
gchar *completion_prev;
+#ifdef G_OS_WIN32
+ gchar *tmp;
+#endif
setlocale (LC_ALL, "");
textdomain (GETTEXT_PACKAGE);
#ifdef G_OS_WIN32
- extern gchar *_glib_get_locale_dir (void);
- gchar *tmp = _glib_get_locale_dir ();
+ tmp = _glib_get_locale_dir ();
bindtextdomain (GETTEXT_PACKAGE, tmp);
g_free (tmp);
#else
completion_cur = NULL;
completion_prev = NULL;
- g_type_init ();
-
if (argc < 2)
{
usage (&argc, &argv, FALSE);
completion_debug ("completion_point=%d", completion_point);
completion_debug ("----");
completion_debug (" 0123456789012345678901234567890123456789012345678901234567890123456789");
- completion_debug ("`%s'", completion_line);
+ completion_debug ("'%s'", completion_line);
completion_debug (" %*s^",
completion_point, "");
completion_debug ("----");
}
}
#if 0
- completion_debug (" cur=`%s'", completion_cur);
- completion_debug ("prev=`%s'", completion_prev);
+ completion_debug (" cur='%s'", completion_cur);
+ completion_debug ("prev='%s'", completion_prev);
#endif
argc = completion_argc;
}
else
{
- g_printerr ("Unknown command `%s'\n", command);
+ g_printerr ("Unknown command '%s'\n", command);
usage (&argc, &argv, FALSE);
goto out;
}