Swap return value and argument of imap_threaded_capability()
authorJakub Kicinski <kubakici@wp.pl>
Fri, 12 Dec 2014 08:17:34 +0000 (09:17 +0100)
committerJakub Kicinski <kubakici@wp.pl>
Fri, 12 Dec 2014 08:17:34 +0000 (09:17 +0100)
imap_threaded_capability() is the only imap_threaded_*() function
which does not return status, instead status is written to a pointer
passed as argument and function returns retrieved capabilities. To
unify behaviour of all imap_threaded_*() functions make it return
status and pass capabilities through an out argument.

src/etpan/imap-thread.c
src/etpan/imap-thread.h
src/imap.c

index 229f29e..66514ff 100644 (file)
@@ -615,7 +615,7 @@ static void capability_run(struct etpan_thread_op * op)
 }
 
 
-struct mailimap_capability_data * imap_threaded_capability(Folder *folder, int *ok)
+int imap_threaded_capability(Folder *folder, struct mailimap_capability_data ** caps)
 {
        struct capa_param param;
        struct capa_result result;
@@ -629,10 +629,10 @@ struct mailimap_capability_data * imap_threaded_capability(Folder *folder, int *
        
        debug_print("capa %d\n", result.error);
        
-       if (ok)
-               *ok = result.error;
+       if (result.error == MAILIMAP_NO_ERROR)
+               *caps = result.caps;
 
-       return result.caps;
+       return result.error;
        
 }
        
index fd61b5d..30bce70 100644 (file)
@@ -47,7 +47,7 @@ void imap_done(Folder * folder);
 
 int imap_threaded_connect(Folder * folder, const char * server, int port);
 int imap_threaded_connect_ssl(Folder * folder, const char * server, int port);
-struct mailimap_capability_data * imap_threaded_capability(Folder *folder, int *ok);
+int imap_threaded_capability(Folder *folder, struct mailimap_capability_data ** caps);
 
 #ifndef G_OS_WIN32
 int imap_threaded_connect_cmd(Folder * folder, const char * command,
index 32ecd38..35fb47f 100644 (file)
@@ -835,12 +835,12 @@ static int imap_get_capabilities(IMAPSession *session)
 {
        struct mailimap_capability_data *capabilities = NULL;
        clistiter *cur;
-       int result = -1;
+       int result;
 
        if (session->capability != NULL)
                return MAILIMAP_NO_ERROR;
 
-       capabilities = imap_threaded_capability(session->folder, &result);
+       result = imap_threaded_capability(session->folder, &capabilities);
 
        if (result != MAILIMAP_NO_ERROR) {
                return result;