Esempio n. 1
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;
}
Esempio n. 2
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);
    }
}
Esempio 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;
}
Esempio n. 4
0
File: lua.c Progetto: Cynede/hexchat
static int api_iterate_closure(lua_State *L)
{
	hexchat_list *list = *(hexchat_list **)luaL_checkudata(L, lua_upvalueindex(1), "list");
	if(hexchat_list_next(ph, list))
	{
		lua_pushvalue(L, lua_upvalueindex(1));
		return 1;
	}
	else
		return 0;
}
Esempio n. 5
0
File: perl.c Progetto: Farow/hexchat
static
XS (XS_Xchat_get_list)
{
	SV *name;
	hexchat_list *list;
	const char *const *fields;
	int count = 0;					  /* return value for scalar context */
	dXSARGS;

	if (items != 1) {
		hexchat_print (ph, "Usage: Xchat::get_list(name)");
	} else {
		SP -= items;				  /*remove the argument list from the stack */

		name = ST (0);

		list = hexchat_list_get (ph, SvPV_nolen (name));

		if (list == NULL) {
			XSRETURN_EMPTY;
		}

		if (GIMME_V == G_SCALAR) {
			while (hexchat_list_next (ph, list)) {
				count++;
			}
			hexchat_list_free (ph, list);
			XSRETURN_IV ((IV) count);
		}

		fields = hexchat_list_fields (ph, SvPV_nolen (name));
		while (hexchat_list_next (ph, list)) {
			XPUSHs (list_item_to_sv (list, fields));
		}
		hexchat_list_free (ph, list);

		PUTBACK;
		return;
	}
}
Esempio 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;
}