aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/imap/MCIMAPIdentity.cpp
blob: a94d01df15565bcbe16b083d24b69414b4ca011f (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
//  MCIMAPIdentity.cpp
//  mailcore2
//
//  Created by Hoa V. DINH on 8/24/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#include "MCIMAPIdentity.h"

using namespace mailcore;

IMAPIdentity::IMAPIdentity()
{
    init();
}

IMAPIdentity::IMAPIdentity(IMAPIdentity * identity)
{
    init();
    mc_foreachhashmapKeyAndValue(String, key, String, value, identity->mValues) {
        mValues->setObjectForKey(key, value);
    }
}

void IMAPIdentity::init()
{
    mValues = new HashMap();
}

IMAPIdentity::~IMAPIdentity()
{
    MC_SAFE_RELEASE(mValues);
}

void IMAPIdentity::setVendor(String * vendor)
{
    setInfoForKey(MCSTR("vendor"), vendor);
}

String * IMAPIdentity::vendor()
{
    return infoForKey(MCSTR("vendor"));
}

void IMAPIdentity::setName(String * name)
{
    setInfoForKey(MCSTR("name"), name);
}

String * IMAPIdentity::name()
{
    return infoForKey(MCSTR("name"));
}

void IMAPIdentity::setVersion(String * version)
{
    setInfoForKey(MCSTR("version"), version);
}

String * IMAPIdentity::version()
{
    return infoForKey(MCSTR("version"));
}

Array * IMAPIdentity::allInfoKeys()
{
    return mValues->allKeys();
}

String * IMAPIdentity::infoForKey(String * key)
{
    return (String *) mValues->objectForKey(key);
}

void IMAPIdentity::setInfoForKey(String * key, String * value)
{
    if (value != NULL) {
        mValues->setObjectForKey(key, value->copy()->autorelease());
    }
    else {
        mValues->removeObjectForKey(key);
    }
}

void IMAPIdentity::removeAllInfos()
{
    mValues->removeAllObjects();
}

Object * IMAPIdentity::copy()
{
    return new IMAPIdentity(this);
}

String * IMAPIdentity::description()
{
    return String::stringWithUTF8Format("<%s:%p %s>", className()->UTF8Characters(), this, MCUTF8DESC(mValues));
}