aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/async/imap/MCIMAPFetchFoldersOperation.cpp
blob: e1f121e8dfc407c909229f1e8f9ffce95380e550 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
//  MCIMAPFetchFoldersOperation.cpp
//  mailcore2
//
//  Created by DINH Viêt Hoà on 1/12/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#include "MCIMAPFetchFoldersOperation.h"

#include <stdlib.h>

#include "MCIMAPSession.h"
#include "MCIMAPAsyncConnection.h"

using namespace mailcore;

IMAPFetchFoldersOperation::IMAPFetchFoldersOperation()
{
    mFetchSubscribedEnabled = false;
    mFolders = NULL;
}

IMAPFetchFoldersOperation::~IMAPFetchFoldersOperation()
{
    MC_SAFE_RELEASE(mFolders);
}

void IMAPFetchFoldersOperation::setFetchSubscribedEnabled(bool enabled)
{
    mFetchSubscribedEnabled = enabled;
}

bool IMAPFetchFoldersOperation::isFetchSubscribedEnabled()
{
    return mFetchSubscribedEnabled;
}

Array * IMAPFetchFoldersOperation::folders()
{
    return mFolders;
}

void IMAPFetchFoldersOperation::main()
{
    ErrorCode error;
    if (mFetchSubscribedEnabled) {
        mFolders = session()->session()->fetchSubscribedFolders(&error);
    }
    else {
        mFolders = session()->session()->fetchAllFolders(&error);
    }
    MC_SAFE_RETAIN(mFolders);
    setError(error);
}