2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef WRTPLUGINS_API_IMESSAGING_SERVICE_H_
20 #define WRTPLUGINS_API_IMESSAGING_SERVICE_H_
22 #include "IMessagingTypes.h"
24 #include <dpl/shared_ptr.h>
25 #include <Commons/ThreadPool.h>
26 #include "IEmailAccount.h"
27 #include "IMessageFolder.h"
29 #include <Commons/EventReceiver.h>
30 #include <Commons/IExternEventCanceler.h>
35 enum MessagingServiceOpType
37 MESSAGING_SERVICE_OP_SEND_MESSAGE = 0,
38 MESSAGING_SERVICE_OP_DOWNLOAD_BODY,
39 MESSAGING_SERVICE_OP_DOWNLOAD_ATTACHMENT,
40 MESSAGING_SERVICE_OP_SYNC,
41 MESSAGING_SERVICE_OP_SYNC_FOLDER,
42 MESSAGING_SERVICE_OP_COUNT,
45 class ReqReceiverMessage;
46 class IMessagingService;
48 typedef DPL::SharedPtr<IMessagingService> IMessagingServicePtr;
50 class IMessagingService:
51 public WrtDeviceApis::Commons::IExternEventCanceler< EventMessagingService >,
55 virtual ~IMessagingService();
58 // * Gets a service of messaging
59 // * @param event @see TizenApis::Api::PluginTemplete::EventGetMessagingService
60 // * @exception WrtDeviceApis::Commons::PlatformException when platform error occurs
63 int getAccountID() const
65 if ( m_messagingServiceType == EMAIL)
67 return getCurrentEmailAccount().getIntId();
69 else if(m_messagingServiceType == SMS)
71 return m_messagingServiceId;
73 else if(m_messagingServiceType == MMS)
75 return m_messagingServiceId;
79 return -1; //default is -1
85 return m_messagingServiceType;
88 std::string getName() const
90 if ( m_messagingServiceType == EMAIL)
92 return getCurrentEmailAccount().getName();
96 return m_messagingServiceName;
100 virtual int createOpId(int type) = 0;
101 virtual int getHandleFromOpId(int opId) = 0;
102 virtual int getOpTypeFromOpId(int opId) = 0;
103 virtual IMessagePtr getMessageFromOpId(int opId) = 0;
104 virtual EventMessagingServicePtr getEventFromOpId(int opId) = 0;
105 virtual EventMessagingServicePtr getEventFromHandle(int handle) = 0;
106 virtual void setHandleToOpId(int opId, int handle) = 0;
107 virtual void setMessageToOpId(int opId, IMessagePtr& message) = 0;
108 virtual void setEventToOpId(int opId, EventMessagingServicePtr &event) = 0;
109 virtual int deleteOpId(int opId)=0;
111 virtual int sync(const IMessagingServicePtr& messagingService, const int limit) = 0;
112 virtual void syncCancel(int handle) = 0;
113 virtual int syncFolder(const IMessagingServicePtr& messagingService, const int folder_id, const int limit) = 0;
114 virtual void syncFolderCancel(int handle) = 0;
116 virtual void cancelOperation(int opId, int handle, int eventType, IMessagePtr& message) = 0;
118 void OnCancelEvent(const EventMessagingServicePtr &event);
119 void setMessagingServiceEvent(const EventMessagingServicePtr &event);
120 EventMessagingServicePtr getMessagingServiceEvent() const;
122 void setRequestReceiver(ReqReceiverMessage* reqReceiver)
124 m_requestReceiver = reqReceiver;
127 ReqReceiverMessage* getRequestReceiver() const
129 return m_requestReceiver;
133 short m_messagingServiceType; //type
134 std::string m_messagingServiceName;
135 int m_messagingServiceId;
137 * Request receiver. Used when there are callback funtions assigned at function executing scope
139 ReqReceiverMessage *m_requestReceiver;
142 * Messaging Service event. Used when there are callback funtions assigned at function executing scope
144 EventMessagingServicePtr m_messagingServiceEvent;
149 void setType(int type)
151 m_messagingServiceType = type;
154 void setName(const std::string& name = "" )
156 m_messagingServiceName = name;
159 void setId(int serviceId)
161 m_messagingServiceId = serviceId;
169 #endif //WRTPLUGINS_API_IMESSAGING_SERVICE_H_