Beispiel #1
0
void
plugingui_open (void)
{
	GtkWidget *view;
	GtkWidget *vbox, *hbox;

	if (plugin_window)
	{
		mg_bring_tofront (plugin_window);
		return;
	}

	plugin_window = mg_create_generic_tab ("Addons", _(DISPLAY_NAME": Plugins and Scripts"),
														 FALSE, TRUE, plugingui_close, NULL,
														 500, 250, &vbox, 0);

	view = plugingui_treeview_new (vbox);
	g_object_set_data (G_OBJECT (plugin_window), "view", view);


	hbox = gtk_hbutton_box_new ();
	gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_SPREAD);
	gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
	gtk_box_pack_end (GTK_BOX (vbox), hbox, 0, 0, 0);

	gtkutil_button (hbox, GTK_STOCK_REVERT_TO_SAVED, NULL,
	                plugingui_loadbutton_cb, NULL, _("_Load..."));

	gtkutil_button (hbox, GTK_STOCK_DELETE, NULL,
	                plugingui_unload, NULL, _("_UnLoad"));

	fe_pluginlist_update ();

	gtk_widget_show_all (plugin_window);
}
Beispiel #2
0
static int plugin_free(xchat_plugin *pl, int do_deinit, int allow_refuse)
{
	GSList *list, *next;
	xchat_hook *hook;
	xchat_deinit_func *deinit_func;

	// fake plugin added by xchat_plugingui_add()
	if (pl->fake)
		goto xit;

	// run the plugin's deinit routine, if any
	if (do_deinit && pl->deinit_callback != nullptr)
	{
		deinit_func = (xchat_deinit_func*)pl->deinit_callback;
		if (!deinit_func(pl) && allow_refuse)
			return FALSE;
	}

	// remove all of this plugin's hooks
	list = hook_list;
	while (list)
	{
		hook = (xchat_hook*)list->data;
		next = list->next;
		if (hook->pl == pl)
			xchat_unhook(nullptr, hook);
		list = next;
	}

#ifdef USE_PLUGIN
	if (pl->handle)
#ifdef USE_GMODULE
		g_module_close((GModule*)pl->handle);
#else
		dlclose(pl->handle);
#endif
#endif

xit:
	if (pl->free_strings)
	{
		if (pl->name)
			free(pl->name);
		if (pl->desc)
			free(pl->desc);
		if (pl->version)
			free(pl->version);
	}
	if (pl->filename)
		free(pl->filename);
	free(pl);

	plugin_list = g_slist_remove(plugin_list, pl);

#ifdef USE_PLUGIN
	fe_pluginlist_update();
#endif

	return TRUE;
}
Beispiel #3
0
void
signal_printer_plugin_unloaded(gpointer *params)
{
	gchar *name    = params[0];

	fe_pluginlist_update();

	session_print_format(current_sess, "plugin unloaded", name);
}
Beispiel #4
0
static int
plugin_free (hexchat_plugin *pl, int do_deinit, int allow_refuse)
{
	GSList *list, *next;
	hexchat_hook *hook;
	hexchat_deinit_func *deinit_func;

	/* fake plugin added by hexchat_plugingui_add() */
	if (pl->fake)
		goto xit;

	/* run the plugin's deinit routine, if any */
	if (do_deinit && pl->deinit_callback != NULL)
	{
		deinit_func = pl->deinit_callback;
		if (!deinit_func (pl) && allow_refuse)
			return FALSE;
	}

	/* remove all of this plugin's hooks */
	list = hook_list;
	while (list)
	{
		hook = list->data;
		next = list->next;
		if (hook->pl == pl)
			hexchat_unhook (NULL, hook);
		list = next;
	}

#ifdef USE_PLUGIN
	if (pl->handle)
		g_module_close (pl->handle);
#endif

xit:
	if (pl->free_strings)
	{
		if (pl->name)
			free (pl->name);
		if (pl->desc)
			free (pl->desc);
		if (pl->version)
			free (pl->version);
	}
	if (pl->filename)
		free ((char *)pl->filename);
	free (pl);

	plugin_list = g_slist_remove (plugin_list, pl);

#ifdef USE_PLUGIN
	fe_pluginlist_update ();
#endif

	return TRUE;
}
Beispiel #5
0
void* xchat_plugingui_add(xchat_plugin *ph, const char *filename,
							const char *name, const char *desc,
							const char *version, char *reserved)
{
#ifdef USE_PLUGIN
	ph = plugin_list_add(nullptr, strdup(filename), strdup(name), strdup(desc),
								strdup(version), nullptr, nullptr, TRUE, TRUE);
	fe_pluginlist_update();
#endif

	return ph;
}
Beispiel #6
0
void
module_glist (struct session *sess)
{
	gchar *titles[] = { _("Name"), _("Description") };
	GtkWidget *okb, *ulb;

	if (modlist)
		return;

	modlist = gtk_dialog_new ();
	gtk_signal_connect (GTK_OBJECT (modlist), "delete_event",
							  GTK_SIGNAL_FUNC (module_glist_close), 0);
	gtk_widget_set_usize (modlist, 350, 200);
	gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (modlist)->vbox),
											  4);
	gtk_window_set_position (GTK_WINDOW (modlist), GTK_WIN_POS_CENTER);
	gtk_window_set_title (GTK_WINDOW (modlist), _("X-Chat Plugins"));
	gtk_window_set_wmclass (GTK_WINDOW (modlist), "plugins", "X-Chat");

	modclist = gtk_clist_new_with_titles (2, titles);
	gtk_clist_set_selection_mode (GTK_CLIST (modclist), GTK_SELECTION_BROWSE);
	gtk_clist_column_titles_passive (GTK_CLIST (modclist));
	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (modlist)->vbox), modclist, 1, 1,
							  10);
	gtk_widget_show (modclist);

	gtk_clist_set_column_width (GTK_CLIST (modclist), 0, 40);

#ifdef	USE_GNOME
	okb = gnome_stock_button (GNOME_STOCK_BUTTON_OK);
#else
	okb = gtk_button_new_with_label (_("Ok"));
#endif
	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (modlist)->action_area), okb, 1, 1,
							  10);
	gtk_signal_connect (GTK_OBJECT (okb), "clicked",
							  GTK_SIGNAL_FUNC (module_glist_close),
							  (gpointer) modlist);
	gtk_widget_show (okb);

	ulb = gtk_button_new_with_label (_("Unload"));
	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (modlist)->action_area), ulb, 1, 1,
							  10);
	gtk_signal_connect (GTK_OBJECT (ulb), "clicked",
							  GTK_SIGNAL_FUNC (module_glist_unload),
							  (gpointer) sess);
	gtk_widget_show (ulb);

	fe_pluginlist_update ();

	gtk_widget_show (modlist);
}
Beispiel #7
0
void
plugingui_open (void)
{
    GtkWidget *view;
    GtkWidget *vbox, *action_area;

    if (plugin_window)
    {
        gtk_window_present (GTK_WINDOW (plugin_window));
        return;
    }

    plugin_window = gtk_dialog_new ();
    g_signal_connect (G_OBJECT (plugin_window), "destroy",
                      G_CALLBACK (plugingui_close), 0);
    gtk_window_set_default_size (GTK_WINDOW (plugin_window), 500, 250);
    vbox = GTK_DIALOG (plugin_window)->vbox;
    action_area = GTK_DIALOG (plugin_window)->action_area;
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
    gtk_window_set_position (GTK_WINDOW (plugin_window), GTK_WIN_POS_CENTER);
    gtk_window_set_title (GTK_WINDOW (plugin_window),
                          _("GChat: Plugins and Scripts"));

    view = plugingui_treeview_new (vbox);
    g_object_set_data (G_OBJECT (plugin_window), "view", view);

    gtkutil_button (action_area, GTK_STOCK_REVERT_TO_SAVED, NULL,
                    plugingui_loadbutton_cb, NULL, _("_Load..."));

    gtkutil_button (action_area, GTK_STOCK_DELETE, NULL,
                    plugingui_unload, NULL, _("_Unload"));

    gtkutil_button (action_area,
                    GTK_STOCK_CLOSE, NULL, plugingui_close_button,
                    NULL, _("_Close"));

    fe_pluginlist_update ();

    gtk_widget_show (plugin_window);
}
Beispiel #8
0
void
plugin_add (session *sess, char *filename, void *handle, void *init_func,
				void *deinit_func, char *arg, int fake)
{
	hexchat_plugin *pl;
	char *file;

	file = g_strdup (filename);

	pl = plugin_list_add (sess, file, file, NULL, NULL, handle, deinit_func,
								 fake, FALSE);

	if (!fake)
	{
		/* win32 uses these because it doesn't have --export-dynamic! */
		pl->hexchat_hook_command = hexchat_hook_command;
		pl->hexchat_hook_server = hexchat_hook_server;
		pl->hexchat_hook_print = hexchat_hook_print;
		pl->hexchat_hook_timer = hexchat_hook_timer;
		pl->hexchat_hook_fd = hexchat_hook_fd;
		pl->hexchat_unhook = hexchat_unhook;
		pl->hexchat_print = hexchat_print;
		pl->hexchat_printf = hexchat_printf;
		pl->hexchat_command = hexchat_command;
		pl->hexchat_commandf = hexchat_commandf;
		pl->hexchat_nickcmp = hexchat_nickcmp;
		pl->hexchat_set_context = hexchat_set_context;
		pl->hexchat_find_context = hexchat_find_context;
		pl->hexchat_get_context = hexchat_get_context;
		pl->hexchat_get_info = hexchat_get_info;
		pl->hexchat_get_prefs = hexchat_get_prefs;
		pl->hexchat_list_get = hexchat_list_get;
		pl->hexchat_list_free = hexchat_list_free;
		pl->hexchat_list_fields = hexchat_list_fields;
		pl->hexchat_list_str = hexchat_list_str;
		pl->hexchat_list_next = hexchat_list_next;
		pl->hexchat_list_int = hexchat_list_int;
		pl->hexchat_plugingui_add = hexchat_plugingui_add;
		pl->hexchat_plugingui_remove = hexchat_plugingui_remove;
		pl->hexchat_emit_print = hexchat_emit_print;
#ifdef WIN32
		pl->hexchat_read_fd = (void *) hexchat_read_fd;
#else
		pl->hexchat_read_fd = hexchat_dummy;
#endif
		pl->hexchat_list_time = hexchat_list_time;
		pl->hexchat_gettext = hexchat_gettext;
		pl->hexchat_send_modes = hexchat_send_modes;
		pl->hexchat_strip = hexchat_strip;
		pl->hexchat_free = hexchat_free;
		pl->hexchat_pluginpref_set_str = hexchat_pluginpref_set_str;
		pl->hexchat_pluginpref_get_str = hexchat_pluginpref_get_str;
		pl->hexchat_pluginpref_set_int = hexchat_pluginpref_set_int;
		pl->hexchat_pluginpref_get_int = hexchat_pluginpref_get_int;
		pl->hexchat_pluginpref_delete = hexchat_pluginpref_delete;
		pl->hexchat_pluginpref_list = hexchat_pluginpref_list;
		pl->hexchat_hook_server_attrs = hexchat_hook_server_attrs;
		pl->hexchat_hook_print_attrs = hexchat_hook_print_attrs;
		pl->hexchat_emit_print_attrs = hexchat_emit_print_attrs;
		pl->hexchat_event_attrs_create = hexchat_event_attrs_create;
		pl->hexchat_event_attrs_free = hexchat_event_attrs_free;

		/* run hexchat_plugin_init, if it returns 0, close the plugin */
		if (((hexchat_init_func *)init_func) (pl, &pl->name, &pl->desc, &pl->version, arg) == 0)
		{
			plugin_free (pl, FALSE, FALSE);
			return;
		}
	}

#ifdef USE_PLUGIN
	fe_pluginlist_update ();
#endif
}
Beispiel #9
0
void
plugin_add (session *sess, char *filename, void *handle, void *init_func,
				void *deinit_func, char *arg, int fake)
{
	xchat_plugin *pl;
	char *file;

	file = NULL;
	if (filename)
		file = strdup (filename);

	pl = plugin_list_add (sess, file, file, NULL, NULL, handle, deinit_func,
								 fake, FALSE);

	if (!fake)
	{
		/* win32 uses these because it doesn't have --export-dynamic! */
		pl->xchat_hook_command = xchat_hook_command;
		pl->xchat_hook_server = xchat_hook_server;
		pl->xchat_hook_print = xchat_hook_print;
		pl->xchat_hook_timer = xchat_hook_timer;
		pl->xchat_hook_fd = xchat_hook_fd;
		pl->xchat_unhook = xchat_unhook;
		pl->xchat_print = xchat_print;
		pl->xchat_printf = xchat_printf;
		pl->xchat_command = xchat_command;
		pl->xchat_commandf = xchat_commandf;
		pl->xchat_nickcmp = xchat_nickcmp;
		pl->xchat_set_context = xchat_set_context;
		pl->xchat_find_context = xchat_find_context;
		pl->xchat_get_context = xchat_get_context;
		pl->xchat_get_info = xchat_get_info;
		pl->xchat_get_prefs = xchat_get_prefs;
		pl->xchat_list_get = xchat_list_get;
		pl->xchat_list_free = xchat_list_free;
		pl->xchat_list_fields = xchat_list_fields;
		pl->xchat_list_str = xchat_list_str;
		pl->xchat_list_next = xchat_list_next;
		pl->xchat_list_int = xchat_list_int;
		pl->xchat_plugingui_add = xchat_plugingui_add;
		pl->xchat_plugingui_remove = xchat_plugingui_remove;
		pl->xchat_emit_print = xchat_emit_print;
		pl->xchat_read_fd = (void *) xchat_read_fd;
		pl->xchat_list_time = xchat_list_time;
		pl->xchat_gettext = xchat_gettext;
		pl->xchat_send_modes = xchat_send_modes;
		pl->xchat_strip = xchat_strip;
		pl->xchat_free = xchat_free;

		/* incase new plugins are loaded on older xchat */
		pl->xchat_dummy4 = xchat_dummy;
		pl->xchat_dummy3 = xchat_dummy;
		pl->xchat_dummy2 = xchat_dummy;
		pl->xchat_dummy1 = xchat_dummy;

		/* run xchat_plugin_init, if it returns 0, close the plugin */
		if (((xchat_init_func *)init_func) (pl, &pl->name, &pl->desc, &pl->version, arg) == 0)
		{
			plugin_free (pl, FALSE, FALSE);
			return;
		}
	}

#ifdef USE_PLUGIN
	fe_pluginlist_update ();
#endif
}