tizen beta release
[framework/web/wrt-plugins-common.git] / src / modules / API / Messaging / EmailAccountInfo.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  * @author          Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
18  */
19 #include <sstream>
20 #include <Commons/Exception.h>
21 #include "EmailAccountInfo.h"
22
23 namespace WrtDeviceApis {
24 namespace Messaging{
25 namespace Api {
26 EmailAccountInfo::EmailAccountInfo(int id,
27         const std::string& name,
28         const std::string& address) :
29     m_name(name),
30     m_address(address)
31 {
32     std::stringstream stream;
33     stream << id;
34     if (stream.fail()) {
35         ThrowMsg(Commons::UnknownException,
36                  "Couldn't convert e-mail account id");
37     }
38     m_id = stream.str();
39 }
40
41 EmailAccountInfo::EmailAccountInfo(const std::string& id,
42         const std::string& name,
43         const std::string& address) :
44     m_id(id),
45     m_name(name),
46     m_address(address)
47 {
48 }
49
50 int EmailAccountInfo::getIntId() const
51 {
52     int result = 0;
53     std::stringstream stream(m_id);
54     stream >> result;
55     if (stream.fail()) {
56         ThrowMsg(Commons::UnknownException,
57                  "Couldn't convert e-mail account id");
58     }
59     return result;
60 }
61
62 std::string EmailAccountInfo::getId() const
63 {
64     return m_id;
65 }
66
67 std::string EmailAccountInfo::getName() const
68 {
69     return m_name;
70 }
71
72 std::string EmailAccountInfo::getAddress() const
73 {
74     return m_address;
75 }
76
77 bool EmailAccountInfo::operator==(const EmailAccountInfo& account) const
78 {
79     return (m_id == account.m_id &&
80             m_name == account.m_name &&
81             m_address == account.m_address);
82 }
83 }}
84 }