Пример #1
0
static const char *json_default_name(void)
{
    char *cache;
    char *idstr = get_cpu_str();
    char *res = NULL;
    char *home = NULL;
    char *emap;

    emap = getenv("EVENTMAP");
    if (emap) {
        if (access(emap, R_OK) == 0)
            return emap;
        idstr = malloc(strlen(emap) + strlen("-core") + 1);
        if (!idstr)
            exit(ENOMEM);
        sprintf(idstr, "%s-core", emap);
    }

    cache = getenv("XDG_CACHE_HOME");
    if (!cache) {
        home = getenv("HOME");
        if (!home || asprintf(&cache, "%s/.cache", home) < 0)
            goto out;
    }
    if (cache && idstr)
        asprintf(&res, "%s/pmu-events/%s.json",
                 cache,
                 idstr);
    if (home)
        free(cache);
out:
    free(idstr);
    return res;
}
Пример #2
0
void
menu_about (GtkWidget * wid, gpointer sess)
{
	char buf[512];
	const gchar *author[] = { "Peter Zelezny <*****@*****.**>", 0 };

	snprintf (buf, sizeof (buf),
				 _("An IRC Client for UNIX.\n\n"
				 "This binary was compiled on "__DATE__"\n"
				 "Using GTK %d.%d.%d X %d\n"
				 "Running on %s"),
				 gtk_major_version, gtk_minor_version, gtk_micro_version,
#ifdef USE_XLIB
				VendorRelease (GDK_DISPLAY ()), get_cpu_str());
#else
				666, get_cpu_str());
#endif

	gtk_widget_show (gnome_about_new ("X-Chat", VERSION,
							"(C) 1998-2001 Peter Zelezny", author, buf, 0));
}
Пример #3
0
void
fe_new_window (struct session *sess, int focus)
{
	char buf[512];

	sess->gui = malloc (4);
	current_sess = sess;

	if (!sess->server->front_session)
		sess->server->front_session = sess;
	if (!sess->server->server_session)
		sess->server->server_session = sess;
	if (!current_tab || focus)
		current_tab = sess;

	if (done_intro)
		return;
	done_intro = 1;

	snprintf (buf, sizeof (buf),
				"\n"
				" \017XChat-Text \00310"PACKAGE_VERSION"\n"
				" \017Running on \00310%s \017glib \00310%d.%d.%d\n"
				" \017This binary compiled \00310"__DATE__"\017\n",
				get_cpu_str(),
				glib_major_version, glib_minor_version, glib_micro_version);
	fe_print_text (sess, buf, 0);

	fe_print_text (sess, "\n\nCompiled in Features\0032:\017 "
#ifdef USE_PLUGIN
	"Plugin "
#endif
#ifdef ENABLE_NLS
	"NLS "
#endif
#ifdef USE_OPENSSL
	"OpenSSL "
#endif
#ifdef USE_IPV6
	"IPv6"
#endif
	"\n\n", 0);
	fflush (stdout);
	fflush (stdin);
}
Пример #4
0
static const char *json_default_name(void)
{
	char *cache = getenv("XDG_CACHE_HOME");
	char *idstr = get_cpu_str();
	char *res = NULL;
	char *home = NULL;

	if (!cache) {
		home = getenv("HOME");
		if (!home || asprintf(&cache, "%s/.cache", home) < 0)
			goto out;
	}
	if (cache && idstr)
		asprintf(&res, "%s/pmu-events/%s.json",
			     cache,
			     idstr);
	if (home)
		free(cache);
out:
	free(idstr);
	return res;
}
Пример #5
0
void
handle_ctcp (struct session *sess, char *outbuf, char *to, char *nick,
				 char *msg, char *word[], char *word_eol[])
{
	char *po;
	session *chansess;

	if (!strncasecmp (msg, "VERSION", 7) && !prefs.hidever)
	{
		sprintf (outbuf, "NOTICE %s :\001VERSION xchat "VERSION" %s (PicoGUI)\001\r\n",
					nick, get_cpu_str ());
		tcp_send (sess->server, outbuf);
	}

	if (!ctcp_check (sess, outbuf, nick, word, word_eol, word[4] + 2))
	{
		if (!strncasecmp (msg, "ACTION", 6))
		{
			po = strchr (msg + 7, '\001');
			if (po)
				po[0] = 0;
			channel_action (sess, outbuf, to, nick, msg + 7, FALSE);
			return;
		}
		if (!strncasecmp (msg, "DCC", 3))
		{
			handle_dcc (sess, outbuf, nick, word, word_eol);
			return;
		}
		if (!strncasecmp (msg, "SOUND", 5))
		{
			po = strchr (word[5], '\001');
			if (po)
				po[0] = 0;
			EMIT_SIGNAL (XP_TE_CTCPSND, sess->server->front_session, word[5],
							 nick, NULL, NULL, 0);
			sprintf (outbuf, "%s/%s", prefs.sounddir, word[5]);
			if (strchr (word[5], '/') == 0 && access (outbuf, R_OK) == 0)
			{
				sprintf (outbuf, "%s %s/%s", prefs.soundcmd, prefs.sounddir,
							word[5]);
				xchat_exec (outbuf);
			}
			return;
		}
	}

	po = strchr (msg, '\001');
	if (po)
		po[0] = 0;
	if (!is_channel (sess->server, to))
	{
		EMIT_SIGNAL (XP_TE_CTCPGEN, sess->server->front_session, msg, nick,
						 NULL, NULL, 0);
	} else
	{
		chansess = find_session_from_channel (to, sess->server);
		if (chansess)
		{
			EMIT_SIGNAL (XP_TE_CTCPGENC, chansess, msg, nick, to, NULL, 0);
			return;
		}
		EMIT_SIGNAL (XP_TE_CTCPGENC, sess->server->front_session, msg, nick, to,
						 NULL, 0);
	}
}
Пример #6
0
void
ctcp_handle (session *sess, char *to, char *nick,
				 char *msg, char *word[], char *word_eol[], int id)
{
	char *po;
	session *chansess;
	server *serv = sess->server;
	char outbuf[1024];

	/* consider DCC to be different from other CTCPs */
	if (!strncasecmp (msg, "DCC", 3))
	{
		/* but still let CTCP replies override it */
		if (!ctcp_check (sess, nick, word, word_eol, word[4] + 2))
		{
			if (!ignore_check (word[1], IG_DCC))
				handle_dcc (sess, nick, word, word_eol);
		}
		return;
	}

	/* consider ACTION to be different from other CTCPs. Check
      ignore as if it was a PRIV/CHAN. */
	if (!strncasecmp (msg, "ACTION ", 7))
	{
		if (is_channel (serv, to))
		{
			/* treat a channel action as a CHAN */
			if (ignore_check (word[1], IG_CHAN))
				return;
		} else
		{
			/* treat a private action as a PRIV */
			if (ignore_check (word[1], IG_PRIV))
				return;
		}

		/* but still let CTCP replies override it */
		if (ctcp_check (sess, nick, word, word_eol, word[4] + 2))
			goto generic;

		inbound_action (sess, to, nick, msg + 7, FALSE, id);
		return;
	}

	if (ignore_check (word[1], IG_CTCP))
		return;

	if (!strcasecmp (msg, "VERSION") && !prefs.hidever)
	{
#ifdef FE_AQUA
		snprintf (outbuf, sizeof (outbuf), "VERSION X-Chat Aqua %s (xchat "PACKAGE_VERSION") %s",
                  prefs.xchat_aqua_version, get_cpu_str ());
#else
		snprintf (outbuf, sizeof (outbuf), "VERSION xchat "PACKAGE_VERSION" %s",
					 get_cpu_str ());
#endif
		serv->p_nctcp (serv, nick, outbuf);
	}

	if (!ctcp_check (sess, nick, word, word_eol, word[4] + 2))
	{
		if (!strncasecmp (msg, "SOUND", 5))
		{
			po = strchr (word[5], '\001');
			if (po)
				po[0] = 0;

			if (is_channel (sess->server, to))
			{
				chansess = find_channel (sess->server, to);
				if (!chansess)
					chansess = sess;

				EMIT_SIGNAL (XP_TE_CTCPSNDC, chansess, word[5],
								 nick, to, NULL, 0);
			} else
			{
				EMIT_SIGNAL (XP_TE_CTCPSND, sess->server->front_session, word[5],
								 nick, NULL, NULL, 0);
			}

			/* don't let IRCers specify path */
#ifdef WIN32
			if (strchr (word[5], '/') == NULL && strchr (word[5], '\\') == NULL)
#else
			if (strchr (word[5], '/') == NULL)
#endif
				sound_play (word[5], TRUE);
			return;
		}
	}

generic:
	po = strchr (msg, '\001');
	if (po)
		po[0] = 0;

	if (!is_channel (sess->server, to))
	{
		EMIT_SIGNAL (XP_TE_CTCPGEN, sess->server->front_session, msg, nick,
						 NULL, NULL, 0);
	} else
	{
		chansess = find_channel (sess->server, to);
		if (!chansess)
			chansess = sess;
		EMIT_SIGNAL (XP_TE_CTCPGENC, chansess, msg, nick, to, NULL, 0);
	}
}
Пример #7
0
void
fe_new_window (struct session *sess)
{
    char buf[512];

    sess->gui = malloc (4);

    if (!sess->server->front_session)
        sess->server->front_session = sess;
    if (!current_tab)
        current_tab = sess;

    if (done_intro)
        return;
    done_intro = 1;

    snprintf (buf, sizeof (buf),
              "\n"
              " \017xchat \00310"VERSION"\n"
              " \017Running on \00310%s \017glib \00310%d.%d.%d\n"
              " \017This binary compiled \00310"__DATE__"\017\n",
              get_cpu_str(),
              glib_major_version, glib_minor_version, glib_micro_version);
    fe_print_text (sess, buf);

    strcpy (buf, "\n\nCompiled in Features\0032:\017 ");
#ifdef USE_PERL
    strcat (buf, "Perl ");
#endif
#ifdef USE_PYTHON
    strcat (buf, "Python ");
#endif
#ifdef USE_PLUGIN
    strcat (buf, "Plugin ");
#endif
#ifdef ENABLE_NLS
    strcat (buf, "NLS ");
#endif
#ifdef USE_TRANS
    strcat (buf, "Trans ");
#endif
#ifdef USE_HEBREW
    strcat (buf, "Hebrew ");
#endif
#ifdef USE_OPENSSL
    strcat (buf, "OpenSSL ");
#endif
#ifdef SOCKS
    strcat (buf, "Socks5 ");
#endif
#ifdef HAVE_ICONV
    strcat (buf, "JCode ");
#endif
#ifdef USE_IPV6
    strcat (buf, "IPv6 ");
#endif
    strcat (buf, "\n\n");
    fe_print_text (sess, buf);
    fflush (stdout);
    fflush (stdin);
}
Пример #8
0
void
menu_about (GtkWidget * wid, gpointer sess)
{
	GtkWidget *vbox, *label, *hbox;
	GtkStyle *about_style;
	GtkStyle *head_style;
	char buf[512];

	if (about)
	{
		gdk_window_show (about->window);
		return;
	}
	head_style = gtk_style_new ();
#ifndef WIN32
	gdk_font_unref (head_style->font);
	head_style->font = gdk_font_load ("-*-times-bold-i-*-*-*-240-*");
	if (!head_style->font)
		head_style->font = gdk_font_load ("fixed");
#endif
	head_style->fg[GTK_STATE_NORMAL] = colors[2];

	about_style = gtk_style_new ();
	gdk_font_unref (about_style->font);
	about_style->font = gdk_font_load ("fixed");

	about = gtk_window_new (GTK_WINDOW_DIALOG);
	gtk_window_position (GTK_WINDOW (about), GTK_WIN_POS_CENTER);
	gtk_window_set_title (GTK_WINDOW (about), _("About X-Chat"));
	gtk_container_set_border_width (GTK_CONTAINER (about), 6);
	gtk_signal_connect (GTK_OBJECT (about), "destroy",
							  GTK_SIGNAL_FUNC (about_close), 0);
	gtk_widget_realize (about);

	vbox = gtk_vbox_new (0, 2);
	gtk_container_add (GTK_CONTAINER (about), vbox);
	/*gtk_widget_show (vbox);*/

	label = gtk_entry_new ();
	gtk_entry_set_editable (GTK_ENTRY (label), FALSE);
	gtk_entry_set_text (GTK_ENTRY (label), "X-Chat " VERSION);
	gtk_widget_set_style (label, head_style);
	gtk_style_unref (head_style);
	gtk_container_add (GTK_CONTAINER (vbox), label);

	snprintf (buf, sizeof (buf),
				 _("(C) 1998-2001 Peter Zelezny <*****@*****.**>\n\n"
				 "An IRC Client for UNIX.\n\n"
				 "This binary was compiled on "__DATE__"\n"
				 "Using GTK %d.%d.%d X %d\n"
				 "Running on %s\n"),
				 gtk_major_version, gtk_minor_version, gtk_micro_version,
#ifdef USE_XLIB
				VendorRelease (GDK_DISPLAY ()), get_cpu_str());
#else
				666, get_cpu_str());
#endif

	label = gtk_label_new (buf);
	gtk_container_add (GTK_CONTAINER (vbox), label);
	gtk_widget_set_style (label, about_style);
	gtk_style_unref (about_style);
	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);

	wid = gtk_hseparator_new ();
	gtk_container_add (GTK_CONTAINER (vbox), wid);

	hbox = gtk_hbox_new (0, 2);
	gtk_container_add (GTK_CONTAINER (vbox), hbox);

	wid = gtk_button_new_with_label ("  Continue  ");
	gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
	GTK_WIDGET_SET_FLAGS (GTK_WIDGET (wid), GTK_CAN_DEFAULT);
	gtk_box_pack_end (GTK_BOX (hbox), wid, 0, 0, 0);
	gtk_widget_grab_default (wid);
	gtk_signal_connect (GTK_OBJECT (wid), "clicked",
							  GTK_SIGNAL_FUNC (gtkutil_destroy), about);

	gtk_widget_show_all (about);
}