--- /dev/null
+//
+// Tizen Web Device API
+// Copyright (c) 2013 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.
+//
+
+#include "common/GDBus/connection.h"
+#include "common/logger.h"
+#include <cstring>
+
+namespace common {
+namespace dbus {
+
+Connection& Connection::getInstance()
+{
+ LoggerD("Entered");
+ static Connection instance;
+ return instance;
+}
+
+GDBusConnection* Connection::getDBus()
+{
+ return m_dbus;
+}
+
+Connection::Connection()
+{
+ m_dbus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &m_error);
+ if (!m_dbus || m_error) {
+ LoggerE("Could not get connection");
+ }
+ LoggerD("Connection set");
+}
+
+Connection::~Connection()
+{
+ g_object_unref(m_dbus);
+}
+
+} //namespace dbus
+} //namespace common
--- /dev/null
+//
+// Tizen Web Device API
+// Copyright (c) 2013 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 __TIZEN_DBUS_CONNECTION_H__
+#define __TIZEN_DBUS_CONNECTION_H__
+
+#include <gio/gio.h>
+
+namespace common {
+namespace dbus {
+
+class Connection {
+public:
+ static Connection& getInstance();
+
+ GDBusConnection* getDBus();
+
+private:
+ Connection();
+ Connection(const Connection&);
+ void operator=(const Connection&);
+ virtual ~Connection();
+
+ GDBusConnection* m_dbus;
+ GError* m_error;
+};
+
+} //namespace dbus
+} //namespace common
+
+#endif
--- /dev/null
+//
+// Tizen Web Device API
+// Copyright (c) 2013 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.
+//
+
+/**
+ * @file proxy.cpp
+ */
+
+#include "common/GDBus/proxy.h"
+#include "common/logger.h"
+#include "common/platform_result.h"
+#include <cstring>
+
+namespace common {
+namespace dbus {
+
+using namespace common;
+
+Proxy::Proxy(const std::string& proxy_path,
+ const std::string& proxy_iface,
+ const std::string& signal_name,
+ const std::string& signal_path,
+ const std::string& signal_iface) :
+ m_conn(Connection::getInstance()),
+ m_sub_id(0),
+ m_path(proxy_path),
+ m_iface(proxy_iface),
+ m_signal_name(signal_name),
+ m_signal_path(signal_path),
+ m_signal_iface(signal_iface),
+ m_error(NULL),
+ m_dbus_signal_subscribed(false)
+{
+ LoggerD("Proxy:\n"
+ " proxy_path: %s\n proxy_iface: %s"
+ " signal_name: %s\n signal_path:%s\n signal_iface:%s",
+ m_path.c_str(), m_iface.c_str(),
+ m_signal_name.c_str(), m_signal_path.c_str(), m_signal_iface.c_str());
+
+ const gchar* unique_name = g_dbus_connection_get_unique_name(m_conn.getDBus());
+ LoggerD("Generated unique name: %d", unique_name);
+
+ // path and interface are not obligatory to receive, but
+ // they should be set to send the signals.
+ m_proxy = g_dbus_proxy_new_sync(m_conn.getDBus(),
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ NULL, unique_name, m_path.c_str(), m_iface.c_str(), NULL, &m_error);
+}
+
+Proxy::~Proxy()
+{
+ signalUnsubscribe();
+}
+
+void Proxy::signalCallbackProxy(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ Proxy* this_ptr = static_cast<Proxy*>(user_data);
+ if (!this_ptr) {
+ LoggerW("Proxy is null, nothing to do");
+ return;
+ }
+
+ //It is better to log this only when subclass is responsible of handling
+ //passed signal. If you need it put it into your signalCallback(...) method
+ //LoggerD("signal: %s from: %s path: %s interface: %s",
+ // signal_name, sender_name, object_path, interface_name);
+ this_ptr->signalCallback(connection, sender_name, object_path, interface_name,
+ signal_name, parameters);
+}
+
+void Proxy::signalSubscribe()
+{
+ if(m_dbus_signal_subscribed) {
+ LoggerW("Proxy has already subscribed for listening DBus signal");
+ return;
+ }
+
+ const char* sender = NULL;
+ m_sub_id = g_dbus_connection_signal_subscribe(m_conn.getDBus(),
+ sender,
+ m_signal_iface.c_str(),
+ m_signal_name.c_str(),
+ m_signal_path.c_str(),
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ signalCallbackProxy,
+ static_cast<gpointer>(this),
+ NULL);
+ LoggerD("g_dbus_connection_signal_subscribe returned id: %d", m_sub_id);
+
+ m_dbus_signal_subscribed = true;
+}
+
+void Proxy::signalUnsubscribe()
+{
+ if (!m_dbus_signal_subscribed) {
+ LoggerW("Proxy hasn't subscribed for listening DBus signal");
+ return;
+ }
+
+ g_dbus_connection_signal_unsubscribe(m_conn.getDBus(), m_sub_id);
+ LoggerD("g_dbus_connection_signal_unsubscribe finished");
+
+ m_dbus_signal_subscribed = false;
+}
+
+const std::string& Proxy::getSignalName() const
+{
+ return m_signal_name;
+}
+
+const std::string& Proxy::getSignalPath() const
+{
+ return m_signal_path;
+}
+
+const std::string& Proxy::getSignalInterfaceName() const
+{
+ return m_signal_iface;
+}
+
+} //namespace dbus
+} //namespace common
--- /dev/null
+//
+// Tizen Web Device API
+// Copyright (c) 2013 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.
+//
+
+/**
+ * @file Proxy.h
+ */
+
+#ifndef __TIZEN_DBUS_PROXY_H__
+#define __TIZEN_DBUS_PROXY_H__
+
+#include "common/GDBus/connection.h"
+#include <memory>
+#include <string>
+#include <mutex>
+#include <map>
+#include "common/callback_user_data.h"
+#include "common/picojson.h"
+#include "common/platform_result.h"
+
+namespace common {
+namespace dbus {
+
+
+class Proxy;
+typedef std::shared_ptr<Proxy> ProxyPtr;
+
+/**
+ * This is generic dbus signal listener proxy.
+ */
+class Proxy {
+public:
+
+ virtual ~Proxy();
+ bool isNotProxyGot() { return !m_proxy || m_error; };
+
+ void signalSubscribe();
+ void signalUnsubscribe();
+
+ const std::string& getSignalName() const;
+ const std::string& getSignalPath() const;
+ const std::string& getSignalInterfaceName() const;
+
+protected:
+ /**
+ * @param proxy_path - path of this proxy
+ * @param proxy_iface - interface name of this proxy
+ *
+ * @param signal_name - expected signal name
+ * @param signal_path - expected signal path
+ * @param signal_iface - expected signal interface name
+ */
+ Proxy(const std::string& proxy_path,
+ const std::string& proxy_iface,
+ const std::string& signal_name,
+ const std::string& signal_path,
+ const std::string& signal_iface);
+ /**
+ * Please implement this method in subclass to handle signal.
+ * Executed by static void signalCallbackProxy(...).
+ */
+ virtual void signalCallback(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters) = 0;
+
+private:
+ /**
+ * This method (registered with g_dbus_connection_signal_subscribe) is executed by
+ * DBus when signal is received. It calls
+ * (static_cast<Proxy*>(user_data))->signalCallback(...)
+ */
+
+ static void signalCallbackProxy(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data);
+
+ Connection& m_conn;
+ guint m_sub_id;
+
+ std::string m_path;
+ std::string m_iface;
+
+ std::string m_signal_name;
+ std::string m_signal_path;
+ std::string m_signal_iface;
+
+ GError* m_error;
+ GDBusProxy* m_proxy;
+ bool m_dbus_signal_subscribed;
+};
+
+} //namespace dbus
+} //namespace common
+
+#endif // __TIZEN_DBUS_PROXY_H__
'assert.h',
'virtual_fs.cc',
'virtual_fs.h',
+ 'GDBus/connection.cpp',
+ 'GDBus/connection.h',
+ 'GDBus/proxy.cpp',
+ 'GDBus/proxy.h',
],
'cflags': [
'-fvisibility=default',
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2013 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.
-//
-
-#include "Connection.h"
-#include "common/logger.h"
-#include <cstring>
-#include <email-types.h>
-#include "../message_service.h"
-
-namespace extension {
-namespace messaging {
-namespace DBus {
-
-Connection& Connection::getInstance()
-{
- LoggerD("Entered");
- static Connection instance;
- return instance;
-}
-
-GDBusConnection* Connection::getDBus()
-{
- return m_dbus;
-}
-
-Connection::Connection()
-{
- dbus_g_thread_init();
- g_type_init();
-
- m_dbus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &m_error);
- if (!m_dbus || m_error) {
- LoggerE("Could not get connection");
- }
- LoggerD("Connection set");
-}
-
-Connection::~Connection()
-{
- g_object_unref(m_dbus);
-}
-
-} //namespace DBus
-} //namespace Messaging
-} //namespace DeviceAPI
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2013 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 __TIZEN_DBUS_CONNECTION_H__
-#define __TIZEN_DBUS_CONNECTION_H__
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <gio/gio.h>
-
-namespace extension {
-namespace messaging {
-namespace DBus {
-
-class Connection {
-public:
- static Connection& getInstance();
-
- GDBusConnection* getDBus();
-
-private:
- Connection();
- Connection(const Connection&);
- void operator=(const Connection&);
- virtual ~Connection();
-
- GDBusConnection* m_dbus;
- GError* m_error;
-};
-
-} //namespace DBus
-} //namespace Messaging
-} //namespace DeviceAPI
-
-#endif
--- /dev/null
+//
+// Tizen Web Device API
+// Copyright (c) 2013 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.
+//
+
+#include "messaging/DBus/DBusTypes.h"
+
+namespace extension {
+namespace messaging {
+namespace DBus {
+
+const char* kDBusPathNetworkStatus = "/User/Email/NetworkStatus";
+const char* kDBusIfaceNetworkStatus = "User.Email.NetworkStatus";
+const char* kDBusPathEmailStorageChange = "/User/Email/StorageChange";
+const char* kDBusIfaceEmailStorageChange = "User.Email.StorageChange";
+const char* kDBusNameSignalEmail = "email";
+
+} // namespace DBus
+} // namespace messaging
+} // namespace extension
--- /dev/null
+//
+// Tizen Web Device API
+// Copyright (c) 2013 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.
+//
+
+namespace extension {
+namespace messaging {
+namespace DBus {
+
+/**
+ * List of Tizen path and interface names:
+ */
+extern const char* kDBusPathNetworkStatus;
+extern const char* kDBusIfaceNetworkStatus;
+extern const char* kDBusPathEmailStorageChange;
+extern const char* kDBusIfaceEmailStorageChange;
+/**
+ * Name of email signal
+ */
+extern const char* kDBusNameSignalEmail;
+
+} // namespace DBus
+} // namespace messaging
+} // namespace extension
#include "EmailSignalProxy.h"
#include "common/logger.h"
#include <cstring>
+#include "messaging/DBus/DBusTypes.h"
namespace extension {
namespace messaging {
EmailSignalProxy::EmailSignalProxy(const std::string& proxy_path,
const std::string& proxy_iface) :
- Proxy (proxy_path,
+ common::dbus::Proxy (proxy_path,
proxy_iface,
- Proxy::DBUS_NAME_SIGNAL_EMAIL, //specify email signal details
- DBUS_PATH_NETWORK_STATUS,
- DBUS_IFACE_NETWORK_STATUS)
+ kDBusNameSignalEmail, //specify email signal details
+ kDBusPathNetworkStatus,
+ kDBusIfaceNetworkStatus)
{
}
#ifndef __TIZEN_DBUS_EMAIL_SIGNAL_PROXY_H__
#define __TIZEN_DBUS_EMAIL_SIGNAL_PROXY_H__
-#include "Proxy.h"
+#include "common/GDBus/proxy.h"
namespace extension {
namespace messaging {
class EmailSignalProxy;
typedef std::shared_ptr<EmailSignalProxy> EmailSignalProxyPtr;
-class EmailSignalProxy : public Proxy {
+class EmailSignalProxy : public common::dbus::Proxy {
public:
virtual ~EmailSignalProxy();
//
#include "MessageProxy.h"
-#include "Connection.h"
+#include "common/GDBus/connection.h"
#include "common/logger.h"
#include "../message.h"
#include "../message_email.h"
//#include <MessageFolder.h>
#include "../change_listener_container.h"
#include "../email_manager.h"
+#include "messaging/DBus/DBusTypes.h"
namespace extension {
namespace messaging {
using namespace common;
MessageProxy::MessageProxy():
- Proxy(Proxy::DBUS_PATH_EMAIL_STORAGE_CHANGE,
- Proxy::DBUS_IFACE_EMAIL_STORAGE_CHANGE,
- Proxy::DBUS_NAME_SIGNAL_EMAIL,
- Proxy::DBUS_PATH_EMAIL_STORAGE_CHANGE,
- Proxy::DBUS_IFACE_EMAIL_STORAGE_CHANGE)
+ common::dbus::Proxy(kDBusPathEmailStorageChange,
+ kDBusIfaceEmailStorageChange,
+ kDBusNameSignalEmail,
+ kDBusPathEmailStorageChange,
+ kDBusIfaceEmailStorageChange)
{
}
#include <string>
#include <sstream>
#include <email-types.h>
-#include "Proxy.h"
+#include "common/GDBus/proxy.h"
#include "common/platform_result.h"
namespace extension {
class MessageProxy;
typedef std::shared_ptr<MessageProxy> MessageProxyPtr;
-class MessageProxy: public Proxy {
+class MessageProxy: public common::dbus::Proxy {
public:
virtual ~MessageProxy();
static common::PlatformResult create(MessageProxyPtr* message_proxy);
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2013 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.
-//
-
-/**
- * @file Proxy.cpp
- */
-
-#include "Proxy.h"
-#include "common/logger.h"
-#include "common/platform_result.h"
-#include <cstring>
-#include <email-types.h>
-#include "../message_service.h"
-
-namespace extension {
-namespace messaging {
-namespace DBus {
-
-using namespace common;
-
-const char* Proxy::DBUS_PATH_NETWORK_STATUS = "/User/Email/NetworkStatus";
-const char* Proxy::DBUS_IFACE_NETWORK_STATUS = "User.Email.NetworkStatus";
-const char* Proxy::DBUS_PATH_EMAIL_STORAGE_CHANGE = "/User/Email/StorageChange";
-const char* Proxy::DBUS_IFACE_EMAIL_STORAGE_CHANGE = "User.Email.StorageChange";
-const char* Proxy::DBUS_NAME_SIGNAL_EMAIL = "email";
-
-Proxy::Proxy(const std::string& proxy_path,
- const std::string& proxy_iface,
- const std::string& signal_name,
- const std::string& signal_path,
- const std::string& signal_iface) :
- m_conn(Connection::getInstance()),
- m_sub_id(0),
- m_path(proxy_path),
- m_iface(proxy_iface),
- m_signal_name(signal_name),
- m_signal_path(signal_path),
- m_signal_iface(signal_iface),
- m_error(NULL),
- m_dbus_signal_subscribed(false)
-{
- LoggerD("Proxy:\n"
- " proxy_path: %s\n proxy_iface: %s"
- " signal_name: %s\n signal_path:%s\n signal_iface:%s",
- m_path.c_str(), m_iface.c_str(),
- m_signal_name.c_str(), m_signal_path.c_str(), m_signal_iface.c_str());
-
- const gchar* unique_name = g_dbus_connection_get_unique_name(m_conn.getDBus());
- LoggerD("Generated unique name: %d", unique_name);
-
- // path and interface are not obligatory to receive, but
- // they should be set to send the signals.
- m_proxy = g_dbus_proxy_new_sync(m_conn.getDBus(),
- G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
- NULL, unique_name, m_path.c_str(), m_iface.c_str(), NULL, &m_error);
-}
-
-Proxy::~Proxy()
-{
- signalUnsubscribe();
-}
-
-void Proxy::signalCallbackProxy(GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
-{
- Proxy* this_ptr = static_cast<Proxy*>(user_data);
- if (!this_ptr) {
- LoggerW("Proxy is null, nothing to do");
- return;
- }
-
- //It is better to log this only when subclass is responsible of handling
- //passed signal. If you need it put it into your signalCallback(...) method
- //LoggerD("signal: %s from: %s path: %s interface: %s",
- // signal_name, sender_name, object_path, interface_name);
- this_ptr->signalCallback(connection, sender_name, object_path, interface_name,
- signal_name, parameters);
-}
-
-void Proxy::signalSubscribe()
-{
- if(m_dbus_signal_subscribed) {
- LoggerW("Proxy has already subscribed for listening DBus signal");
- return;
- }
-
- const char* sender = NULL;
- m_sub_id = g_dbus_connection_signal_subscribe(m_conn.getDBus(),
- sender,
- m_signal_iface.c_str(),
- m_signal_name.c_str(),
- m_signal_path.c_str(),
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- signalCallbackProxy,
- static_cast<gpointer>(this),
- NULL);
- LoggerD("g_dbus_connection_signal_subscribe returned id: %d", m_sub_id);
-
- m_dbus_signal_subscribed = true;
-}
-
-void Proxy::signalUnsubscribe()
-{
- if (!m_dbus_signal_subscribed) {
- LoggerW("Proxy hasn't subscribed for listening DBus signal");
- return;
- }
-
- g_dbus_connection_signal_unsubscribe(m_conn.getDBus(), m_sub_id);
- LoggerD("g_dbus_connection_signal_unsubscribe finished");
-
- m_dbus_signal_subscribed = false;
-}
-
-const std::string& Proxy::getSignalName() const
-{
- return m_signal_name;
-}
-
-const std::string& Proxy::getSignalPath() const
-{
- return m_signal_path;
-}
-
-const std::string& Proxy::getSignalInterfaceName() const
-{
- return m_signal_iface;
-}
-
-} //namespace DBus
-} //namespace Messaging
-} //namespace DeviceAPI
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2013 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.
-//
-
-/**
- * @file Proxy.h
- */
-
-#ifndef __TIZEN_DBUS_PROXY_H__
-#define __TIZEN_DBUS_PROXY_H__
-
-#include "Connection.h"
-#include <memory>
-#include <string>
-#include <mutex>
-#include <map>
-#include "common/callback_user_data.h"
-#include "common/picojson.h"
-#include "common/platform_result.h"
-#include "../messaging_instance.h"
-
-namespace extension {
-namespace messaging {
-namespace DBus {
-
-
-class Proxy;
-typedef std::shared_ptr<Proxy> ProxyPtr;
-
-/**
- * This is generic dbus signal listener proxy.
- */
-class Proxy {
-public:
- /**
- * List of Tizen path and interface names:
- */
- static const char* DBUS_PATH_NETWORK_STATUS;
- static const char* DBUS_IFACE_NETWORK_STATUS;
- static const char* DBUS_PATH_EMAIL_STORAGE_CHANGE;
- static const char* DBUS_IFACE_EMAIL_STORAGE_CHANGE;
- /**
- * Name of email signal
- */
- static const char* DBUS_NAME_SIGNAL_EMAIL;
- virtual ~Proxy();
- bool isNotProxyGot() { return !m_proxy || m_error; };
-
- void signalSubscribe();
- void signalUnsubscribe();
-
- const std::string& getSignalName() const;
- const std::string& getSignalPath() const;
- const std::string& getSignalInterfaceName() const;
-
-protected:
- /**
- * @param proxy_path - path of this proxy
- * @param proxy_iface - interface name of this proxy
- *
- * @param signal_name - expected signal name
- * @param signal_path - expected signal path
- * @param signal_iface - expected signal interface name
- */
- Proxy(const std::string& proxy_path,
- const std::string& proxy_iface,
- const std::string& signal_name,
- const std::string& signal_path,
- const std::string& signal_iface);
- /**
- * Please implement this method in subclass to handle signal.
- * Executed by static void signalCallbackProxy(...).
- */
- virtual void signalCallback(GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters) = 0;
-
-private:
- /**
- * This method (registered with g_dbus_connection_signal_subscribe) is executed by
- * DBus when signal is received. It calls
- * (static_cast<Proxy*>(user_data))->signalCallback(...)
- */
-
- static void signalCallbackProxy(GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data);
-
- Connection& m_conn;
- guint m_sub_id;
-
- std::string m_path;
- std::string m_iface;
-
- std::string m_signal_name;
- std::string m_signal_path;
- std::string m_signal_iface;
-
- GError* m_error;
- GDBusProxy* m_proxy;
- bool m_dbus_signal_subscribed;
-};
-
-} //namespace DBus
-} //namespace Messaging
-} //namespace DeviceAPI
-
-#endif // __TIZEN_DBUS_PROXY_H__
#include <email-types.h>
#include "../email_manager.h"
+#include "messaging/DBus/DBusTypes.h"
namespace extension {
namespace messaging {
using namespace common;
SendProxy::SendProxy():
- EmailSignalProxy(Proxy::DBUS_PATH_NETWORK_STATUS,
- Proxy::DBUS_IFACE_NETWORK_STATUS)
+ EmailSignalProxy(kDBusPathNetworkStatus,
+ kDBusIfaceNetworkStatus)
{
}
case NOTI_DOWNLOAD_FAIL:
{
LoggerD("Sync failed!");
- common::UnknownException err("Sync failed!");
- callback->setError(err.name(), err.message());
+ callback->setError("UnknownError", "Sync failed!");
callback->getQueue().resolve(
obj.at(JSON_CALLBACK_ID).get<double>(),
response->serialize()
#include "MsgCommon/FilterIterator.h"
#include "common/scope_exit.h"
+#include "messaging/DBus/DBusTypes.h"
using namespace common;
using namespace extension::tizen;
instance.m_slot_size = slot_size;
}
- PlatformResult ret = DBus::SyncProxy::create(DBus::Proxy::DBUS_PATH_NETWORK_STATUS,
- DBus::Proxy::DBUS_IFACE_NETWORK_STATUS,
+ PlatformResult ret = DBus::SyncProxy::create(DBus::kDBusPathNetworkStatus,
+ DBus::kDBusIfaceNetworkStatus,
&instance.m_proxy_sync);
CHECK_ERROR(ret, "create sync proxy failed");
if (!instance.m_proxy_sync) {
}
instance.m_proxy_sync->signalSubscribe();
- ret = DBus::LoadBodyProxy::create(DBus::Proxy::DBUS_PATH_NETWORK_STATUS,
- DBus::Proxy::DBUS_IFACE_NETWORK_STATUS,
+ ret = DBus::LoadBodyProxy::create(DBus::kDBusPathNetworkStatus,
+ DBus::kDBusIfaceNetworkStatus,
&instance.m_proxy_load_body);
CHECK_ERROR(ret, "create load body proxy failed");
if (!instance.m_proxy_load_body) {
#include "email-api-mailbox.h"
#include "common/callback_user_data.h"
+#include "common/GDBus/connection.h"
#include "common/platform_exception.h"
#include "common/platform_result.h"
#include "messaging_util.h"
#include "message_service.h"
-#include "DBus/Connection.h"
#include "DBus/SyncProxy.h"
#include "DBus/LoadBodyProxy.h"
#include "DBus/LoadAttachmentProxy.h"
'find_msg_callback_user_data.h',
'messaging_database_manager.cc',
'messaging_databese_manager.h',
- 'DBus/Connection.cpp',
- 'DBus/Connection.h',
'DBus/EmailSignalProxy.cpp',
'DBus/EmailSignalProxy.h',
'DBus/LoadAttachmentProxy.cpp',
'DBus/LoadBodyProxy.h',
'DBus/MessageProxy.cpp',
'DBus/MessageProxy.h',
- 'DBus/Proxy.cpp',
- 'DBus/Proxy.h',
'DBus/SendProxy.cpp',
'DBus/SendProxy.h',
'DBus/SyncProxy.cpp',
'DBus/SyncProxy.h',
+ 'DBus/DBusTypes.h',
+ 'DBus/DBusTypes.cpp',
'MsgCommon/Any.cpp',
'MsgCommon/Any.h',
'MsgCommon/AbstractFilter.cpp',