return imapc_connection_cmd(conn, callback, context);
}
+bool imapc_client_is_server_selected(struct imapc_client *client,
+ const char *name)
+{
+ struct imapc_connection *conn = imapc_client_find_connection(client);
+ const char *conn_name = imapc_connection_get_selected_mailbox_name(conn);
+ return null_strcmp(conn_name, name) == 0;
+}
+
static struct imapc_client_connection *
imapc_client_get_unboxed_connection(struct imapc_client *client)
{
bool idle_plus_waiting:1;
bool imap4rev2_enabled:1;
bool select_waiting_reply:1;
- /* TRUE if IMAP server is in SELECTED state. select_box may be NULL
+ /* The name of the folder if in SELECTED state. select_box may be NULL
though, if we already closed the mailbox from client point of
view. */
- bool selected_on_server:1;
+ char *selected_on_server;
};
static void imapc_connection_capability_cb(const struct imapc_command_reply *reply,
array_free(&conn->aborted_cmd_tags);
imapc_client_unref(&conn->client);
event_unref(&conn->event);
+ i_free(conn->selected_on_server);
i_free(conn->ips);
i_free(conn);
}
conn->select_waiting_reply = FALSE;
conn->qresync_selecting_box = NULL;
conn->selected_box = NULL;
- conn->selected_on_server = FALSE;
+ i_free_and_null(conn->selected_on_server);
/* fall through */
case IMAPC_CONNECTION_STATE_DONE:
/* if we came from imapc_client_get_capabilities(), stop so
conn->selected_box = conn->qresync_selecting_box;
conn->qresync_selecting_box = NULL;
} else {
- conn->selected_on_server = FALSE;
+ i_free_and_null(conn->selected_on_server);
}
}
return 0;
i_assert(conn->qresync_selecting_box == NULL);
- if (conn->selected_on_server &&
+ if (conn->selected_on_server != NULL &&
(conn->capabilities & IMAPC_CAPABILITY_QRESYNC) != 0) {
/* server will send a [CLOSED] once selected mailbox is
closed */
} else {
/* we'll have to assume that all the future untagged messages
are for the mailbox we're selecting */
+ i_free_and_null(conn->selected_on_server);
+ conn->selected_on_server = i_strdup(box->name);
conn->selected_box = box;
- conn->selected_on_server = TRUE;
}
conn->select_waiting_reply = TRUE;
}
conn->qresync_selecting_box = NULL;
conn->selected_box = NULL;
if (via_tagged_reply)
- conn->selected_on_server = FALSE;
+ i_free_and_null(conn->selected_on_server);
else {
/* We didn't actually send UNSELECT command, so don't
touch selected_on_server state. */
{
return cmd->start_time;
}
+
+const char *
+imapc_connection_get_selected_mailbox_name(struct imapc_connection *conn)
+{
+ return conn->selected_on_server;
+}