Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Messaging / EventGetMessagingService.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #ifndef WRTPLUGINS_API_GET_MESSAGING_SERVICE_EVENT_MESSAGING_H_
19 #define WRTPLUGINS_API_GET_MESSAGING_SERVICE_EVENT_MESSAGING_H_
20
21 #include <vector>
22 #include <Commons/IEvent.h>
23 #include <dpl/shared_ptr.h>
24 #include <Commons/Exception.h>
25 #include <Security.h>
26
27 #include "IMessagingService.h"
28 #include "IMessagingTypes.h"
29
30 namespace DeviceAPI {
31 namespace Messaging {
32 class EventGetMessagingService: public WrtDeviceApis::Commons::IEvent<EventGetMessagingService>, public DeviceAPI::Common::SecurityAccessor
33 {
34         
35 public:
36         static const int MESSAGING_SERVICE_MANAGER_EVENT_TYPE_ALL = 1;
37         static const int MESSAGING_SERVICE_MANAGER_EVENT_TYPE_ACCOUNT = 2;
38
39 private:
40         
41      long m_accountID;
42         int m_messagingServiceType;
43      int m_eventType;
44                 
45      std::vector< IMessagingServicePtr > m_messagingServices;
46         
47 public:
48         void setAccountID(long value) {
49                 //ToDo : check vailded Account, now temporary
50                 m_accountID = value;
51                 m_eventType = MESSAGING_SERVICE_MANAGER_EVENT_TYPE_ACCOUNT; //if set account, type will be changed as account type
52         }
53
54         long getAccountID() const {
55                 return m_accountID;
56         }
57
58         void setEventType(int type) {
59                 m_eventType = type;
60         }
61         
62         int getEventType() const{
63                 return m_eventType;
64         }       
65
66         void setMessagingServiceType(int type) {
67                 m_messagingServiceType = type;
68         }
69
70         int getMessagingServiceType() const {
71                 return m_messagingServiceType;
72         }
73                 
74         void setMessagingServicesRef(const std::vector< IMessagingServicePtr > &msgServices)
75         {
76                 m_messagingServices = msgServices;
77         }
78
79         std::size_t getNumberOfMessagingService()
80         {
81                 return m_messagingServices.size();
82         }
83                 
84         IMessagingServicePtr getMessagingService(std::size_t index)
85         {
86                 if (index >= m_messagingServices.size() || m_messagingServices.size() == 0) {
87                         Throw(WrtDeviceApis::Commons::InvalidArgumentException);
88                 }
89                 
90                 return m_messagingServices[index];
91         }
92         
93         std::vector<IMessagingServicePtr> getMessagingServices()
94         {
95                 return m_messagingServices;
96         }
97         
98         EventGetMessagingService() 
99         {
100                 m_accountID = -1, 
101                 m_eventType = MESSAGING_SERVICE_MANAGER_EVENT_TYPE_ALL;
102         }
103 };
104
105 typedef DPL::SharedPtr<EventGetMessagingService> EventGetMessagingServicePtr;
106
107 } // Messaging
108 } // DeviceAPI
109 #endif //WRTPLUGINS_API_GET_MESSAGING_SERVICE_EVENT_MESSAGING_H_