Update change log and spec for wrt-plugins-tizen_0.2.73
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Messaging / SyncNetworkStatus.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  * @author          Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
19  */
20
21 #include <dpl/assert.h>
22 #include <Commons/Exception.h>
23 #include "SyncNetworkStatus.h"
24 #include <dpl/log/log.h>
25
26 namespace {
27 const char* DBUS_INTERFACE_NETWORK_STATUS = "User.Email.NetworkStatus";
28 const int DBUS_MESSAGE_PARAMETERS_NUMBER = 5;
29 }
30
31 namespace TizenApis {
32 namespace Platform {
33 namespace Messaging {
34
35 SyncNetworkStatus::SyncNetworkStatus(const DBus::MessagePtr& message)
36 {
37     Assert(message->getInterface() == DBUS_INTERFACE_NETWORK_STATUS);
38     initialize(message);
39 }
40
41 int SyncNetworkStatus::getStatus() const
42 {
43     return m_status;
44 }
45
46 int SyncNetworkStatus::getHandle() const
47 {
48     return m_handle;
49 }
50
51 std::string SyncNetworkStatus::getSource() const
52 {
53     return m_source;
54 }
55
56 int SyncNetworkStatus::getMailId() const
57 {
58     return m_mailId;
59 }
60
61 int SyncNetworkStatus::getErrorCode() const
62 {
63     return m_errorCode;
64 }
65
66 void SyncNetworkStatus::initialize(const DBus::MessagePtr& message)
67 {
68     DBus::Message::ReadIterator it = message->getReadIterator();
69     for (int i = 0; i < DBUS_MESSAGE_PARAMETERS_NUMBER; it->next(), ++i) {
70         if (!it->isValid()) {
71             ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Missing some properties.");
72         }
73
74         switch (i) {
75         case 0: m_status = it->getInt();
76                  LogDebug("status :" << m_status);
77             break;
78         case 1: m_mailId = it->getInt();
79                  LogDebug("mail ID :" << m_mailId);
80             break;
81         case 2: m_source = it->getString();
82                  LogDebug("source :" << m_source);
83             break;
84         case 3: m_handle = it->getInt();
85                  LogDebug("handle :" << m_handle);
86             break;
87         case 4: m_errorCode = it->getInt();
88                  LogDebug("error Code :" << m_errorCode);
89             break;
90         }
91     }
92 }
93 }
94 }
95 }