Example #1
0
void xchat_print(xchat_plugin *ph, const char *text)
{
	if (!is_session(ph->context))
	{
		DEBUG(PrintTextf(0, "%s\txchat_print called without a valid context.\n", ph->name));
		return;
	}

	PrintText(ph->context, (char*)text);
}
Example #2
0
int
hexchat_set_context (hexchat_plugin *ph, hexchat_context *context)
{
	if (is_session (context))
	{
		ph->context = context;
		return 1;
	}
	return 0;
}
Example #3
0
static void
search_search (session * sess, const gchar *text)
{
	if (!is_session (sess))
	{
		fe_message (_("The window you opened this Search "
						"for doesn't exist anymore."), FE_MSG_ERROR);
		return;
	}

	last = gtk_xtext_search (GTK_XTEXT (sess->gui->xtext), text,
									 last, case_match, search_backward);
	if (!last)
		fe_message (_("Search hit end, not found."), FE_MSG_ERROR);
}
Example #4
0
static void
dns_addr_callback (GObject *obj, GAsyncResult *result, gpointer user_data)
{
	GResolver *resolver = G_RESOLVER(obj);
	session *sess = (session*)user_data;
	gchar *addr;

	g_return_if_fail (is_session(sess));

	addr = g_resolver_lookup_by_address_finish (resolver, result, NULL);
	if (addr)
		PrintTextf (sess, _("Resolved to %s"), addr);
	else
		PrintText (sess, _("Not found"));
}
Example #5
0
void
hexchat_command (hexchat_plugin *ph, const char *command)
{
	char *command_utf8;

	if (!is_session (ph->context))
	{
		DEBUG(PrintTextf(0, "%s\thexchat_command called without a valid context.\n", ph->name));
		return;
	}

	/* scripts/plugins continue to send non-UTF8... *sigh* */
	command_utf8 = text_fixup_invalid_utf8 (command, -1, NULL);
	handle_command (ph->context, command_utf8, FALSE);
	g_free (command_utf8);
}
Example #6
0
void xchat_command(xchat_plugin *ph, const char *command)
{
	char *conv;
	int len = -1;

	if (!is_session(ph->context))
	{
		DEBUG(PrintTextf(0, "%s\txchat_command called without a valid context.\n", ph->name));
		return;
	}

	// scripts/plugins continue to send non-UTF8... *sigh*
	conv = text_validate((char**)&command, &len);
	handle_command(ph->context, (char*)command, FALSE);
	g_free (conv);
}
Example #7
0
hexchat_list *
hexchat_list_get (hexchat_plugin *ph, const char *name)
{
	hexchat_list *list;

	list = malloc (sizeof (hexchat_list));
	list->pos = NULL;

	switch (str_hash (name))
	{
	case 0x556423d0: /* channels */
		list->type = LIST_CHANNELS;
		list->next = sess_list;
		break;

	case 0x183c4:	/* dcc */
		list->type = LIST_DCC;
		list->next = dcc_list;
		break;

	case 0xb90bfdd2:	/* ignore */
		list->type = LIST_IGNORE;
		list->next = ignore_list;
		break;

	case 0xc2079749:	/* notify */
		list->type = LIST_NOTIFY;
		list->next = notify_list;
		list->head = (void *)ph->context;	/* reuse this pointer */
		break;

	case 0x6a68e08: /* users */
		if (is_session (ph->context))
		{
			list->type = LIST_USERS;
			list->head = list->next = userlist_flat_list (ph->context);
			fe_userlist_set_selected (ph->context);
			break;
		}	/* fall through */

	default:
		free (list);
		return NULL;
	}

	return list;
}
Example #8
0
xchat_list* xchat_list_get(xchat_plugin *ph, const char *name)
{
	xchat_list *list;

	list = (xchat_list*)malloc(sizeof(xchat_list));
	list->pos = nullptr;

	switch (str_hash(name))
	{
	case 0x556423d0: // channels
		list->type = LIST_CHANNELS;
		list->next = sess_list;
		break;

	case 0x183c4:	// dcc
		list->type = LIST_DCC;
		list->next = dcc_list;
		break;

	case 0xb90bfdd2:	// ignore
		list->type = LIST_IGNORE;
		list->next = ignore_list;
		break;

	case 0xc2079749:	// notify
		list->type = LIST_NOTIFY;
		list->next = notify_list;
		list->head = (GSList*)ph->context;	// reuse this pointer
		break;

	case 0x6a68e08: // users
		if (is_session(ph->context))
		{
			list->type = LIST_USERS;
			list->head = list->next = userlist_flat_list(ph->context);
			fe_userlist_set_selected(ph->context);
			break;
		}	// fall through

	default:
		free(list);
		return nullptr;
	}

	return list;
}
Example #9
0
static void
servlist_connect_cb (GtkWidget *button, gpointer userdata)
{
	if (!selected_net)
		return;

	if (servlist_savegui () != 0)
	{
		fe_message (_("User name and Real name cannot be left blank."), FE_MSG_ERROR);
		return;
	}

	if (!is_session (servlist_sess))
		servlist_sess = NULL;
	else if (servlist_sess->server->connected)
		servlist_sess = NULL;

	servlist_connect (servlist_sess, selected_net, TRUE);

	mg_close_gen(NULL, serverlist_win);
}
Example #10
0
const char *
hexchat_get_info (hexchat_plugin *ph, const char *id)
{
	session *sess;
	guint32 hash;

	/*                 1234567890 */
	if (!strncmp (id, "event_text", 10))
	{
		char *e = (char *)id + 10;
		if (*e == ' ') e++;	/* 2.8.0 only worked without a space */
		return text_find_format_string (e);
	}

	hash = str_hash (id);
	/* do the session independant ones first */
	switch (hash)
	{
		case 0x325acab5:	/* libdirfs */
#ifdef USE_PLUGIN
			return plugin_get_libdir ();
#else
			return NULL;
#endif

		case 0x14f51cd8: /* version */
			return PACKAGE_VERSION;

		case 0xdd9b1abd:	/* xchatdir */
		case 0xe33f6c4a:	/* xchatdirfs */
		case 0xd00d220b:	/* configdir */
			return get_xdir ();
	}

	sess = ph->context;
	if (!is_session (sess))
	{
		DEBUG(PrintTextf(0, "%s\thexchat_get_info called without a valid context.\n", ph->name));
		return NULL;
	}

	switch (hash)
	{
	case 0x2de2ee: /* away */
		if (sess->server->is_away)
			return sess->server->last_away_reason;
		return NULL;

  	case 0x2c0b7d03: /* channel */
		return sess->channel;

	case 0x2c0d614c: /* charset */
		{
			const char *locale;

			if (sess->server->encoding)
				return sess->server->encoding;

			locale = NULL;
			g_get_charset (&locale);
			return locale;
		}

	case 0x30f5a8: /* host */
		return sess->server->hostname;

	case 0x1c0e99c1: /* inputbox */
		return fe_get_inputbox_contents (sess);

	case 0x633fb30:	/* modes */
		return sess->current_modes;

	case 0x6de15a2e:	/* network */
		return server_get_network (sess->server, FALSE);

	case 0x339763: /* nick */
		return sess->server->nick;

	case 0x4889ba9b: /* password */
	case 0x438fdf9: /* nickserv */
		if (sess->server->network)
			return ((ircnet *)sess->server->network)->pass;
		return NULL;

	case 0xca022f43: /* server */
		if (!sess->server->connected)
			return NULL;
		return sess->server->servername;

	case 0x696cd2f: /* topic */
		return sess->topic;

	case 0x3419f12d: /* gtkwin_ptr */
		return fe_gui_info_ptr (sess, 1);

	case 0x506d600b: /* native win_ptr */
		return fe_gui_info_ptr (sess, 0);

	case 0x6d3431b5: /* win_status */
		switch (fe_gui_info (sess, 0))	/* check window status */
		{
		case 0: return "normal";
		case 1: return "active";
		case 2: return "hidden";
		}
		return NULL;
	}

	return NULL;
}
Example #11
0
gboolean
key_handle_key_press (GtkWidget *wid, GdkEventKey *evt, session *sess)
{
	struct key_binding *kb;
	int n;
	GSList *list;

	/* where did this event come from? */
	list = sess_list;
	while (list)
	{
		sess = list->data;
		if (sess->gui->input_box == wid)
		{
			if (sess->gui->is_tab)
				sess = current_tab;
			break;
		}
		list = list->next;
	}
	if (!list)
		return FALSE;
	current_sess = sess;

	if (plugin_emit_keypress (sess, evt->state, evt->keyval, gdk_keyval_to_unicode (evt->keyval)))
		return 1;

	/* maybe the plugin closed this tab? */
	if (!is_session (sess))
		return 1;

	list = keybind_list;
	while (list)
	{
		kb = (struct key_binding*)list->data;

		if (kb->keyval == evt->keyval && kb->mod == key_modifier_get_valid (evt->state))
		{
			if (kb->action < 0 || kb->action > KEY_MAX_ACTIONS)
				return 0;

			/* Run the function */
			n = key_actions[kb->action].handler (wid, evt, kb->data1,
															 kb->data2, sess);
			switch (n)
			{
			case 0:
				return 1;
			case 2:
				g_signal_stop_emission_by_name (G_OBJECT (wid),
														"key_press_event");
				return 1;
			}
		}
		list = g_slist_next (list);
	}

	switch (evt->keyval)
	{
	case GDK_KEY_space:
		key_action_tab_clean ();
		break;
	}

	return 0;
}
Example #12
0
File: fkeys.c Project: n2i/xvnkb
gboolean
key_handle_key_press (GtkWidget *wid, GdkEventKey *evt, session *sess)
{
	struct key_binding *kb, *last = NULL;
	int keyval = evt->keyval;
	int mod, n;
	GSList *list;

	/* where did this event come from? */
	list = sess_list;
	while (list)
	{
		sess = list->data;
		if (sess->gui->input_box == wid)
		{
			if (sess->gui->is_tab)
				sess = current_tab;
			break;
		}
		list = list->next;
	}
	if (!list)
		return FALSE;
	current_sess = sess;

	if (plugin_emit_keypress (sess, evt->state, evt->keyval, evt->length, evt->string))
		return 1;

	/* maybe the plugin closed this tab? */
	if (!is_session (sess))
		return 1;

	mod = evt->state & (STATE_CTRL | STATE_ALT | STATE_SHIFT);

	kb = keys_root;
	while (kb)
	{
		if (kb->keyval == keyval && kb->mod == mod)
		{
			if (kb->action < 0 || kb->action > KEY_MAX_ACTIONS)
				return 0;

			/* Bump this binding to the top of the list */
			if (last != NULL)
			{
				last->next = kb->next;
				kb->next = keys_root;
				keys_root = kb;
			}
			/* Run the function */
			n = key_actions[kb->action].handler (wid, evt, kb->data1,
															 kb->data2, sess);
			switch (n)
			{
			case 0:
				return 1;
			case 2:
				g_signal_stop_emission_by_name (G_OBJECT (wid),
														"key_press_event");
				return 1;
			}
		}
		last = kb;
		kb = kb->next;
	}

	switch (keyval)
	{
	case GDK_space:
		key_action_tab_clean ();
		break;
	}

	return 0;
}
Example #13
0
static void
banlist_closegui (GtkWidget *wid, session *sess)
{
	if (is_session (sess))
		sess->res->banlist_window = 0;
}
Example #14
0
const char* xchat_get_info(xchat_plugin *ph, const char *id)
{
	session *sess;
	unsigned int hash;

	// 1234567890
	if (!strncmp(id, "event_text", 10))
	{
		char *e = (char*)id + 10;
		if (*e == ' ') e++;	// 2.8.0 only worked without a space
		return text_find_format_string(e);
	}

	hash = str_hash(id);
	// do the session independant ones first
	switch (hash)
	{
	case 0x325acab5:	// libdirfs
		return XCHATLIBDIR;

	case 0x14f51cd8: // version
		return PACKAGE_VERSION;

	case 0xdd9b1abd:	// xchatdir
		return get_xdir_utf8();

	case 0xe33f6c4a:	// xchatdirfs
		return get_xdir_fs();
	}

	sess = ph->context;
	if (!is_session(sess))
	{
		DEBUG(PrintTextf(0, "%s\txchat_get_info called without a valid context.\n", ph->name));
		return nullptr;
	}

	switch (hash)
	{
	case 0x2de2ee: // away
		if (sess->server->is_away)
			return sess->server->last_away_reason;
		return nullptr;

	case 0x2c0b7d03: // channel
		return sess->channel;

	case 0x2c0d614c: // charset
		{
			const char *locale;

			if (sess->server->encoding)
				return sess->server->encoding;

			locale = nullptr;
			g_get_charset(&locale);
			return locale;
		}

	case 0x30f5a8: // host
		return sess->server->hostname;

	case 0x1c0e99c1: // inputbox
		return fe_get_inputbox_contents(sess);

	case 0x633fb30:	// modes
		return sess->current_modes;

	case 0x6de15a2e:	// network
		return server_get_network(sess->server, FALSE);

	case 0x339763: // nick
		return sess->server->nick;

	case 0x438fdf9: // nickserv
		if (sess->server->network)
			return ((ircnet*)sess->server->network)->nickserv;
		return nullptr;

	case 0xca022f43: // server
		if (!sess->server->connected)
			return nullptr;
		return sess->server->servername;

	case 0x696cd2f: // topic
		return sess->topic;

	case 0x3419f12d: // gtkwin_ptr
		return (const char*)fe_gui_info_ptr(sess, 1);

	case 0x506d600b: // native win_ptr
		return (const char*)fe_gui_info_ptr(sess, 0);

	case 0x6d3431b5: // win_status
		switch (fe_gui_info(sess, 0))	// check window status
		{
		case 0: return "normal";
		case 1: return "active";
		case 2: return "hidden";
		}
		return nullptr;
	}

	return nullptr;
}