Fix coding style 54/235254/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Wed, 3 Jun 2020 06:14:00 +0000 (15:14 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Wed, 3 Jun 2020 06:32:35 +0000 (15:32 +0900)
Change-Id: Iab844f1eabd63d8ccca897d48aa43c5ef72aacf2
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/theme/api/theme.cc
src/theme/api/theme_loader.cc
src/theme/dbus/request_broker.cc
src/theme/dbus/request_broker.h
test/unit_tests/test_theme_info_loader.cc

index 6c0bae3..3037bf0 100644 (file)
@@ -40,7 +40,7 @@
 
 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;
@@ -57,7 +57,7 @@ extern "C" EXPORT_API int theme_get_id(theme_h handle, char **id) {
   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;
@@ -74,7 +74,7 @@ extern "C" EXPORT_API int theme_get_version(theme_h handle, char **ver) {
   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;
@@ -91,7 +91,7 @@ extern "C" EXPORT_API int theme_get_tool_version(theme_h handle, char **ver) {
   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;
@@ -108,8 +108,8 @@ extern "C" EXPORT_API int theme_get_title(theme_h handle, char **title) {
   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;
@@ -126,7 +126,7 @@ extern "C" EXPORT_API int theme_get_resolution(
   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;
@@ -144,7 +144,7 @@ extern "C" EXPORT_API int theme_get_preview(theme_h handle, char **preview) {
 }
 
 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;
@@ -162,7 +162,7 @@ extern "C" EXPORT_API int theme_get_description(
 }
 
 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;
@@ -174,7 +174,7 @@ extern "C" EXPORT_API int theme_get_string(theme_h handle,
     LOG(ERROR) << "Failed to get string with given key";
     return THEME_MANAGER_IO_ERROR;
   }
-  char *value_raw = strdup(value.c_str());
+  charvalue_raw = strdup(value.c_str());
   if (value_raw == nullptr) {
     LOG(ERROR) << "Out of memory";
     return THEME_MANAGER_OUT_OF_MEMORY;
@@ -185,7 +185,7 @@ extern "C" EXPORT_API int theme_get_string(theme_h handle,
 }
 
 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";
@@ -200,7 +200,7 @@ extern "C" EXPORT_API int theme_get_string_array(theme_h handle,
     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";
@@ -226,8 +226,8 @@ extern "C" EXPORT_API int theme_get_string_array(theme_h handle,
   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;
@@ -239,8 +239,8 @@ extern "C" EXPORT_API int theme_get_int(theme_h handle,
   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;
@@ -252,8 +252,8 @@ extern "C" EXPORT_API int theme_get_float(theme_h handle,
   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;
@@ -265,7 +265,7 @@ extern "C" EXPORT_API int theme_get_bool(theme_h handle,
   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_hnew_handle) {
   if (handle == nullptr || new_handle == nullptr) {
     LOG(ERROR) << "Invalid parameter";
     return THEME_MANAGER_INVALID_PARAMETER;
index 032d778..524e821 100644 (file)
@@ -65,7 +65,7 @@ class ThemeEventHandler : public IThemeEvent {
 
 }  // namespace
 
-extern "C" EXPORT_API int theme_loader_create(theme_loader_h *handle) {
+extern "C" EXPORT_API int theme_loader_create(theme_loader_hhandle) {
   if (handle == nullptr) {
     LOG(ERROR) << "Invalid parameter";
     return THEME_MANAGER_INVALID_PARAMETER;
@@ -110,7 +110,7 @@ extern "C" EXPORT_API int theme_loader_load_current(theme_loader_h handle,
 }
 
 extern "C" EXPORT_API int theme_loader_load(theme_loader_h handle,
-    const char *id, theme_h* theme) {
+    const charid, theme_h* theme) {
   if (handle == nullptr || id == nullptr || theme == nullptr) {
     LOG(ERROR) << "Invalid parameter";
     return THEME_MANAGER_INVALID_PARAMETER;
@@ -125,7 +125,7 @@ extern "C" EXPORT_API int theme_loader_load(theme_loader_h handle,
 }
 
 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;
@@ -134,7 +134,7 @@ extern "C" EXPORT_API int theme_loader_query_id(theme_loader_h handle,
   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";
@@ -143,7 +143,7 @@ extern "C" EXPORT_API int theme_loader_query_id(theme_loader_h handle,
 
   int idx = 0;
   for (auto& id : id_list) {
-    char *id_char = strdup(id.c_str());
+    charid_char = strdup(id.c_str());
     if (id_char == nullptr) {
       LOG(ERROR) << "Out of memory";
       for (int i = 0; i < idx; i++)
@@ -162,7 +162,7 @@ extern "C" EXPORT_API int theme_loader_query_id(theme_loader_h handle,
 
 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) {
+    voiddata, theme_loader_event_h* event_h) {
   if (handle == nullptr || loaded == nullptr ||
       unloaded == nullptr || event_h == nullptr) {
     LOG(ERROR) << "Invalid parameter";
index 13154c3..fb43986 100644 (file)
 #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;
+  GVariantreply_body = nullptr;
   int command;
-  char *serialized = nullptr;
+  charserialized = nullptr;
   g_variant_get(parameters, "(i&s)", &command, &serialized);
 
   Command cmd = static_cast<Command>(command);
@@ -99,10 +99,8 @@ bool RequestBroker::EmitSignal(std::string signal_name,
       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) {
@@ -122,18 +120,18 @@ bool RequestBroker::Listen() {
     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>";
+  GErrorerror = nullptr;
+  GDBusNodeInfointrospection_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";
@@ -146,8 +144,7 @@ bool RequestBroker::Listen() {
   }
 
   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) {
@@ -156,10 +153,8 @@ bool RequestBroker::Listen() {
   }
 
   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";
@@ -170,14 +165,11 @@ bool RequestBroker::Listen() {
 }
 
 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;
+  charserialized = nullptr;
   int command;
   g_variant_get(parameters, "(i&s)", &command, &serialized);
 
@@ -193,7 +185,7 @@ void RequestBroker::OnReceiveDbusSignal(GDBusConnection* connection,
 
 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;
@@ -202,9 +194,8 @@ bool RequestBroker::Subscribe() {
 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 {};
@@ -218,18 +209,17 @@ tizen_base::Bundle RequestBroker::SendData(Command cmd,
   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);
+  GVariantreply_body = g_dbus_message_get_body(reply);
   int command;
-  char *serialized = nullptr;
+  charserialized = 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,
@@ -240,7 +230,7 @@ void RequestBroker::OnResultReceivedCb(GObject *source_object,
   }
 
   int command;
-  char *serialized = nullptr;
+  charserialized = nullptr;
 
   GVariant* reply_body = g_dbus_message_get_body(reply);
   g_variant_get(reply_body, "(i&s)", &command, &serialized);
@@ -258,17 +248,14 @@ void RequestBroker::OnResultReceivedCb(GObject *source_object,
 
 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,
index 5c92256..39b2779 100644 (file)
@@ -42,26 +42,19 @@ class RequestBroker {
   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;
index d691f20..d31eb0a 100644 (file)
 using namespace ttm::loader;
 
 static GDBusMessage* msg;
-static GVariant *gv;
+static GVariantgv;
 
 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) {
+  GDBusConnectioncon =
+      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 gcharname,
+  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(GDBusMessagemessage) {
   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) {
+  GDBusConnectionconnection,
+  GDBusMessagemessage, GDBusSendMessageFlags flags, gint timeout_msec,
+  volatile guint32* out_serial, GCancellable* cancellable, GError** error) {
   return msg;
 }