Exemple #1
0
static void
xdcc_get (char *nick, char *host, char *arg)
{
    int num;
    GSList *list;
    fileoffer *offer;

    if (arg[0] == '#')
        arg++;

    num = atoi (arg);
    list = g_slist_nth (file_list, num - 1);
    if (!list)
      {
          xchat_commandf (ph, "quote NOTICE %s :No such file number #%d!",
                          nick, num);
          return;
      }

    if (num_open_dccs () >= xdcc_slots)
      {
          xchat_commandf (ph,
                          "quote NOTICE %s :All slots full. Try again later.",
                          nick);
          return;
      }

    offer = (fileoffer *) list->data;
    offer->downloads++;
    xchat_commandf (ph, "quote NOTICE %s :Sending offer #%d %s", nick, num,
                    offer->file);
    xchat_commandf (ph, "dcc send %s %s", nick, offer->fullpath);
}
Exemple #2
0
static void
xdcc_remote (char *from, char *msg)
{
    char *ex, *nick, *host;

    ex = strchr (from, '!');
    if (!ex)
        return;
    ex[0] = 0;
    nick = from;
    host = ex + 1;

    if (xdcc_on == 0)
      {
          xchat_commandf (ph, "notice %s XDCC is turned OFF!", from);
          return;
      }

    if (strncasecmp (msg, "LIST", 4) == 0)
        xdcc_list (nick, host, msg + 4, "quote notice");
    else if (strncasecmp (msg, "GET ", 4) == 0)
        xdcc_get (nick, host, msg + 4);
    else
        xchat_commandf (ph, "notice %s Unknown XDCC command!", from);
}
Exemple #3
0
static int
dccoffer_cb (char *word[], void *userdata)
{
	int result;
	struct stat64 buffer;									/* buffer for storing file info */
	char sum[65];											/* buffer for checksum */

	result = stat64 (word[3], &buffer);
	if (result == 0)										/* stat returns 0 on success */
	{
		if (buffer.st_size <= (unsigned long long) get_limit () * 1048576)
		{
			sha256_file (word[3], sum);						/* word[3] is the full filename */
			xchat_commandf (ph, "quote PRIVMSG %s :SHA-256 checksum for %s (remote): %s", word[2], word[1], sum);
		}
		else
		{
			xchat_set_context (ph, xchat_find_context (ph, NULL, word[3]));
			xchat_printf (ph, "quote PRIVMSG %s :SHA-256 checksum for %s (remote): (size limit reached, no checksum calculated)", word[2], word[1]);
		}
	}
	else
	{
		xchat_printf (ph, "File access error!\n");
	}

	return XCHAT_EAT_NONE;
}
Exemple #4
0
static int
connected_cb (char *word[], gpointer data)
{
	GList *chans, *chan;
	const char *server;
	xchat_context *context;

	if (channels == NULL)
		return XCHAT_EAT_NONE;

	server = xchat_get_info (ph, "server");

	context = g_hash_table_lookup (networks, server);
	if (context) {
		xchat_set_context (ph, context);

		chans = g_hash_table_lookup (channels, server);
		for (chan = chans; chan; chan = g_list_next (chan)) {
			xchat_commandf (ph, "JOIN %s", chan->data);
		}

		g_list_foreach (chans, (GFunc) g_free, NULL);
		g_list_free (chans);

		/* Now that we've connected and re-joined, we can remove this server
		 * from the list */
		g_hash_table_remove (networks, server);
		g_hash_table_remove (channels, server);
	}

	return XCHAT_EAT_NONE;
}
Exemple #5
0
static int
connect_cb (char *word[], void *userdata)
{
	if (get_info ())
	{
		xchat_printf (ph, "%s\tSASL enabled\n", name);
		xchat_commandf (ph, "QUOTE CAP REQ :sasl");
	}

	return XCHAT_EAT_NONE;
}
Exemple #6
0
static int
authend_cb (char *word[], char *word_eol[], void *userdata)
{
	if (get_info ())
	{
		/* omit cryptic server message parts */
		xchat_printf (ph, "%s\t%s\n", name, ++word_eol[4]);
		xchat_commandf (ph, "QUOTE CAP END");
	}

	return XCHAT_EAT_ALL;
}
Exemple #7
0
static int
cap_cb (char *word[], char *word_eol[], void *userdata)
{
	if (get_info ())
	{
		/* FIXME test sasl cap */
		/* this is visible in the rawlog in case someone needs it, otherwise it's just noise */
		/* xchat_printf (ph, "%s\t%s\n", name, word_eol[1]); */
		xchat_commandf (ph, "QUOTE AUTHENTICATE PLAIN");
	}

	return XCHAT_EAT_ALL;
}
Exemple #8
0
static void
xdcc_list (char *nick, char *host, char *arg, char *cmd)
{
    GSList *list;
    int i = 0;
    fileoffer *offer;

    xchat_commandf (ph, "%s %s :XDCC List:", cmd, nick);
    list = file_list;
    while (list)
      {
          i++;
          offer = (fileoffer *) list->data;
          xchat_commandf (ph, "%s %s :[#%d] %s - %s [%d dl]", cmd,
                          nick, i, offer->file, offer->desc,
                          offer->downloads);
          list = list->next;
      }

    if (i == 0)
        xchat_commandf (ph, "%s %s :- list empty.", cmd, nick);
    else
        xchat_commandf (ph, "%s %s :%d files listed.", cmd, nick, i);
}
Exemple #9
0
static int
server_cb (char *word[], char *word_eol[], void *userdata)
{
	size_t len;
	char* buf;
	char* enc;
	sasl_info* p;

	if (strcmp ("AUTHENTICATE", word[1]) == 0 && strcmp ("+", word[2]) == 0)
	{
		p = get_info ();

		if (!p)
		{
			return XCHAT_EAT_NONE;
		}

		xchat_printf (ph, "%s\tAuthenticating as %s\n", name, p->login);

		len = strlen (p->login) * 2 + 2 + strlen (p->password);
		buf = (char*) malloc (len + 1);
		strcpy (buf, p->login);
		strcpy (buf + strlen (p->login) + 1, p->login);
		strcpy (buf + strlen (p->login) * 2 + 2, p->password);
		enc = g_base64_encode ((unsigned char*) buf, len);

		/* xchat_printf (ph, "AUTHENTICATE %s\}", enc); */
		xchat_commandf (ph, "QUOTE AUTHENTICATE %s", enc);

		free (enc);
		free (buf);

		return XCHAT_EAT_ALL;
	}

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

	return XCHAT_EAT_XCHAT;
}
Exemple #11
0
static void
connect_to_network (gchar *key, xchat_context *context, gpointer data)
{
	xchat_set_context (ph, context);
	xchat_commandf (ph, "SERVER %s", key);
}
Exemple #12
0
static int
winamp(char *word[], char *word_eol[], void *userdata)
{

char current_play[2048], *p;
char p_esc[2048];
char cur_esc[2048];
char truc[2048];
HWND hwndWinamp = FindWindow("Winamp v1.x",NULL);

    if (hwndWinamp)
	{
	    {
	        if (!stricmp("PAUSE", word[2]))
			{
			   if (SendMessage(hwndWinamp,WM_USER, 0, 104))
				{
			   	   SendMessage(hwndWinamp, WM_COMMAND, 40046, 0);
			
			       if (SendMessage(hwndWinamp, WM_USER, 0, 104) == PLAYING)
			   	       xchat_printf(ph, "Winamp: playing");
			       else
                       xchat_printf(ph, "Winamp: paused");
				}
            }
			else
		        if (!stricmp("STOP", word[2]))
			    {
			       SendMessage(hwndWinamp, WM_COMMAND, 40047, 0);
			       xchat_printf(ph, "Winamp: stopped");
			    }
			else
			    if (!stricmp("PLAY", word[2]))
			    {
			         SendMessage(hwndWinamp, WM_COMMAND, 40045, 0);
			         xchat_printf(ph, "Winamp: playing");
			    }
        	else

			    if (!stricmp("NEXT", word[2]))
			    {
			         SendMessage(hwndWinamp, WM_COMMAND, 40048, 0);
			         xchat_printf(ph, "Winamp: next playlist entry");
			    }
			else

                if (!stricmp("PREV", word[2]))
			    {
			         SendMessage(hwndWinamp, WM_COMMAND, 40044, 0);
			         xchat_printf(ph, "Winamp: previous playlist entry");
			    }
		    else

                if (!stricmp("START", word[2]))
			    {
			         SendMessage(hwndWinamp, WM_COMMAND, 40154, 0);
			         xchat_printf(ph, "Winamp: playlist start");
			    }

		    else

                if (!word_eol[2][0])
			    {
					GetWindowText(hwndWinamp, current_play, sizeof(current_play));

					if (strchr(current_play, '-'))
					{
	
					p = current_play + strlen(current_play) - 8;
					while (p >= current_play)
					{
						if (!strnicmp(p, "- Winamp", 8)) break;
							p--;
					}

					if (p >= current_play) p--;
	
					while (p >= current_play && *p == ' ') p--;
						*++p=0;
	
	
					p = strchr(current_play, '.') + 1;

 					song_strcpy(p_esc, p);
 					song_strcpy(cur_esc, current_play);
	
					if (p)
					{
						sprintf(truc, "me is now playing:%s", p_esc);
					}
					else
					{
						sprintf(truc, "me is now playing:%s", cur_esc);
					}
	
	   				xchat_commandf(ph, truc);
	
				}
				else xchat_print(ph, "Winamp: Nothing being played.");
			}
		    else
                xchat_printf(ph, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START]\n");
         }

	}
	else
	{
       xchat_print(ph, "Winamp not found.\n");
	}
	return XCHAT_EAT_ALL;
}