int
main (int argc, char *argv[])
{
	GDBusProxy *proxy;

#if !GLIB_CHECK_VERSION (2, 35, 0)
	/* Initialize GType system */
	g_type_init ();
#endif

	/* Create a D-Bus proxy; NM_DBUS_* defined in nm-dbus-interface.h */
	proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
	                                       G_DBUS_PROXY_FLAGS_NONE,
	                                       NULL,
	                                       NM_DBUS_SERVICE,
	                                       NM_DBUS_PATH_SETTINGS,
	                                       NM_DBUS_INTERFACE_SETTINGS,
	                                       NULL, NULL);
	g_assert (proxy != NULL);

	/* List connections of system settings service */
	list_connections (proxy);

	g_object_unref (proxy);

	return 0;
}
예제 #2
0
int command_silc(void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) {
    char *action;

    if (argc < 2) {
        if (silc_plugin->running) {
            weechat_printf(buffer, "SILC version %s is running :)", SILC_PLUGIN_VERSION);
            list_connections(buffer);
            return WEECHAT_RC_OK;
        } else {
            weechat_printf(buffer, "SILC is not running :(");
            return WEECHAT_RC_ERROR;
        }
    }

    action = argv[1];

    if (strncmp(action, "connect", 7) == 0) {
        return command_silc_connect(data, buffer, argc, argv, argv_eol);
    }
    if (strncmp(action, "disconnect", 10) == 0) {
        return command_silc_disconnect(data, buffer, argc, argv, argv_eol);
    }
    if (strncmp(action, "join", 4) == 0) {
        return command_silc_join(data, buffer, argc, argv, argv_eol);
    }
    if (strncmp(action, "msg", 3) == 0) {
        return command_silc_msg(data, buffer, argc, argv, argv_eol);
    }

    weechat_printf(buffer, "unrecognized command %s", action);
    return WEECHAT_RC_ERROR;
}
static gboolean
impl_settings_list_connections (NMSettingsService *self,
                                GPtrArray **connections,
                                GError **error)
{
	GSList *list = NULL, *iter;

	list = list_connections (NM_SETTINGS_INTERFACE (self));
	*connections = g_ptr_array_sized_new (g_slist_length (list) + 1);
	for (iter = list; iter; iter = g_slist_next (iter)) {
		g_ptr_array_add (*connections,
		                 g_strdup (nm_connection_get_path (NM_CONNECTION (iter->data))));
	}
	g_slist_free (list);
	return TRUE;
}
static NMSettingsConnectionInterface *
get_connection_by_path (NMSettingsInterface *settings, const char *path)
{
	NMExportedConnection *connection = NULL;
	GSList *list = NULL, *iter;

	list = list_connections (settings);
	for (iter = list; iter; iter = g_slist_next (iter)) {
		if (!strcmp (nm_connection_get_path (NM_CONNECTION (iter->data)), path)) {
			connection = NM_EXPORTED_CONNECTION (iter->data);
			break;
		}
	}
	g_slist_free (list);

	return (NMSettingsConnectionInterface *) connection;
}
예제 #5
0
파일: main.c 프로젝트: mmattsson/InstaWorks
/// @brief List all peers currently connected to the server.
/// @param out The output file stream to display the connections on.
/// @param cmd The command request being processed.
/// @param info The parse info to use when parsing the request.
static bool list_conn_cmd(FILE *out, const char *cmd, iw_cmd_parse_info *info) {
    return list_connections(out, false);
}
예제 #6
0
파일: main.c 프로젝트: mmattsson/InstaWorks
/// @brief List all peers currently connected to the server.
/// @param out The output file stream to display the connections on.
static bool list_conn_gui(FILE *out) {
    return list_connections(out, true);
}