Make the test client quit when it has authenticated.
[doldaconnect.git] / clients / test.c
index fdc46c2..cf4bc4c 100644 (file)
@@ -5,18 +5,19 @@
 #include <doldaconnect/uilib.h>
 #include <doldaconnect/uimisc.h>
 
+int done;
+
 void authcallback(int err, wchar_t *reason, void *data)
 {
     printf("Logged in: %i\n", err);
+    dc_queuecmd(NULL, NULL, L"quit", NULL);
 }
 
 int main(int argc, char **argv)
 {
-    int i;
     struct pollfd pfd;
-    int fd, done;
+    int fd;
     struct dc_response *resp;
-    struct dc_intresp *ires;
     
     dc_init();
     fd = dc_connect(NULL);
@@ -40,8 +41,9 @@ int main(int argc, char **argv)
        {
            if(!wcscmp(resp->cmdname, L".connect"))
            {
-               printf("Connected\n");
-               dc_loginasync(NULL, 1, NULL, authcallback, NULL);
+               printf("Connected: %i\n", resp->code);
+               if(resp->code == 201)
+                   dc_loginasync(NULL, 1, NULL, authcallback, NULL);
            }
            dc_freeresp(resp);
        }