Merge branch 'master' of /srv/git/r/doldaconnect
[doldaconnect.git] / clients / gnome-trans-applet / conduit-dclib.c
index afc90c3..6ce3f82 100644 (file)
@@ -84,8 +84,7 @@ static char *gettag(struct dc_transfer *dt)
        return(NULL);
     if((mbspath = icwcstombs(dt->path, "UTF-8")) == NULL)
        return(NULL);
-    /* XXX: Achtung! Too DC-specific! */
-    if((p = strrchr(mbspath, '\\')) == NULL)
+    if((p = strrchr(mbspath, '/')) == NULL)
        p = mbspath;
     else
        p++;
@@ -142,7 +141,7 @@ static void inittrans(struct conduit *conduit, struct dc_transfer *dt)
     dtd->conduit = conduit;
     dt->udata = dtd;
     dt->destroycb = dtfreecb;
-    dc_queuecmd(lstrargcb, dt, L"lstrarg", L"%%i", dt->id, NULL);
+    dc_queuecmd(lstrargcb, dt, L"lstrarg", L"%i", dt->id, NULL);
 }
 
 static void trlistcb(int resp, struct conduit *conduit)
@@ -195,12 +194,12 @@ static void dcfdcb(struct conduit *conduit, int fd, GdkInputCondition condition)
     {
        if(!wcscmp(resp->cmdname, L".connect"))
        {
-           if(resp->code == 200)
+           if(dc_checkprotocol(resp, DC_LATEST))
            {
-               dc_loginasync(NULL, 1, noconv, (void (*)(int, wchar_t *, void *))logincb, conduit);
-           } else {
                dc_disconnect();
                disconnected(conduit);
+           } else {
+               dc_loginasync(NULL, 1, noconv, (void (*)(int, wchar_t *, void *))logincb, conduit);
            }
        } else if(!wcscmp(resp->cmdname, L".notify")) {
            dc_uimisc_handlenotify(resp);
@@ -273,14 +272,11 @@ static int init(struct conduit *conduit)
 static int connect(struct conduit *conduit)
 {
     struct data *data;
-    char *host;
     
     data = conduit->cdata;
     if(inuse != NULL)
        return(-1);
-    if((host = getenv("DCSERVER")) == NULL)
-       host = "localhost";
-    if((data->fd = dc_connect(host, -1)) < 0)
+    if((data->fd = dc_connect(NULL)) < 0)
        return(-1);
     data->gdkread = gdk_input_add(data->fd, GDK_INPUT_READ, (void (*)(gpointer, int, GdkInputCondition))dcfdcb, conduit);
     updatewrite(conduit);
@@ -304,11 +300,31 @@ static void destroy(struct conduit *conduit)
     free(data);
 }
 
+static int cancel(struct conduit *conduit, struct transfer *transfer)
+{
+    struct data *data;
+    struct dtdata *dtd;
+    struct dc_transfer *dt;
+    
+    data = conduit->cdata;
+    for(dt = dc_transfers; dt != NULL; dt = dt->next)
+    {
+       if(((dtd = dt->udata) != NULL) && (dtd->ct == transfer))
+       {
+           dc_queuecmd(NULL, NULL, L"cancel", L"%i", dt->id, NULL);
+           return(0);
+       }
+    }
+    errno = -ESRCH;
+    return(-1);
+}
+
 static struct conduitiface st_conduit_dclib =
 {
     .init = init,
     .connect = connect,
     .destroy = destroy,
+    .cancel = cancel,
 };
 
 struct conduitiface *conduit_dclib = &st_conduit_dclib;