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 <dpl/log/log.h>
23 #include "IMessagingTypes.h"
25 #include <dpl/shared_ptr.h>
26 #include <Commons/ThreadPool.h>
27 #include "IEmailAccount.h"
28 #include "IMessageFolder.h"
30 #include <Commons/EventReceiver.h>
31 #include <Commons/IExternEventCanceler.h>
36 enum MessagingServiceOpType
38 MESSAGING_SERVICE_OP_SEND_MESSAGE = 0,
39 MESSAGING_SERVICE_OP_DOWNLOAD_BODY,
40 MESSAGING_SERVICE_OP_DOWNLOAD_ATTACHMENT,
41 MESSAGING_SERVICE_OP_SYNC,
42 MESSAGING_SERVICE_OP_SYNC_FOLDER,
43 MESSAGING_SERVICE_OP_COUNT,
46 class ReqReceiverMessage;
47 class IMessagingService;
49 typedef DPL::SharedPtr<IMessagingService> IMessagingServicePtr;
51 class IMessagingService:
52 public WrtDeviceApis::Commons::IExternEventCanceler< EventMessagingService >,
56 virtual ~IMessagingService();
59 // * Gets a service of messaging
60 // * @param event @see TizenApis::Api::PluginTemplete::EventGetMessagingService
61 // * @exception WrtDeviceApis::Commons::PlatformException when platform error occurs
64 int getAccountID() const
66 if ( m_messagingServiceType == EMAIL)
68 return getCurrentEmailAccount().getIntId();
70 else if(m_messagingServiceType == SMS)
72 return m_messagingServiceId;
74 else if(m_messagingServiceType == MMS)
76 return m_messagingServiceId;
80 return -1; //default is -1
86 return m_messagingServiceType;
89 std::string getName() const
91 if ( m_messagingServiceType == EMAIL)
93 return getCurrentEmailAccount().getName();
97 return m_messagingServiceName;
101 virtual int createOpId(int type) = 0;
102 virtual int getHandleFromOpId(int opId) = 0;
103 virtual int getOpTypeFromOpId(int opId) = 0;
104 virtual IMessagePtr getMessageFromOpId(int opId) = 0;
105 virtual EventMessagingServicePtr getEventFromOpId(int opId) = 0;
106 virtual EventMessagingServicePtr getEventFromHandle(int handle) = 0;
107 virtual void setHandleToOpId(int opId, int handle) = 0;
108 virtual void setMessageToOpId(int opId, IMessagePtr& message) = 0;
109 virtual void setEventToOpId(int opId, EventMessagingServicePtr &event) = 0;
110 virtual int deleteOpId(int opId)=0;
112 virtual int sync(const IMessagingServicePtr& messagingService, const int limit) = 0;
113 virtual void syncCancel(int handle) = 0;
114 virtual int syncFolder(const IMessagingServicePtr& messagingService, const int folder_id, const int limit) = 0;
115 virtual void syncFolderCancel(int handle) = 0;
117 virtual void cancelOperation(int opId, int handle, int eventType, IMessagePtr& message) = 0;
119 void OnCancelEvent(const EventMessagingServicePtr &event);
120 void setMessagingServiceEvent(const EventMessagingServicePtr &event);
121 EventMessagingServicePtr getMessagingServiceEvent() const;
123 void setRequestReceiver(ReqReceiverMessage* reqReceiver)
125 m_requestReceiver = reqReceiver;
128 ReqReceiverMessage* getRequestReceiver() const
130 return m_requestReceiver;
134 short m_messagingServiceType; //type
135 std::string m_messagingServiceName;
136 int m_messagingServiceId;
138 * Request receiver. Used when there are callback funtions assigned at function executing scope
140 ReqReceiverMessage *m_requestReceiver;
143 * Messaging Service event. Used when there are callback funtions assigned at function executing scope
145 EventMessagingServicePtr m_messagingServiceEvent;
150 void setType(int type)
152 m_messagingServiceType = type;
155 void setName(const std::string& name = "" )
157 m_messagingServiceName = name;
160 void setId(int serviceId)
162 m_messagingServiceId = serviceId;
170 #endif //WRTPLUGINS_API_IMESSAGING_SERVICE_H_