<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="HexChat"
processorArchitecture="*"
version="1.0.0.0"
type="win32"
/>
<description>HexChat IRC Client</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--This Id value indicates the application supports Windows 7 functionality-->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--This Id value indicates the application supports Windows 8 functionality-->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--This Id value indicates the application supports Windows 8.1 functionality-->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!--This Id value indicates the application supports Windows 10 functionality-->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
nt-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long *//* X-Tray
* Copyright (C) 1998, 2005 Peter Zelezny, Michael Hotaling <Mike.Hotaling@SinisterDevelopments.com>
*
* X-Tray is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* X-Tray is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with X-Tray; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <tchar.h>
#include "hexchat-plugin.h"
#include "hextray.h"
#include "resource.h"
#include "hexchat.h"
#include "utility.h"
// from util.c of xchat source code ( slightly modified to fit X-Tray Syntax )
char *xchat_strip_color (char *text)
{
int nc = 0;
int i = 0;
int col = 0;
int len = strlen(text);
char *new_str = (char *)malloc(len + 2);
while (len > 0)
{
if ((col && isdigit(*text) && (nc < 2)) || (col && isdigit(*(text+1)) && (nc < 3) && (*text == ',')))
{
nc++;
if(*text == ',')
{
nc = 0;
}
}
else
{
col = 0;
switch (*text)
{
case '\003': /*ATTR_COLOR: */
{
col = 1;
nc = 0;
}
break;
case '\007': /*ATTR_BEEP: */
case '\017': /*ATTR_RESET: */
case '\026': /*ATTR_REVERSE: */
case '\002': /*ATTR_BOLD: */
case '\037': /*ATTR_UNDERLINE: */
break;
default:
{
new_str[i] = *text;
i++;
}
break;
}
}
text++;
len--;
}
new_str[i] = 0;
return new_str;
}
void check_special_chars (char *cmd)
{
int occur = 0;
int len = strlen (cmd);
int i = 0, j = 0;
char *buf;
if (!len)
return;
buf = (char *)malloc (len + 1);
if (buf)
{
while (cmd[j])
{
switch (cmd[j])
{
case '%':
{
occur++;
switch (cmd[j + 1])
{
case 'R':
buf[i] = '\026';
break;
case 'U':
buf[i] = '\037';
break;
case 'B':
buf[i] = '\002';
break;
case 'C':
buf[i] = '\003';
break;
case 'O':
buf[i] = '\017';
break;
case '%':
buf[i] = '%';
break;
default:
buf[i] = '%';
j--;
break;
}
j++;
}
break;
default:
{
buf[i] = cmd[j];
}
break;
}
j++;
i++;
}
buf[i] = 0;
if (occur)
strcpy (cmd, buf);
free (buf);
}
}
void xchat_globally_away(TCHAR *tszAway)
{
char szTemp[512];
char szAway[512];
ConvertString(tszAway, szAway, 512);
_snprintf(szTemp, 512, "ALLSERV AWAY %s\0", szAway);
check_special_chars(szTemp);
xchat_exec(szTemp);
}
void xchat_away(TCHAR *tszAway)
{
char szTemp[512];
char szAway[512];
ConvertString(tszAway, szAway, 512);
_snprintf(szTemp, 512, szAway);
check_special_chars(szTemp);
xchat_commandf(ph, "AWAY %s\0", szTemp);
}
void xchat_globally_back()
{
std::vector<int> xs;
std::vector<int>::iterator xsi;
xchat_list *xl = xchat_list_get(ph, "channels");
if(xl)
{
while(xchat_list_next(ph, xl))
{
xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id"));
if((xsi == xs.end()) &&
((strlen(xchat_list_str(ph, xl, "server")) > 0) ||
(strlen(xchat_list_str(ph, xl, "channel")) > 0)))
{
xs.push_back(xchat_list_int(ph, xl, "id"));
xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context"));
xchat_back();
}
}
xchat_list_free(ph, xl);
}
}
void xchat_back()
{
if(xchat_get_info(ph, "away"))
{
xchat_command(ph, "BACK");
}
}
HMENU setServerMenu()
{
HMENU sTemp = CreateMenu();
TCHAR wszServer[128];
TCHAR wszNick[128];
TCHAR wszMenuEntry[256];
std::vector<int> xs;
std::vector<int>::iterator xsi;
xchat_list *xl = xchat_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(xchat_list_next(ph, xl))
{
xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id"));
if( (xsi == xs.end()) &&
((strlen(xchat_list_str(ph, xl, "server")) > 0) ||
(strlen(xchat_list_str(ph, xl, "channel")) > 0)))
{
xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context"));
xs.push_back(xchat_list_int(ph, xl, "id"));
char *network = _strdup(xchat_list_str(ph, xl, "network"));
char *server = _strdup(xchat_list_str(ph, xl, "server"));
char *nick = _strdup(xchat_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(!xchat_get_info(ph, "away"))
{
AppendMenu(sTemp, MF_STRING, (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry);
}
else
{
AppendMenu(sTemp, (MF_CHECKED | MF_STRING), (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry);
}
}
free(network);
free(server);
free(nick);
}
}
xchat_list_free(ph, xl);
}
return sTemp;
}
struct _xchat_context *xchat_find_server(int find_id)
{
xchat_context *xc;
xchat_list *xl = xchat_list_get(ph, "channels");
int id;
if(!xl)
return NULL;
while(xchat_list_next(ph, xl))
{
id = xchat_list_int(ph, xl, "id");
if(id == -1)
{
return NULL;
}
else if(id == find_id)
{
xc = (xchat_context *)xchat_list_str(ph, xl, "context");
xchat_list_free(ph, xl);
return xc;
}
}
xchat_list_free(ph, xl);
return NULL;
}
void xchat_exec(char *command)
{
xchat_set_context(ph, xchat_find_context(ph, NULL, NULL));
xchat_command(ph, command);
}