ce4fc51b69b3763b6b0bd3f83abc6a2fac752636
[framework/web/wrt-plugins-common.git] / src / modules / API / Messaging / IEmailAccount.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  *
18  *
19  * @file       IEmailAccount.cpp
20  * @author     Pawel Misiak (p.misiak@samsung.com)
21  * @version    0.1
22  * @brief
23  */
24 #include <algorithm>
25 #include <Commons/Exception.h>
26 #include "IEmailAccount.h"
27
28 namespace WrtDeviceApis {
29 namespace Messaging {
30 namespace Api {
31 IEmailAccount::IEmailAccount() :
32     m_currentAccount("", "", ""),
33     m_validAccount(false)
34 {
35 }
36
37 IEmailAccount::~IEmailAccount()
38 {
39 }
40
41 void IEmailAccount::setCurrentEmailAccount(const EmailAccountInfo& account)
42 {
43     std::vector<EmailAccountInfo> accounts = getEmailAccounts();
44     if (std::find(accounts.begin(), accounts.end(),
45                   account) != accounts.end()) {
46         m_currentAccount = account;
47     } else {
48         ThrowMsg(Commons::InvalidArgumentException,
49                  "Wrong account name, account not exist");
50     }
51 }
52
53 EmailAccountInfo IEmailAccount::getCurrentEmailAccount() const
54 {
55     return m_currentAccount;
56 }
57
58 bool IEmailAccount::isCurrentAccountValid() const
59 {
60     return m_validAccount;
61 }
62
63 void IEmailAccount::setCurrentAccountValid(bool state)
64 {
65     m_validAccount = state;
66 }
67 }}
68 }