Ejemplo n.º 1
0
void hexchat_globally_back()
{
    std::vector<int> xs;
    std::vector<int>::iterator xsi;
    hexchat_list *xl = hexchat_list_get(ph, "channels");

    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)))
            {
                xs.push_back(hexchat_list_int(ph, xl, "id"));
                hexchat_set_context(ph, (hexchat_context *)hexchat_list_str(ph, xl, "context"));
                hexchat_back();
            }
        }

        hexchat_list_free(ph, xl);
    }
}
Ejemplo n.º 2
0
struct _hexchat_context *hexchat_find_server(int find_id)
{
    hexchat_context *xc;
    hexchat_list *xl = hexchat_list_get(ph, "channels");
    int id;

    if(!xl)
        return NULL;

    while(hexchat_list_next(ph, xl))
    {
        id = hexchat_list_int(ph, xl, "id");

        if(id == -1)
        {
            return NULL;
        }
        else if(id == find_id)
        {
            xc = (hexchat_context *)hexchat_list_str(ph, xl, "context");

            hexchat_list_free(ph, xl);

            return xc;
        }
    }

    hexchat_list_free(ph, xl);

    return NULL;
}
Ejemplo n.º 3
0
static int
get_current_context_type (void)
{
    int type = 0;
    hexchat_list *list;
    hexchat_context *cur_ctx;

    list = hexchat_list_get (ph, "channels");
    if (!list)
        return 0;

    cur_ctx = hexchat_get_context (ph);

    while (hexchat_list_next (ph, list))
    {
        if ((hexchat_context*)hexchat_list_str (ph, list, "context") == cur_ctx)
        {
            type = hexchat_list_int (ph, list, "type");
            break;
        }
    }

    hexchat_list_free (ph, list);
    return type;
}
Ejemplo n.º 4
0
Archivo: perl.c Proyecto: Farow/hexchat
static SV *
list_item_to_sv ( hexchat_list *list, const char *const *fields )
{
	HV *hash = newHV();
	SV *field_value;
	const char *field;
	int field_index = 0;
	const char *field_name;
	int name_len;

	while (fields[field_index] != NULL) {
		field_name = fields[field_index] + 1;
		name_len = strlen (field_name);

		switch (fields[field_index][0]) {
		case 's':
			field = hexchat_list_str (ph, list, field_name);
			if (field != NULL) {
				field_value = newSVpvn (field, strlen (field));
			} else {
				field_value = &PL_sv_undef;
			}
			break;
		case 'p':
			field_value = newSViv (PTR2IV (hexchat_list_str (ph, list,
																	 field_name)));
			break;
		case 'i':
			field_value = newSVuv (hexchat_list_int (ph, list, field_name));
			break;
		case 't':
			field_value = newSVnv (hexchat_list_time (ph, list, field_name));
			break;
		default:
			field_value = &PL_sv_undef;
		}
		(void)hv_store (hash, field_name, name_len, field_value, 0);
		field_index++;
	}
	return sv_2mortal (newRV_noinc ((SV *) hash));
}
Ejemplo n.º 5
0
Archivo: lua.c Proyecto: Cynede/hexchat
static inline int list_marshal(lua_State *L, const char *key, hexchat_list *list)
{
	char const *str = hexchat_list_str(ph, list, key);
	int number;
	if(str)
	{
		if(!strcmp(key, "context"))
		{
			hexchat_context **u = lua_newuserdata(L, sizeof(hexchat_context *));
			*u = (hexchat_context *)str;
			luaL_newmetatable(L, "context");
			lua_setmetatable(L, -2);
			return 1;
		}
		lua_pushstring(L, str);
		return 1;
	}
	number = hexchat_list_int(ph, list, key);
	if(number != -1)
	{
		lua_pushinteger(L, number);
		return 1;
	}
	if (list != NULL)
	{
		time_t tm = hexchat_list_time(ph, list, key);
		if(tm != -1)
		{
			lua_pushinteger(L, tm);
			return 1;
		}
	}

	lua_pushnil(L);
	return 1;
}
Ejemplo n.º 6
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;
}