X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=clients%2Fgtk2%2Fhublist-old.c;fp=clients%2Fgtk2%2Fhublist-old.c;h=83da7fcf2a8d3629cf7fb51fa941dffd648f83a9;hb=0d04e87edb98d0a426db309038e9f288270abfbb;hp=0000000000000000000000000000000000000000;hpb=b1099f1fdf1bd3885a73fc6c087dfe816aa63e5c;p=doldaconnect.git diff --git a/clients/gtk2/hublist-old.c b/clients/gtk2/hublist-old.c new file mode 100644 index 0000000..83da7fc --- /dev/null +++ b/clients/gtk2/hublist-old.c @@ -0,0 +1,91 @@ +/* + * Dolda Connect - Modular multiuser Direct Connect-style client + * Copyright (C) 2007 Fredrik Tolf (fredrik@dolda2000.com) + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "dolcon.h" +#include "hublist.h" + +int pubhuboldhandler(int op, char *buf, size_t len) +{ + static GtkListStore *model = NULL; + int i; + char *p, *p2; + wchar_t *wbuf; + char *fields[4], *names[3]; + int cols[3]; + GtkTreeIter iter; + + switch(op) + { + case PHO_INIT: + model = gtk_list_store_new(4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT); + break; + case PHO_DATA: + p = buf; + while((p = memchr(p, '\n', len)) != NULL) + { + *(p++) = 0; + for(i = 0, p2 = buf; i < 4; i++) { + fields[i] = p2; + if((p2 = strchr(p2, '|')) == NULL) + break; + *(p2++) = 0; + } + if(i == 4) { + for(i = 0; i < 4; i++) { + if((wbuf = icsmbstowcs(fields[i], DCCHARSET, NULL)) == NULL) { + fields[i] = sstrdup(_("(Invalid character)")); + } else { + if((fields[i] = icwcstombs(wbuf, "UTF-8")) == NULL) + break; + } + } + if(i == 4) { + if(validhub(fields[0], fields[2], NULL)) { + gtk_list_store_append(model, &iter); + gtk_list_store_set(model, &iter, 0, fields[1], 1, fields[0], 2, fields[2], 3, atoi(fields[3]), -1); + } + } + for(i--; i >= 0; i--) + free(fields[i]); + } + } + return(p - buf); + break; + case PHO_EOF: + cols[0] = 3; names[0] = _("# users"); + cols[1] = 1; names[1] = _("Name"); + cols[2] = 2; names[2] = _("Description"); + setpubhubmodel(GTK_TREE_MODEL(model), 3, 3, cols, names); + break; + case PHO_FINI: + if(model != NULL) + g_object_unref(model); + model = NULL; + break; + } + return(0); +}