using namespace ttm::loader;
-extern "C" EXPORT_API int theme_get_id(theme_h handle, char **id) {
+extern "C" EXPORT_API int theme_get_id(theme_h handle, char** id) {
if (handle == nullptr || id == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
return THEME_MANAGER_ERROR_NONE;
}
-extern "C" EXPORT_API int theme_get_version(theme_h handle, char **ver) {
+extern "C" EXPORT_API int theme_get_version(theme_h handle, char** ver) {
if (handle == nullptr || ver == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
return THEME_MANAGER_ERROR_NONE;
}
-extern "C" EXPORT_API int theme_get_tool_version(theme_h handle, char **ver) {
+extern "C" EXPORT_API int theme_get_tool_version(theme_h handle, char** ver) {
if (handle == nullptr || ver == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
return THEME_MANAGER_ERROR_NONE;
}
-extern "C" EXPORT_API int theme_get_title(theme_h handle, char **title) {
+extern "C" EXPORT_API int theme_get_title(theme_h handle, char** title) {
if (handle == nullptr || title == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
return THEME_MANAGER_ERROR_NONE;
}
-extern "C" EXPORT_API int theme_get_resolution(
- theme_h handle, char **resolution) {
+extern "C" EXPORT_API int theme_get_resolution(theme_h handle,
+ char** resolution) {
if (handle == nullptr || resolution == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
return THEME_MANAGER_ERROR_NONE;
}
-extern "C" EXPORT_API int theme_get_preview(theme_h handle, char **preview) {
+extern "C" EXPORT_API int theme_get_preview(theme_h handle, char** preview) {
if (handle == nullptr || preview == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
}
extern "C" EXPORT_API int theme_get_description(
- theme_h handle, char **description) {
+ theme_h handle, char** description) {
if (handle == nullptr || description == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
}
extern "C" EXPORT_API int theme_get_string(theme_h handle,
- const char *key, char **val) {
+ const char* key, char** val) {
if (handle == nullptr || key == nullptr || val == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
LOG(ERROR) << "Failed to get string with given key";
return THEME_MANAGER_IO_ERROR;
}
- char *value_raw = strdup(value.c_str());
+ char* value_raw = strdup(value.c_str());
if (value_raw == nullptr) {
LOG(ERROR) << "Out of memory";
return THEME_MANAGER_OUT_OF_MEMORY;
}
extern "C" EXPORT_API int theme_get_string_array(theme_h handle,
- const char *key, char ***val, int *cnt) {
+ const char* key, char*** val, int* cnt) {
if (handle == nullptr || key == nullptr ||
val == nullptr || cnt == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_ERROR_NONE;
}
- char **values_raw = static_cast<char**>(
+ char** values_raw = static_cast<char**>(
calloc(values.size(), sizeof(*values_raw)));
if (values_raw == nullptr) {
LOG(ERROR) << "Out of memory";
return THEME_MANAGER_ERROR_NONE;
}
-extern "C" EXPORT_API int theme_get_int(theme_h handle,
- const char *key, int *val) {
+extern "C" EXPORT_API int theme_get_int(theme_h handle, const char* key,
+ int* val) {
if (handle == nullptr || key == nullptr || val == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
return THEME_MANAGER_ERROR_NONE;
}
-extern "C" EXPORT_API int theme_get_float(theme_h handle,
- const char *key, float *val) {
+extern "C" EXPORT_API int theme_get_float(theme_h handle, const char* key,
+ float* val) {
if (handle == nullptr || key == nullptr || val == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
return THEME_MANAGER_ERROR_NONE;
}
-extern "C" EXPORT_API int theme_get_bool(theme_h handle,
- const char *key, bool *val) {
+extern "C" EXPORT_API int theme_get_bool(theme_h handle, const char* key,
+ bool* val) {
if (handle == nullptr || key == nullptr || val == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
return THEME_MANAGER_ERROR_NONE;
}
-extern "C" EXPORT_API int theme_clone(theme_h handle, theme_h *new_handle) {
+extern "C" EXPORT_API int theme_clone(theme_h handle, theme_h* new_handle) {
if (handle == nullptr || new_handle == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
} // namespace
-extern "C" EXPORT_API int theme_loader_create(theme_loader_h *handle) {
+extern "C" EXPORT_API int theme_loader_create(theme_loader_h* handle) {
if (handle == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
}
extern "C" EXPORT_API int theme_loader_load(theme_loader_h handle,
- const char *id, theme_h* theme) {
+ const char* id, theme_h* theme) {
if (handle == nullptr || id == nullptr || theme == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
}
extern "C" EXPORT_API int theme_loader_query_id(theme_loader_h handle,
- char ***ids, int *count) {
+ char*** ids, int* count) {
if (handle == nullptr) {
LOG(ERROR) << "Invalid parameter";
return THEME_MANAGER_INVALID_PARAMETER;
auto* p = static_cast<ThemeInfoLoader*>(handle);
std::vector<std::string> id_list = p->QueryThemeId();
- char **ids_raw = static_cast<char **>(
+ char** ids_raw = static_cast<char**>(
calloc(id_list.size(), sizeof(*ids_raw)));
if (ids_raw == nullptr) {
LOG(ERROR) << "Out of memory";
int idx = 0;
for (auto& id : id_list) {
- char *id_char = strdup(id.c_str());
+ char* id_char = strdup(id.c_str());
if (id_char == nullptr) {
LOG(ERROR) << "Out of memory";
for (int i = 0; i < idx; i++)
extern "C" EXPORT_API int theme_loader_add_event(theme_loader_h handle,
theme_loader_loaded_cb loaded, theme_loader_unloaded_cb unloaded,
- void *data, theme_loader_event_h* event_h) {
+ void* data, theme_loader_event_h* event_h) {
if (handle == nullptr || loaded == nullptr ||
unloaded == nullptr || event_h == nullptr) {
LOG(ERROR) << "Invalid parameter";
#include "theme/dbus/request_broker.h"
#include "theme/utils/logging.h"
-#define THEME_MANAGER_DBUS_NAME "org.tizen.theme_manager"
-#define THEME_MANAGER_INTERFACE_NAME "org.tizen.theme_manager"
-#define THEME_MANAGER_OBJECT_PATH "/org/tizen/theme_manager"
+namespace {
+const char kDbusBusName[] = "tizen.theme_manager";
+const char kDbusInterfaceName[] = "org.tizen.theme_manager";
+const char kDbusObjectPath[] = "/org/tizen/theme_manager";
+const char kDBusMethodSendData[] = "SendData";
+
+}
namespace ttm {
namespace dbus {
-void RequestBroker::OnReceiveDbusMethod(GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data) {
+void RequestBroker::OnReceiveDbusMethod(GDBusConnection* connection,
+ const gchar* sender, const gchar* object_path, const gchar* interface_name,
+ const gchar* method_name, GVariant* parameters,
+ GDBusMethodInvocation* invocation, gpointer user_data) {
RequestBroker* broker = static_cast<RequestBroker*>(user_data);
- GVariant *reply_body = nullptr;
+ GVariant* reply_body = nullptr;
int command;
- char *serialized = nullptr;
+ char* serialized = nullptr;
g_variant_get(parameters, "(i&s)", &command, &serialized);
Command cmd = static_cast<Command>(command);
reinterpret_cast<char*>(data.ToRaw().first.get()));
result = g_dbus_connection_emit_signal(connection_,
- nullptr,
- THEME_MANAGER_OBJECT_PATH,
- THEME_MANAGER_INTERFACE_NAME,
- signal_name.c_str(), serialized, &err);
+ nullptr, kDbusObjectPath, kDbusInterfaceName, signal_name.c_str(),
+ serialized, &err);
if (result == FALSE) {
LOG(ERROR) << "g_dbus_connection_emit_signal() is failed";
if (err != nullptr) {
nullptr
};
gchar introspection_xml[] =
- " <node>"
+ "<node>"
" <interface name='org.tizen.theme_manager'>"
- " <method name='SendData'>"
- " <arg type='i' name='command' direction='in'/>"
- " <arg type='s' name='serialized' direction='in'/>"
- " <arg type='i' name='command' direction='out'/>"
- " <arg type='s' name='serialized' direction='out'/>"
- " </method>"
+ " <method name='SendData'>"
+ " <arg type='i' name='command' direction='in'/>"
+ " <arg type='s' name='serialized' direction='in'/>"
+ " <arg type='i' name='command' direction='out'/>"
+ " <arg type='s' name='serialized' direction='out'/>"
+ " </method>"
" </interface>"
- " </node>";
- GError *error = nullptr;
- GDBusNodeInfo *introspection_data =
+ "</node>";
+ GError* error = nullptr;
+ GDBusNodeInfo* introspection_data =
g_dbus_node_info_new_for_xml(introspection_xml, &error);
if (!introspection_data) {
LOG(ERROR) << "g_dbus_node_info_new_for_xml is failed";
}
registration_id_ = g_dbus_connection_register_object(
- connection_,
- THEME_MANAGER_OBJECT_PATH, introspection_data->interfaces[0],
+ connection_, kDbusObjectPath, introspection_data->interfaces[0],
&interface_vtable, this, nullptr, nullptr);
g_dbus_node_info_unref(introspection_data);
if (registration_id_ == 0) {
}
int owner_id = g_bus_own_name_on_connection(connection_,
- THEME_MANAGER_DBUS_NAME,
- G_BUS_NAME_OWNER_FLAGS_NONE,
- nullptr, nullptr,
- nullptr, nullptr);
+ kDbusBusName, G_BUS_NAME_OWNER_FLAGS_NONE,
+ nullptr, nullptr, nullptr, nullptr);
if (!owner_id) {
g_object_unref(connection_);
LOG(ERROR) << "g_bus_own_name_on_connection error";
}
void RequestBroker::OnReceiveDbusSignal(GDBusConnection* connection,
- const gchar* sender_name,
- const gchar* object_path,
- const gchar* interface_name,
- const gchar* signal_name,
- GVariant* parameters,
- void* user_data) {
+ const gchar* sender_name, const gchar* object_path,
+ const gchar* interface_name, const gchar* signal_name,
+ GVariant* parameters, void* user_data) {
RequestBroker* broker = static_cast<RequestBroker*>(user_data);
- char *serialized = nullptr;
+ char* serialized = nullptr;
int command;
g_variant_get(parameters, "(i&s)", &command, &serialized);
bool RequestBroker::Subscribe() {
subscribe_id_ = g_dbus_connection_signal_subscribe(connection_, nullptr,
- THEME_MANAGER_INTERFACE_NAME, nullptr, THEME_MANAGER_OBJECT_PATH, nullptr,
+ kDbusInterfaceName, nullptr, kDbusObjectPath, nullptr,
G_DBUS_SIGNAL_FLAGS_NONE, OnReceiveDbusSignal, this, nullptr);
return subscribe_id_ > 0;
tizen_base::Bundle RequestBroker::SendData(Command cmd,
tizen_base::Bundle& data) {
GError* err = nullptr;
- GDBusMessage* msg = g_dbus_message_new_method_call(
- THEME_MANAGER_DBUS_NAME, THEME_MANAGER_OBJECT_PATH,
- THEME_MANAGER_INTERFACE_NAME, "SendData");
+ GDBusMessage* msg = g_dbus_message_new_method_call(kDbusInterfaceName,
+ kDbusObjectPath, kDbusInterfaceName, kDBusMethodSendData);
if (!msg) {
LOG(ERROR) << "Can't allocate new method call";
return {};
GDBusMessage* reply = g_dbus_connection_send_message_with_reply_sync(
connection_, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE,
-1, nullptr, nullptr, &err);
- GVariant *reply_body = g_dbus_message_get_body(reply);
+ GVariant* reply_body = g_dbus_message_get_body(reply);
int command;
- char *serialized = nullptr;
+ char* serialized = nullptr;
g_variant_get(reply_body, "(i&s)", &command, &serialized);
tizen_base::Bundle result(serialized);
return result;
}
-void RequestBroker::OnResultReceivedCb(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data) {
+void RequestBroker::OnResultReceivedCb(GObject* source_object,
+ GAsyncResult* res, gpointer user_data) {
GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(source_object);
GError* err = nullptr;
GDBusMessage* reply = g_dbus_connection_send_message_with_reply_finish(conn,
}
int command;
- char *serialized = nullptr;
+ char* serialized = nullptr;
GVariant* reply_body = g_dbus_message_get_body(reply);
g_variant_get(reply_body, "(i&s)", &command, &serialized);
void RequestBroker::SendDataAsync(Command cmd, tizen_base::Bundle& data) {
GDBusMessage* msg = g_dbus_message_new_method_call(
- THEME_MANAGER_DBUS_NAME, THEME_MANAGER_OBJECT_PATH,
- THEME_MANAGER_INTERFACE_NAME, "SendData");
+ kDbusBusName, kDbusObjectPath, kDbusInterfaceName, kDBusMethodSendData);
if (!msg) {
LOG(ERROR) << "Can't allocate new method call";
return;
}
- g_dbus_message_set_body(msg,
- g_variant_new("(is)",
- static_cast<int>(cmd),
- reinterpret_cast<char*>(data.ToRaw().first.get())));
+ g_dbus_message_set_body(msg, g_variant_new("(is)", static_cast<int>(cmd),
+ reinterpret_cast<char*>(data.ToRaw().first.get())));
g_dbus_connection_send_message_with_reply(connection_, msg,
G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, nullptr,
void SendDataAsync(Command cmd, tizen_base::Bundle&);
private:
- static void OnReceiveDbusMethod(GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data);
+ static void OnReceiveDbusMethod(GDBusConnection* connection,
+ const gchar* sender, const gchar* object_path,
+ const gchar* interface_name, const gchar* method_name,
+ GVariant* parameters, GDBusMethodInvocation* invocation,
+ gpointer user_data);
static void OnReceiveDbusSignal(GDBusConnection* connection,
- const gchar* sender_name,
- const gchar* object_path,
- const gchar* interface_name,
- const gchar* signal_name,
- GVariant* parameters,
- void* user_data);
+ const gchar* sender_name, const gchar* object_path,
+ const gchar* interface_name, const gchar* signal_name,
+ GVariant* parameters, void* user_data);
- static void OnResultReceivedCb(GObject *source_object,
- GAsyncResult *res,
- gpointer user_data);
+ static void OnResultReceivedCb(GObject* source_object,
+ GAsyncResult* res, gpointer user_data);
RequestBroker() = default;
~RequestBroker() = default;
using namespace ttm::loader;
static GDBusMessage* msg;
-static GVariant *gv;
+static GVariant* gv;
static GDBusConnection* __g_bus_get_sync_fake(GBusType type,
- GCancellable *cancel, GError **error) {
- GDBusConnection *con =
- reinterpret_cast<GDBusConnection*>(g_object_new(G_TYPE_OBJECT, NULL));
+ GCancellable* cancel, GError** error) {
+ GDBusConnection* con =
+ reinterpret_cast<GDBusConnection*>(g_object_new(G_TYPE_OBJECT, nullptr));
return con;
}
-void __g_variant_get_fake(GVariant *value, const gchar *format_string,
+void __g_variant_get_fake(GVariant* value, const gchar* format_string,
va_list l) {
}
-GDBusMessage* __g_dbus_message_new_method_call_fake(const gchar *name,
- const gchar *path, const gchar *interface_, const gchar *method) {
+GDBusMessage* __g_dbus_message_new_method_call_fake(const gchar* name,
+ const gchar* path, const gchar* interface_, const gchar* method) {
return msg;
}
-void __g_dbus_message_set_body_fake(GDBusMessage *message, GVariant *body) {
+void __g_dbus_message_set_body_fake(GDBusMessage* message, GVariant* body) {
}
-GVariant* __g_dbus_message_get_body_fake(GDBusMessage *message) {
+GVariant* __g_dbus_message_get_body_fake(GDBusMessage* message) {
return gv;
}
GDBusMessage* __g_dbus_connection_send_message_with_reply_sync_fake(
- GDBusConnection *connection,
- GDBusMessage *message, GDBusSendMessageFlags flags, gint timeout_msec,
- volatile guint32 *out_serial, GCancellable *cancellable, GError **error) {
+ GDBusConnection* connection,
+ GDBusMessage* message, GDBusSendMessageFlags flags, gint timeout_msec,
+ volatile guint32* out_serial, GCancellable* cancellable, GError** error) {
return msg;
}