Implemented new type of message - message_config_user_name 32/190932/2
authorKrzysztof Wieclaw <k.wieclaw@samsung.com>
Tue, 9 Oct 2018 11:39:57 +0000 (13:39 +0200)
committerKrzysztof Wieclaw <k.wieclaw@samsung.com>
Tue, 23 Oct 2018 12:09:47 +0000 (14:09 +0200)
Change-Id: I12971372aa90a14bd38dfdd1d3f8f8cc430c4f95
Signed-off-by: Krzysztof Wieclaw <k.wieclaw@samsung.com>
.cproject
inc/messages/message.h
inc/messages/message_config_user_name.h [new file with mode: 0644]
src/messages/message_config_user_name.c [new file with mode: 0644]

index 3c9c23e..18ba695 100644 (file)
--- a/.cproject
+++ b/.cproject
@@ -16,7 +16,7 @@
                                </extensions>
                        </storageModule>
                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-                               <configuration artifactName="org.tizen.gear-racing-controller-ssa" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1322065053" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
+                               <configuration artifactName="org.tizen.gear-racing-controller-sb" buildArtefactType="org.tizen.nativecore.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.tizen.nativecore.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;" id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1322065053" name="Debug" parent="org.tizen.nativecore.config.sbi.gcc45.app.debug">
                                        <folderInfo id="org.tizen.nativecore.config.sbi.gcc45.app.debug.1322065053." name="/" resourcePath="">
                                                <toolChain id="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug.1847471508" name="Tizen Native Toolchain" superClass="org.tizen.nativecore.toolchain.sbi.gcc45.app.debug">
                                                        <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.328737878" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/lib/glib-2.0/include&quot;"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_cflags.core.398744298" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.core" valueType="stringList">
-                                                                       <listOptionValue builtIn="false" value="${TC_COMPILER_MISC}"/>
-                                                                       <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
+                                                                       <listOptionValue builtIn="false" value="$(TC_COMPILER_MISC)"/>
+                                                                       <listOptionValue builtIn="false" value="$(RS_COMPILER_MISC)"/>
                                                                        <listOptionValue builtIn="false" value=" -fPIE"/>
-                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;$(SBI_SYSROOT)&quot;"/>
                                                                        <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
                                                                <option id="gnu.c.compiler.option.include.paths.321037953" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.544193418" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.1152050479" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.2074193141" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
-                                                                       <listOptionValue builtIn="false" value="${TC_LINKER_MISC}"/>
-                                                                       <listOptionValue builtIn="false" value="${RS_LINKER_MISC}"/>
+                                                                       <listOptionValue builtIn="false" value="$(TC_LINKER_MISC)"/>
+                                                                       <listOptionValue builtIn="false" value="$(RS_LINKER_MISC)"/>
                                                                        <listOptionValue builtIn="false" value="-pie -lpthread "/>
-                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;${PROJ_PATH}/.exportMap&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-L&quot;${SBI_SYSROOT}/usr/lib&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="--sysroot=&quot;$(SBI_SYSROOT)&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-Xlinker --version-script=&quot;$(PROJ_PATH)/.exportMap&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="-L&quot;$(SBI_SYSROOT)/usr/lib&quot;"/>
                                                                        <listOptionValue builtIn="false" value="$(RS_LIBRARIES)"/>
                                                                </option>
                                                                <option id="gnu.cpp.link.option.paths.83999257" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
index d4a2d96..2cf653e 100644 (file)
@@ -31,7 +31,8 @@ typedef enum message_type {
        MESSAGE_KEEP_ALIVE,       /** Keep alive request */
        MESSAGE_ACK,              /** Message delivery confirmation */
        MESSAGE_COMMAND,          /** Message with command data */
-       MESSAGE_BYE               /** Connection end request */
+       MESSAGE_BYE,              /** Connection end request */
+       MESSAGE_CONFIG_USER_NAME  /** User name to be set */
 } message_type_e;
 
 #define IP_ADDRESS_LEN 15
diff --git a/inc/messages/message_config_user_name.h b/inc/messages/message_config_user_name.h
new file mode 100644 (file)
index 0000000..d8ddd93
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 MESSAGE_CONFIG_USER_NAME_H
+#define MESSAGE_CONFIG_USER_NAME_H
+
+#include "messages/message.h"
+
+/**
+ * @brief Config user name message data
+ */
+typedef struct message_config_user_name {
+       message_t base;        /** Base class */
+       char *user_name; /** User name */
+} message_config_user_name_t;
+
+/**
+ * @brief Initializes message_config_user_name_t object.
+ *
+ * @param[in] message config user name message.
+ */
+void message_config_user_name_init(message_config_user_name_t *message);
+
+/**
+ * @brief Get name from mesage.
+ *
+ * @param[in] message config user name message.
+ *
+ * @return Const pointer to name.
+ */
+const char *message_config_user_name_get_name(message_config_user_name_t *message);
+
+/**
+ * @brief Set name for message.
+ *
+ * @param[in] message config user name message.
+ * @param[in] name name to be set.
+ */
+void message_config_user_name_set_name(message_config_user_name_t *message, const char *name);
+
+/**
+ * @brief Destroys message_config_user_name_t object.
+ *
+ * @param[in] message message.
+ */
+void message_config_user_name_destroy(message_config_user_name_t *message);
+
+/**
+ * @brief Deserializes message_config_user_name_t from reader's buffer.
+ *
+ * @param[in] message config user name message.
+ * @param[in] reader reader object.
+ *
+ * @return 0 on success, other value on failure.
+ */
+int message_config_user_name_deserialize(message_config_user_name_t *message, reader_t *reader);
+
+/**
+ * @brief Serializes message_config_user_name_t into writer's buffer.
+ *
+ * @param[in] message config user name message.
+ * @param[in] writer writer object.
+ *
+ * @return 0 on success, other value on failure.
+ */
+int message_config_user_name_serialize(message_config_user_name_t *message, writer_t *writer);
+
+#endif /* end of include guard: MESSAGE_CONFIG_USER_NAME_H */
diff --git a/src/messages/message_config_user_name.c b/src/messages/message_config_user_name.c
new file mode 100644 (file)
index 0000000..49b2728
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 MESSAGE_CONFIG_USER_NAME_C
+#define MESSAGE_CONFIG_USER_NAME_C
+
+#include "messages/message_config_user_name.h"
+
+#include <string.h>
+#include "messages/macros.h"
+
+static int _message_config_user_name_serialze_vcall(message_t *msg, writer_t *writer)
+{
+       message_config_user_name_t *command_msg = container_of(msg, message_config_user_name_t, base);
+       return message_config_user_name_serialize(command_msg, writer);
+}
+
+static int _message_config_user_name_deserialize_vcall(message_t *msg, reader_t *reader)
+{
+       message_config_user_name_t *command_msg = container_of(msg, message_config_user_name_t, base);
+       return message_config_user_name_deserialize(command_msg, reader);
+}
+
+static void _message_config_user_name_destroy_vcall(message_t *msg)
+{
+       message_config_user_name_t *command_msg = container_of(msg, message_config_user_name_t, base);
+       message_config_user_name_destroy(command_msg);
+}
+
+void message_config_user_name_init(message_config_user_name_t *message)
+{
+       message_base_init(&message->base);
+
+       message_set_type(&message->base, MESSAGE_CONFIG_USER_NAME);
+
+       message->base.vtable.serialize = _message_config_user_name_serialze_vcall;
+       message->base.vtable.deserialize = _message_config_user_name_deserialize_vcall;
+       message->base.vtable.destroy = _message_config_user_name_destroy_vcall;
+
+       message->user_name = NULL;
+}
+
+void message_config_user_name_destroy(message_config_user_name_t *message)
+{
+       free((void*)message->user_name);
+       message->user_name = NULL;
+       message_base_destroy(&message->base);
+}
+
+int message_config_user_name_deserialize(message_config_user_name_t *message, reader_t *reader)
+{
+       int err = 0;
+
+       err |= message_base_deserialize(&message->base, reader);
+       err |= reader_read_string(reader, &message->user_name);
+
+       return err;
+}
+
+int message_config_user_name_serialize(message_config_user_name_t *message, writer_t *writer)
+{
+       int err = 0;
+
+       err |= message_base_serialize(&message->base, writer);
+       err |= writer_write_string(writer, message->user_name);
+
+       return err;
+}
+
+const char *message_config_user_name_get_name(message_config_user_name_t *message)
+{
+       return message->user_name;
+}
+
+void message_config_user_name_set_name(message_config_user_name_t *message, const char *name)
+{
+       free((void*)message->user_name);
+       message->user_name = strdup(name);
+}
+
+#endif /* end of include guard: MESSAGE_CONFIG_USER_NAME_C */