Merge branch 'dolcon-split'
authorFredrik Tolf <fredrik@dolda2000.com>
Sat, 21 Jul 2007 03:51:02 +0000 (05:51 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Sat, 21 Jul 2007 03:51:02 +0000 (05:51 +0200)
Conflicts:

po/sv.po

13 files changed:
.gitignore
clients/gtk2/Makefile.am
clients/gtk2/dolcon.c [moved from clients/gtk2/main.c with 84% similarity]
clients/gtk2/dolcon.h [new file with mode: 0644]
clients/gtk2/hublist-old.c [new file with mode: 0644]
clients/gtk2/hublist-xml.c [new file with mode: 0644]
clients/gtk2/hublist.c [new file with mode: 0644]
clients/gtk2/hublist.h [new file with mode: 0644]
common/makegdesc
config/util/Makefile.am
config/util/dolconf.c
po/POTFILES.in
po/sv.po

index b56d617..cb9c624 100644 (file)
@@ -6,6 +6,7 @@ Makefile.in
 .deps
 .libs
 *.gtk
+*.gtkh
 
 /m4
 /configure
index b79d524..50efcd7 100644 (file)
@@ -3,13 +3,17 @@ bin_PROGRAMS=dolcon
 app_DATA=dolcon.desktop
 endif
 
-dolcon_SOURCES=        main.c \
+dolcon_SOURCES=        dolcon.c \
+               hublist.c \
+               hublist.h \
+               hublist-xml.c \
+               hublist-old.c \
                progressbar.c \
                progressbar.h
 
 EXTRA_DIST=mainwnd.desc inpdialog.desc pref.desc reslist.desc dolcon.desktop
 
-BUILT_SOURCES=mainwnd.gtk inpdialog.gtk pref.gtk reslist.gtk
+BUILT_SOURCES= mainwnd.gtk inpdialog.gtk pref.gtk reslist.gtk
 
 main.c: mainwnd.gtk inpdialog.gtk pref.gtk reslist.gtk
 
@@ -20,7 +24,10 @@ dolcon_CPPFLAGS=@GTK2_CFLAGS@ @LIBXML_CFLAGS@ \
                -DLOCALEDIR=\"$(localedir)\"
 
 .desc.gtk: $(top_srcdir)/common/makegdesc
-       cpp $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $< | $(top_srcdir)/common/makegdesc >$@
+       target="$@"; \
+       basename="$${target%.gtk}"; \
+       cpp $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $< \
+        | $(top_srcdir)/common/makegdesc -h "$${basename}.gtkh" >$@
 
 mainwnd.desc: ../../config.h
 
similarity index 84%
rename from clients/gtk2/main.c
rename to clients/gtk2/dolcon.c
index 5b286f3..02a2423 100644 (file)
 #include <sys/time.h>
 #include <pwd.h>
 #include <locale.h>
-#include <libintl.h>
 #include <assert.h>
 
-/* "Programming with libxml2 is like the thrilling embrace of an
- * exotic strangler."
- *    --Me */
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "dolcon.h"
+#include "hublist.h"
 #include "progressbar.h"
 
 #define TRHISTSIZE 10
-#define PHO_INIT 0
-#define PHO_DATA 1
-#define PHO_EOF 2
-#define PHO_FINI 3
 
 struct trdata
 {
@@ -90,15 +81,11 @@ struct knownspeed
 
 GtkWidget *inpdialog;
 GtkListStore *fnmodel, *ulmodel, *dlmodel, *reslist;
-int (*pubhubhandler)(int, char *, size_t *) = NULL;
 GtkTreeStore *srchmodel;
 GtkTreeModelFilter *srchmodelfilter;
 GtkTextTagTable *chattags;
 int dcfd = -1, gdkread = -1, gdkwrite = -1;
-int pubhubfd = -1, pubhubtag = -1, filterpubhub = 0;
 int curchat = -1;
-regex_t pubhubfilter;
-pid_t pubhubproc = 0;
 char *pubhubaddr = NULL;
 char *connectas = NULL;
 char *dcserver = NULL;
@@ -110,59 +97,13 @@ struct srchsize *srchsizes = NULL;
 struct knownspeed *knownspeeds = NULL;
 int numsizes = 0, numspeeds = 0, ksqueryseq = -1, ksquerytag = -1, lsrestag = -1;
 
-gboolean initdeath(GtkWidget *, gpointer);
-void cb_main_connmenu_activate(GtkWidget *widget, gpointer data);
-void cb_main_dconnmenu_activate(GtkWidget *widget, gpointer data);
-void cb_main_prefmenu_activate(GtkWidget *widget, gpointer data);
-void cb_main_lsres_activate(GtkWidget *widget, gpointer data);
-void cb_main_sdmenu_activate(GtkWidget *widget, gpointer data);
-void cb_inpdialog_entry_activate(GtkWidget *widget, gpointer data);
-void cb_main_fnaddr_activate(GtkWidget *widget, gpointer data);
-void cb_main_pubhubfilter_activate(GtkWidget *widget, gpointer data);
-void cb_main_dcnctbtn_clicked(GtkWidget *widget, gpointer data);
-void cb_main_phublist_cchange(GtkWidget *widget, gpointer data);
-void cb_main_phublist_activate(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data);
-void cb_main_chatnodes_activate(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data);
-void cb_main_srchres_activate(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data);
-void cb_main_chatstr_activate(GtkWidget *widget, gpointer data);
-void cb_main_simplesrch_changed(GtkWidget *widget, gpointer data);
-void cb_main_realsrch_changed(GtkWidget *widget, gpointer data);
-void cb_main_srchbtn_clicked(GtkWidget *widget, gpointer data);
-void cb_main_srchcanbtn_clicked(GtkWidget *widget, gpointer data);
-gboolean cb_main_trlist_keypress(GtkWidget *widget, GdkEventKey *event, gpointer data);
-void cb_main_filternoslots_toggled(GtkToggleButton *widget, gpointer data);
-void cb_main_srhash_activate(GtkWidget *widget, gpointer data);
-void cb_main_srcopy_activate(GtkWidget *widget, gpointer data);
-void cb_main_trhash_activate(GtkWidget *widget, gpointer data);
-void cb_main_trcopy_activate(GtkWidget *widget, gpointer data);
-void cb_main_trreset_activate(GtkWidget *widget, gpointer data);
-void cb_main_trcancel_activate(GtkWidget *widget, gpointer data);
-gboolean cb_main_srpopup(GtkWidget *widget, GdkEventButton *event, gpointer data);
-gboolean cb_main_trpopup(GtkWidget *widget, GdkEventButton *event, gpointer data);
-void cb_reslist_reload_clicked(GtkWidget *widget, gpointer data);
-void cb_reslist_delete_clicked(GtkWidget *widget, gpointer data);
-void cb_reslist_search_clicked(GtkWidget *widget, gpointer data);
-void cb_reslist_list_cchange(GtkWidget *widget, gpointer data);
-void cb_reslist_list_activate(GtkWidget *widget, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data);
-gboolean cb_reslist_list_keypress(GtkWidget *widget, GdkEventKey *event, gpointer data);
 void dcfdcallback(gpointer data, gint source, GdkInputCondition condition);
 void srchstatupdate(void);
-void transnicebytefunc(GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
-void transnicebytefunc2(GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
-void transspeedinfo(GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
-void transerrorinfo(GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
-void percentagefunc(GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
-void hidezerofunc(GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
-void speedtimefunc(GtkTreeViewColumn *col, GtkCellRenderer *rend, GtkTreeModel *model, GtkTreeIter *iter, gpointer data);
-
-#define DCCHARSET "windows-1252"
 
-#define _(text) gettext(text)
-
-#include "mainwnd.gtk"
-#include "inpdialog.gtk"
-#include "pref.gtk"
-#include "reslist.gtk"
+#include "mainwnd.gtkh"
+#include "inpdialog.gtkh"
+#include "pref.gtkh"
+#include "reslist.gtkh"
 
 void updatewrite(void)
 {
@@ -696,12 +637,6 @@ char *inputbox(char *title, char *prompt, char *def, int echo)
 }
 
 int msgbox(int type, int buttons, char *format, ...)
-#if defined(__GNUC__)
-    __attribute__ ((format (printf, 3, 4)))
-#endif
-;
-
-int msgbox(int type, int buttons, char *format, ...)
 {
     GtkWidget *swnd;
     va_list args;
@@ -1485,371 +1420,29 @@ void setpubhubmodel(GtkTreeModel *model, int sortcol, int numcols, int *cols, ch
     g_object_unref(sortmodel);
 }
 
-xmlNodePtr findnode(xmlNodePtr node, char *name)
-{
-    for(; node != NULL; node = node->next)
-    {
-       if(!strcmp((char *)node->name, name))
-           break;
-    }
-    return(node);
-}
-
-int pubhubxmlhandler(int op, char *buf, size_t *len)
-{
-    static xmlParserCtxtPtr ctxt = NULL;
-    int i, match;
-    xmlNodePtr dr, r, cr, c, n;
-    int numcols, *cols, sortcol;
-    GType type, *types;
-    char **names, *name, *stype, *attr;
-    GtkListStore *model;
-    GtkTreeIter iter;
-    
-    numcols = 0;
-    names = NULL;
-    types = NULL;
-    switch(op)
-    {
-    case PHO_INIT:
-       break;
-    case PHO_DATA:
-       if(ctxt == NULL) {
-           ctxt = xmlCreatePushParserCtxt(NULL, NULL, buf, *len, pubhubaddr);
-           *len = 0;
-           if(ctxt == NULL)
-               return(1);
-       } else {
-           xmlParseChunk(ctxt, buf, *len, 0);
-           *len = 0;
-       }
-       break;
-    case PHO_EOF:
-       if(ctxt == NULL)
-       {
-           msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("A hub list could not be read from %s"), pubhubaddr);
-           break;
-       }
-       xmlParseChunk(ctxt, NULL, 0, 1);
-       if(!ctxt->wellFormed)
-       {
-           msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("The hub list at %s is not valid"), pubhubaddr);
-           break;
-       }
-       dr = r = cr = NULL;
-       dr = xmlDocGetRootElement(ctxt->myDoc);
-       if(dr != NULL)
-           r = findnode(dr->children, "Hubs");
-       if(r != NULL)
-           cr = findnode(r->children, "Columns");
-       if(cr == NULL)
-       {
-           msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The hub list at %s cannot be understood"), pubhubaddr);
-           break;
-       }
-       for(c = findnode(cr->children, "Column"); c != NULL; c = findnode(c->next, "Column"))
-       {
-           name = (char *)xmlGetProp(c, (xmlChar *)"Name");
-           stype = (char *)xmlGetProp(c, (xmlChar *)"Type");
-           type = G_TYPE_INVALID;
-           if(stype != NULL)
-           {
-               if(!strcmp(stype, "string"))
-                   type = G_TYPE_STRING;
-               else if(!strcmp(stype, "int"))
-                   type = G_TYPE_INT;
-               else if(!strcmp(stype, "bytes"))
-                   type = G_TYPE_INT64;
-           }
-           if((name != NULL) && (type != G_TYPE_INVALID))
-           {
-               names = srealloc(names, (numcols + 1) * sizeof(*names));
-               types = srealloc(types, (numcols + 1) * sizeof(*names));
-               names[numcols] = sstrdup(name);
-               types[numcols] = type;
-               numcols++;
-           }
-           if(name != NULL)
-               xmlFree(name);
-           if(stype != NULL)
-               xmlFree(stype);
-       }
-       if(numcols == 0)
-       {
-           msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The hub list at %s did not contain any columns"), pubhubaddr);
-           break;
-       }
-       for(i = 0; i < numcols; i++)
-       {
-           if(!strcmp(names[i], "Address"))
-           {
-               name = names[0];
-               names[0] = names[i];
-               names[i] = name;
-               type = types[0];
-               types[0] = types[i];
-               types[i] = type;
-               break;
-           }
-       }
-       if(i == numcols)
-       {
-           msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The hub list at %s did not contain the address to any hubs"), pubhubaddr);
-           break;
-       }
-       model = gtk_list_store_newv(numcols, types);
-       for(n = findnode(r->children, "Hub"); n != NULL; n = findnode(n->next, "Hub"))
-       {
-           if(!xmlHasProp(n, (xmlChar *)"Address") || !xmlHasProp(n, (xmlChar *)"Name"))
-               continue;
-           if(filterpubhub)
-           {
-               match = 0;
-               attr = (char *)xmlGetProp(n, (xmlChar *)"Name");
-               if(!regexec(&pubhubfilter, attr, 0, NULL, 0))
-                   match = 1;
-               xmlFree(attr);
-               if((attr = (char *)xmlGetProp(n, (xmlChar *)"Description")) != NULL)
-               {
-                   if(!regexec(&pubhubfilter, attr, 0, NULL, 0))
-                       match = 1;
-                   xmlFree(attr);
-               }
-               if(!match)
-                   continue;
-           }
-           gtk_list_store_append(model, &iter);
-           for(i = 0; i < numcols; i++)
-           {
-               attr = (char *)xmlGetProp(n, (xmlChar *)names[i]);
-               if(attr != NULL)
-               {
-                   if(types[i] == G_TYPE_STRING)
-                       gtk_list_store_set(model, &iter, i, attr, -1);
-                   else if(types[i] == G_TYPE_INT)
-                       gtk_list_store_set(model, &iter, i, atoi(attr), -1);
-                   else if(types[i] == G_TYPE_INT64)
-                       gtk_list_store_set(model, &iter, i, strtoll(attr, NULL, 0), -1);
-                   xmlFree(attr);
-               }
-           }
-       }
-       cols = smalloc((numcols - 1) * sizeof(*cols));
-       for(i = 1; i < numcols; i++)
-           cols[i - 1] = i;
-       sortcol = 0;
-       for(i = 0; i < numcols; i++)
-       {
-           if(!strcmp(names[i], "Users"))
-               sortcol = i;
-       }
-       setpubhubmodel(GTK_TREE_MODEL(model), sortcol, numcols - 1, cols, names + 1);
-       free(cols);
-       g_object_unref(model);
-       break;
-    case PHO_FINI:
-       if(ctxt != NULL)
-       {
-           if(ctxt->myDoc != NULL)
-               xmlFreeDoc(ctxt->myDoc);
-           xmlFreeParserCtxt(ctxt);
-           ctxt = NULL;
-       }
-       break;
-    }
-    if(numcols != 0)
-    {
-       for(i = 0; i < numcols; i++)
-           free(names[i]);
-       free(names);
-       free(types);
-    }
-    return(0);
-}
-
-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:
-       while((p = memchr(buf, '\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(!filterpubhub || !regexec(&pubhubfilter, fields[0], 0, NULL, 0) || !regexec(&pubhubfilter, fields[2], 0, NULL, 0)) {
-                       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]);
-           }
-           memmove(buf, p, *len -= 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);
-}
-
-void pubhubfdcallback(gpointer data, gint source, GdkInputCondition condition)
-{
-    static char buf[65536];
-    static size_t bufpos = 0;
-    int ret, reset;
-    
-    if(!(condition & GDK_INPUT_READ))
-       return;
-    if(bufpos == sizeof(buf))
-       bufpos = 0;
-    ret = read(pubhubfd, buf + bufpos, sizeof(buf) - bufpos);
-    reset = 0;
-    if(ret <= 0)
-    {
-       if(ret < 0)
-           msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not read from public hub listing process: %s"), strerror(errno));
-       else
-           pubhubhandler(PHO_EOF, NULL, NULL);
-       reset = 1;
-    } else {
-       bufpos += ret;
-       if(pubhubhandler(PHO_DATA, buf, &bufpos))
-           reset = 1;
-    }
-    if(reset)
-    {
-       pubhubhandler(PHO_FINI, NULL, NULL);
-       pubhubhandler = NULL;
-       gdk_input_remove(pubhubtag);
-       close(pubhubfd);
-       kill(pubhubproc, SIGINT);
-       pubhubfd = pubhubtag = -1;
-       pubhubproc = 0;
-       bufpos = 0;
-       if(filterpubhub)
-       {
-           regfree(&pubhubfilter);
-           filterpubhub = 0;
-       }
-    }
-}
-
 void cb_main_pubhubfilter_activate(GtkWidget *widget, gpointer data)
 {
-    int pipe1[2], pipe2[2];
-    int len, err;
-    const char *buf, *p;
+    int err;
+    const char *buf;
     char errbuf[1024];
+    regex_t *filter;
     
-    if(pubhubtag >= 0)
-       gdk_input_remove(pubhubtag);
-    if(pubhubfd >= 0)
-       close(pubhubfd);
-    if(pubhubproc > 0)
-       kill(pubhubproc, SIGINT);
-    if(pubhubhandler != NULL)
-    {
-       pubhubhandler(PHO_FINI, NULL, NULL);
-       pubhubhandler = NULL;
-    }
-    if(filterpubhub)
-    {
-       regfree(&pubhubfilter);
-       filterpubhub = 0;
-    }
     buf = gtk_entry_get_text(GTK_ENTRY(main_pubhubfilter));
     if(*buf)
     {
-       if((err = regcomp(&pubhubfilter, buf, REG_EXTENDED | REG_ICASE | REG_NOSUB)) != 0)
+       filter = smalloc(sizeof(*filter));
+       if((err = regcomp(filter, buf, REG_EXTENDED | REG_ICASE | REG_NOSUB)) != 0)
        {
-           regerror(err, &pubhubfilter, errbuf, sizeof(errbuf));
+           regerror(err, filter, errbuf, sizeof(errbuf));
            msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "Could not compile regex: %s", errbuf);
-           regfree(&pubhubfilter);
-           filterpubhub = 0;
+           regfree(filter);
+           free(filter);
            return;
        }
-       filterpubhub = 1;
-    }
-    pipe(pipe1);
-    if((pubhubproc = fork()) == 0)
-    {
-       dup2(pipe1[1], 1);
-       close(pipe1[0]);
-       close(pipe1[1]);
-       execlp("wget", "wget", "-qO", "-", pubhubaddr, NULL);
-       perror("wget");
-       exit(127);
-    }
-    close(pipe1[1]);
-    pubhubfd = pipe1[0];
-    len = strlen(pubhubaddr);
-    p = pubhubaddr + len;
-    if((len > 4) && !strncmp(p - 4, ".bz2", 4))
-    {
-       p -= 4;
-       len -= 4;
-       pipe(pipe2);
-       if(fork() == 0)
-       {
-           dup2(pipe1[0], 0);
-           dup2(pipe2[1], 1);
-           close(pipe1[0]);
-           close(pipe2[0]);
-           close(pipe2[1]);
-           execlp("bzcat", "bzcat", NULL);
-           perror("bzcat");
-           exit(127);
-       }
-       close(pipe1[0]);
-       close(pipe2[1]);
-       pubhubfd = pipe2[0];
-    }
-    if((len > 4) && !strncmp(p - 4, ".xml", 4))
-    {
-       p -= 4;
-       len -= 4;
-       pubhubhandler = pubhubxmlhandler;
     } else {
-       pubhubhandler = pubhuboldhandler;
+       filter = NULL;
     }
-    pubhubhandler(PHO_INIT, NULL, NULL);
-    pubhubtag = gdk_input_add(pubhubfd, GDK_INPUT_READ, pubhubfdcallback, NULL);
+    fetchhublist(pubhubaddr, filter);
 }
 
 void cb_main_dcnctbtn_clicked(GtkWidget *widget, gpointer data)
@@ -2684,3 +2277,8 @@ int main(int argc, char **argv)
     gtk_main();
     return(0);
 }
+
+#include "mainwnd.gtk"
+#include "inpdialog.gtk"
+#include "pref.gtk"
+#include "reslist.gtk"
diff --git a/clients/gtk2/dolcon.h b/clients/gtk2/dolcon.h
new file mode 100644 (file)
index 0000000..00d2424
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  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
+*/
+
+#ifndef _DOLCON_H
+#define _DOLCON_H
+
+#include <libintl.h>
+
+#define _(text) gettext(text)
+#define DCCHARSET "windows-1252"
+
+int msgbox(int type, int buttons, char *format, ...)
+#if defined(__GNUC__)
+    __attribute__ ((format (printf, 3, 4)))
+#endif
+;
+
+void setpubhubmodel(GtkTreeModel *model, int sortcol, int numcols, int *cols, char **names);
+
+#endif
diff --git a/clients/gtk2/hublist-old.c b/clients/gtk2/hublist-old.c
new file mode 100644 (file)
index 0000000..83da7fc
--- /dev/null
@@ -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 <stdlib.h>
+#include <string.h>
+#include <gtk/gtk.h>
+#include <doldaconnect/utils.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#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);
+}
diff --git a/clients/gtk2/hublist-xml.c b/clients/gtk2/hublist-xml.c
new file mode 100644 (file)
index 0000000..e67f717
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ *  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 <stdlib.h>
+#include <string.h>
+#include <doldaconnect/utils.h>
+#include <gtk/gtk.h>
+
+/* "Programming with libxml2 is like the thrilling embrace of an
+ * exotic strangler."
+ *    --Me */
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "dolcon.h"
+#include "hublist.h"
+
+static xmlNodePtr findnode(xmlNodePtr node, char *name)
+{
+    for(; node != NULL; node = node->next)
+    {
+       if(!strcmp((char *)node->name, name))
+           break;
+    }
+    return(node);
+}
+
+static int checkvalid(xmlNodePtr n)
+{
+    int match;
+    char *name, *descr;
+    
+    name = (char *)xmlGetProp(n, (xmlChar *)"Name");
+    descr = (char *)xmlGetProp(n, (xmlChar *)"Description");
+    match = validhub(name, descr, NULL);
+    xmlFree(name);
+    if(descr != NULL)
+       xmlFree(descr);
+    return(match);
+}
+
+int pubhubxmlhandler(int op, char *buf, size_t len)
+{
+    static xmlParserCtxtPtr ctxt = NULL;
+    int i;
+    xmlNodePtr dr, r, cr, c, n;
+    int numcols, *cols, sortcol;
+    GType type, *types;
+    char **names, *name, *stype, *attr;
+    GtkListStore *model;
+    GtkTreeIter iter;
+    
+    numcols = 0;
+    names = NULL;
+    types = NULL;
+    switch(op)
+    {
+    case PHO_INIT:
+       break;
+    case PHO_DATA:
+       if(ctxt == NULL) {
+           ctxt = xmlCreatePushParserCtxt(NULL, NULL, buf, len, NULL);
+           if(ctxt == NULL)
+               return(-1);
+       } else {
+           xmlParseChunk(ctxt, buf, len, 0);
+       }
+       return(len);
+    case PHO_EOF:
+       if(ctxt == NULL)
+       {
+           msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("A hub list could not be read from the server"));
+           break;
+       }
+       xmlParseChunk(ctxt, NULL, 0, 1);
+       if(!ctxt->wellFormed)
+       {
+           msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("The hub list is not valid"));
+           break;
+       }
+       dr = r = cr = NULL;
+       dr = xmlDocGetRootElement(ctxt->myDoc);
+       if(dr != NULL)
+           r = findnode(dr->children, "Hubs");
+       if(r != NULL)
+           cr = findnode(r->children, "Columns");
+       if(cr == NULL)
+       {
+           msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The hub list cannot be understood"));
+           break;
+       }
+       for(c = findnode(cr->children, "Column"); c != NULL; c = findnode(c->next, "Column"))
+       {
+           name = (char *)xmlGetProp(c, (xmlChar *)"Name");
+           stype = (char *)xmlGetProp(c, (xmlChar *)"Type");
+           type = G_TYPE_INVALID;
+           if(stype != NULL)
+           {
+               if(!strcmp(stype, "string"))
+                   type = G_TYPE_STRING;
+               else if(!strcmp(stype, "int"))
+                   type = G_TYPE_INT;
+               else if(!strcmp(stype, "bytes"))
+                   type = G_TYPE_INT64;
+           }
+           if((name != NULL) && (type != G_TYPE_INVALID))
+           {
+               names = srealloc(names, (numcols + 1) * sizeof(*names));
+               types = srealloc(types, (numcols + 1) * sizeof(*names));
+               names[numcols] = sstrdup(name);
+               types[numcols] = type;
+               numcols++;
+           }
+           if(name != NULL)
+               xmlFree(name);
+           if(stype != NULL)
+               xmlFree(stype);
+       }
+       if(numcols == 0)
+       {
+           msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The hub list did not contain any columns"));
+           break;
+       }
+       for(i = 0; i < numcols; i++)
+       {
+           if(!strcmp(names[i], "Address"))
+           {
+               name = names[0];
+               names[0] = names[i];
+               names[i] = name;
+               type = types[0];
+               types[0] = types[i];
+               types[i] = type;
+               break;
+           }
+       }
+       if(i == numcols)
+       {
+           msgbox(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The hub list did not contain the address to any hubs"));
+           break;
+       }
+       model = gtk_list_store_newv(numcols, types);
+       for(n = findnode(r->children, "Hub"); n != NULL; n = findnode(n->next, "Hub"))
+       {
+           if(!xmlHasProp(n, (xmlChar *)"Address") || !xmlHasProp(n, (xmlChar *)"Name"))
+               continue;
+           if(!checkvalid(n))
+               continue;
+           gtk_list_store_append(model, &iter);
+           for(i = 0; i < numcols; i++)
+           {
+               attr = (char *)xmlGetProp(n, (xmlChar *)names[i]);
+               if(attr != NULL)
+               {
+                   if(types[i] == G_TYPE_STRING)
+                       gtk_list_store_set(model, &iter, i, attr, -1);
+                   else if(types[i] == G_TYPE_INT)
+                       gtk_list_store_set(model, &iter, i, atoi(attr), -1);
+                   else if(types[i] == G_TYPE_INT64)
+                       gtk_list_store_set(model, &iter, i, strtoll(attr, NULL, 0), -1);
+                   xmlFree(attr);
+               }
+           }
+       }
+       cols = smalloc((numcols - 1) * sizeof(*cols));
+       for(i = 1; i < numcols; i++)
+           cols[i - 1] = i;
+       sortcol = 0;
+       for(i = 0; i < numcols; i++)
+       {
+           if(!strcmp(names[i], "Users"))
+               sortcol = i;
+       }
+       setpubhubmodel(GTK_TREE_MODEL(model), sortcol, numcols - 1, cols, names + 1);
+       free(cols);
+       g_object_unref(model);
+       break;
+    case PHO_FINI:
+       if(ctxt != NULL)
+       {
+           if(ctxt->myDoc != NULL)
+               xmlFreeDoc(ctxt->myDoc);
+           xmlFreeParserCtxt(ctxt);
+           ctxt = NULL;
+       }
+       break;
+    }
+    if(numcols != 0)
+    {
+       for(i = 0; i < numcols; i++)
+           free(names[i]);
+       free(names);
+       free(types);
+    }
+    return(0);
+}
diff --git a/clients/gtk2/hublist.c b/clients/gtk2/hublist.c
new file mode 100644 (file)
index 0000000..7212146
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ *  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 <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <regex.h>
+#include <signal.h>
+#include <string.h>
+#include <stdarg.h>
+#include <gtk/gtk.h>
+#include <errno.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "dolcon.h"
+#include "hublist.h"
+
+static regex_t *filter = NULL;
+static pid_t fetchpid = 0;
+static int listfd = -1;
+static int iotag = -1;
+static int (*handler)(int, char *, size_t) = NULL;
+static char readbuf[65536];
+static off_t bufpos = 0;
+
+void aborthublist(void)
+{
+    if(fetchpid > 0) {
+       gdk_input_remove(iotag);
+       iotag = -1;
+       close(listfd);
+       listfd = -1;
+       kill(fetchpid, SIGINT);
+       fetchpid = 0;
+       if(filter != NULL) {
+           regfree(filter);
+           free(filter);
+           filter = NULL;
+       }
+       if(handler != NULL) {
+           handler(PHO_FINI, NULL, 0);
+           handler = NULL;
+       }
+    }
+}
+
+int validhub(char *field, ...)
+{
+    int match;
+    va_list args;
+    
+    if(filter == NULL)
+       return(1);
+    match = 0;
+    va_start(args, field);
+    do {
+       if(!regexec(filter, field, 0, NULL, 0)) {
+           match = 1;
+           break;
+       }
+    } while((field = va_arg(args, char *)) != NULL);
+    va_end(args);
+    return(match);
+}
+
+static void readcb(gpointer data, gint source, GdkInputCondition cond)
+{
+    int ret;
+    
+    if(!(cond & GDK_INPUT_READ))
+       return;
+    if(bufpos == sizeof(readbuf))
+       bufpos = 0;
+    ret = read(listfd, readbuf + bufpos, sizeof(readbuf) - bufpos);
+    if(ret <= 0) {
+       if(ret < 0)
+           msgbox(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Could not read from public hub listing process: %s"), strerror(errno));
+       else
+           handler(PHO_EOF, NULL, 0);
+       aborthublist();
+    } else {
+       bufpos += ret;
+       if((ret = handler(PHO_DATA, readbuf, (size_t)bufpos)) < 0)
+           aborthublist();
+       else
+           memmove(readbuf, readbuf + ret, bufpos -= ret);
+    }
+}
+
+void fetchhublist(char *url, regex_t *flt)
+{
+    int pfd[2];
+    int len;
+    char *p;
+    
+    aborthublist();
+    filter = flt;
+    pipe(pfd);
+    if((fetchpid = fork()) == 0) {
+       dup2(pfd[1], 1);
+       close(pfd[0]);
+       close(pfd[1]);
+       execlp("wget", "wget", "-qO", "-", url, NULL);
+       perror("wget");
+       exit(127);
+    }
+    close(pfd[1]);
+    listfd = pfd[0];
+    len = strlen(url);
+    p = url + len;
+    if((len > 4) && !strncmp(p - 4, ".bz2", 4)) {
+       p -= 4;
+       len -= 4;
+       pipe(pfd);
+       if(fork() == 0) {
+           dup2(listfd, 0);
+           dup2(pfd[1], 1);
+           close(listfd);
+           close(pfd[0]);
+           close(pfd[1]);
+           execlp("bzcat", "bzcat", NULL);
+           perror("bzcat");
+           exit(127);
+       }
+       close(listfd);
+       close(pfd[1]);
+       listfd = pfd[0];
+    }
+    if((len > 4) && !strncmp(p - 4, ".xml", 4)) {
+       p -= 4;
+       len -= 4;
+       handler = pubhubxmlhandler;
+    } else {
+       handler = pubhuboldhandler;
+    }
+    bufpos = 0;
+    handler(PHO_INIT, NULL, 0);
+    iotag = gdk_input_add(listfd, GDK_INPUT_READ, readcb, NULL);
+}
diff --git a/clients/gtk2/hublist.h b/clients/gtk2/hublist.h
new file mode 100644 (file)
index 0000000..5c09d55
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  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
+*/
+
+#ifndef _HUBLIST_H
+#define _HUBLIST_H
+
+#include <regex.h>
+
+#define PHO_INIT 0
+#define PHO_DATA 1
+#define PHO_EOF 2
+#define PHO_FINI 3
+
+int validhub(char *field, ...);
+void fetchhublist(char *url, regex_t *flt);
+
+int pubhubxmlhandler(int op, char *buf, size_t len);
+int pubhuboldhandler(int op, char *buf, size_t len);
+
+#endif
index 0eaf7c7..cfcb6f1 100755 (executable)
@@ -1,5 +1,10 @@
 #!/usr/bin/perl
 
+use Getopt::Long;
+use IO::File;
+
+GetOptions(\%args, "h=s") || exit 1;
+
 $tempvar = 0;
 
 sub printwidgets
@@ -423,6 +428,20 @@ sub printwidgets
     }
 }
 
+sub printheader
+{
+    my($widget, $handle);
+    $handle = $_[1];
+    foreach $widget (@{$_[0]})
+    {
+       if($widget->{"var"})
+       {
+           $handle->print("extern GtkWidget *" . $options{"prefix"} . $widget->{"name"} .";\n");
+       }
+       printheader($widget->{"subwidgets"}, $handle) if($widget->{"subwidgets"});
+    }
+}
+
 sub printvars
 {
     my($widget);
@@ -488,6 +507,14 @@ while(<>)
     }
 }
 
+if($args{"h"})
+{
+    $hfile = IO::File->new($args{"h"}, "w") || die;
+    $hfile->print("GtkWidget *create_" . $options{"prefix"} . "wnd(void);\n");
+    printheader $rootwidgets, $hfile;
+    $hfile->close();
+}
+
 printvars $rootwidgets;
 print "\n";
 print "GtkWidget *create_" . $options{"prefix"} . "wnd(void)\n";
index 08fe0c4..6f84a4e 100644 (file)
@@ -23,6 +23,8 @@ dolconf_CPPFLAGS=     @GTK2_CFLAGS@ \
 dolconf_LDADD=         $(top_srcdir)/common/libcommon.a $(top_srcdir)/lib/libdcui.la
 
 .desc.gtk: $(top_srcdir)/common/makegdesc
-       $(top_srcdir)/common/makegdesc $< >$@
+       target="$@"; \
+       basename="$${target%.gtk}"; \
+       $(top_srcdir)/common/makegdesc -h "$${basename}.gtkh" $< >$@
 
 EXTRA_DIST=dolconf-assistant.desc dolconf-wnd.desc
index a637909..1d09c33 100644 (file)
@@ -58,28 +58,10 @@ GtkListStore *shares;
 int state, dirty = 1;
 int ignoreclose = 0;
 
-void astcancel(GtkWidget *widget, gpointer uudata);
-void astupdate(GtkWidget *widget, GtkWidget *page, gpointer uudata);
-void cb_ast_wnd_apply(GtkWidget *widget, gpointer uudata);
-void cb_ast_nick_changed(GtkWidget *widget, gpointer uudata);
-void cb_ast_shareadd_clicked(GtkWidget *widget, gpointer uudata);
-void cb_ast_sharerem_clicked(GtkWidget *widget, gpointer uudata);
-void cb_ast_checkports(GtkWidget *widget, gpointer uudata);
-void cb_ast_mode_nat_toggled(GtkWidget *widget, gpointer uudata);
-void cb_cfw_mode_act_toggled(GtkWidget *widget, gpointer uudata);
-void cb_cfw_orport_toggled(GtkWidget *widget, gpointer uudata);
-void cb_cfw_oraddr_toggled(GtkWidget *widget, gpointer uudata);
-void cb_cfw_uinet_toggled(GtkWidget *widget, gpointer uudata);
-void cb_cfw_save_activate(GtkWidget *widget, gpointer uudata);
-void cb_cfw_hup_activate(GtkWidget *widget, gpointer uudata);
-void cb_cfw_quit_activate(GtkWidget *widget, gpointer uudata);
-void cb_cfw_shareadd_clicked(GtkWidget *widget, gpointer uudata);
-void cb_cfw_sharerem_clicked(GtkWidget *widget, gpointer uudata);
-
 #define _(text) gettext(text)
 
-#include "dolconf-assistant.gtk"
-#include "dolconf-wnd.gtk"
+#include "dolconf-assistant.gtkh"
+#include "dolconf-wnd.gtkh"
 
 int v_nonempty(const char *val)
 {
@@ -865,3 +847,6 @@ int main(int argc, char **argv)
     }
     return(0);
 }
+
+#include "dolconf-assistant.gtk"
+#include "dolconf-wnd.gtk"
index 2cda989..96ff8da 100644 (file)
@@ -1,4 +1,7 @@
-clients/gtk2/main.c
+clients/gtk2/dolcon.c
+clients/gtk2/hublist.c
+clients/gtk2/hublist-xml.c
+clients/gtk2/hublist-old.c
 clients/gtk2/inpdialog.gtk
 clients/gtk2/mainwnd.gtk
 clients/gtk2/pref.gtk
index 7dea8cd..b370e15 100644 (file)
--- a/po/sv.po
+++ b/po/sv.po
@@ -8,8 +8,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: doldaconnect 0.1.1\n"
 "Report-Msgid-Bugs-To: fredrik@dolda2000.com\n"
-"POT-Creation-Date: 2007-07-21 05:45+0200\n"
-"PO-Revision-Date: 2007-05-30 00:18+0200\n"
+"POT-Creation-Date: 2007-07-19 06:41+0200\n"
+"PO-Revision-Date: 2007-07-19 06:46+0200\n"
 "Last-Translator: Fredrik Tolf <fredrik@dolda2000.com>\n"
 "Language-Team: Swedish <sv@li.org>\n"
 "MIME-Version: 1.0\n"
@@ -17,83 +17,84 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-#: clients/gtk2/main.c:304 clients/gtk2/main.c:327 clients/gtk2/main.c:383
-#: clients/gtk2/main.c:398 clients/gtk2/main.c:432 clients/gtk2/main.c:577
-#: clients/gtk2/main.c:600
+#: clients/gtk2/dolcon.c:245 clients/gtk2/dolcon.c:268
+#: clients/gtk2/dolcon.c:324 clients/gtk2/dolcon.c:339
+#: clients/gtk2/dolcon.c:373 clients/gtk2/dolcon.c:518
+#: clients/gtk2/dolcon.c:541
 msgid "Unknown"
 msgstr "Okänt"
 
-#: clients/gtk2/main.c:474
+#: clients/gtk2/dolcon.c:415
 msgid "Not found"
 msgstr "Kunde inte hittas"
 
-#: clients/gtk2/main.c:476
+#: clients/gtk2/dolcon.c:417
 msgid "No slots"
 msgstr "Inga kanaler lediga"
 
-#: clients/gtk2/main.c:477
+#: clients/gtk2/dolcon.c:418
 msgid "%H:%M:%S"
 msgstr "%H:%M:%S"
 
-#: clients/gtk2/main.c:478
+#: clients/gtk2/dolcon.c:419
 #, c-format
 msgid "%s (reported at %s)"
 msgstr "%s (rapporterades kl. %s)"
 
-#: clients/gtk2/main.c:670 clients/gtk2/main.c:2677
+#: clients/gtk2/dolcon.c:611 clients/gtk2/dolcon.c:2270
 msgid "Disconnected"
 msgstr "Frånkopplad"
 
-#: clients/gtk2/main.c:799 config/util/dolconf.c:815
+#: clients/gtk2/dolcon.c:734 config/util/dolconf.c:797
 msgid "Could not get your home directory!"
 msgstr "Kunde inte hitta din hemkatalog!"
 
-#: clients/gtk2/main.c:806
+#: clients/gtk2/dolcon.c:741
 #, c-format
 msgid "Could not open configuration file for writing: %s"
 msgstr "Kunde inte skriva till konfigurationsfilen: %s"
 
-#: clients/gtk2/main.c:847 clients/gtk2/main.c:851
+#: clients/gtk2/dolcon.c:782 clients/gtk2/dolcon.c:786
 msgid "Login"
 msgstr "Logga in"
 
-#: clients/gtk2/main.c:887
+#: clients/gtk2/dolcon.c:822
 msgid "Could not negotiate an acceptable authentication mechanism"
 msgstr "Kunde inte förhandla fram en acceptabel autentiseringsmekanism"
 
-#: clients/gtk2/main.c:892
+#: clients/gtk2/dolcon.c:827
 msgid "The server has encountered an error"
 msgstr "Servern har råkat ut för ett fel"
 
-#: clients/gtk2/main.c:897
+#: clients/gtk2/dolcon.c:832
 msgid "Internal client error"
 msgstr "Internt fel i klienten"
 
-#: clients/gtk2/main.c:906
+#: clients/gtk2/dolcon.c:841
 msgid "Login attempt failed!"
 msgstr "Inloggningsförsöket misslyckades!"
 
-#: clients/gtk2/main.c:952
+#: clients/gtk2/dolcon.c:887
 msgid "Discrete sizes"
 msgstr "Enskilda storlekar"
 
-#: clients/gtk2/main.c:1079
+#: clients/gtk2/dolcon.c:1014
 msgid "The server refused the connection"
 msgstr "Servern vägrade förbindelsen"
 
-#: clients/gtk2/main.c:1083
+#: clients/gtk2/dolcon.c:1018
 msgid "Server protocol revision mismatch"
 msgstr "Fel protokoll-revision hos servern"
 
-#: clients/gtk2/main.c:1089
+#: clients/gtk2/dolcon.c:1024
 msgid "Connected"
 msgstr "Ansluten"
 
-#: clients/gtk2/main.c:1317
+#: clients/gtk2/dolcon.c:1252
 msgid "The server has closed the connection"
 msgstr "Servern har stängt förbindelsen"
 
-#: clients/gtk2/main.c:1319
+#: clients/gtk2/dolcon.c:1254
 #, c-format
 msgid ""
 "The connection to the server failed:\n"
@@ -104,11 +105,11 @@ msgstr ""
 "\n"
 "%s"
 
-#: clients/gtk2/main.c:1339
+#: clients/gtk2/dolcon.c:1274
 msgid "Preferences"
 msgstr "Inställningar"
 
-#: clients/gtk2/main.c:1378
+#: clients/gtk2/dolcon.c:1313
 #, c-format
 msgid ""
 "Could not connect:\n"
@@ -119,156 +120,153 @@ msgstr ""
 "\n"
 "%s"
 
-#: clients/gtk2/main.c:1385
+#: clients/gtk2/dolcon.c:1320
 #: clients/gnome-trans-applet/dolcon-trans-applet.c:111
 msgid "Connecting..."
 msgstr "Ansluter..."
 
-#: clients/gtk2/main.c:1394
+#: clients/gtk2/dolcon.c:1329
 msgid "Connect"
 msgstr "Anslut"
 
-#: clients/gtk2/main.c:1394
+#: clients/gtk2/dolcon.c:1329
 msgid "Server address:"
 msgstr "Serverns adress:"
 
-#: clients/gtk2/main.c:1407 clients/gtk2/main.c:1428 clients/gtk2/main.c:1863
-#: clients/gtk2/main.c:1905 clients/gtk2/main.c:1969 clients/gtk2/main.c:2057
-#: clients/gtk2/main.c:2154
+#: clients/gtk2/dolcon.c:1342 clients/gtk2/dolcon.c:1363
+#: clients/gtk2/dolcon.c:1456 clients/gtk2/dolcon.c:1498
+#: clients/gtk2/dolcon.c:1562 clients/gtk2/dolcon.c:1650
+#: clients/gtk2/dolcon.c:1747
 msgid "Not connected to DC server"
 msgstr "Ej ansluten till DC-servern"
 
-#: clients/gtk2/main.c:1414 clients/gtk2/main.c:1447 clients/gtk2/main.c:1876
-#: clients/gtk2/main.c:1923 clients/gtk2/main.c:1982 clients/gtk2/main.c:2075
-#: clients/gtk2/main.c:2130 clients/gtk2/main.c:2201 clients/gtk2/main.c:2326
-#: clients/gtk2/main.c:2353
+#: clients/gtk2/dolcon.c:1349 clients/gtk2/dolcon.c:1382
+#: clients/gtk2/dolcon.c:1469 clients/gtk2/dolcon.c:1516
+#: clients/gtk2/dolcon.c:1575 clients/gtk2/dolcon.c:1668
+#: clients/gtk2/dolcon.c:1723 clients/gtk2/dolcon.c:1794
+#: clients/gtk2/dolcon.c:1919 clients/gtk2/dolcon.c:1946
 msgid "You do not have permission to do that"
 msgstr "Du har inte tillstånd att göra det"
 
-#: clients/gtk2/main.c:1434
+#: clients/gtk2/dolcon.c:1369
 msgid "Illegal address entered"
 msgstr "Ogiltig adress"
 
-#: clients/gtk2/main.c:1449 clients/gtk2/main.c:1925
+#: clients/gtk2/dolcon.c:1384 clients/gtk2/dolcon.c:1518
 msgid "The server could not parse that address"
 msgstr "Servern kunde inte tolka den adressen"
 
-#: clients/gtk2/main.c:1451 clients/gtk2/main.c:1927
+#: clients/gtk2/dolcon.c:1386 clients/gtk2/dolcon.c:1520
 msgid "There are too many hubs connected"
 msgstr "För många hubbar är anslutna"
 
-#: clients/gtk2/main.c:1530
-#, c-format
-msgid "A hub list could not be read from %s"
-msgstr "Kunde inte läsa hublista från %s"
-
-#: clients/gtk2/main.c:1536
-#, c-format
-msgid "The hub list at %s is not valid"
-msgstr "Hublistan från %s är inte giltig"
-
-#: clients/gtk2/main.c:1547
-#, c-format
-msgid "The hub list at %s cannot be understood"
-msgstr "Hublistan från %s är oförståelig"
-
-#: clients/gtk2/main.c:1579
-#, c-format
-msgid "The hub list at %s did not contain any columns"
-msgstr "Hublistan från %s innehöll inga kolumner"
-
-#: clients/gtk2/main.c:1597
-#, c-format
-msgid "The hub list at %s did not contain the address to any hubs"
-msgstr "Hublistan från %s innehöll inte adressen till några hubbar"
-
-#: clients/gtk2/main.c:1698
-msgid "(Invalid character)"
-msgstr "(Ogiltig bokstav)"
-
-#: clients/gtk2/main.c:1717 clients/gtk2/mainwnd.gtk:193
-#: clients/gtk2/mainwnd.gtk:230
-msgid "# users"
-msgstr "Antal användare"
-
-#: clients/gtk2/main.c:1718 clients/gtk2/mainwnd.gtk:235
-msgid "Name"
-msgstr "Namn"
-
-#: clients/gtk2/main.c:1719 clients/gtk2/mainwnd.gtk:240
-msgid "Description"
-msgstr "Beskrivning"
-
-#: clients/gtk2/main.c:1746
-#, c-format
-msgid "Could not read from public hub listing process: %s"
-msgstr "Kunde inte läsa från processen som hämtar den publika hublistan: %s"
-
-#: clients/gtk2/main.c:1868 clients/gtk2/main.c:1974
+#: clients/gtk2/dolcon.c:1461 clients/gtk2/dolcon.c:1567
 msgid "No hub selected"
 msgstr "Ingen hub vald"
 
-#: clients/gtk2/main.c:1984
+#: clients/gtk2/dolcon.c:1577
 msgid ""
 "This hub could not support all the types of characters in your chat message"
 msgstr "Den här hubben klarar inte av alla sorters bokstäver i ditt meddelande"
 
-#: clients/gtk2/main.c:1986
+#: clients/gtk2/dolcon.c:1579
 msgid "This hub does not support chatting"
 msgstr "Den här hubben klarar inte av att chatta"
 
-#: clients/gtk2/main.c:1988
+#: clients/gtk2/dolcon.c:1581
 #, c-format
 msgid "An error occurred while trying to chat (%i)"
 msgstr "Ett fel uppstod under försöket att chatta (%i)"
 
-#: clients/gtk2/main.c:2065
+#: clients/gtk2/dolcon.c:1658
 msgid "Please enter a search expression before searching"
 msgstr "Skriv in ett sökuttryck först"
 
-#: clients/gtk2/main.c:2073
+#: clients/gtk2/dolcon.c:1666
 msgid "Could not find any hubs to search on"
 msgstr "Kunde inte hitta någon hub att söka på"
 
-#: clients/gtk2/main.c:2077
+#: clients/gtk2/dolcon.c:1670
 msgid "The server could not parse your search expression"
 msgstr "Servern kunde inte tolka ditt sökuttryck"
 
-#: clients/gtk2/main.c:2079
+#: clients/gtk2/dolcon.c:1672
 #, c-format
 msgid "An error occurred while trying to search (%i)"
 msgstr "Ett fel uppstod under försöket att söka (%i)"
 
-#: clients/gtk2/main.c:2132 clients/gtk2/main.c:2355
+#: clients/gtk2/dolcon.c:1725 clients/gtk2/dolcon.c:1948
 #, c-format
 msgid "An error occurred while trying to cancel (%i)"
 msgstr "Ett fel uppstod under försöket att avbryta (%i)"
 
-#: clients/gtk2/main.c:2203
+#: clients/gtk2/dolcon.c:1796
 #, c-format
 msgid "An error occurred while trying to queue the download (%i)"
 msgstr "Ett fel uppstod under försöket att lägga till nerladdningen (%i)"
 
-#: clients/gtk2/main.c:2328
+#: clients/gtk2/dolcon.c:1921
 #, c-format
 msgid "An error occurred while trying to reset (%i)"
 msgstr "Ett fel uppstod under försöket att återställa (%i)"
 
-#: clients/gtk2/main.c:2463
+#: clients/gtk2/dolcon.c:2056
 #, c-format
 msgid "An error occurred (%ls)"
 msgstr "Ett fel uppstod (%ls)"
 
-#: clients/gtk2/main.c:2581 clients/gtk2/mainwnd.gtk:453
+#: clients/gtk2/dolcon.c:2174 clients/gtk2/mainwnd.gtk:453
 #, c-format
 msgid "Ready to search"
 msgstr "Redo att söka"
 
-#: clients/gtk2/main.c:2583
+#: clients/gtk2/dolcon.c:2176
 #, c-format
 msgid "Search scheduled and will be submitted in %i seconds"
 msgstr "Sökningen är schemalagd och kommer genomföras om %i sekunder"
 
+#: clients/gtk2/hublist.c:95
+#, c-format
+msgid "Could not read from public hub listing process: %s"
+msgstr "Kunde inte läsa från processen som hämtar den publika hublistan: %s"
+
+#: clients/gtk2/hublist-xml.c:91
+msgid "A hub list could not be read from the server"
+msgstr "Kunde inte läsa hublista från servern"
+
+#: clients/gtk2/hublist-xml.c:97
+msgid "The hub list is not valid"
+msgstr "Hublistan är inte giltig"
+
+#: clients/gtk2/hublist-xml.c:108
+msgid "The hub list cannot be understood"
+msgstr "Hublistan är oförståelig"
+
+#: clients/gtk2/hublist-xml.c:140
+msgid "The hub list did not contain any columns"
+msgstr "Hublistan innehöll inga kolumner"
+
+#: clients/gtk2/hublist-xml.c:158
+msgid "The hub list did not contain the address to any hubs"
+msgstr "Hublistan innehöll inte adresser till några hubbar"
+
+#: clients/gtk2/hublist-old.c:60
+msgid "(Invalid character)"
+msgstr "(Ogiltig bokstav)"
+
+#: clients/gtk2/hublist-old.c:79 clients/gtk2/mainwnd.gtk:193
+#: clients/gtk2/mainwnd.gtk:230
+msgid "# users"
+msgstr "Antal användare"
+
+#: clients/gtk2/hublist-old.c:80 clients/gtk2/mainwnd.gtk:235
+msgid "Name"
+msgstr "Namn"
+
+#: clients/gtk2/hublist-old.c:81 clients/gtk2/mainwnd.gtk:240
+msgid "Description"
+msgstr "Beskrivning"
+
 #: clients/gtk2/inpdialog.gtk:16
 msgid " "
 msgstr " "
@@ -515,93 +513,93 @@ msgstr "Ingen överföring vald"
 msgid "Initializing"
 msgstr "Förbereder"
 
-#: config/util/dolconf.c:134
+#: config/util/dolconf.c:116
 #, c-format
 msgid "%s must not be empty"
 msgstr "Fältet \"%s\" får inte vara tomt"
 
-#: config/util/dolconf.c:139
+#: config/util/dolconf.c:121
 #, c-format
 msgid "%s must not contain spaces, `|' or `$'"
 msgstr "Fältet \"%s\" får inte innehålla mellanrum, '|' eller '$'"
 
-#: config/util/dolconf.c:144
+#: config/util/dolconf.c:126
 #, c-format
 msgid "%s must be a natural number"
 msgstr "Fältet \"%s\" måste vara ett naturligt tal"
 
-#: config/util/dolconf.c:149
+#: config/util/dolconf.c:131
 #, c-format
 msgid "%s must be an integer"
 msgstr "Fältet \"%s\" måste vara ett heltal"
 
-#: config/util/dolconf.c:154
+#: config/util/dolconf.c:136
 #, c-format
 msgid "%s must be an IP address"
 msgstr "Fältet \"%s\" måste vara en IP-adress"
 
-#: config/util/dolconf.c:163
+#: config/util/dolconf.c:145
 msgid "Screen name"
 msgstr "Användarnamn"
 
-#: config/util/dolconf.c:169
+#: config/util/dolconf.c:151
 msgid "Upload slots"
 msgstr "Uppladdningskanaler"
 
-#: config/util/dolconf.c:170
+#: config/util/dolconf.c:152
 msgid "Connection speed"
 msgstr "Anslutningshastighet"
 
-#: config/util/dolconf.c:171
+#: config/util/dolconf.c:153
 msgid "E-mail address"
 msgstr "E-post-adress:"
 
-#: config/util/dolconf.c:172
+#: config/util/dolconf.c:154
 msgid "Share description"
 msgstr "Beskrivning"
 
-#: config/util/dolconf.c:173
+#: config/util/dolconf.c:155
 msgid "Direct Connect TCP port"
 msgstr "TCP-port för Direct Connect"
 
-#: config/util/dolconf.c:174
+#: config/util/dolconf.c:156
 msgid "Direct Connect UDP port"
 msgstr "UDP-port för Direct Connect"
 
-#: config/util/dolconf.c:215
+#: config/util/dolconf.c:197
 msgid "Dolda Connect configurator"
 msgstr "Dolda Connect-konfigurerare"
 
-#: config/util/dolconf.c:314
+#: config/util/dolconf.c:296
 #, c-format
 msgid "Could not open the configuration file for reading: %s"
 msgstr "Kunde inte läsa konfigurationsfilen: %s"
 
-#: config/util/dolconf.c:375
+#: config/util/dolconf.c:357
 #, c-format
 msgid "Could not open the configuration file for writing: %s"
 msgstr "Kunde inte skriva till konfigurationsfilen: %s"
 
-#: config/util/dolconf.c:513
+#: config/util/dolconf.c:495
 #, c-format
 msgid "Internal error (Auto-generated variable %s has an invalid value \"%s\")"
 msgstr ""
 "Internt fel (Autogenererade variabeln %s har det ogiltiga värdet \"%s\")"
 
-#: config/util/dolconf.c:551
+#: config/util/dolconf.c:533
 msgid "Shares:\n"
 msgstr "Utdelningar:\n"
 
-#: config/util/dolconf.c:612 config/util/dolconf-assistant.gtk:128
+#: config/util/dolconf.c:594 config/util/dolconf-assistant.gtk:128
 msgid "Shared directories"
 msgstr "Delade kataloger"
 
-#: config/util/dolconf.c:728 config/util/dolconf.c:733
-#: config/util/dolconf.c:739
+#: config/util/dolconf.c:710 config/util/dolconf.c:715
+#: config/util/dolconf.c:721
 msgid "Could not connect to server"
 msgstr "Kunde inte ansluta till servern"
 
-#: config/util/dolconf.c:761
+#: config/util/dolconf.c:743
 msgid ""
 "There are unsaved changes. Do you wish to discard the changes and exit "
 "anyway?"
@@ -609,7 +607,7 @@ msgstr ""
 "Vissa ändringar har inte ännu sparats. Vill du låta bli att spara dem och "
 "avsluta i alla fall?"
 
-#: config/util/dolconf.c:822
+#: config/util/dolconf.c:804
 msgid ""
 "It appears that you have not run this setup program before. Would you like "
 "to run the first-time setup assistant?"
@@ -617,7 +615,7 @@ msgstr ""
 "Du tycks inte ha kört det här inställningsprogrammet tidigare. Vill du köra "
 "förstagångs-assistenten?"
 
-#: config/util/dolconf.c:833
+#: config/util/dolconf.c:815
 msgid ""
 "The configuration file appears to have been edited outside the control of "
 "this program. If you continue using this program, all settings not handled "
@@ -627,7 +625,7 @@ msgstr ""
 "kontroll. Om du fortsätter använda det här programmet, kommer inställningar "
 "som det inte hanterar förloras. Vill du fortsätta?"
 
-#: config/util/dolconf.c:862
+#: config/util/dolconf.c:844
 msgid "Internal error (Unknown state)"
 msgstr "Internt fel (Okänt läge)"