summaryrefslogtreecommitdiff
path: root/mobile_src/Messaging/MailSender.h
diff options
context:
space:
mode:
Diffstat (limited to 'mobile_src/Messaging/MailSender.h')
-rwxr-xr-xmobile_src/Messaging/MailSender.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/mobile_src/Messaging/MailSender.h b/mobile_src/Messaging/MailSender.h
new file mode 100755
index 0000000..f469969
--- /dev/null
+++ b/mobile_src/Messaging/MailSender.h
@@ -0,0 +1,80 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef MAILSENDER_H_
+#define MAILSENDER_H_
+
+#include <map>
+#include <dpl/event/event_listener.h>
+#include <dpl/thread.h>
+#include <dpl/scoped_ptr.h>
+#include "DBus/Connection.h"
+#include "DBus/MessageEvent.h"
+#include "IEmail.h"
+
+namespace DeviceAPI {
+namespace Messaging {
+
+// TODO Not thread-safe, make it.
+class MailSender : private DPL::Event::EventListener<DBus::MessageEvent>
+{
+ public:
+ static MailSender& getInstance();
+
+ public:
+ int send(const IEmailPtr& mail);
+ void cancel(int handle);
+
+ protected:
+ void OnEventReceived(const DBus::MessageEvent& event);
+
+ private:
+ struct SendRequestData
+ {
+ int handle;
+ IEmailPtr mail;
+
+ explicit SendRequestData(const IEmailPtr& mail) :
+ handle(0),
+ mail(mail)
+ {
+ }
+ explicit SendRequestData(const int handle, const IEmailPtr& mail) :
+ handle(handle),
+ mail(mail)
+ {
+ }
+ };
+
+ typedef std::map<int, SendRequestData> SendRequests;
+ typedef SendRequests::iterator SendRequestsIterator;
+
+ private:
+ MailSender();
+ ~MailSender();
+
+ int sendInternal(const IEmailPtr& data);
+ void cancelInternal(const SendRequestData& data);
+ int getHandle(int mailId);
+
+ DPL::ScopedPtr<DPL::Thread> m_dbusThread;
+ DBus::ConnectionPtr m_dbus;
+ SendRequests m_requests;
+};
+}
+}
+#endif // MAILSENDER_H_