Exemple #1
0
static void
tray_priv (char *from, char *text)
{
	const char *network;

	if (alert_match_word (from, prefs.hex_irc_no_hilight))
		return;

	tray_set_flash (ICON_MSG);

	network = hexchat_get_info (ph, "network");
	if (!network)
		network = hexchat_get_info (ph, "server");

	tray_priv_count++;
	if (tray_priv_count == 1)
		tray_set_tipf (_(DISPLAY_NAME": Private message from: %s (%s)"),
							from, network);
	else
		tray_set_tipf (_(DISPLAY_NAME": %u private messages, latest from: %s (%s)"),
							tray_priv_count, from, network);

	if (prefs.hex_input_balloon_priv)
		tray_set_balloonf (text, _("Private message from: %s (%s)"),
								 from, network);
}
Exemple #2
0
static int
tray_dcc_cb (char *word[], void *userdata)
{
	const char *network;

/*	if (tray_status == TS_FILEOFFER)
		return HEXCHAT_EAT_NONE;*/

	network = hexchat_get_info (ph, "network");
	if (!network)
		network = hexchat_get_info (ph, "server");

	if (prefs.hex_input_tray_priv && (!prefs.hex_away_omit_alerts || tray_find_away_status () != 1))
	{
		tray_set_flash (ICON_FILE);

		tray_file_count++;
		if (tray_file_count == 1)
			tray_set_tipf (_(DISPLAY_NAME": File offer from: %s (%s)"),
								word[1], network);
		else
			tray_set_tipf (_(DISPLAY_NAME": %u file offers, latest from: %s (%s)"),
								tray_file_count, word[1], network);
	}

	if (prefs.hex_input_balloon_priv && (!prefs.hex_away_omit_alerts || tray_find_away_status () != 1))
		tray_set_balloonf ("", _("File offer from: %s (%s)"),
								word[1], network);

	return HEXCHAT_EAT_NONE;
}
static int
incoming_priv_cb (char *word[], gpointer userdata)
{
	int priv;

	if (hexchat_get_prefs (ph, "input_balloon_priv", NULL, &priv) == 3 && priv && should_alert ())
	{
		const char *network = hexchat_get_info (ph, "network");
		if (!network)
			network = hexchat_get_info (ph, "server");

		if (userdata != NULL) /* Special event */
		{
			if (GPOINTER_TO_INT (userdata) == 3)
			{
				if (!is_ignored (word[2]))
					show_notificationf (word[1], _("File offer from: %s (%s)"), word[2], network);
			}
			else if (GPOINTER_TO_INT (userdata) == 2)
			{
				if (!is_ignored (word[2]))
					show_notificationf (word[1], _("Invited to channel by: %s (%s)"), word[2], network);
			}
			else
			{
				if (!is_ignored (word[1]))
					show_notificationf (word[2], _("Notice from: %s (%s)"), word[1], network);
			}
		}
		else
			show_notificationf (word[2], _("Private message from: %s (%s)"), word[1], network);
	}
	return HEXCHAT_EAT_NONE;
}
Exemple #4
0
static int
tray_hilight_cb (char *word[], void *userdata)
{
	/*if (tray_status == TS_HIGHLIGHT)
		return HEXCHAT_EAT_NONE;*/

	if (prefs.hex_input_tray_hilight)
	{
		tray_set_flash (ICON_HILIGHT);

		/* FIXME: hides any previous private messages */
		tray_hilight_count++;
		if (tray_hilight_count == 1)
			tray_set_tipf (_(DISPLAY_NAME": Highlighted message from: %s (%s)"),
								word[1], hexchat_get_info (ph, "channel"));
		else
			tray_set_tipf (_(DISPLAY_NAME": %u highlighted messages, latest from: %s (%s)"),
								tray_hilight_count, word[1], hexchat_get_info (ph, "channel"));
	}

	if (prefs.hex_input_balloon_hilight)
		tray_set_balloonf (word[2], _("Highlighted message from: %s (%s)"),
								 word[1], hexchat_get_info (ph, "channel"));

	return HEXCHAT_EAT_NONE;
}
static gboolean
should_alert (void)
{
	int omit_away, omit_focused, omit_tray;

	if (hexchat_get_prefs (ph, "gui_focus_omitalerts", NULL, &omit_focused) == 3 && omit_focused)
	{
		const char *status = hexchat_get_info (ph, "win_status");

		if (status && !g_strcmp0 (status, "active"))
			return FALSE;
	}

	if (hexchat_get_prefs (ph, "away_omit_alerts", NULL, &omit_away) == 3 && omit_away)
	{
		if (hexchat_get_info (ph, "away"))
			return FALSE;
	}

	if (hexchat_get_prefs (ph, "gui_tray_quiet", NULL, &omit_tray) == 3 && omit_tray)
	{
		int tray_enabled;

		if (hexchat_get_prefs (ph, "gui_tray", NULL, &tray_enabled) == 3 && tray_enabled)
		{
			const char *status = hexchat_get_info (ph, "win_status");

			if (status && g_strcmp0 (status, "hidden") != 0)
				return FALSE;
		}
	}

	return TRUE;
}
int cmd_otr (char *word[], char *word_eol[], void *userdata)
{
	const char *own_nick = hexchat_get_info (ph, "nick");
	char *target = (char *)hexchat_get_info (ph, "channel");
	const char *server = hexchat_get_info (ph, "server");
	IRC_CTX ircctxs = {
				.nick = (char *)own_nick,
				.address = (char *)server
			},
Exemple #7
0
void hexchat_back()
{
    if(hexchat_get_info(ph, "away"))
    {
        hexchat_command(ph, "BACK");
    }
}
Exemple #8
0
/**
 * Command handler for /setkey
 */
static int handle_setkey(char *word[], char *word_eol[], void *userdata) {
    const char *nick;
    const char *key;
    
    // Check syntax
    if (*word[2] == '\0') {
        hexchat_printf(ph, "%s\n", usage_setkey);
        return HEXCHAT_EAT_HEXCHAT;
    }
    
    if (*word[3] == '\0') {
        // /setkey password
        nick = hexchat_get_info(ph, "channel");
        key = word_eol[2];
    } else {
        // /setkey #channel password
        //nick = word[2];
        nick = word[2];
		key = word_eol[3];
    }
    
    // Set password
    if (keystore_store_key(nick, key)) {
        hexchat_printf(ph, "Stored key for %s\n", nick);
    } else {
        hexchat_printf(ph, "\00305Failed to store key in blow.ini\n", nick, key);
    }
    
    return HEXCHAT_EAT_HEXCHAT;
}
Exemple #9
0
/**
 * Called when a message is to be sent.
 */
static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
    const char *own_nick;
    // Encrypt the message if possible
    const char *channel = hexchat_get_info(ph, "channel");
    char *encrypted = fish_encrypt_for_nick(channel, word_eol[1]);
    if (!encrypted) return HEXCHAT_EAT_NONE;
    
    // Display message
    own_nick = hexchat_get_info(ph, "nick");
    hexchat_emit_print(ph, "Your Message", own_nick, word_eol[1], NULL);
    
    // Send message
    hexchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted);
    
    free(encrypted);
    return HEXCHAT_EAT_HEXCHAT;
}
Exemple #10
0
/**
 * Returns the path to the key store file.
 */
gchar *get_config_filename(void) {
    char *filename_fs, *filename_utf8;

    filename_utf8 = g_build_filename(hexchat_get_info(ph, "configdir"), "addon_fishlim.conf", NULL);
    filename_fs = g_filename_from_utf8 (filename_utf8, -1, NULL, NULL, NULL);

    g_free (filename_utf8);
    return filename_fs;
}
static int
incoming_hilight_cb (char *word[], gpointer userdata)
{
	int hilight;

	if (hexchat_get_prefs (ph, "input_balloon_hilight", NULL, &hilight) == 3 && hilight && should_alert())
	{
		show_notificationf (word[2], _("Highlighted message from: %s (%s)"), word[1], hexchat_get_info (ph, "channel"));
	}
	return HEXCHAT_EAT_NONE;
}
static int
incoming_message_cb (char *word[], gpointer userdata)
{
	int message;

	if (hexchat_get_prefs (ph, "input_balloon_chans", NULL, &message) == 3 && message && should_alert ())
	{
		show_notificationf (word[2], _("Channel message from: %s (%s)"), word[1], hexchat_get_info (ph, "channel"));
	}
	return HEXCHAT_EAT_NONE;
}
Exemple #13
0
void
fe_tray_set_balloon (const char *title, const char *text)
{
#ifndef WIN32
#if 0
	const char *argv[8];
	const char *path;
	char time[16];
#endif
	WinStatus ws;

	/* no balloons if the window is focused */
	ws = tray_get_window_status ();
	if ((prefs.hex_away_omit_alerts && hexchat_get_info(ph, "away")) ||
		(prefs.hex_gui_focus_omitalerts && ws == WS_FOCUSED))
		return;

	/* bit 1 of flags means "no balloons unless hidden/iconified" */
	if (ws != WS_HIDDEN && prefs.hex_gui_tray_quiet)
		return;

	/* FIXME: this should close the current balloon */
	if (!text)
		return;

#ifdef USE_LIBNOTIFY
	NotifyNotification *notification;
	char *notify_text, *notify_title;

	if (!notify_is_initted())
		notify_init(PACKAGE_NAME);

	notify_text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP);
	notify_title = strip_color (title, -1, STRIP_ALL);

	notification = XC_NOTIFY_NEW (notify_title, notify_text, HEXCHATSHAREDIR "/icons/hicolor/scalable/apps/hexchat.svg", NULL);

#if NOTIFY_CHECK_VERSION(0,7,0)
	notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("hexchat"));
#endif

	g_free ((char *)notify_title);
	g_free ((char *)notify_text);

	notify_notification_set_timeout (notification, prefs.hex_input_balloon_time*1000);
	notify_notification_show (notification, NULL);

	g_object_unref (notification);
#endif
#endif
}
Exemple #14
0
static int command_console_exec(char *word[], char *word_eol[], void *userdata)
{
	char const *channel = hexchat_get_info(ph, "channel");
	if(channel && !strcmp(channel, console_tab))
	{
		if(interp)
		{
			hexchat_printf(ph, "> %s", word_eol[1]);
			inject_string(interp, word_eol[1]);
		}
		return HEXCHAT_EAT_ALL;
	}
	return HEXCHAT_EAT_NONE;
}
Exemple #15
0
gboolean
tray_toggle_visibility (gboolean force_hide)
{
	static int x, y;
	static GdkScreen *screen;
	static int maximized;
	GtkWindow *win;

	if (!sticon)
		return FALSE;

	/* ph may have an invalid context now */
	hexchat_set_context (ph, hexchat_find_context (ph, NULL, NULL));

	win = GTK_WINDOW (hexchat_get_info (ph, "gtkwin_ptr"));

	tray_stop_flash ();
	tray_reset_counts ();

	if (!win)
		return FALSE;

#if GTK_CHECK_VERSION(2,20,0)
	if (force_hide || gtk_widget_get_visible (GTK_WIDGET (win)))
#else
	if (force_hide || GTK_WIDGET_VISIBLE (win))
#endif
	{
		if (prefs.hex_gui_tray_away)
			hexchat_command (ph, "ALLSERV AWAY");
		gtk_window_get_position (win, &x, &y);
		screen = gtk_window_get_screen (win);
		maximized = prefs.hex_gui_win_state;
		gtk_widget_hide (GTK_WIDGET (win));
	}
	else
	{
		if (prefs.hex_gui_tray_away)
			hexchat_command (ph, "ALLSERV BACK");
		gtk_window_set_screen (win, screen);
		gtk_window_move (win, x, y);
		if (maximized)
			gtk_window_maximize (win);
		gtk_widget_show (GTK_WIDGET (win));
		gtk_window_present (win);
	}

	return TRUE;
}
Exemple #16
0
static int
tray_message_cb (char *word[], void *userdata)
{
	if (/*tray_status == TS_MESSAGE ||*/ tray_status == TS_HIGHLIGHT)
		return HEXCHAT_EAT_NONE;
		
	if (prefs.hex_input_tray_chans)
	{
		tray_set_flash (ICON_MSG);

		tray_pub_count++;
		if (tray_pub_count == 1)
			tray_set_tipf (_(DISPLAY_NAME": Channel message from: %s (%s)"),
								word[1], hexchat_get_info (ph, "channel"));
		else
			tray_set_tipf (_(DISPLAY_NAME": %u channel messages."), tray_pub_count);
	}

	if (prefs.hex_input_balloon_chans)
		tray_set_balloonf (word[2], _("Channel message from: %s (%s)"),
								 word[1], hexchat_get_info (ph, "channel"));

	return HEXCHAT_EAT_NONE;
}
Exemple #17
0
static sasl_info*
get_info (void)
{
	const char* name;
	name = hexchat_get_info (ph, "network");

	if (name)
	{
		return find_info (name);
	}
	else
	{
		return NULL;
	}
}
Exemple #18
0
static int
printInfo (char *word[], char *word_eol[], void *user_data)
{
	/* query WMI info only at the first time SysInfo is called, then cache it to save time */
	if (firstRun)
	{
		hexchat_printf (ph, "%s first execution, querying and caching WMI info...\n", name);
		wmiOs = getWmiInfo (0);
		wmiCpu = getWmiInfo (1);
		wmiVga = getWmiInfo (2);
		firstRun = 0;
	}
	if (hexchat_list_int (ph, NULL, "type") >= 2)
	{
		/* uptime will work correctly for up to 50 days, should be enough */
		hexchat_commandf (ph, "ME ** SysInfo ** Client: HexChat %s (x%d) ** OS: %s ** CPU: %s (%s) ** RAM: %s ** VGA: %s ** Uptime: %.2f Hours **",
			hexchat_get_info (ph, "version"),
			getCpuArch (),
			wmiOs,
			wmiCpu,
			getCpuMhz (),
			getMemoryInfo (),
			wmiVga, (float) GetTickCount() / 1000 / 60 / 60);
	}
	else
	{
		hexchat_printf (ph, " * Client:  HexChat %s (x%d)\n", hexchat_get_info (ph, "version"), getCpuArch ());
		hexchat_printf (ph, " * OS:      %s\n", wmiOs);
		hexchat_printf (ph, " * CPU:     %s (%s)\n", wmiCpu, getCpuMhz ());
		hexchat_printf (ph, " * RAM:     %s\n", getMemoryInfo ());
		hexchat_printf (ph, " * VGA:     %s\n", wmiVga);
		hexchat_printf (ph, " * Uptime:  %.2f Hours\n", (float) GetTickCount() / 1000 / 60 / 60);
	}

	return HEXCHAT_EAT_HEXCHAT;
}
Exemple #19
0
static int api_hexchat_get_info(lua_State *L)
{
	char const *key = luaL_checkstring(L, 1);
	char const *data = hexchat_get_info(ph, key);
	if(data)
	{
		if(!strcmp(key, "gtkwin_ptr") || !strcmp(key, "win_ptr"))
			lua_pushlightuserdata(L, (void *)data);
		else
			lua_pushstring(L, data);
		return 1;
	}
	lua_pushnil(L);
	return 1;
}
Exemple #20
0
void loadThemes() {
    char *hDir, *hFile, *line, *lineCap, *val;
    FILE *f;
    hexchat_print(ph,"loading themes\n");
    hDir=(char*)calloc(1024,sizeof(char));
    strcpy(hDir,hexchat_get_info(ph,"configdir"));
    hFile=str3cat(hDir,"\\","mpcInfo.theme.txt");
    f = fopen(hFile,"r");
    free(hDir);
    free(hFile);
    if(f==NULL)
    {
        hexchat_print(ph,"no theme in homedir, checking global theme");
        f=fopen("mpcInfo.theme.txt","r");
    }
    //hexchat_printf(ph,"file_desc: %p\n",f);
    if (f==NULL) hexchat_print(ph, "no theme found, using hardcoded\n");
    else {
        if (f > 0)
        {
            line=" ";
        } else
        {
            line="\0";
        }

        while (line[0]!=0)
        {
            line=readLine(f);
            val=split(line,'=');
            printf("line: %s\n",line);
            printf("val: %s\n",val);
            lineCap=toUpper(line);
            if (strcmp(lineCap,"OFF_LINE")==0) notRunTheme=themeAdd(notRunTheme,val);
            if (strcmp(lineCap,"TITLE_LINE")==0) titleTheme=themeAdd(titleTheme,val);
            if (strcmp(lineCap,"MP3_LINE")==0) mp3Theme=themeAdd(mp3Theme,val);
            if (strcmp(lineCap,"OGG_LINE")==0) mp3Theme=themeAdd(oggTheme,val);
            free(lineCap);
        }
        fclose(f);
        hexchat_print(ph, "theme loaded successfull\n");
    }
    if (notRunTheme.size==0) notRunTheme=themeAdd(notRunTheme,"Media Player Classic not running");
    if (titleTheme.size==0) titleTheme=themeAdd(titleTheme,"say Playing %title in Media Player Classic");
    if (mp3Theme.size==0) mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%mode] in Media Player Classic ");
    if (oggTheme.size==0) oggTheme=themeAdd(oggTheme,"me listens to %art with %tit from %alb [%gen|%br kbps|%frq kHz|%chan channels] in Media Player Classic ");
    //mp3Theme=themeAdd(mp3Theme,"me listens to %art with %tit from %alb [%time|%length|%perc%|%br kbps|%frq kHz|%mode] in Media Player Classic ");
}
Exemple #21
0
static void autoload_scripts(void)
{
	char *path = g_build_filename(hexchat_get_info(ph, "configdir"), "addons", NULL);
	GDir *dir = g_dir_open(path, 0, NULL);
	if(dir)
	{
		char const *filename;
		while((filename = g_dir_read_name(dir)))
		{
			if(is_lua_file(filename))
				load_script(filename);
		}
		g_dir_close(dir);
	}
	g_free(path);
}
Exemple #22
0
static char const *expand_path(char const *path)
{
	if(g_path_is_absolute(path))
		return path;
#ifndef G_OS_WIN32
	if(path[0] == '~')
	{
		if(!path[1] || path[1] == '/')
		{
			g_free(expand_buffer);
			expand_buffer = g_build_filename(g_get_home_dir(), path + 1, NULL);
			return expand_buffer;
		}
		else
		{
			char *user = g_strdup(path + 1);
			char *slash_pos = strchr(user, '/');
			struct passwd *pw;
			if(slash_pos)
				*slash_pos = 0;
			pw = getpwnam(user);
			g_free(user);
			if(pw)
			{
				slash_pos = strchr(path, '/');
				if(!slash_pos)
					return pw->pw_dir;

				g_free(expand_buffer);
				expand_buffer = g_strconcat(pw->pw_dir, slash_pos, NULL);
				return expand_buffer;
			}
			else
			{
				return path;
			}
		}
	}
	else
#endif
	{
		g_free(expand_buffer);
		expand_buffer = g_build_filename(hexchat_get_info(ph, "configdir"), "addons", path, NULL);
		return expand_buffer;
	}
}
Exemple #23
0
static WinStatus
tray_get_window_status (void)
{
	const char *st;

	st = hexchat_get_info (ph, "win_status");

	if (!st)
		return WS_HIDDEN;

	if (!strcmp (st, "active"))
		return WS_FOCUSED;

	if (!strcmp (st, "hidden"))
		return WS_HIDDEN;

	return WS_NORMAL;
}
Exemple #24
0
static int
print_version_quiet (void *userdata)
{
	char *version = check_version ();

	/* if it's not the current version AND not network error */
	if (!(strcmp (version, hexchat_get_info (ph, "version")) == 0) && !(strcmp (version, "Unknown") == 0))
	{
#ifdef _WIN64 /* use this approach, the wProcessorArchitecture method always returns 0 (=x86) for plugins for some reason */
		hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\nhttps://github.com/downloads/hexchat/hexchat/HexChat%%20%s%%20x64.exe\n", name, version);
#else
		hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\nhttps://github.com/downloads/hexchat/hexchat/HexChat%%20%s%%20x86.exe\n", name, version);
#endif
		/* print update url once, then stop the timer */
		return 0;
	}
	/* keep checking */
	return 1;
}
Exemple #25
0
static int
perl_auto_load (void *unused)
{
	const char *xdir;
	char *sub_dir;
#ifdef WIN32
	int copied = 0;
	char *slash = NULL;
#endif

	/* get the dir in local filesystem encoding (what opendir() expects!) */
	xdir = hexchat_get_info (ph, "configdir");

	/* don't pollute the filesystem with script files, this only causes misuse of the folders
	 * only use ~/.config/hexchat/addons/ and %APPDATA%\HexChat\addons */
#if 0
	/* autoload from ~/.config/hexchat/ or %APPDATA%\HexChat\ on win32 */
	perl_auto_load_from_path (xdir);
#endif

	sub_dir = malloc (strlen (xdir) + 8);
	strcpy (sub_dir, xdir);
	strcat (sub_dir, "/addons");
	perl_auto_load_from_path (sub_dir);
	free (sub_dir);

#if 0
#ifdef WIN32
	/* autoload from  C:\Program Files\HexChat\plugins\ */
	sub_dir = malloc (1025 + 9);
	copied = GetModuleFileName( 0, sub_dir, 1024 );
	sub_dir[copied] = '\0';
	slash = strrchr( sub_dir, '\\' );
	if( slash != NULL ) {
		*slash = '\0';
	}
	perl_auto_load_from_path ( strncat (sub_dir, "\\plugins", 9));
	free (sub_dir);
#endif
#endif
	return 0;
}
Exemple #26
0
static
XS (XS_Xchat_get_info)
{
	SV *temp = NULL;
	dXSARGS;
	if (items != 1) {
		hexchat_print (ph, "Usage: Xchat::get_info(id)");
	} else {
		SV *id = ST (0);
		const char *RETVAL;

		RETVAL = hexchat_get_info (ph, SvPV_nolen (id));
		if (RETVAL == NULL) {
			XSRETURN_UNDEF;
		}

		if (!strncmp ("win_ptr", SvPV_nolen (id), 7)
			|| !strncmp ("gtkwin_ptr", SvPV_nolen (id), 10))
		{
			XSRETURN_IV (PTR2IV (RETVAL));
		} else {
			
			if (
				!strncmp ("libdirfs", SvPV_nolen (id), 8) ||
				!strncmp ("xchatdirfs", SvPV_nolen (id), 10) ||
				!strncmp ("configdir", SvPV_nolen (id), 9)
			) {
				XSRETURN_PV (RETVAL);
			} else {
				temp = newSVpv (RETVAL, 0);
				SvUTF8_on (temp);
				PUSHMARK (SP);
				XPUSHs (sv_2mortal (temp));
				PUTBACK;
			}
		}
	}
}
Exemple #27
0
LRESULT CALLBACK sdTrayProc(HWND hWnd, int msg)
{
	switch(msg)
	{
	case ACT_EXIT:
		{
			g_bCanQuit = true;
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		}
		break;
	case ACT_RESTORE:
		{
			/*************************************************/
			/** user wants us to restore the HexChat window **/
			/** and of autoaway is on, set as back ******** **/
			/*************************************************/
			SendMessage(g_hXchatWnd, WM_SYSCOMMAND, SC_RESTORE, 0);
			SetForegroundWindow(hWnd);
			
			if((!g_iIsActive) && (g_dwPrefs & (1<<PREF_AOM)))
			{
				hexchat_globally_back();
				g_iIsActive = 1;
			}
		}
		break;
	case ACT_SETTINGS:
		{
			ShowWindow(g_hPrefDlg, SW_SHOW);
		}
		break;
	case ACT_AWAY:
		{
			hexchat_globally_away(g_szAway);
		}
		break;
	case ACT_BACK:
		{
			hexchat_globally_back();
		}
		break;
	default:
		{
			if(msg > 0)
			{
				hexchat_set_context(ph, hexchat_find_server(msg-1));

				if(!hexchat_get_info(ph, "away"))
				{
					hexchat_away(g_szAway);
				}
				else
				{
					hexchat_back();
				}
			}
		}
		break;
	}

	return 1;
}
Exemple #28
0
int event_cb(char *word[], void *userdata)
{
	int iEvent = (int)userdata;

	if(iEvent > 10 && iEvent != 21)
		return HEXCHAT_EAT_NONE;

	/***************************************************************************************/
	/***** if the window is minimized or if we're allowed to show alerts when its not	 **/
	/***** and if the option to show the specified alert is true and if we're even		**/
	/***** allowed to show alerts at all then we show them (a bit confusing but it works) **/
	/***************************************************************************************/
	if(((g_iIsActive == 0) || !(g_dwPrefs & (1<<PREF_OSBWM))) && (g_dwPrefs & (1<<PREF_AMAE)) && (g_dwPrefs & (1<<iEvent)))
	{	
		/*********************************/
		/*********** Our Buffers *********/
		/*********************************/
		char			szInfo[512];
		char			szName[64];
		DWORD			dwInfoFlags;
		int iTime		= g_iTime*1000;
		char *szTemp	= NULL;

		if(g_dwPrefs & (1<<PREF_KAOI))
		{
			iTime = 0;
		}

		switch(iEvent)
		{
		case CHAN_HILIGHT:
			_snprintf(szInfo, 512, "%s:\r\n%s", word[1], word[2]);
			_snprintf(szName, 64, "Highlight: %s", hexchat_get_info (ph, "channel"));
			dwInfoFlags = NIIF_INFO;
			break;
		case CHAN_MESSAGE:
			_snprintf(szInfo, 512, "%s:\r\n%s", word[1], word[2]);
			_snprintf(szName, 64, "Channel Message: %s", hexchat_get_info (ph, "channel"));
			dwInfoFlags = NIIF_INFO;
			break;
		case CHAN_TOPIC_CHANGE:
			_snprintf(szInfo, 512, "%s has changed the topic to %s", word[1], word[2]);
			_snprintf(szName, 64, "Topic Change: %s", word[3]);
			dwInfoFlags = NIIF_INFO;
			break;
		case CHAN_INVITE:
			_snprintf(szInfo, 512, "%s has invited you into %s", word[1], word[2]);
			_snprintf(szName, 64, "Invite");
			dwInfoFlags = NIIF_INFO;
			break;
		case CHAN_KICKED:
			_snprintf(szInfo, 512, "Kicked from %s by %s:\r\n%s", word[2], word[3], word[4]);
			_snprintf(szName, 64, "Kick");
			dwInfoFlags = NIIF_WARNING;
			break;
		case CHAN_BANNED:
			_snprintf(szInfo, 512, "Cannot join %s You are banned.", word[1]);
			_snprintf(szName, 64, "Banned");
			dwInfoFlags = NIIF_WARNING;
			break;
		case CTCP_GENERIC:
			_snprintf(szInfo, 512, "%s:\r\nCTCP %s", word[2], word[1]);
			_snprintf(szName, 64, "CTCP");
			dwInfoFlags = NIIF_INFO;
			break;
		case PMSG_RECEIVE:
			_snprintf(szInfo, 512, "%s:\r\n%s", word[1], word[2]);
			_snprintf(szName, 64, "Private Message");
			dwInfoFlags = NIIF_INFO;
			break;
		case SERV_DISCONNECT:
			_snprintf(szInfo, 512, "Disconnected\r\nError: %s", word[1]);
			_snprintf(szName, 64, "Disconnect");
			dwInfoFlags = NIIF_ERROR;
			break;
		case SERV_KILLED:
			_snprintf(szInfo, 512, "Killed(%s(%s))", word[1], word[2]);
			_snprintf(szName, 64, "Server Admin has killed you");
			dwInfoFlags = NIIF_ERROR;
			break;
		case SERV_NOTICE:
			_snprintf(szInfo, 512, "Notice:\r\n%s: %s", word[1], word[2]);
			_snprintf(szName, 64, "Notice");
			dwInfoFlags = NIIF_INFO;
			break;
		case 11:
			_snprintf(szInfo, 512, ":\r\n%s: %s", word[1], word[2]);
			_snprintf(szName, 64, "Notice");
			dwInfoFlags = NIIF_INFO;
			break;
		}

		/**************************************************************************************/
		/***** Use windows instead of balloons, and if its a window should we keep it open ****/
		/***** indefinitely?															   ****/
		/**************************************************************************************/
		szTemp = hexchat_strip_color(szInfo);

		if(g_dwPrefs & (1<<PREF_UWIOB))
		{
			sdSystemAlert((HINSTANCE)g_hInstance, IDD_ALERT, szTemp, szName, iTime);
		}
		else
		{
			ShowBalloon(g_hXchatWnd, 1, szTemp, szName, iTime, dwInfoFlags);
		}

		free(szTemp);
	}

	if(g_dwPrefs & (1<<PREF_BLINK) && (g_dwPrefs & (1<<iEvent)))
	{
		BlinkIcon(g_hXchatWnd, 1, g_hIcons[0], g_hIcons[(iEvent+1)], 700, 5);
	}

	/***********************************/
	/***** pass the events to HexChat **/
	/***********************************/
	return HEXCHAT_EAT_NONE;
}
Exemple #29
0
HMENU setServerMenu()
{
    HMENU sTemp = CreateMenu();
    TCHAR wszServer[128];
    TCHAR wszNick[128];
    TCHAR wszMenuEntry[256];

    std::vector<int> xs;
    std::vector<int>::iterator xsi;
    hexchat_list *xl = hexchat_list_get(ph, "channels");

    AppendMenu(sTemp, MF_STRING, ACT_AWAY, _T("Set Globally Away"));
    AppendMenu(sTemp, MF_STRING, ACT_BACK, _T("Set Globally Back"));
    AppendMenu(sTemp, MF_SEPARATOR, 0, NULL);

    if(xl)
    {
        while(hexchat_list_next(ph, xl))
        {
            xsi = std::find(xs.begin(), xs.end(), hexchat_list_int(ph, xl, "id"));

            if( (xsi == xs.end()) &&
                    ((strlen(hexchat_list_str(ph, xl, "server")) > 0) ||
                     (strlen(hexchat_list_str(ph, xl, "channel")) > 0)))
            {
                hexchat_set_context(ph, (hexchat_context *)hexchat_list_str(ph, xl, "context"));
                xs.push_back(hexchat_list_int(ph, xl, "id"));

                char *network	= _strdup(hexchat_list_str(ph, xl, "network"));
                char *server	= _strdup(hexchat_list_str(ph, xl, "server"));
                char *nick		= _strdup(hexchat_get_info(ph, "nick"));

                if(network != NULL)
                {
                    ConvertString(network, wszServer, 128);
                }
                else
                {
                    ConvertString(server, wszServer, 128);
                }

                if(server != NULL)
                {
                    ConvertString(nick, wszNick, 128);
                    _sntprintf(wszMenuEntry, 256, _T("%s @ %s\0"), wszNick, wszServer);

                    if(!hexchat_get_info(ph, "away"))
                    {
                        AppendMenu(sTemp, MF_STRING, (hexchat_list_int(ph, xl, "id") + 1), wszMenuEntry);
                    }
                    else
                    {
                        AppendMenu(sTemp, (MF_CHECKED | MF_STRING), (hexchat_list_int(ph, xl, "id") + 1), wszMenuEntry);
                    }
                }

                free(network);
                free(server);
                free(nick);
            }
        }

        hexchat_list_free(ph, xl);
    }

    return sTemp;
}
Exemple #30
0
static int
print_version (char *word[], char *word_eol[], void *userdata)
{
	char *version;
	int prevbuf;
	int convbuf;

	if (!g_ascii_strcasecmp ("HELP", word[2]))
	{
		hexchat_printf (ph, upd_help);
		return HEXCHAT_EAT_HEXCHAT;
	}
	else if (!g_ascii_strcasecmp ("SET", word[2]))
	{
		if (!g_ascii_strcasecmp ("", word_eol[4]))
		{
			hexchat_printf (ph, "%s\tEnter a value!\n", name);
			return HEXCHAT_EAT_HEXCHAT;
		}
		if (!g_ascii_strcasecmp ("delay", word[3]))
		{
			convbuf = atoi (word[4]);	/* don't use word_eol, numbers must not contain spaces */

			if (convbuf > 0 && convbuf < INT_MAX)
			{
				prevbuf = hexchat_pluginpref_get_int (ph, "delay");
				hexchat_pluginpref_set_int (ph, "delay", convbuf);
				hexchat_printf (ph, "%s\tUpdate check startup delay is set to %d seconds (from %d).\n", name, convbuf, prevbuf);
			}
			else
			{
				hexchat_printf (ph, "%s\tInvalid input!\n", name);
			}
		}
		else if (!g_ascii_strcasecmp ("freq", word[3]))
		{
			convbuf = atoi (word[4]);	/* don't use word_eol, numbers must not contain spaces */

			if (convbuf > 0 && convbuf < INT_MAX)
			{
				prevbuf = hexchat_pluginpref_get_int (ph, "freq");
				hexchat_pluginpref_set_int (ph, "freq", convbuf);
				hexchat_printf (ph, "%s\tUpdate check frequency is set to %d minutes (from %d).\n", name, convbuf, prevbuf);
			}
			else
			{
				hexchat_printf (ph, "%s\tInvalid input!\n", name);
			}
		}
		else
		{
			hexchat_printf (ph, "%s\tInvalid variable name! Use 'delay' or 'freq'!\n", name);
			return HEXCHAT_EAT_HEXCHAT;
		}

		return HEXCHAT_EAT_HEXCHAT;
	}
	else if (!g_ascii_strcasecmp ("", word[2]))
	{
		version = check_version ();

		if (strcmp (version, hexchat_get_info (ph, "version")) == 0)
		{
			hexchat_printf (ph, "%s\tYou have the latest version of HexChat installed!\n", name);
		}
		else if (strcmp (version, "Unknown") == 0)
		{
			hexchat_printf (ph, "%s\tUnable to check for HexChat updates!\n", name);
		}
		else
		{
#ifdef _WIN64 /* use this approach, the wProcessorArchitecture method always returns 0 (=x86) for some reason */
			hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\nhttps://github.com/downloads/hexchat/hexchat/HexChat%%20%s%%20x64.exe\n", name, version);
#else
			hexchat_printf (ph, "%s\tA HexChat update is available! You can download it from here:\nhttps://github.com/downloads/hexchat/hexchat/HexChat%%20%s%%20x86.exe\n", name, version);
#endif
		}
		return HEXCHAT_EAT_HEXCHAT;
	}
	else
	{
		hexchat_printf (ph, upd_help);
		return HEXCHAT_EAT_HEXCHAT;
	}
}