-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-
-SET(project_prefix "capi")
-SET(prefix "/usr")
-SET(version "0.0.1")
-SET(maintainer "Wootak Jung<wootak.jung@samsung.com>")
-SET(description "Telephony Core API")
-SET(service "telephony")
-SET(dependents "dlog tapi glib-2.0 \
- capi-base-common openssl1.1 capi-system-info \
- cynara-client cynara-session cynara-creds-self")
-SET(pc_dependents "capi-base-common tapi")
-
-SET(Services
- "application"
- "base"
- "content"
- "location"
- "media"
- "messaging"
- "network"
- "social"
- "telephony"
- "system"
- )
-
-#FILE(STRINGS config.cfg configs REGEX "^ *[^#]")
-FOREACH(lines ${configs})
-# MESSAGE(${lines})
- IF(${lines} MATCHES "([^=]*)=['\"](.*)['\"]")
- SET(key ${CMAKE_MATCH_1})
- SET(value ${CMAKE_MATCH_2})
-# MESSAGE("${key} -> ${value}")
- SET(${key} "${value}")
- ENDIF()
-ENDFOREACH(lines ${configs})
-
-LIST(FIND Services ${service} sfind)
-
-IF( ${sfind} EQUAL -1 )
- MESSAGE(FATAL_ERROR "Service must be one of ")
- FOREACH( s IN ${Services} )
- MESSAGE(FATAL_ERROR "[${s}]")
- ENDFOREACH( s IN ${Services} )
-ENDIF( ${sfind} EQUAL -1 )
-
-SET(fw_name "${project_prefix}-${service}")
-
-PROJECT(${fw_name})
-
-SET(CMAKE_INSTALL_PREFIX ${prefix})
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(LIBDIR ${LIB_INSTALL_DIR})
-SET(VERSION ${version})
-
-SET(INC_DIR include)
-INCLUDE_DIRECTORIES(${INC_DIR})
+CMAKE_MINIMUM_REQUIRED(VERSION 3.9)
+PROJECT(capi-telephony C)
INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_name} REQUIRED ${dependents})
-FOREACH(flag ${${fw_name}_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(ADDITIONAL_CFLAGS "-Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ADDITIONAL_CFLAGS}")
-SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-
-IF("${ARCH}" STREQUAL "arm")
- ADD_DEFINITIONS("-DTARGET")
-ENDIF("${ARCH}" STREQUAL "arm")
-
-ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
-ADD_DEFINITIONS("-DTIZEN_DEBUG")
-
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIBDIR}")
-
-aux_source_directory(src SOURCES)
-ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
-
-TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
-
-SET_TARGET_PROPERTIES(${fw_name}
- PROPERTIES
- VERSION ${FULLVER}
- SOVERSION ${MAJORVER}
- CLEAN_DIRECT_OUTPUT 1
-)
-
-INSTALL(TARGETS ${fw_name} DESTINATION ${LIBDIR})
-INSTALL(
- DIRECTORY ${INC_DIR}/ DESTINATION include/${service}
- FILES_MATCHING
- PATTERN "*_private.h" EXCLUDE
- PATTERN "${INC_DIR}/*.h"
- )
+INCLUDE_DIRECTORIES(common)
+INCLUDE_DIRECTORIES(include)
-SET(PC_NAME ${fw_name})
-SET(PC_REQUIRED ${pc_dependents})
-SET(PC_LDFLAGS -l${fw_name})
+SET(EXTRA_FLAGS "-Wall -Werror -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_FLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS} -std=c++11")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
-CONFIGURE_FILE(
- capi-telephony.pc.in
- ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
- @ONLY
-)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIBDIR}/pkgconfig)
+PKG_CHECK_MODULES(pkgs REQUIRED dlog tapi glib-2.0 capi-base-common openssl1.1
+ capi-system-info cynara-client cynara-session cynara-creds-self)
+INCLUDE_DIRECTORIES(${pkgs_INCLUDE_DIRS})
+LINK_DIRECTORIES(${pkgs_LIBRARY_DIRS})
-#ADD_SUBDIRECTORY(test_src)
+FILE(GLOB SRCS src/*.c)
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LIBRARIES})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
-IF(UNIX)
+FILE(GLOB HEADERS include/*.h)
+INSTALL(FILES ${HEADERS} DESTINATION ${HEADER_DIR})
-ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
-ADD_CUSTOM_COMMAND(
- DEPENDS clean
- COMMENT "distribution clean"
- COMMAND find
- ARGS .
- -not -name config.cmake -and \(
- -name tester.c -or
- -name Testing -or
- -name CMakeFiles -or
- -name cmake.depends -or
- -name cmake.check_depends -or
- -name CMakeCache.txt -or
- -name cmake.check_cache -or
- -name *.cmake -or
- -name Makefile -or
- -name core -or
- -name core.* -or
- -name gmon.out -or
- -name install_manifest.txt -or
- -name *.pc -or
- -name *~ \)
- | grep -v TC | xargs rm -rf
- TARGET distclean
- VERBATIM
-)
+SET(PC_REQUIRES "capi-base-common")
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+INSTALL(FILES ${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-ENDIF(UNIX)
+ADD_SUBDIRECTORY(tests)
\ No newline at end of file
+++ /dev/null
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
-
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+++ /dev/null
-<manifest>
- <request>
- <domain name="_"/>
- </request>
-</manifest>
+libdir=@LIB_INSTALL_DIR@
+includedir=@HEADER_DIR@
-# Package Information for pkg-config
-
-prefix=@PREFIX@
-exec_prefix=/usr
-libdir=@LIBDIR@
-includedir=/usr/include/telephony
-
-Name: @PC_NAME@
-Description: @PACKAGE_DESCRIPTION@
-Version: @VERSION@
-Requires: @PC_REQUIRED@
-Libs: -L${libdir} @PC_LDFLAGS@
+Name: @PROJECT_NAME@
+Description: Telephony Core API
+Version: @FULLVER@
+Requires: @PC_REQUIRES@
+Libs: -L${libdir} -l@PROJECT_NAME@
Cflags: -I${includedir}
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __CAPI_TELEPHONY_PRIVATE_H__
+#define __CAPI_TELEPHONY_PRIVATE_H__
+
+#include <gio/gio.h>
+#include <glib.h>
+#include <system_info.h>
+#include "telephony_common.h"
+#include "telephony_call.h"
+
+#define TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony"
+
+#ifdef API
+#undef API
+#endif
+#define API __attribute__((visibility("default")))
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "CAPI_TELEPHONY"
+
+#define CHECK_INPUT_PARAMETER(arg) \
+ if (arg == NULL) { \
+ LOGE("INVALID_PARAMETER"); \
+ return TELEPHONY_ERROR_INVALID_PARAMETER; \
+ }
+
+#define CHECK_TELEPHONY_SUPPORTED(feature_name) { \
+ bool telephony_supported = FALSE; \
+ if (!system_info_get_platform_bool(feature_name, &telephony_supported)) { \
+ if (telephony_supported == FALSE) { \
+ LOGE("telephony feature is disabled"); \
+ return TELEPHONY_ERROR_NOT_SUPPORTED; \
+ } \
+ } else { \
+ LOGE("Error - Feature getting from System Info"); \
+ return TELEPHONY_ERROR_OPERATION_FAILED; \
+ } \
+}
+
+/**
+ * @brief Definition for the max length of call number
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ */
+#define TELEPHONY_CALL_NUMBER_LEN_MAX 82
+
+typedef struct {
+ GSList *evt_list;
+ struct tapi_handle *tapi_h;
+} telephony_data;
+
+/*
+ * Need to define the struct same as tapi_handle of libslp-tapi
+ * because we are request dbus directly using dbus_connection, path
+ */
+struct tapi_handle {
+ gpointer dbus_connection;
+ char *path;
+ char *cp_name;
+ GHashTable *evt_list;
+ GCancellable *ca;
+
+ GHashTable *cache_property;
+ guint prop_callback_evt_id;
+};
+
+/**
+ * @brief The structure type for the call information.
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ */
+typedef struct {
+ unsigned int id; /**< The handle of the call */
+ char number[TELEPHONY_CALL_NUMBER_LEN_MAX + 1]; /**< Calling number */
+ telephony_call_type_e type; /**< Type of call (voice, video, emergency) */
+ telephony_call_status_e status; /**< Call Status */
+ telephony_call_direction_e direction; /**< Call direction (MO, MT) */
+ bool conference_status; /**< true: Conference call, false: Single call */
+} telephony_call_info_s;
+
+/**
+ * @brief Check if the caller process has a privilege.
+ * @return @c 1 when the caller has the privilege,
+ * otherwise 0
+ */
+bool telephony_check_legacy_telephony_privilege();
+
+#endif /* __CAPI_TELEPHONY_PRIVATE_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __CAPI_TELEPHONY_PRIVATE_H__
-#define __CAPI_TELEPHONY_PRIVATE_H__
-
-#include <gio/gio.h>
-#include <glib.h>
-#include <system_info.h>
-#include "telephony_common.h"
-#include "telephony_call.h"
-
-#define TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "CAPI_TELEPHONY"
-
-#define CHECK_INPUT_PARAMETER(arg) \
- if (arg == NULL) { \
- LOGE("INVALID_PARAMETER"); \
- return TELEPHONY_ERROR_INVALID_PARAMETER; \
- }
-
-#define CHECK_TELEPHONY_SUPPORTED(feature_name) { \
- bool telephony_supported = FALSE; \
- if (!system_info_get_platform_bool(feature_name, &telephony_supported)) { \
- if (telephony_supported == FALSE) { \
- LOGE("telephony feature is disabled"); \
- return TELEPHONY_ERROR_NOT_SUPPORTED; \
- } \
- } else { \
- LOGE("Error - Feature getting from System Info"); \
- return TELEPHONY_ERROR_OPERATION_FAILED; \
- } \
-}
-
-/**
- * @brief Definition for the max length of call number
- * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
- */
-#define TELEPHONY_CALL_NUMBER_LEN_MAX 82
-
-typedef struct {
- GSList *evt_list;
- struct tapi_handle *tapi_h;
-} telephony_data;
-
-/*
- * Need to define the struct same as tapi_handle of libslp-tapi
- * because we are request dbus directly using dbus_connection, path
- */
-struct tapi_handle {
- gpointer dbus_connection;
- char *path;
- char *cp_name;
- GHashTable *evt_list;
- GCancellable *ca;
-
- GHashTable *cache_property;
- guint prop_callback_evt_id;
-};
-
-/**
- * @brief The structure type for the call information.
- * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
- */
-typedef struct {
- unsigned int id; /**< The handle of the call */
- char number[TELEPHONY_CALL_NUMBER_LEN_MAX + 1]; /**< Calling number */
- telephony_call_type_e type; /**< Type of call (voice, video, emergency) */
- telephony_call_status_e status; /**< Call Status */
- telephony_call_direction_e direction; /**< Call direction (MO, MT) */
- bool conference_status; /**< true: Conference call, false: Single call */
-} telephony_call_info_s;
-
-/**
- * @brief Check if the caller process has a privilege.
- * @return @c 1 when the caller has the privilege,
- * otherwise 0
- */
-bool telephony_check_legacy_telephony_privilege();
-
-#endif /* __CAPI_TELEPHONY_PRIVATE_H__ */
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
-Name: capi-telephony
-Summary: Telephony Core API
-Version: 0.1.86
-Release: 1
-Group: System/Libraries
-License: Apache-2.0
-Source0: %{name}-%{version}.tar.gz
+Name: capi-telephony
+Version: 0.2.0
+Release: 0
+Summary: Telephony Core API
+
+Group: Telephony/API
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+Source1001: %{name}.manifest
+
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(tapi)
BuildRequires: pkgconfig(cynara-creds-self)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
-
%if 0%{?gcov:1}
+BuildRequires: tar
BuildRequires: lcov
%endif
Telephony public API library
%package devel
-Summary: Telephony Core API
-Group: Developement/Libraries
-Requires: %{name} = %{version}-%{release}
+Summary: Telephony Core API
+Group: Telephony/Development
+Requires: %{name} = %{version}
+Requires: pkgconfig
%description devel
Telephony public API library (development library)
+%package unittests
+Summary: Test Programs for %{name}
+Group: Telephony/Testing
+
+%description unittests
+The %{name}-unittests pacakge contains programs for checking quality the %{name}.
+
%if 0%{?gcov:1}
%package gcov
-Summary: Telephony public API library(gcov)
-Group: Developement/Libraries
+Summary: Coverage Data of %{name}
+Group: Telephony/Testing
+
%description gcov
-gcov objects for coverage test
+The %{name}-gcov pacakge contains gcov objects
%endif
+%define tel_header_dir %{_includedir}/telephony
+
%prep
%setup -q
+cp %{SOURCE1001} ./%{name}.manifest
%build
-
%if 0%{?gcov:1}
export CFLAGS+=" -fprofile-arcs -ftest-coverage"
export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
%endif
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
- -DLIB_INSTALL_DIR=%{_libdir} \
- -DFULLVER=%{version} \
- -DMAJORVER=${MAJORVER}
-
-make %{?jobs:-j%jobs}
-
-%if 0%{?gcov:1}
-mkdir -p gcov-obj
-find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
-%endif
+%cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
+ -DCMAKE_VERBOSE_MAKEFILE=OFF \
+ -DBIN_INSTALL_DIR:PATH=%{_bindir} \
+ -DHEADER_DIR:PATH=%{tel_header_dir} \
+ -DTEST_INSTALL_DIR:PATH=%{_bindir}/%{name}
+make %{?_smp_mflags}
%install
-rm -rf %{buildroot}
%make_install
%if 0%{?gcov:1}
-mkdir -p %{buildroot}%{_datadir}/gcov/obj
-install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
+find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T -
+install -d -m 755 %{buildroot}%{_datadir}/gcov/obj
+tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj
%endif
%post -p /sbin/ldconfig
-
%postun -p /sbin/ldconfig
%files
-%manifest capi-telephony.manifest
-%{_libdir}/libcapi-telephony.so.*
-%license LICENSE
-#%{_bindir}/telephony-test
+%manifest %{name}.manifest
+%{_libdir}/lib%{name}.so.*
+%license LICENSE.APLv2
%files devel
-%{_includedir}/telephony/telephony.h
-%{_includedir}/telephony/telephony_common.h
-%{_includedir}/telephony/telephony_call.h
-%{_includedir}/telephony/telephony_sim.h
-%{_includedir}/telephony/telephony_network.h
-%{_includedir}/telephony/telephony_modem.h
-%{_libdir}/pkgconfig/*.pc
-%{_libdir}/libcapi-telephony.so
+%{_libdir}/lib%{name}*.so
+%{_libdir}/pkgconfig/%{name}*.pc
+%{tel_header_dir}/telephony*.h
+
+%files unittests
+%manifest %{name}.manifest
+%{_bindir}/telephony-test
+%license LICENSE.APLv2
%if 0%{?gcov:1}
%files gcov
-%{_datadir}/gcov/obj/*
-%endif
\ No newline at end of file
+%{_datadir}/gcov/*
+%endif
}
/* LCOV_EXCL_STOP */
-int telephony_call_get_preferred_voice_subscription(telephony_h handle, telephony_call_preferred_voice_subs_e *call_sub)
+API int telephony_call_get_preferred_voice_subscription(telephony_h handle, telephony_call_preferred_voice_subs_e *call_sub)
{
int ret;
TapiHandle *tapi_h;
return TELEPHONY_ERROR_NONE;
}
-int telephony_call_get_call_list(telephony_h handle,
+API int telephony_call_get_call_list(telephony_h handle,
unsigned int *count, telephony_call_h **call_list)
{
int ret;
return TELEPHONY_ERROR_NONE;
}
-int telephony_call_release_call_list(unsigned int count, telephony_call_h **call_list)
+API int telephony_call_release_call_list(unsigned int count, telephony_call_h **call_list)
{
/* LCOV_EXCL_START */
int i;
/* LCOV_EXCL_STOP */
}
-int telephony_call_get_handle_id(telephony_call_h call_handle, unsigned int *handle_id)
+API int telephony_call_get_handle_id(telephony_call_h call_handle, unsigned int *handle_id)
{
/* LCOV_EXCL_START */
CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
/* LCOV_EXCL_STOP */
}
-int telephony_call_get_number(telephony_call_h call_handle, char **number)
+API int telephony_call_get_number(telephony_call_h call_handle, char **number)
{
/* LCOV_EXCL_START */
CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
/* LCOV_EXCL_STOP */
}
-int telephony_call_get_type(telephony_call_h call_handle,
+API int telephony_call_get_type(telephony_call_h call_handle,
telephony_call_type_e *type)
{
/* LCOV_EXCL_START */
/* LCOV_EXCL_STOP */
}
-int telephony_call_get_status(telephony_call_h call_handle,
+API int telephony_call_get_status(telephony_call_h call_handle,
telephony_call_status_e *status)
{
/* LCOV_EXCL_START */
/* LCOV_EXCL_STOP */
}
-int telephony_call_get_direction(telephony_call_h call_handle,
+API int telephony_call_get_direction(telephony_call_h call_handle,
telephony_call_direction_e *direction)
{
/* LCOV_EXCL_START */
/* LCOV_EXCL_STOP */
}
-int telephony_call_get_conference_status(telephony_call_h call_handle, bool *conference_status)
+API int telephony_call_get_conference_status(telephony_call_h call_handle, bool *conference_status)
{
/* LCOV_EXCL_START */
CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
}
/* LCOV_EXCL_STOP */
-int telephony_set_noti_cb(telephony_h handle,
+API int telephony_set_noti_cb(telephony_h handle,
telephony_noti_e noti_id, telephony_noti_cb cb, void *user_data)
{
telephony_evt_cb_data *evt_cb_data = NULL;
return TELEPHONY_ERROR_NONE;
}
-int telephony_unset_noti_cb(telephony_h handle, telephony_noti_e noti_id)
+API int telephony_unset_noti_cb(telephony_h handle, telephony_noti_e noti_id)
{
telephony_evt_cb_data *evt_cb_data = NULL;
GSList *list = NULL;
return TELEPHONY_ERROR_NONE;
}
-int telephony_init(telephony_handle_list_s *list)
+API int telephony_init(telephony_handle_list_s *list)
{
char **cp_list;
int cp_count = 0;
return TELEPHONY_ERROR_NONE;
}
-int telephony_deinit(telephony_handle_list_s *list)
+API int telephony_deinit(telephony_handle_list_s *list)
{
unsigned int i;
return TELEPHONY_ERROR_NONE;
}
-int telephony_get_state(telephony_state_e *state)
+API int telephony_get_state(telephony_state_e *state)
{
int res = 0;
int value = 0;
return TELEPHONY_ERROR_NONE;
}
-int telephony_set_state_changed_cb(telephony_state_changed_cb callback, void *user_data)
+API int telephony_set_state_changed_cb(telephony_state_changed_cb callback, void *user_data)
{
int res = 0;
return TELEPHONY_ERROR_NONE;
}
-int telephony_unset_state_changed_cb(telephony_state_changed_cb callback)
+API int telephony_unset_state_changed_cb(telephony_state_changed_cb callback)
{
int res = 0;
#include "telephony_private.h"
/* LCOV_EXCL_START */
-int telephony_modem_get_imei(telephony_h handle, char **imei)
+API int telephony_modem_get_imei(telephony_h handle, char **imei)
{
GVariant *gv = NULL;
GError *gerr = NULL;
}
/* LCOV_EXCL_STOP */
-int telephony_modem_get_power_status(telephony_h handle,
+API int telephony_modem_get_power_status(telephony_h handle,
telephony_modem_power_status_e *status)
{
TapiHandle *tapi_h;
}
/* LCOV_EXCL_START */
-int telephony_modem_get_meid(telephony_h handle, char **meid)
+API int telephony_modem_get_meid(telephony_h handle, char **meid)
{
int ret = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
#define TELEPHONY_NETWORK_MCC_LEN 3
-int telephony_network_get_lac(telephony_h handle, int *lac)
+API int telephony_network_get_lac(telephony_h handle, int *lac)
{
int ret = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_cell_id(telephony_h handle, int *cell_id)
+API int telephony_network_get_cell_id(telephony_h handle, int *cell_id)
{
int ret = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_rssi(telephony_h handle, telephony_network_rssi_e *rssi)
+API int telephony_network_get_rssi(telephony_h handle, telephony_network_rssi_e *rssi)
{
int ret;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_roaming_status(telephony_h handle, bool *status)
+API int telephony_network_get_roaming_status(telephony_h handle, bool *status)
{
int ret;
int temp = 0;
return ret;
}
-int telephony_network_get_mcc(telephony_h handle, char **mcc)
+API int telephony_network_get_mcc(telephony_h handle, char **mcc)
{
int ret = TELEPHONY_ERROR_NONE;
char *plmn_str = NULL;
return ret;
}
-int telephony_network_get_mnc(telephony_h handle, char **mnc)
+API int telephony_network_get_mnc(telephony_h handle, char **mnc)
{
int ret = TELEPHONY_ERROR_NONE;
char *plmn_str = NULL;
return ret;
}
-int telephony_network_get_network_name(telephony_h handle, char **network_name)
+API int telephony_network_get_network_name(telephony_h handle, char **network_name)
{
int ret;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_network_name_option(telephony_h handle, telephony_network_name_option_e *network_name_option)
+API int telephony_network_get_network_name_option(telephony_h handle, telephony_network_name_option_e *network_name_option)
{
int ret;
int name_option = 0;
return ret;
}
-int telephony_network_get_type(telephony_h handle, telephony_network_type_e *network_type)
+API int telephony_network_get_type(telephony_h handle, telephony_network_type_e *network_type)
{
int ret;
int act;
return ret;
}
-int telephony_network_get_ps_type(telephony_h handle, telephony_network_ps_type_e *ps_type)
+API int telephony_network_get_ps_type(telephony_h handle, telephony_network_ps_type_e *ps_type)
{
int ret;
int service_type = 0;
return ret;
}
-int telephony_network_get_service_state(telephony_h handle, telephony_network_service_state_e *network_service_state)
+API int telephony_network_get_service_state(telephony_h handle, telephony_network_service_state_e *network_service_state)
{
int ret;
int service_type = 0;
return ret;
}
-int telephony_network_get_default_data_subscription(telephony_h handle,
+API int telephony_network_get_default_data_subscription(telephony_h handle,
telephony_network_default_data_subs_e *default_data_sub)
{
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_default_subscription(telephony_h handle,
+API int telephony_network_get_default_subscription(telephony_h handle,
telephony_network_default_subs_e *default_sub)
{
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_selection_mode(telephony_h handle, telephony_network_selection_mode_e *mode)
+API int telephony_network_get_selection_mode(telephony_h handle, telephony_network_selection_mode_e *mode)
{
int ret = TELEPHONY_ERROR_OPERATION_FAILED;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_tac(telephony_h handle, int *tac)
+API int telephony_network_get_tac(telephony_h handle, int *tac)
{
int ret = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_system_id(telephony_h handle, int *sid)
+API int telephony_network_get_system_id(telephony_h handle, int *sid)
{
int ret = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_network_id(telephony_h handle, int *nid)
+API int telephony_network_get_network_id(telephony_h handle, int *nid)
{
int ret = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_base_station_id(telephony_h handle, int *bs_id)
+API int telephony_network_get_base_station_id(telephony_h handle, int *bs_id)
{
int ret = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_base_station_latitude(telephony_h handle, int *bs_latitude)
+API int telephony_network_get_base_station_latitude(telephony_h handle, int *bs_latitude)
{
int ret = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_base_station_longitude(telephony_h handle, int *bs_longitude)
+API int telephony_network_get_base_station_longitude(telephony_h handle, int *bs_longitude)
{
int ret = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
return ret;
}
-int telephony_network_get_signal_strength(telephony_h handle, int *dbm)
+API int telephony_network_get_signal_strength(telephony_h handle, int *dbm)
{
int ret;
TapiHandle *tapi_h;
/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
-int telephony_sim_get_icc_id(telephony_h handle, char **icc_id)
+API int telephony_sim_get_icc_id(telephony_h handle, char **icc_id)
{
int error_code = TELEPHONY_ERROR_NONE;
TapiHandle *tapi_h;
}
/* LCOV_EXCL_STOP */
-int telephony_sim_get_operator(telephony_h handle, char **sim_operator)
+API int telephony_sim_get_operator(telephony_h handle, char **sim_operator)
{
int error_code = TELEPHONY_ERROR_NONE;
TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
return error_code;
}
-int telephony_sim_get_msin(telephony_h handle, char **msin)
+API int telephony_sim_get_msin(telephony_h handle, char **msin)
{
int error_code = TELEPHONY_ERROR_NONE;
TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
return error_code;
}
-int telephony_sim_get_spn(telephony_h handle, char **spn)
+API int telephony_sim_get_spn(telephony_h handle, char **spn)
{
int error_code = TELEPHONY_ERROR_NONE;
TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
return error_code;
}
-int telephony_sim_is_changed(telephony_h handle, bool *is_changed)
+API int telephony_sim_is_changed(telephony_h handle, bool *is_changed)
{
int card_changed = 0;
TelSimCardStatus_t sim_card_state = 0x00;
return error_code;
}
-int telephony_sim_get_state(telephony_h handle, telephony_sim_state_e *sim_state)
+API int telephony_sim_get_state(telephony_h handle, telephony_sim_state_e *sim_state)
{
TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
int error_code = TELEPHONY_ERROR_NONE;
return error_code;
}
-int telephony_sim_get_application_list(telephony_h handle, unsigned int *app_list)
+API int telephony_sim_get_application_list(telephony_h handle, unsigned int *app_list)
{
int error_code = TELEPHONY_ERROR_NONE;
TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
return error_code;
}
-int telephony_sim_get_subscriber_number(telephony_h handle, char **subscriber_number)
+API int telephony_sim_get_subscriber_number(telephony_h handle, char **subscriber_number)
{
int error_code = TELEPHONY_ERROR_NONE;
GError *gerr = NULL;
return error_code;
}
-int telephony_sim_get_subscriber_id(telephony_h handle, char **subscriber_id)
+API int telephony_sim_get_subscriber_id(telephony_h handle, char **subscriber_id)
{
int error_code = TELEPHONY_ERROR_NONE;
TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
return error_code;
}
-int telephony_sim_get_lock_state(telephony_h handle, telephony_sim_lock_state_e *lock_state)
+API int telephony_sim_get_lock_state(telephony_h handle, telephony_sim_lock_state_e *lock_state)
{
/* LCOV_EXCL_START */
TelSimCardStatus_t sim_card_state;
/* LCOV_EXCL_STOP */
}
-int telephony_sim_get_group_id1(telephony_h handle, char **gid1)
+API int telephony_sim_get_group_id1(telephony_h handle, char **gid1)
{
int error_code = TELEPHONY_ERROR_NONE;
TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
return error_code;
}
-int telephony_sim_get_call_forwarding_indicator_state(telephony_h handle, bool *state)
+API int telephony_sim_get_call_forwarding_indicator_state(telephony_h handle, bool *state)
{
int error_code = TELEPHONY_ERROR_NONE;
TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN;
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(telephony-test C)
-SET(test "telephony-test")
-
-SET(test_src
- main.c
- menu.c
- call.c
- modem.c
- network.c
- sim.c
-)
-
-##Address-Space Layout Randomization
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
-SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
-
-ADD_EXECUTABLE(${test} ${test_src})
-TARGET_LINK_LIBRARIES(${test} ${fw_name} ${${fw_test}_LDFLAGS})
-INSTALL(TARGETS ${test} RUNTIME DESTINATION bin/)
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include <telephony.h>
-
-#include "menu.h"
-#include "call.h"
-
-extern int subs_type;
-
-static int call_noti_tbl[] = {
- TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE,
- TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE,
- TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD,
- TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING,
- TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING,
- TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING,
- TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION
-};
-
-static const char *convert_call_type(telephony_call_type_e type)
-{
- switch (type) {
- case TELEPHONY_CALL_TYPE_VOICE:
- return "VOICE";
- case TELEPHONY_CALL_TYPE_VIDEO:
- return "VIDEO";
- case TELEPHONY_CALL_TYPE_E911:
- return "E911";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_call_status(telephony_call_status_e type)
-{
- switch (type) {
- case TELEPHONY_CALL_STATUS_IDLE:
- return "IDLE";
- case TELEPHONY_CALL_STATUS_ACTIVE:
- return "ACTIVE";
- case TELEPHONY_CALL_STATUS_HELD:
- return "HELD";
- case TELEPHONY_CALL_STATUS_DIALING:
- return "DIALING";
- case TELEPHONY_CALL_STATUS_ALERTING:
- return "ALERTING";
- case TELEPHONY_CALL_STATUS_INCOMING:
- return "INCOMING";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_call_direction(telephony_call_direction_e direction)
-{
- switch (direction) {
- case TELEPHONY_CALL_DIRECTION_MO:
- return "MO";
- case TELEPHONY_CALL_DIRECTION_MT:
- return "MT";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_call_pref_voice_subs(telephony_call_preferred_voice_subs_e pref_voice_subs)
-{
- switch (pref_voice_subs) {
- case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_CURRENT_NETWORK:
- return "CURRENT_NETWORK";
- case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_ASK_ALWAYS:
- return "ASK_ALWAYS";
- case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_SIM1:
- return "SIM1";
- case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_SIM2:
- return "SIM2";
- case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_UNKNOWN:
- default:
- return "UNKNOWN";
- }
-}
-
-static void call_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
-{
- int ret;
- telephony_call_h *call_list;
- unsigned int call_count;
- int i;
-
- msg("");
- switch (noti_id) {
- case TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE:
- msgb("NOTI_VOICE_CALL_STATUS_IDLE received!!!");
- msg(" - handle_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE:
- msgb("NOTI_VOICE_CALL_STATUS_ACTIVE received!!!");
- msg(" - handle_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD:
- msgb("NOTI_VOICE_CALL_STATUS_HELD received!!!");
- msg(" - handle_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING:
- msgb("NOTI_VOICE_CALL_STATUS_DIALING received!!!");
- msg(" - handle_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING:
- msgb("NOTI_VOICE_CALL_STATUS_ALERTING received!!!");
- msg(" - handle_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING:
- msgb("NOTI_VOICE_CALL_STATUS_INCOMING received!!!");
- msg(" - handle_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION:
- msgb("NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION received!!!");
- msg(" - preferred_voice_subscription = %s", convert_call_pref_voice_subs(*(int *)data));
- return;
- default:
- msgb("Unknown notification received!!!");
- return;
- }
-
- msg("call telephony_call_get_call_list()");
- ret = telephony_call_get_call_list(handle, &call_count, &call_list);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_call_get_call_list() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return;
- }
-
- msg(" - count = %d", call_count);
- for (i = 0; i < call_count; i++) {
- unsigned int handle_id;
- char *number;
- telephony_call_type_e type;
- telephony_call_status_e status;
- telephony_call_direction_e direction;
- bool conf_status;
-
- telephony_call_get_handle_id(call_list[i], &handle_id);
- telephony_call_get_number(call_list[i], &number);
- telephony_call_get_type(call_list[i], &type);
- telephony_call_get_status(call_list[i], &status);
- telephony_call_get_direction(call_list[i], &direction);
- telephony_call_get_conference_status(call_list[i], &conf_status);
-
- msg("");
- msg(" - handle_id = %d", handle_id);
- msg(" - number = %s", number);
- msg(" - type = %s", convert_call_type(type));
- msg(" - status = %s", convert_call_status(status));
- msg(" - direction = %s", convert_call_direction(direction));
- msg(" - conference_status = %s", conf_status ? "TRUE" : "FALSE");
- free(number);
- }
- telephony_call_release_call_list(call_count, &call_list);
-}
-
-static int run_call_get_call_list(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_call_h *call_list;
- unsigned int call_count;
- int i;
-
- msg("call telephony_call_get_call_list()");
-
- ret = telephony_call_get_call_list(handle_list->handle[subs_type], &call_count, &call_list);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_call_get_call_list() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - count = %d", call_count);
- for (i = 0; i < call_count; i++) {
- unsigned int handle_id;
- char *number;
- telephony_call_type_e type;
- telephony_call_status_e status;
- telephony_call_direction_e direction;
- bool conf_status;
-
- telephony_call_get_handle_id(call_list[i], &handle_id);
- telephony_call_get_number(call_list[i], &number);
- telephony_call_get_type(call_list[i], &type);
- telephony_call_get_status(call_list[i], &status);
- telephony_call_get_direction(call_list[i], &direction);
- telephony_call_get_conference_status(call_list[i], &conf_status);
-
- msg("");
- msg(" - handle_id = %d", handle_id);
- msg(" - number = %s", number);
- msg(" - type = %s", convert_call_type(type));
- msg(" - status = %s", convert_call_status(status));
- msg(" - direction = %s", convert_call_direction(direction));
- msg(" - conference_status = %s", conf_status ? "TRUE" : "FALSE");
- free(number);
- }
- telephony_call_release_call_list(call_count, &call_list);
-
- return 0;
-}
-
-static int run_call_get_pref_voice_subs(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_call_preferred_voice_subs_e pref_voice_subs;
-
- msg("call telephony_call_get_preferred_voice_subscriptions()");
-
- ret = telephony_call_get_preferred_voice_subscription(handle_list->handle[subs_type], &pref_voice_subs);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_call_get_preferred_voice_subscription() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - preferred_voice_subscription = %s", convert_call_pref_voice_subs(pref_voice_subs));
-
- return 0;
-}
-
-struct menu_data menu_call[] = {
- {"1", "telephony_call_get_preferred_voice_subscription", NULL, run_call_get_pref_voice_subs, NULL},
- {"2", "telephony_call_get_call_list", NULL, run_call_get_call_list, NULL},
- {NULL, },
-};
-
-void register_call_event(telephony_handle_list_s *handle_list)
-{
- int ret, i;
-
- for (i = 0; i < (sizeof(call_noti_tbl) / sizeof(int)); i++) {
- ret = telephony_set_noti_cb(handle_list->handle[subs_type], call_noti_tbl[i], call_noti_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE)
- msg("telephony_set_noti_cb() failed!!! i(%d), ret(%d,%s)", i, ret, get_error_message(ret));
- }
-}
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 __CALL_H__
-#define __CALL_H__
-
-#include <telephony.h>
-
-void register_call_event(telephony_handle_list_s *handle_list);
-
-#endif
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <telephony.h>
-
-#include "menu.h"
-#include "call.h"
-#include "modem.h"
-#include "network.h"
-#include "sim.h"
-
-#define SIM_SEL_MENU_KEY_COUNT 2
-
-extern struct menu_data menu_call[];
-extern struct menu_data menu_modem[];
-extern struct menu_data menu_network[];
-extern struct menu_data menu_sim[];
-
-telephony_handle_list_s handle_list;
-int subs_type = 0;
-
-static char data_subscription_type[MENU_DATA_SIZE + 1] = "";
-
-static struct menu_data menu_main[] = {
- {"1", "Call", menu_call, NULL, NULL},
- {"2", "Modem", menu_modem, NULL, NULL},
- {"3", "Network", menu_network, NULL, NULL},
- {"4", "SIM", menu_sim, NULL, NULL},
- {NULL, },
-};
-
-static int __select_handle_register_event(MManager *mm, struct menu_data *menu)
-{
- subs_type = atoi(data_subscription_type) - 1;
-
- if (subs_type < 0 || subs_type > handle_list.count - 1) {
- msg("Please select an existing CP Name");
- return RET_FAILURE;
- }
-
- msg("");
-
- menu_manager_set_user_data(mm, &handle_list);
-
- register_call_event(&handle_list);
- register_modem_event(&handle_list);
- register_network_event(&handle_list);
- register_sim_event(&handle_list);
-
- return RET_SUCCESS;
-}
-
-static gboolean __create_sim_selection_menu(struct menu_data sim_selection_menu[SIM_SEL_MENU_KEY_COUNT+1])
-{
- unsigned int index_count = 0;
- unsigned int i = 0;
- int ret;
-
- ret = telephony_init(&handle_list);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_init() failed!!! ret(%d,%s)", ret, get_error_message(ret));
- return FALSE;
- }
-
- /*
- * Available CPs are displayed as below (in UI) -
- * Modems(1=SIM1,2=SIM2)
- */
- index_count += snprintf((char *)&sim_selection_menu[0].title[index_count], 100, "Modems(");
-
- for (i = 0; i < handle_list.count; i++) {
- if (i != 0)
- strncat((char *)&sim_selection_menu[0].title[index_count++], ",", sizeof(char));
-
- index_count += snprintf((char *)&sim_selection_menu[0].title[index_count], 100, "%d=SIM%d", i + 1, i + 1);
- }
- strncat((char *)&sim_selection_menu[0].title[index_count++], ")", sizeof(char));
- strncat((char *)&sim_selection_menu[0].title[index_count], "\0", sizeof(char));
-
- sim_selection_menu[0].key = "1";
- sim_selection_menu[0].sub_menu = NULL;
- sim_selection_menu[0].callback = NULL;
- sim_selection_menu[0].data = data_subscription_type;
-
- sim_selection_menu[1].key = "2";
- snprintf((char *)&sim_selection_menu[1].title, 100, "run");
- sim_selection_menu[1].sub_menu = menu_main;
- sim_selection_menu[1].callback = __select_handle_register_event;
- sim_selection_menu[1].data = NULL;
-
- return TRUE;
-}
-
-int main(int arg, char **argv)
-{
- GMainLoop *mainloop = NULL;
- GIOChannel *channel = g_io_channel_unix_new(STDIN_FILENO);
- MManager *manager;
- struct menu_data sim_selection_menu[SIM_SEL_MENU_KEY_COUNT+1] = { {NULL, }, };
-
-#if !GLIB_CHECK_VERSION(2, 35, 0)
- g_type_init();
-#endif
- mainloop = g_main_loop_new(NULL, FALSE);
-
- msg("");
- msg("* Telephony Test application ");
-
- if (__create_sim_selection_menu(sim_selection_menu) == FALSE)
- goto OUT;
-
- manager = menu_manager_new(sim_selection_menu, mainloop);
- if (!manager)
- goto OUT;
-
- menu_manager_run(manager);
-
- g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
- on_menu_manager_keyboard, manager);
- g_main_loop_run(mainloop);
-
-OUT:
- g_main_loop_unref(mainloop);
- msg("******* Bye bye *******");
-
- return 0;
-}
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.
- */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <glib.h>
-#include <asm/unistd.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-
-#include "menu.h"
-
-#define DEFAULT_MENU_MENU "m"
-#define DEFAULT_MENU_PREV "p"
-#define DEFAULT_MENU_QUIT "q"
-#define DEFAULT_MENU_NONE "-"
-#define TAB_SPACE " "
-
-struct menu_manager {
- GQueue *stack;
- GQueue *title_stack;
-
- struct menu_data *menu;
-
- char *buf;
-
- void *user_data;
- GMainLoop *mainloop;
-};
-
-
-char key_buffer[MENU_DATA_SIZE];
-int flag_pid_display = 1;
-
-
-static void _show_prompt(void)
-{
- msgn("(%5d) >> ", get_tid());
-}
-
-static void _show_reserved_menu(void)
-{
- msg(ANSI_COLOR_DARKGRAY HR_SINGLE2 ANSI_COLOR_NORMAL);
- msg(ANSI_COLOR_DARKGRAY " [ " ANSI_COLOR_NORMAL "%s" ANSI_COLOR_DARKGRAY
- " ] " ANSI_COLOR_NORMAL "Previous menu " , DEFAULT_MENU_PREV);
- msg(ANSI_COLOR_DARKGRAY " [ " ANSI_COLOR_NORMAL "%s" ANSI_COLOR_DARKGRAY
- " ] " ANSI_COLOR_NORMAL "Show Menu " , DEFAULT_MENU_MENU);
- msg(ANSI_COLOR_DARKGRAY " [ " ANSI_COLOR_NORMAL "%s" ANSI_COLOR_DARKGRAY
- " ] " ANSI_COLOR_NORMAL "Quit " , DEFAULT_MENU_QUIT);
-}
-
-static void _show_input_ok(void)
-{
- msg("OK.");
-}
-
-static void _show_menu(MManager *m, struct menu_data menu[])
-{
- int i = 0;
- int len = 0;
- struct menu_data *item;
- char title_buf[256] = { 0, };
-
- if (!menu)
- return;
-
- msg("");
- msg(HR_DOUBLE);
-
- len = g_queue_get_length(m->title_stack);
- msgn(ANSI_COLOR_YELLOW " Main");
- if (len > 0) {
- for (i = 0; i < len; i++) {
- msgn(ANSI_COLOR_NORMAL " >> " ANSI_COLOR_YELLOW "%s",
- (char *)g_queue_peek_nth(m->title_stack, i));
- }
- }
- msg(ANSI_COLOR_NORMAL);
- msg(HR_SINGLE);
-
- hide_pid();
- i = 0;
-
- while (1) {
- item = menu + i;
- if (item->key == NULL)
- break;
-
- if (!g_strcmp0(item->key, "-")) {
- msgn(" ");
- } else if (!g_strcmp0(item->key, "_")) {
- msg(ANSI_COLOR_DARKGRAY HR_SINGLE2 ANSI_COLOR_NORMAL);
-
- if (item->callback)
- item->callback(m, item);
-
- i++;
-
- continue;
- } else if (!g_strcmp0(item->key, "*")) {
- msg(" %s", item->title);
- if (item->callback)
- item->callback(m, item);
- } else {
- msgn(ANSI_COLOR_DARKGRAY " [" ANSI_COLOR_NORMAL "%3s"
- ANSI_COLOR_DARKGRAY "] " ANSI_COLOR_NORMAL, item->key);
- }
-
- memset(title_buf, 0, 256);
- if (item->title) {
- snprintf(title_buf, MAX_TITLE, "%s", item->title);
-
- if (strlen(item->title) >= MAX_TITLE) {
- title_buf[MAX_TITLE - 2] = '.';
- title_buf[MAX_TITLE - 1] = '.';
- }
- }
-
- if (item->data) {
- msg("%s " ANSI_COLOR_LIGHTBLUE "(%s)" ANSI_COLOR_NORMAL,
- title_buf, item->data);
- } else if (!g_strcmp0(item->key, "*")) {
- /* none */
- } else {
- msg("%s", title_buf);
- }
-
- if (item->sub_menu)
- msg("\e[1A\e[%dC >", (int)POS_MORE);
-
- i++;
- }
-
- show_pid();
-
- _show_reserved_menu();
-
- msg(HR_DOUBLE);
-
- _show_prompt();
-}
-
-static void _show_item_data_input_msg(struct menu_data *item)
-{
- msg("");
- msg(HR_DOUBLE);
- msg(" Input [%s] data ", item->title);
- msg(HR_SINGLE);
- msg(" current = [%s]", item->data);
- msgn(" new >> ");
-}
-
-static void _move_menu(MManager *mm, struct menu_data menu[], char *key)
-{
- struct menu_data *item;
- int i = 0;
-
- if (!mm->menu)
- return;
-
- if (!g_strcmp0(DEFAULT_MENU_PREV, key)) {
- if (g_queue_get_length(mm->stack) > 0) {
- mm->menu = g_queue_pop_tail(mm->stack);
- g_queue_pop_tail(mm->title_stack);
- }
-
- _show_menu(mm, mm->menu);
- mm->buf = key_buffer;
-
- return;
- } else if (!g_strcmp0(DEFAULT_MENU_MENU, key)) {
- _show_menu(mm, mm->menu);
- return;
- } else if (!g_strcmp0(DEFAULT_MENU_QUIT, key)) {
- g_main_loop_quit(mm->mainloop);
- return;
- } else if (!g_strcmp0(DEFAULT_MENU_NONE, key)) {
- _show_prompt();
- return;
- }
-
- while (1) {
- int ret = RET_SUCCESS;
- item = menu + i;
- if (item->key == NULL)
- break;
-
- if (!g_strcmp0(item->key, key)) {
- if (item->callback) {
- ret = item->callback(mm, item);
- _show_prompt();
- }
-
- if (RET_SUCCESS == ret) {
- if (item->sub_menu) {
- g_queue_push_tail(mm->stack, mm->menu);
- //g_queue_push_tail(mm->title_stack, (gpointer *)item->title);
- g_queue_push_tail(mm->title_stack, item->title);
-
- mm->menu = item->sub_menu;
- _show_menu(mm, mm->menu);
- mm->buf = key_buffer;
- }
-
- if (item->data) {
- _show_item_data_input_msg(item);
- mm->buf = item->data;
- }
- }
-
- return;
- }
-
- i++;
- }
-
- _show_prompt();
-}
-
-MManager *menu_manager_new(struct menu_data items[], GMainLoop *mainloop)
-{
- MManager *mm;
-
- mm = calloc(sizeof(struct menu_manager), 1);
- if (!mm)
- return NULL;
-
- mm->stack = g_queue_new();
- mm->title_stack = g_queue_new();
- mm->menu = items;
- mm->mainloop = mainloop;
-
- return mm;
-}
-
-int menu_manager_run(MManager *mm)
-{
- _show_menu(mm, mm->menu);
-
- mm->buf = key_buffer;
-
- return 0;
-}
-
-int menu_manager_set_user_data(MManager *mm, void *user_data)
-{
- if (!mm)
- return -1;
-
- mm->user_data = user_data;
-
- return 0;
-}
-
-void *menu_manager_ref_user_data(MManager *mm)
-{
- if (!mm)
- return NULL;
-
- return mm->user_data;
-}
-
-gboolean on_menu_manager_keyboard(GIOChannel *src, GIOCondition con,
- gpointer data)
-{
- MManager *mm = data;
- char local_buf[MENU_DATA_SIZE + 1] = { 0, };
-
- if (fgets(local_buf, MENU_DATA_SIZE, stdin) == NULL)
- return TRUE;
-
- if (strlen(local_buf) > 0) {
- if (local_buf[strlen(local_buf) - 1] == '\n')
- local_buf[strlen(local_buf) - 1] = '\0';
- }
-
- if (mm->buf == key_buffer) {
- if (strlen(local_buf) < 1) {
- _show_prompt();
- return TRUE;
- }
-
- _move_menu(mm, mm->menu, local_buf);
- } else {
- if (mm->buf) {
- memset(mm->buf, 0, MENU_DATA_SIZE);
- memcpy(mm->buf, local_buf, MENU_DATA_SIZE);
- _show_input_ok();
- }
- mm->buf = key_buffer;
- _move_menu(mm, mm->menu, (char *)DEFAULT_MENU_MENU);
- }
-
- return TRUE;
-}
-
-pid_t get_tid()
-{
- return syscall(__NR_gettid);
-}
-
-void hide_pid()
-{
- flag_pid_display = 0;
-}
-
-void show_pid()
-{
- flag_pid_display = 1;
-}
-
-int is_pid_show()
-{
- return flag_pid_display;
-}
-
-static void _hex_dump(const char *pad, int size, const void *data)
-{
- char buf[255] = {0, };
- char hex[4] = {0, };
- int i;
- unsigned char *p;
-
- if (size <= 0) {
- msg("%sno data", pad);
- return;
- }
- p = (unsigned char *)data;
-
- snprintf(buf, 255, "%s%04X: ", pad, 0);
- for (i = 0; i < size; i++) {
- snprintf(hex, 4, "%02X ", p[i]);
- strncat(buf, hex, strlen(hex));
-
- if ((i + 1) % 8 == 0) {
- if ((i + 1) % 16 == 0) {
- msg("%s", buf);
- memset(buf, 0, 255);
- snprintf(buf, 255, "%s%04X: ", pad, i + 1);
- } else {
- strncat(buf, TAB_SPACE, strlen(TAB_SPACE));
- }
- }
- }
-
- msg("%s", buf);
-}
-
-void menu_print_dump(int data_len, void *data)
-{
- if (!data)
- return;
-
- msg("");
- msg(" \tlen=%d", data_len);
- _hex_dump(" ", data_len, data);
-
- msg("");
-}
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 __MENU_H__
-#define __MENU_H__
-
-__BEGIN_DECLS
-
-#define ANSI_COLOR_NORMAL "\e[0m"
-
-#define ANSI_COLOR_BLACK "\e[0;30m"
-#define ANSI_COLOR_RED "\e[0;31m"
-#define ANSI_COLOR_GREEN "\e[0;32m"
-#define ANSI_COLOR_BROWN "\e[0;33m"
-#define ANSI_COLOR_BLUE "\e[0;34m"
-#define ANSI_COLOR_MAGENTA "\e[0;35m"
-#define ANSI_COLOR_CYAN "\e[0;36m"
-#define ANSI_COLOR_LIGHTGRAY "\e[0;37m"
-
-#define ANSI_COLOR_DARKGRAY "\e[1;30m"
-#define ANSI_COLOR_LIGHTRED "\e[1;31m"
-#define ANSI_COLOR_LIGHTGREEN "\e[1;32m"
-#define ANSI_COLOR_YELLOW "\e[1;33m"
-#define ANSI_COLOR_LIGHTBLUE "\e[1;34m"
-#define ANSI_COLOR_LIGHTMAGENTA "\e[1;35m"
-#define ANSI_COLOR_LIGHTCYAN "\e[1;36m"
-#define ANSI_COLOR_WHITE "\e[1;37m"
-
-
-#define msg(fmt, args...) do { fprintf(stdout, fmt "\n", ##args); \
- fflush(stdout); } while (0)
-#define msgn(fmt, args...) do { fprintf(stdout, fmt, ##args); \
- fflush(stdout); } while (0)
-
-/* Bold (green) */
-#define msgb(fmt, args...) do { fprintf(stdout, ANSI_COLOR_LIGHTGREEN fmt \
- ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
-
-/* Property message */
-#define msgp(fmt, args...) do { fprintf(stdout, ANSI_COLOR_LIGHTMAGENTA fmt \
- ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
-
-#define msgt(n, fmt, args...) do { fprintf(stdout, "\e[%dC" fmt "\n", \
- 3 + ((n) * 2), ##args); fflush(stdout); } while (0)
-
-#define pmsg(fmt, args...) do { \
- if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
- fprintf(stdout, fmt "\n", ##args); fflush(stdout); } while (0)
-
-#define pmsgb(fmt, args...) do { \
- if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
- fprintf(stdout, ANSI_COLOR_LIGHTGREEN fmt \
- ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
-
-#define pmsgt(n, fmt, args...) do { \
- if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
- fprintf(stdout, "\e[%dC" fmt "\n", \
- 3 + ((n) * 2), ##args); fflush(stdout); } while (0)
-
-#define MENU_DATA_SIZE 255
-
-
-
-/*
- * Horizontal Line - width: 65
- * .12345678901234567890123456789012345678901234567890.
- */
-#define HR_SINGLE "----------------------------------------" \
- "-------------------------"
-#define HR_DOUBLE "========================================" \
- "========================="
-#define HR_SINGLE2 " ---------------------------------------" \
- "------------------------ "
-
-#define MAX_WIDTH strlen(HR_SINGLE)
-#define MAX_TITLE ((MAX_WIDTH) - 10)
-#define POS_MORE ((MAX_WIDTH) - 3)
-#define RET_SUCCESS 0
-#define RET_FAILURE -1
-
-typedef struct menu_manager MManager;
-
-struct menu_data {
- const char *key;
- char title[100];
- struct menu_data *sub_menu;
- int (*callback)(MManager *mm, struct menu_data *menu);
- char *data;
-};
-
-MManager *menu_manager_new(struct menu_data items[], GMainLoop *mainloop);
-int menu_manager_run(MManager *mm);
-int menu_manager_set_user_data(MManager *mm, void *user_data);
-void *menu_manager_ref_user_data(MManager *mm);
-
-gboolean on_menu_manager_keyboard(GIOChannel *src, GIOCondition con, gpointer data);
-
-pid_t get_tid();
-void hide_pid();
-void show_pid();
-int is_pid_show();
-void menu_print_dump(int data_len, void *data);
-
-__END_DECLS
-
-#endif
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include <telephony.h>
-
-#include "menu.h"
-#include "modem.h"
-
-extern int subs_type;
-
-static int modem_noti_tbl[] = {
- TELEPHONY_NOTI_MODEM_POWER_STATUS
-};
-
-static const char *convert_modem_power_status(telephony_modem_power_status_e power_status)
-{
- switch (power_status) {
- case TELEPHONY_MODEM_POWER_STATUS_ON:
- return "ON";
- case TELEPHONY_MODEM_POWER_STATUS_OFF:
- return "OFF";
- case TELEPHONY_MODEM_POWER_STATUS_RESET:
- return "RESET";
- case TELEPHONY_MODEM_POWER_STATUS_LOW:
- return "LOW";
- case TELEPHONY_MODEM_POWER_STATUS_UNKNOWN:
- default:
- return "UNKNOWN";
- }
-}
-
-static void modem_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
-{
- msg("");
- switch (noti_id) {
- case TELEPHONY_NOTI_MODEM_POWER_STATUS:
- msgb("NOTI_MODEM_POWER_STATUS received!!!");
- msg(" - power_status = %s", convert_modem_power_status(*(int *)data));
- break;
- default:
- break;
- }
-}
-
-static int run_modem_get_imei(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *imei = NULL;
-
- msg("call telephony_modem_get_imei()");
-
- ret = telephony_modem_get_imei(handle_list->handle[subs_type], &imei);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_modem_get_meid() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - imei = %s", imei);
-
- return 0;
-}
-
-static int run_modem_get_power_status(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_modem_power_status_e power_status;
-
- msg("call telephony_modem_get_power_status()");
-
- ret = telephony_modem_get_power_status(handle_list->handle[subs_type], &power_status);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_modem_get_power_status() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - power_status = %s", convert_modem_power_status(power_status));
-
- return 0;
-}
-
-static int run_modem_get_meid(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *meid = NULL;
-
- msg("call telephony_modem_get_meid()");
-
- ret = telephony_modem_get_meid(handle_list->handle[subs_type], &meid);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_modem_get_meid() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - meid = %s", meid);
-
- return 0;
-}
-
-struct menu_data menu_modem[] = {
- {"1", "telephony_modem_get_imei", NULL, run_modem_get_imei, NULL},
- {"2", "telephony_modem_get_power_status", NULL, run_modem_get_power_status, NULL},
- {"3", "telephony_modem_get_meid", NULL, run_modem_get_meid, NULL},
- {NULL, }
-};
-
-void register_modem_event(telephony_handle_list_s *handle_list)
-{
- int ret, i;
-
- for (i = 0; i < (sizeof(modem_noti_tbl) / sizeof(int)); i++) {
- ret = telephony_set_noti_cb(handle_list->handle[subs_type], modem_noti_tbl[i], modem_noti_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE)
- msg("telephony_set_noti_cb() failed!!! i(%d), ret(%d,%s)", i, ret, get_error_message(ret));
- }
-}
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 __MODEM_H__
-#define __MODEM_H__
-
-#include <telephony.h>
-
-void register_modem_event(telephony_handle_list_s *handle_list);
-
-#endif
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include <telephony.h>
-
-#include "menu.h"
-#include "network.h"
-
-extern int subs_type;
-
-static int network_noti_tbl[] = {
- TELEPHONY_NOTI_NETWORK_SERVICE_STATE,
- TELEPHONY_NOTI_NETWORK_CELLID,
- TELEPHONY_NOTI_NETWORK_ROAMING_STATUS,
- TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL,
- TELEPHONY_NOTI_NETWORK_NETWORK_NAME,
- TELEPHONY_NOTI_NETWORK_PS_TYPE,
- TELEPHONY_NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION,
- TELEPHONY_NOTI_NETWORK_DEFAULT_SUBSCRIPTION,
- TELEPHONY_NOTI_NETWORK_LAC,
- TELEPHONY_NOTI_NETWORK_TAC,
- TELEPHONY_NOTI_NETWORK_SYSTEM_ID,
- TELEPHONY_NOTI_NETWORK_NETWORK_ID,
- TELEPHONY_NOTI_NETWORK_BS_ID,
- TELEPHONY_NOTI_NETWORK_BS_LATITUDE,
- TELEPHONY_NOTI_NETWORK_BS_LONGITUDE
-};
-
-static const char *convert_network_name_option(telephony_network_name_option_e name_option)
-{
- switch (name_option) {
- case TELEPHONY_NETWORK_NAME_OPTION_NETWORK:
- return "NETWORK";
- case TELEPHONY_NETWORK_NAME_OPTION_SPN:
- return "SPN";
- case TELEPHONY_NETWORK_NAME_OPTION_ANY:
- return "ANY";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_network_service_state(telephony_network_service_state_e service_state)
-{
- switch (service_state) {
- case TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE:
- return "IN_SERVICE";
- case TELEPHONY_NETWORK_SERVICE_STATE_OUT_OF_SERVICE:
- return "OUT_OF_SERVICE";
- case TELEPHONY_NETWORK_SERVICE_STATE_EMERGENCY_ONLY:
- return "EMERGENCY_ONLY";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_network_type(telephony_network_type_e network_type)
-{
- switch (network_type) {
- case TELEPHONY_NETWORK_TYPE_GSM:
- return "GSM";
- case TELEPHONY_NETWORK_TYPE_GPRS:
- return "GPRS";
- case TELEPHONY_NETWORK_TYPE_EDGE:
- return "EDGE";
- case TELEPHONY_NETWORK_TYPE_UMTS:
- return "UMTS";
- case TELEPHONY_NETWORK_TYPE_HSDPA:
- return "HSDPA";
- case TELEPHONY_NETWORK_TYPE_LTE:
- return "LTE";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_network_ps_type(telephony_network_ps_type_e ps_type)
-{
- switch (ps_type) {
- case TELEPHONY_NETWORK_PS_TYPE_HSDPA:
- return "HSDPA";
- case TELEPHONY_NETWORK_PS_TYPE_HSUPA:
- return "HSUPA";
- case TELEPHONY_NETWORK_PS_TYPE_HSPA:
- return "HSPA";
- case TELEPHONY_NETWORK_PS_TYPE_HSPAP:
- return "HSPAP";
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_network_dds(telephony_network_default_data_subs_e dds)
-{
- switch (dds) {
- case TELEPHONY_NETWORK_DEFAULT_DATA_SUBS_SIM1:
- return "SIM1";
- case TELEPHONY_NETWORK_DEFAULT_DATA_SUBS_SIM2:
- return "SIM2";
- case TELEPHONY_NETWORK_DEFAULT_DATA_SUBS_UNKNOWN:
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_network_ds(telephony_network_default_subs_e ds)
-{
- switch (ds) {
- case TELEPHONY_NETWORK_DEFAULT_SUBS_SIM1:
- return "SIM1";
- case TELEPHONY_NETWORK_DEFAULT_SUBS_SIM2:
- return "SIM2";
- case TELEPHONY_NETWORK_DEFAULT_SUBS_UNKNOWN:
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_network_selection_mode(telephony_network_selection_mode_e mode)
-{
- switch (mode) {
- case TELEPHONY_NETWORK_SELECTION_MODE_AUTOMATIC:
- return "AUTOMATIC";
- case TELEPHONY_NETWORK_SELECTION_MODE_MANUAL:
- return "MANUAL";
- default:
- return "UNKNOWN";
- }
-}
-
-static void network_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
-{
- msg("");
- switch (noti_id) {
- case TELEPHONY_NOTI_NETWORK_SERVICE_STATE:
- msgb("NOTI_NETWORK_SERVICE_STATE received!!!");
- msg(" - service_state = %s", convert_network_service_state(*(int *)data));
- break;
- case TELEPHONY_NOTI_NETWORK_CELLID:
- msgb("NOTI_NETWORK_CELLID received!!!");
- msg(" - cell_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_ROAMING_STATUS:
- msgb("NOTI_NETWORK_ROAMING_STATUS received!!!");
- msg(" - roaming_status = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL:
- msgb("NOTI_NETWORK_SIGNALSTRENGTH_LEVEL received!!!");
- msg(" - rssi = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_NETWORK_NAME:
- msgb("NOTI_NETWORK_NETWORK_NAME received!!!");
- msg(" - network_name = %s", (char *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_PS_TYPE:
- msgb("NOTI_NETWORK_PS_TYPE received!!!");
- msg(" - ps_type = %s", convert_network_ps_type(*(int *)data));
- break;
- case TELEPHONY_NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION:
- msgb("NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION received!!!");
- msg(" - default_data_subscription = %s", convert_network_dds(*(int *)data));
- break;
- case TELEPHONY_NOTI_NETWORK_DEFAULT_SUBSCRIPTION:
- msgb("NOTI_NETWORK_DEFAULT_SUBSCRIPTION received!!!");
- msg(" - default_subscription = %s", convert_network_ds(*(int *)data));
- break;
- case TELEPHONY_NOTI_NETWORK_LAC:
- msgb("NOTI_NETWORK_LAC received!!!");
- msg(" - lac = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_TAC:
- msgb("NOTI_NETWORK_TAC received!!!");
- msg(" - tac = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_SYSTEM_ID:
- msgb("NOTI_NETWORK_SYSTEM_ID received!!!");
- msg(" - system_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_NETWORK_ID:
- msgb("NOTI_NETWORK_NETWORK_ID received!!!");
- msg(" - network_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_BS_ID:
- msgb("NOTI_NETWORK_BS_ID received!!!");
- msg(" - base_station_id = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_BS_LATITUDE:
- msgb("NOTI_NETWORK_BS_LATITUDE received!!!");
- msg(" - base_station_latitude = %d", *(int *)data);
- break;
- case TELEPHONY_NOTI_NETWORK_BS_LONGITUDE:
- msgb("NOTI_NETWORK_BS_LONGITUDE received!!!");
- msg(" - base_station_longitude = %d", *(int *)data);
- break;
- default:
- msgb("Unknown notification received!!!");
- break;
- }
-}
-
-static int run_network_get_cell_id(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- int cell_id;
-
- msg("call telephony_network_get_cell_id()");
-
- ret = telephony_network_get_cell_id(handle_list->handle[subs_type], &cell_id);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_cell_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - cell_id = %d", cell_id);
-
- return 0;
-}
-
-static int run_network_get_lac(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- int lac;
-
- msg("call telephony_network_get_lac()");
-
- ret = telephony_network_get_lac(handle_list->handle[subs_type], &lac);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_lac() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - lac = %d", lac);
-
- return 0;
-}
-
-static int run_network_get_mcc(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *mcc;
-
- msg("call telephony_network_get_mcc()");
-
- ret = telephony_network_get_mcc(handle_list->handle[subs_type], &mcc);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_mcc() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - mcc = %s", mcc);
-
- return 0;
-}
-
-static int run_network_get_mnc(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *mnc;
-
- msg("call telephony_network_get_mnc()");
-
- ret = telephony_network_get_mnc(handle_list->handle[subs_type], &mnc);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_mnc() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - mnc = %s", mnc);
-
- return 0;
-}
-
-static int run_network_get_network_name(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *network_name;
-
- msg("call telephony_network_get_network_name()");
-
- ret = telephony_network_get_network_name(handle_list->handle[subs_type], &network_name);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_network_name() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - network_name = %s", network_name);
-
- return 0;
-}
-
-static int run_network_get_network_name_option(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_network_name_option_e name_option;
-
- msg("call telephony_network_get_network_name_option()");
-
- ret = telephony_network_get_network_name_option(handle_list->handle[subs_type], &name_option);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_network_name_option() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - network_name_option = %s", convert_network_name_option(name_option));
-
- return 0;
-}
-
-static int run_network_get_roaming_status(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- bool roaming_status;
-
- msg("call telephony_network_get_roaming_status()");
-
- ret = telephony_network_get_roaming_status(handle_list->handle[subs_type], &roaming_status);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_roaming_status() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - roaming_status = %s", roaming_status ? "TRUE" : "FALSE");
-
- return 0;
-}
-
-static int run_network_get_rssi(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_network_rssi_e rssi;
-
- msg("call telephony_network_get_rssi()");
-
- ret = telephony_network_get_rssi(handle_list->handle[subs_type], &rssi);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_rssi() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - rssi = %d", rssi);
-
- return 0;
-}
-
-static int run_network_get_service_state(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_network_service_state_e service_state;
-
- msg("call telephony_network_get_service_state()");
-
- ret = telephony_network_get_service_state(handle_list->handle[subs_type], &service_state);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_service_state() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - service_state = %s", convert_network_service_state(service_state));
-
- return 0;
-}
-
-static int run_network_get_type(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_network_type_e type;
-
- msg("call telephony_network_get_type()");
-
- ret = telephony_network_get_type(handle_list->handle[subs_type], &type);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_type() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - type = %s", convert_network_type(type));
-
- return 0;
-}
-
-static int run_network_get_ps_type(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_network_ps_type_e ps_type;
-
- msg("call telephony_network_get_ps_type()");
-
- ret = telephony_network_get_ps_type(handle_list->handle[subs_type], &ps_type);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_ps_type() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - ps_type = %s", convert_network_ps_type(ps_type));
-
- return 0;
-}
-
-static int run_network_get_dds(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_network_default_data_subs_e dds;
-
- msg("call telephony_network_get_default_data_subscription()");
-
- ret = telephony_network_get_default_data_subscription(handle_list->handle[subs_type], &dds);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_default_data_subscription() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - default_data_subscription = %s", convert_network_dds(dds));
-
- return 0;
-}
-
-static int run_network_get_ds(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_network_default_subs_e ds;
-
- msg("call telephony_network_get_default_subscription()");
-
- ret = telephony_network_get_default_subscription(handle_list->handle[subs_type], &ds);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_default_subscription() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - default_subscription = %s", convert_network_ds(ds));
-
- return 0;
-}
-
-static int run_network_get_selection_mode(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_network_selection_mode_e mode;
-
- msg("call telephony_network_get_selection_mode()");
-
- ret = telephony_network_get_selection_mode(handle_list->handle[subs_type], &mode);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_selection_mode() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - selection_mode = %s", convert_network_selection_mode(mode));
-
- return 0;
-}
-
-static int run_network_get_tac(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- int tac;
-
- msg("call telephony_network_get_tac()");
-
- ret = telephony_network_get_tac(handle_list->handle[subs_type], &tac);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_tac() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - tac = %d", tac);
-
- return 0;
-}
-
-static int run_network_get_system_id(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- int system_id;
-
- msg("call telephony_network_get_system_id()");
-
- ret = telephony_network_get_system_id(handle_list->handle[subs_type], &system_id);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_system_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - system_id = %d", system_id);
-
- return 0;
-}
-
-static int run_network_get_network_id(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- int network_id;
-
- msg("call telephony_network_get_network_id()");
-
- ret = telephony_network_get_network_id(handle_list->handle[subs_type], &network_id);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_network_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - network_id = %d", network_id);
-
- return 0;
-}
-
-static int run_network_get_bs_id(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- int bs_id;
-
- msg("call telephony_network_get_base_station_id()");
-
- ret = telephony_network_get_base_station_id(handle_list->handle[subs_type], &bs_id);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_base_station_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - base_station_id = %d", bs_id);
-
- return 0;
-}
-
-static int run_network_get_bs_latitude(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- int bs_latitude;
-
- msg("call telephony_network_get_base_station_latitude()");
-
- ret = telephony_network_get_base_station_latitude(handle_list->handle[subs_type], &bs_latitude);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_base_station_latitude() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - base_station_latitude = %d", bs_latitude);
-
- return 0;
-}
-
-static int run_network_get_bs_longitude(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- int bs_longitude;
-
- msg("call telephony_network_get_base_station_longitude()");
-
- ret = telephony_network_get_base_station_longitude(handle_list->handle[subs_type], &bs_longitude);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_base_station_longitude() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - base_station_longitude = %d", bs_longitude);
-
- return 0;
-}
-
-static int run_network_get_signal_strength(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- int dbm;
-
- msg("call telephony_network_get_signal_strength()");
-
- ret = telephony_network_get_signal_strength(handle_list->handle[subs_type], &dbm);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_network_get_signal_strength() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - signal strength in dBm = %d", dbm);
-
- return 0;
-}
-
-struct menu_data menu_network[] = {
- {"1", "telephony_network_get_cell_id", NULL, run_network_get_cell_id, NULL},
- {"2", "telephony_network_get_lac", NULL, run_network_get_lac, NULL},
- {"3", "telephony_network_get_mcc", NULL, run_network_get_mcc, NULL},
- {"4", "telephony_network_get_mnc", NULL, run_network_get_mnc, NULL},
- {"5", "telephony_network_get_network_name", NULL, run_network_get_network_name, NULL},
- {"6", "telephony_network_get_network_name_option", NULL, run_network_get_network_name_option, NULL},
- {"7", "telephony_network_get_roaming_status", NULL, run_network_get_roaming_status, NULL},
- {"8", "telephony_network_get_rssi", NULL, run_network_get_rssi, NULL},
- {"9", "telephony_network_get_service_state", NULL, run_network_get_service_state, NULL},
- {"10", "telephony_network_get_type", NULL, run_network_get_type, NULL},
- {"11", "telephony_network_get_ps_type", NULL, run_network_get_ps_type, NULL},
- {"12", "telephony_network_get_default_data_subscription", NULL, run_network_get_dds, NULL},
- {"13", "telephony_network_get_default_subscription", NULL, run_network_get_ds, NULL},
- {"14", "telephony_network_get_selection_mode", NULL, run_network_get_selection_mode, NULL},
- {"15", "telephony_network_get_tac", NULL, run_network_get_tac, NULL},
- {"16", "telephony_network_get_system_id", NULL, run_network_get_system_id, NULL},
- {"17", "telephony_network_get_network_id", NULL, run_network_get_network_id, NULL},
- {"18", "telephony_network_get_base_station_id", NULL, run_network_get_bs_id, NULL},
- {"19", "telephony_network_get_base_station_latitude", NULL, run_network_get_bs_latitude, NULL},
- {"20", "telephony_network_get_base_station_longitude", NULL, run_network_get_bs_longitude, NULL},
- {"21", "telephony_network_get_signal_strength", NULL, run_network_get_signal_strength, NULL},
- {NULL, },
-};
-
-void register_network_event(telephony_handle_list_s *handle_list)
-{
- int ret, i;
-
- for (i = 0; i < (sizeof(network_noti_tbl) / sizeof(int)); i++) {
- ret = telephony_set_noti_cb(handle_list->handle[subs_type], network_noti_tbl[i], network_noti_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE)
- msg("telephony_set_noti_cb() failed!!! i(%d), ret(%d,%s)", i, ret, get_error_message(ret));
- }
-}
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 __NETWORK_H__
-#define __NETWORK_H__
-
-#include <telephony.h>
-
-void register_network_event(telephony_handle_list_s *handle_list);
-
-#endif
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include <telephony.h>
-
-#include "menu.h"
-#include "sim.h"
-
-extern int subs_type;
-
-static int sim_noti_tbl[] = {
- TELEPHONY_NOTI_SIM_STATUS,
- TELEPHONY_NOTI_SIM_CALL_FORWARDING_INDICATOR_STATE
-};
-
-static const char *convert_sim_state(telephony_sim_state_e state)
-{
- switch (state) {
- case TELEPHONY_SIM_STATE_UNAVAILABLE:
- return "UNAVAILABLE";
- case TELEPHONY_SIM_STATE_LOCKED:
- return "LOCKED";
- case TELEPHONY_SIM_STATE_AVAILABLE:
- return "AVAILABLE";
- case TELEPHONY_SIM_STATE_UNKNOWN:
- default:
- return "UNKNOWN";
- }
-}
-
-static const char *convert_sim_lock_state(telephony_sim_lock_state_e lock_state)
-{
- switch (lock_state) {
- case TELEPHONY_SIM_LOCK_STATE_PIN_REQUIRED:
- return "PIN_REQUIRED";
- case TELEPHONY_SIM_LOCK_STATE_PUK_REQUIRED:
- return "PUK_REQUIRED";
- case TELEPHONY_SIM_LOCK_STATE_PERM_LOCKED:
- return "PERM_LOCKED";
- case TELEPHONY_SIM_LOCK_STATE_NCK_REQUIRED:
- return "NCK_REQUIRED";
- case TELEPHONY_SIM_LOCK_STATE_UNKNOWN:
- default:
- return "UNKNOWN";
- }
-}
-
-static void sim_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
-{
- msg("");
- switch (noti_id) {
- case TELEPHONY_NOTI_SIM_STATUS:
- msgb("NOTI_SIM_STATUS received!!!");
- msg(" - state = %s", convert_sim_state(*(int *)data));
- break;
- case TELEPHONY_NOTI_SIM_CALL_FORWARDING_INDICATOR_STATE:
- msgb("NOTI_CALL_FORWARDING_INDICATOR_STATE received!!!");
- msg(" - call_forwarding_indicator_state = %s", *(int *)data ? "TRUE" : "FALSE");
- break;
- default:
- msgb("Unknown notification received!!!");
- break;
- }
-}
-
-static int run_sim_is_changed(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- bool is_changed;
-
- msg("call telephony_sim_is_changed()");
-
- ret = telephony_sim_is_changed(handle_list->handle[subs_type], &is_changed);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_is_changed() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - is_changed = %s", is_changed ? "TRUE" : "FALSE");
-
- return 0;
-}
-
-static int run_sim_get_operator(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *operator;
-
- msg("call telephony_sim_get_operator()");
-
- ret = telephony_sim_get_operator(handle_list->handle[subs_type], &operator);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_operator() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - operator = %s", operator);
-
- return 0;
-}
-
-static int run_sim_get_icc_id(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *icc_id;
-
- msg("call telephony_sim_get_icc_id()");
-
- ret = telephony_sim_get_icc_id(handle_list->handle[subs_type], &icc_id);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_icc_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - icc_id = %s", icc_id);
-
- return 0;
-}
-
-static int run_sim_get_msin(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *msin;
-
- msg("call telephony_sim_get_msin()");
-
- ret = telephony_sim_get_msin(handle_list->handle[subs_type], &msin);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_msin() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - msin = %s", msin);
-
- return 0;
-}
-
-static int run_sim_get_spn(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *spn;
-
- msg("call telephony_sim_get_spn()");
-
- ret = telephony_sim_get_spn(handle_list->handle[subs_type], &spn);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_spn() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - spn = %s", spn);
-
- return 0;
-}
-
-static int run_sim_get_state(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_sim_state_e state;
-
- msg("call telephony_sim_get_state()");
-
- ret = telephony_sim_get_state(handle_list->handle[subs_type], &state);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_state() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - state = %s", convert_sim_state(state));
-
- return 0;
-}
-
-static int run_sim_get_app_list(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_sim_application_type_e app_list;
-
- msg("call telephony_sim_get_application_list()");
-
- ret = telephony_sim_get_application_list(handle_list->handle[subs_type], &app_list);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_application_list() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - application_list = 0x%x", app_list);
-
- return 0;
-}
-
-static int run_sim_get_subs_number(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *subs_number;
-
- msg("call telephony_sim_get_subscriber_number()");
-
- ret = telephony_sim_get_subscriber_number(handle_list->handle[subs_type], &subs_number);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_subscriber_number() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - subscriber_number = %s", subs_number);
-
- return 0;
-}
-
-static int run_sim_get_subs_id(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *subs_id;
-
- msg("call telephony_sim_get_subscriber_id()");
-
- ret = telephony_sim_get_subscriber_id(handle_list->handle[subs_type], &subs_id);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_subscriber_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - subscriber_id = %s", subs_id);
-
- return 0;
-}
-
-static int run_sim_get_lock_state(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- telephony_sim_lock_state_e lock_state;
-
- msg("call telephony_sim_get_lock_state()");
-
- ret = telephony_sim_get_lock_state(handle_list->handle[subs_type], &lock_state);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_lock_state() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - lock_state = %s", convert_sim_lock_state(lock_state));
-
- return 0;
-}
-
-static int run_sim_get_group_id1(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- char *gid1;
-
- msg("call telephony_sim_get_group_id1()");
-
- ret = telephony_sim_get_group_id1(handle_list->handle[subs_type], &gid1);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_group_id1() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - gid1 = %s", gid1);
-
- return 0;
-}
-
-static int run_sim_get_call_forward_ind_state(MManager *mm, struct menu_data *menu)
-{
- telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
- int ret;
- bool call_forward_ind_state;
-
- msg("call telephony_sim_get_call_forwarding_indicator_state()");
-
- ret = telephony_sim_get_call_forwarding_indicator_state(handle_list->handle[subs_type], &call_forward_ind_state);
- if (ret != TELEPHONY_ERROR_NONE) {
- msg("telephony_sim_get_call_forwarding_indicator_state() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
- return 0;
- }
-
- msg(" - call_forwarding_indicator_state = %s", call_forward_ind_state ? "TRUE" : "FALSE");
-
- return 0;
-}
-
-struct menu_data menu_sim[] = {
- {"1", "telephony_sim_is_changed", NULL, run_sim_is_changed, NULL},
- {"2", "telephony_sim_get_operator", NULL, run_sim_get_operator, NULL},
- {"3", "telephony_sim_get_icc_id", NULL, run_sim_get_icc_id, NULL},
- {"4", "telephony_sim_get_msin", NULL, run_sim_get_msin, NULL},
- {"5", "telephony_sim_get_spn", NULL, run_sim_get_spn, NULL},
- {"6", "telephony_sim_get_state", NULL, run_sim_get_state, NULL},
- {"7", "telephony_sim_get_application_list", NULL, run_sim_get_app_list, NULL},
- {"8", "telephony_sim_get_subscriber_number", NULL, run_sim_get_subs_number, NULL},
- {"9", "telephony_sim_get_subscriber_id", NULL, run_sim_get_subs_id, NULL},
- {"10", "telephony_sim_get_lock_state", NULL, run_sim_get_lock_state, NULL},
- {"11", "telephony_sim_get_group_id1", NULL, run_sim_get_group_id1, NULL},
- {"12", "telephony_sim_get_call_forwarding_indicator_state", NULL, run_sim_get_call_forward_ind_state, NULL},
- {NULL, },
-};
-
-void register_sim_event(telephony_handle_list_s *handle_list)
-{
- int ret, i;
-
- for (i = 0; i < (sizeof(sim_noti_tbl) / sizeof(int)); i++) {
- ret = telephony_set_noti_cb(handle_list->handle[subs_type], sim_noti_tbl[i], sim_noti_cb, NULL);
- if (ret != TELEPHONY_ERROR_NONE)
- msg("telephony_set_noti_cb() failed!!! i(%d), ret(%d,%s)", i, ret, get_error_message(ret));
- }
-}
-
+++ /dev/null
-/*
- * telephony
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 _SIM_H_
-#define _SIM_H_
-
-#include <telephony.h>
-
-void register_sim_event(telephony_handle_list_s *handle_list);
-
-#endif /* _SIM_H_ */
-
--- /dev/null
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
+
+SET(TELE_TEST "telephony-test")
+
+FILE(GLOB TEST_SRCS *.c)
+ADD_EXECUTABLE(${TELE_TEST} ${TEST_SRCS})
+TARGET_LINK_LIBRARIES(${TELE_TEST} ${PROJECT_NAME})
+SET_TARGET_PROPERTIES(${TELE_TEST} PROPERTIES COMPILE_FLAGS "-fPIE")
+INSTALL(TARGETS ${TELE_TEST} DESTINATION ${BIN_INSTALL_DIR})
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include <telephony.h>
+
+#include "menu.h"
+#include "call.h"
+
+extern int subs_type;
+
+static int call_noti_tbl[] = {
+ TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE,
+ TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE,
+ TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD,
+ TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING,
+ TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING,
+ TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING,
+ TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION
+};
+
+static const char *convert_call_type(telephony_call_type_e type)
+{
+ switch (type) {
+ case TELEPHONY_CALL_TYPE_VOICE:
+ return "VOICE";
+ case TELEPHONY_CALL_TYPE_VIDEO:
+ return "VIDEO";
+ case TELEPHONY_CALL_TYPE_E911:
+ return "E911";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_call_status(telephony_call_status_e type)
+{
+ switch (type) {
+ case TELEPHONY_CALL_STATUS_IDLE:
+ return "IDLE";
+ case TELEPHONY_CALL_STATUS_ACTIVE:
+ return "ACTIVE";
+ case TELEPHONY_CALL_STATUS_HELD:
+ return "HELD";
+ case TELEPHONY_CALL_STATUS_DIALING:
+ return "DIALING";
+ case TELEPHONY_CALL_STATUS_ALERTING:
+ return "ALERTING";
+ case TELEPHONY_CALL_STATUS_INCOMING:
+ return "INCOMING";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_call_direction(telephony_call_direction_e direction)
+{
+ switch (direction) {
+ case TELEPHONY_CALL_DIRECTION_MO:
+ return "MO";
+ case TELEPHONY_CALL_DIRECTION_MT:
+ return "MT";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_call_pref_voice_subs(telephony_call_preferred_voice_subs_e pref_voice_subs)
+{
+ switch (pref_voice_subs) {
+ case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_CURRENT_NETWORK:
+ return "CURRENT_NETWORK";
+ case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_ASK_ALWAYS:
+ return "ASK_ALWAYS";
+ case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_SIM1:
+ return "SIM1";
+ case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_SIM2:
+ return "SIM2";
+ case TELEPHONY_CALL_PREFERRED_VOICE_SUBS_UNKNOWN:
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static void call_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
+{
+ int ret;
+ telephony_call_h *call_list;
+ unsigned int call_count;
+ int i;
+
+ msg("");
+ switch (noti_id) {
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE:
+ msgb("NOTI_VOICE_CALL_STATUS_IDLE received!!!");
+ msg(" - handle_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE:
+ msgb("NOTI_VOICE_CALL_STATUS_ACTIVE received!!!");
+ msg(" - handle_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD:
+ msgb("NOTI_VOICE_CALL_STATUS_HELD received!!!");
+ msg(" - handle_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING:
+ msgb("NOTI_VOICE_CALL_STATUS_DIALING received!!!");
+ msg(" - handle_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING:
+ msgb("NOTI_VOICE_CALL_STATUS_ALERTING received!!!");
+ msg(" - handle_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING:
+ msgb("NOTI_VOICE_CALL_STATUS_INCOMING received!!!");
+ msg(" - handle_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION:
+ msgb("NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION received!!!");
+ msg(" - preferred_voice_subscription = %s", convert_call_pref_voice_subs(*(int *)data));
+ return;
+ default:
+ msgb("Unknown notification received!!!");
+ return;
+ }
+
+ msg("call telephony_call_get_call_list()");
+ ret = telephony_call_get_call_list(handle, &call_count, &call_list);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_call_get_call_list() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return;
+ }
+
+ msg(" - count = %d", call_count);
+ for (i = 0; i < call_count; i++) {
+ unsigned int handle_id;
+ char *number;
+ telephony_call_type_e type;
+ telephony_call_status_e status;
+ telephony_call_direction_e direction;
+ bool conf_status;
+
+ telephony_call_get_handle_id(call_list[i], &handle_id);
+ telephony_call_get_number(call_list[i], &number);
+ telephony_call_get_type(call_list[i], &type);
+ telephony_call_get_status(call_list[i], &status);
+ telephony_call_get_direction(call_list[i], &direction);
+ telephony_call_get_conference_status(call_list[i], &conf_status);
+
+ msg("");
+ msg(" - handle_id = %d", handle_id);
+ msg(" - number = %s", number);
+ msg(" - type = %s", convert_call_type(type));
+ msg(" - status = %s", convert_call_status(status));
+ msg(" - direction = %s", convert_call_direction(direction));
+ msg(" - conference_status = %s", conf_status ? "TRUE" : "FALSE");
+ free(number);
+ }
+ telephony_call_release_call_list(call_count, &call_list);
+}
+
+static int run_call_get_call_list(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_call_h *call_list;
+ unsigned int call_count;
+ int i;
+
+ msg("call telephony_call_get_call_list()");
+
+ ret = telephony_call_get_call_list(handle_list->handle[subs_type], &call_count, &call_list);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_call_get_call_list() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - count = %d", call_count);
+ for (i = 0; i < call_count; i++) {
+ unsigned int handle_id;
+ char *number;
+ telephony_call_type_e type;
+ telephony_call_status_e status;
+ telephony_call_direction_e direction;
+ bool conf_status;
+
+ telephony_call_get_handle_id(call_list[i], &handle_id);
+ telephony_call_get_number(call_list[i], &number);
+ telephony_call_get_type(call_list[i], &type);
+ telephony_call_get_status(call_list[i], &status);
+ telephony_call_get_direction(call_list[i], &direction);
+ telephony_call_get_conference_status(call_list[i], &conf_status);
+
+ msg("");
+ msg(" - handle_id = %d", handle_id);
+ msg(" - number = %s", number);
+ msg(" - type = %s", convert_call_type(type));
+ msg(" - status = %s", convert_call_status(status));
+ msg(" - direction = %s", convert_call_direction(direction));
+ msg(" - conference_status = %s", conf_status ? "TRUE" : "FALSE");
+ free(number);
+ }
+ telephony_call_release_call_list(call_count, &call_list);
+
+ return 0;
+}
+
+static int run_call_get_pref_voice_subs(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_call_preferred_voice_subs_e pref_voice_subs;
+
+ msg("call telephony_call_get_preferred_voice_subscriptions()");
+
+ ret = telephony_call_get_preferred_voice_subscription(handle_list->handle[subs_type], &pref_voice_subs);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_call_get_preferred_voice_subscription() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - preferred_voice_subscription = %s", convert_call_pref_voice_subs(pref_voice_subs));
+
+ return 0;
+}
+
+struct menu_data menu_call[] = {
+ {"1", "telephony_call_get_preferred_voice_subscription", NULL, run_call_get_pref_voice_subs, NULL},
+ {"2", "telephony_call_get_call_list", NULL, run_call_get_call_list, NULL},
+ {NULL, },
+};
+
+void register_call_event(telephony_handle_list_s *handle_list)
+{
+ int ret, i;
+
+ for (i = 0; i < (sizeof(call_noti_tbl) / sizeof(int)); i++) {
+ ret = telephony_set_noti_cb(handle_list->handle[subs_type], call_noti_tbl[i], call_noti_cb, NULL);
+ if (ret != TELEPHONY_ERROR_NONE)
+ msg("telephony_set_noti_cb() failed!!! i(%d), ret(%d,%s)", i, ret, get_error_message(ret));
+ }
+}
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __CALL_H__
+#define __CALL_H__
+
+#include <telephony.h>
+
+void register_call_event(telephony_handle_list_s *handle_list);
+
+#endif
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <telephony.h>
+
+#include "menu.h"
+#include "call.h"
+#include "modem.h"
+#include "network.h"
+#include "sim.h"
+
+#define SIM_SEL_MENU_KEY_COUNT 2
+
+extern struct menu_data menu_call[];
+extern struct menu_data menu_modem[];
+extern struct menu_data menu_network[];
+extern struct menu_data menu_sim[];
+
+telephony_handle_list_s handle_list;
+int subs_type = 0;
+
+static char data_subscription_type[MENU_DATA_SIZE + 1] = "";
+
+static struct menu_data menu_main[] = {
+ {"1", "Call", menu_call, NULL, NULL},
+ {"2", "Modem", menu_modem, NULL, NULL},
+ {"3", "Network", menu_network, NULL, NULL},
+ {"4", "SIM", menu_sim, NULL, NULL},
+ {NULL, },
+};
+
+static int __select_handle_register_event(MManager *mm, struct menu_data *menu)
+{
+ subs_type = atoi(data_subscription_type) - 1;
+
+ if (subs_type < 0 || subs_type > handle_list.count - 1) {
+ msg("Please select an existing CP Name");
+ return RET_FAILURE;
+ }
+
+ msg("");
+
+ menu_manager_set_user_data(mm, &handle_list);
+
+ register_call_event(&handle_list);
+ register_modem_event(&handle_list);
+ register_network_event(&handle_list);
+ register_sim_event(&handle_list);
+
+ return RET_SUCCESS;
+}
+
+static gboolean __create_sim_selection_menu(struct menu_data sim_selection_menu[SIM_SEL_MENU_KEY_COUNT+1])
+{
+ unsigned int index_count = 0;
+ unsigned int i = 0;
+ int ret;
+
+ ret = telephony_init(&handle_list);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_init() failed!!! ret(%d,%s)", ret, get_error_message(ret));
+ return FALSE;
+ }
+
+ /*
+ * Available CPs are displayed as below (in UI) -
+ * Modems(1=SIM1,2=SIM2)
+ */
+ index_count += snprintf((char *)&sim_selection_menu[0].title[index_count], 100, "Modems(");
+
+ for (i = 0; i < handle_list.count; i++) {
+ if (i != 0)
+ strncat((char *)&sim_selection_menu[0].title[index_count++], ",", sizeof(char));
+
+ index_count += snprintf((char *)&sim_selection_menu[0].title[index_count], 100, "%d=SIM%d", i + 1, i + 1);
+ }
+ strncat((char *)&sim_selection_menu[0].title[index_count++], ")", sizeof(char));
+ strncat((char *)&sim_selection_menu[0].title[index_count], "\0", sizeof(char));
+
+ sim_selection_menu[0].key = "1";
+ sim_selection_menu[0].sub_menu = NULL;
+ sim_selection_menu[0].callback = NULL;
+ sim_selection_menu[0].data = data_subscription_type;
+
+ sim_selection_menu[1].key = "2";
+ snprintf((char *)&sim_selection_menu[1].title, 100, "run");
+ sim_selection_menu[1].sub_menu = menu_main;
+ sim_selection_menu[1].callback = __select_handle_register_event;
+ sim_selection_menu[1].data = NULL;
+
+ return TRUE;
+}
+
+int main(int arg, char **argv)
+{
+ GMainLoop *mainloop = NULL;
+ GIOChannel *channel = g_io_channel_unix_new(STDIN_FILENO);
+ MManager *manager;
+ struct menu_data sim_selection_menu[SIM_SEL_MENU_KEY_COUNT+1] = { {NULL, }, };
+
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+ g_type_init();
+#endif
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ msg("");
+ msg("* Telephony Test application ");
+
+ if (__create_sim_selection_menu(sim_selection_menu) == FALSE)
+ goto OUT;
+
+ manager = menu_manager_new(sim_selection_menu, mainloop);
+ if (!manager)
+ goto OUT;
+
+ menu_manager_run(manager);
+
+ g_io_add_watch(channel, (G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL),
+ on_menu_manager_keyboard, manager);
+ g_main_loop_run(mainloop);
+
+OUT:
+ g_main_loop_unref(mainloop);
+ msg("******* Bye bye *******");
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <glib.h>
+#include <asm/unistd.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#include "menu.h"
+
+#define DEFAULT_MENU_MENU "m"
+#define DEFAULT_MENU_PREV "p"
+#define DEFAULT_MENU_QUIT "q"
+#define DEFAULT_MENU_NONE "-"
+#define TAB_SPACE " "
+
+struct menu_manager {
+ GQueue *stack;
+ GQueue *title_stack;
+
+ struct menu_data *menu;
+
+ char *buf;
+
+ void *user_data;
+ GMainLoop *mainloop;
+};
+
+
+char key_buffer[MENU_DATA_SIZE];
+int flag_pid_display = 1;
+
+
+static void _show_prompt(void)
+{
+ msgn("(%5d) >> ", get_tid());
+}
+
+static void _show_reserved_menu(void)
+{
+ msg(ANSI_COLOR_DARKGRAY HR_SINGLE2 ANSI_COLOR_NORMAL);
+ msg(ANSI_COLOR_DARKGRAY " [ " ANSI_COLOR_NORMAL "%s" ANSI_COLOR_DARKGRAY
+ " ] " ANSI_COLOR_NORMAL "Previous menu " , DEFAULT_MENU_PREV);
+ msg(ANSI_COLOR_DARKGRAY " [ " ANSI_COLOR_NORMAL "%s" ANSI_COLOR_DARKGRAY
+ " ] " ANSI_COLOR_NORMAL "Show Menu " , DEFAULT_MENU_MENU);
+ msg(ANSI_COLOR_DARKGRAY " [ " ANSI_COLOR_NORMAL "%s" ANSI_COLOR_DARKGRAY
+ " ] " ANSI_COLOR_NORMAL "Quit " , DEFAULT_MENU_QUIT);
+}
+
+static void _show_input_ok(void)
+{
+ msg("OK.");
+}
+
+static void _show_menu(MManager *m, struct menu_data menu[])
+{
+ int i = 0;
+ int len = 0;
+ struct menu_data *item;
+ char title_buf[256] = { 0, };
+
+ if (!menu)
+ return;
+
+ msg("");
+ msg(HR_DOUBLE);
+
+ len = g_queue_get_length(m->title_stack);
+ msgn(ANSI_COLOR_YELLOW " Main");
+ if (len > 0) {
+ for (i = 0; i < len; i++) {
+ msgn(ANSI_COLOR_NORMAL " >> " ANSI_COLOR_YELLOW "%s",
+ (char *)g_queue_peek_nth(m->title_stack, i));
+ }
+ }
+ msg(ANSI_COLOR_NORMAL);
+ msg(HR_SINGLE);
+
+ hide_pid();
+ i = 0;
+
+ while (1) {
+ item = menu + i;
+ if (item->key == NULL)
+ break;
+
+ if (!g_strcmp0(item->key, "-")) {
+ msgn(" ");
+ } else if (!g_strcmp0(item->key, "_")) {
+ msg(ANSI_COLOR_DARKGRAY HR_SINGLE2 ANSI_COLOR_NORMAL);
+
+ if (item->callback)
+ item->callback(m, item);
+
+ i++;
+
+ continue;
+ } else if (!g_strcmp0(item->key, "*")) {
+ msg(" %s", item->title);
+ if (item->callback)
+ item->callback(m, item);
+ } else {
+ msgn(ANSI_COLOR_DARKGRAY " [" ANSI_COLOR_NORMAL "%3s"
+ ANSI_COLOR_DARKGRAY "] " ANSI_COLOR_NORMAL, item->key);
+ }
+
+ memset(title_buf, 0, 256);
+ if (item->title) {
+ snprintf(title_buf, MAX_TITLE, "%s", item->title);
+
+ if (strlen(item->title) >= MAX_TITLE) {
+ title_buf[MAX_TITLE - 2] = '.';
+ title_buf[MAX_TITLE - 1] = '.';
+ }
+ }
+
+ if (item->data) {
+ msg("%s " ANSI_COLOR_LIGHTBLUE "(%s)" ANSI_COLOR_NORMAL,
+ title_buf, item->data);
+ } else if (!g_strcmp0(item->key, "*")) {
+ /* none */
+ } else {
+ msg("%s", title_buf);
+ }
+
+ if (item->sub_menu)
+ msg("\e[1A\e[%dC >", (int)POS_MORE);
+
+ i++;
+ }
+
+ show_pid();
+
+ _show_reserved_menu();
+
+ msg(HR_DOUBLE);
+
+ _show_prompt();
+}
+
+static void _show_item_data_input_msg(struct menu_data *item)
+{
+ msg("");
+ msg(HR_DOUBLE);
+ msg(" Input [%s] data ", item->title);
+ msg(HR_SINGLE);
+ msg(" current = [%s]", item->data);
+ msgn(" new >> ");
+}
+
+static void _move_menu(MManager *mm, struct menu_data menu[], char *key)
+{
+ struct menu_data *item;
+ int i = 0;
+
+ if (!mm->menu)
+ return;
+
+ if (!g_strcmp0(DEFAULT_MENU_PREV, key)) {
+ if (g_queue_get_length(mm->stack) > 0) {
+ mm->menu = g_queue_pop_tail(mm->stack);
+ g_queue_pop_tail(mm->title_stack);
+ }
+
+ _show_menu(mm, mm->menu);
+ mm->buf = key_buffer;
+
+ return;
+ } else if (!g_strcmp0(DEFAULT_MENU_MENU, key)) {
+ _show_menu(mm, mm->menu);
+ return;
+ } else if (!g_strcmp0(DEFAULT_MENU_QUIT, key)) {
+ g_main_loop_quit(mm->mainloop);
+ return;
+ } else if (!g_strcmp0(DEFAULT_MENU_NONE, key)) {
+ _show_prompt();
+ return;
+ }
+
+ while (1) {
+ int ret = RET_SUCCESS;
+ item = menu + i;
+ if (item->key == NULL)
+ break;
+
+ if (!g_strcmp0(item->key, key)) {
+ if (item->callback) {
+ ret = item->callback(mm, item);
+ _show_prompt();
+ }
+
+ if (RET_SUCCESS == ret) {
+ if (item->sub_menu) {
+ g_queue_push_tail(mm->stack, mm->menu);
+ //g_queue_push_tail(mm->title_stack, (gpointer *)item->title);
+ g_queue_push_tail(mm->title_stack, item->title);
+
+ mm->menu = item->sub_menu;
+ _show_menu(mm, mm->menu);
+ mm->buf = key_buffer;
+ }
+
+ if (item->data) {
+ _show_item_data_input_msg(item);
+ mm->buf = item->data;
+ }
+ }
+
+ return;
+ }
+
+ i++;
+ }
+
+ _show_prompt();
+}
+
+MManager *menu_manager_new(struct menu_data items[], GMainLoop *mainloop)
+{
+ MManager *mm;
+
+ mm = calloc(sizeof(struct menu_manager), 1);
+ if (!mm)
+ return NULL;
+
+ mm->stack = g_queue_new();
+ mm->title_stack = g_queue_new();
+ mm->menu = items;
+ mm->mainloop = mainloop;
+
+ return mm;
+}
+
+int menu_manager_run(MManager *mm)
+{
+ _show_menu(mm, mm->menu);
+
+ mm->buf = key_buffer;
+
+ return 0;
+}
+
+int menu_manager_set_user_data(MManager *mm, void *user_data)
+{
+ if (!mm)
+ return -1;
+
+ mm->user_data = user_data;
+
+ return 0;
+}
+
+void *menu_manager_ref_user_data(MManager *mm)
+{
+ if (!mm)
+ return NULL;
+
+ return mm->user_data;
+}
+
+gboolean on_menu_manager_keyboard(GIOChannel *src, GIOCondition con,
+ gpointer data)
+{
+ MManager *mm = data;
+ char local_buf[MENU_DATA_SIZE + 1] = { 0, };
+
+ if (fgets(local_buf, MENU_DATA_SIZE, stdin) == NULL)
+ return TRUE;
+
+ if (strlen(local_buf) > 0) {
+ if (local_buf[strlen(local_buf) - 1] == '\n')
+ local_buf[strlen(local_buf) - 1] = '\0';
+ }
+
+ if (mm->buf == key_buffer) {
+ if (strlen(local_buf) < 1) {
+ _show_prompt();
+ return TRUE;
+ }
+
+ _move_menu(mm, mm->menu, local_buf);
+ } else {
+ if (mm->buf) {
+ memset(mm->buf, 0, MENU_DATA_SIZE);
+ memcpy(mm->buf, local_buf, MENU_DATA_SIZE);
+ _show_input_ok();
+ }
+ mm->buf = key_buffer;
+ _move_menu(mm, mm->menu, (char *)DEFAULT_MENU_MENU);
+ }
+
+ return TRUE;
+}
+
+pid_t get_tid()
+{
+ return syscall(__NR_gettid);
+}
+
+void hide_pid()
+{
+ flag_pid_display = 0;
+}
+
+void show_pid()
+{
+ flag_pid_display = 1;
+}
+
+int is_pid_show()
+{
+ return flag_pid_display;
+}
+
+static void _hex_dump(const char *pad, int size, const void *data)
+{
+ int i;
+ char buf[255];
+ unsigned char *p;
+
+ if (size <= 0) {
+ msg("%sno data", pad);
+ return;
+ }
+ p = (unsigned char *)data;
+
+ int len = snprintf(buf, 255, "%s%04X: ", pad, 0);
+ for (i = 0; i < size; i++) {
+ len += snprintf(buf + len, sizeof(buf) - len, "%02X ", p[i]);
+
+ if ((i + 1) % 8 == 0) {
+ if ((i + 1) % 16 == 0) {
+ msg("%s", buf);
+ len = snprintf(buf, sizeof(buf), "%s%04X: ", pad, i + 1);
+ } else {
+ len += snprintf(buf + len, sizeof(buf) - len, "%s", TAB_SPACE);
+ }
+ }
+ }
+
+ msg("%s", buf);
+}
+
+void menu_print_dump(int data_len, void *data)
+{
+ if (!data)
+ return;
+
+ msg("");
+ msg(" \tlen=%d", data_len);
+ _hex_dump(" ", data_len, data);
+
+ msg("");
+}
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __MENU_H__
+#define __MENU_H__
+
+__BEGIN_DECLS
+
+#define ANSI_COLOR_NORMAL "\e[0m"
+
+#define ANSI_COLOR_BLACK "\e[0;30m"
+#define ANSI_COLOR_RED "\e[0;31m"
+#define ANSI_COLOR_GREEN "\e[0;32m"
+#define ANSI_COLOR_BROWN "\e[0;33m"
+#define ANSI_COLOR_BLUE "\e[0;34m"
+#define ANSI_COLOR_MAGENTA "\e[0;35m"
+#define ANSI_COLOR_CYAN "\e[0;36m"
+#define ANSI_COLOR_LIGHTGRAY "\e[0;37m"
+
+#define ANSI_COLOR_DARKGRAY "\e[1;30m"
+#define ANSI_COLOR_LIGHTRED "\e[1;31m"
+#define ANSI_COLOR_LIGHTGREEN "\e[1;32m"
+#define ANSI_COLOR_YELLOW "\e[1;33m"
+#define ANSI_COLOR_LIGHTBLUE "\e[1;34m"
+#define ANSI_COLOR_LIGHTMAGENTA "\e[1;35m"
+#define ANSI_COLOR_LIGHTCYAN "\e[1;36m"
+#define ANSI_COLOR_WHITE "\e[1;37m"
+
+
+#define msg(fmt, args...) do { fprintf(stdout, fmt "\n", ##args); \
+ fflush(stdout); } while (0)
+#define msgn(fmt, args...) do { fprintf(stdout, fmt, ##args); \
+ fflush(stdout); } while (0)
+
+/* Bold (green) */
+#define msgb(fmt, args...) do { fprintf(stdout, ANSI_COLOR_LIGHTGREEN fmt \
+ ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
+
+/* Property message */
+#define msgp(fmt, args...) do { fprintf(stdout, ANSI_COLOR_LIGHTMAGENTA fmt \
+ ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
+
+#define msgt(n, fmt, args...) do { fprintf(stdout, "\e[%dC" fmt "\n", \
+ 3 + ((n) * 2), ##args); fflush(stdout); } while (0)
+
+#define pmsg(fmt, args...) do { \
+ if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
+ fprintf(stdout, fmt "\n", ##args); fflush(stdout); } while (0)
+
+#define pmsgb(fmt, args...) do { \
+ if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
+ fprintf(stdout, ANSI_COLOR_LIGHTGREEN fmt \
+ ANSI_COLOR_NORMAL "\n", ##args); fflush(stdout); } while (0)
+
+#define pmsgt(n, fmt, args...) do { \
+ if (is_pid_show()) { fprintf(stdout, "(%5d) ", get_tid()); } \
+ fprintf(stdout, "\e[%dC" fmt "\n", \
+ 3 + ((n) * 2), ##args); fflush(stdout); } while (0)
+
+#define MENU_DATA_SIZE 255
+
+
+
+/*
+ * Horizontal Line - width: 65
+ * .12345678901234567890123456789012345678901234567890.
+ */
+#define HR_SINGLE "----------------------------------------" \
+ "-------------------------"
+#define HR_DOUBLE "========================================" \
+ "========================="
+#define HR_SINGLE2 " ---------------------------------------" \
+ "------------------------ "
+
+#define MAX_WIDTH strlen(HR_SINGLE)
+#define MAX_TITLE ((MAX_WIDTH) - 10)
+#define POS_MORE ((MAX_WIDTH) - 3)
+#define RET_SUCCESS 0
+#define RET_FAILURE -1
+
+typedef struct menu_manager MManager;
+
+struct menu_data {
+ const char *key;
+ char title[100];
+ struct menu_data *sub_menu;
+ int (*callback)(MManager *mm, struct menu_data *menu);
+ char *data;
+};
+
+MManager *menu_manager_new(struct menu_data items[], GMainLoop *mainloop);
+int menu_manager_run(MManager *mm);
+int menu_manager_set_user_data(MManager *mm, void *user_data);
+void *menu_manager_ref_user_data(MManager *mm);
+
+gboolean on_menu_manager_keyboard(GIOChannel *src, GIOCondition con, gpointer data);
+
+pid_t get_tid();
+void hide_pid();
+void show_pid();
+int is_pid_show();
+void menu_print_dump(int data_len, void *data);
+
+__END_DECLS
+
+#endif
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include <telephony.h>
+
+#include "menu.h"
+#include "modem.h"
+
+extern int subs_type;
+
+static int modem_noti_tbl[] = {
+ TELEPHONY_NOTI_MODEM_POWER_STATUS
+};
+
+static const char *convert_modem_power_status(telephony_modem_power_status_e power_status)
+{
+ switch (power_status) {
+ case TELEPHONY_MODEM_POWER_STATUS_ON:
+ return "ON";
+ case TELEPHONY_MODEM_POWER_STATUS_OFF:
+ return "OFF";
+ case TELEPHONY_MODEM_POWER_STATUS_RESET:
+ return "RESET";
+ case TELEPHONY_MODEM_POWER_STATUS_LOW:
+ return "LOW";
+ case TELEPHONY_MODEM_POWER_STATUS_UNKNOWN:
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static void modem_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
+{
+ msg("");
+ switch (noti_id) {
+ case TELEPHONY_NOTI_MODEM_POWER_STATUS:
+ msgb("NOTI_MODEM_POWER_STATUS received!!!");
+ msg(" - power_status = %s", convert_modem_power_status(*(int *)data));
+ break;
+ default:
+ break;
+ }
+}
+
+static int run_modem_get_imei(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *imei = NULL;
+
+ msg("call telephony_modem_get_imei()");
+
+ ret = telephony_modem_get_imei(handle_list->handle[subs_type], &imei);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_modem_get_meid() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - imei = %s", imei);
+
+ return 0;
+}
+
+static int run_modem_get_power_status(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_modem_power_status_e power_status;
+
+ msg("call telephony_modem_get_power_status()");
+
+ ret = telephony_modem_get_power_status(handle_list->handle[subs_type], &power_status);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_modem_get_power_status() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - power_status = %s", convert_modem_power_status(power_status));
+
+ return 0;
+}
+
+static int run_modem_get_meid(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *meid = NULL;
+
+ msg("call telephony_modem_get_meid()");
+
+ ret = telephony_modem_get_meid(handle_list->handle[subs_type], &meid);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_modem_get_meid() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - meid = %s", meid);
+
+ return 0;
+}
+
+struct menu_data menu_modem[] = {
+ {"1", "telephony_modem_get_imei", NULL, run_modem_get_imei, NULL},
+ {"2", "telephony_modem_get_power_status", NULL, run_modem_get_power_status, NULL},
+ {"3", "telephony_modem_get_meid", NULL, run_modem_get_meid, NULL},
+ {NULL, }
+};
+
+void register_modem_event(telephony_handle_list_s *handle_list)
+{
+ int ret, i;
+
+ for (i = 0; i < (sizeof(modem_noti_tbl) / sizeof(int)); i++) {
+ ret = telephony_set_noti_cb(handle_list->handle[subs_type], modem_noti_tbl[i], modem_noti_cb, NULL);
+ if (ret != TELEPHONY_ERROR_NONE)
+ msg("telephony_set_noti_cb() failed!!! i(%d), ret(%d,%s)", i, ret, get_error_message(ret));
+ }
+}
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __MODEM_H__
+#define __MODEM_H__
+
+#include <telephony.h>
+
+void register_modem_event(telephony_handle_list_s *handle_list);
+
+#endif
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include <telephony.h>
+
+#include "menu.h"
+#include "network.h"
+
+extern int subs_type;
+
+static int network_noti_tbl[] = {
+ TELEPHONY_NOTI_NETWORK_SERVICE_STATE,
+ TELEPHONY_NOTI_NETWORK_CELLID,
+ TELEPHONY_NOTI_NETWORK_ROAMING_STATUS,
+ TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL,
+ TELEPHONY_NOTI_NETWORK_NETWORK_NAME,
+ TELEPHONY_NOTI_NETWORK_PS_TYPE,
+ TELEPHONY_NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION,
+ TELEPHONY_NOTI_NETWORK_DEFAULT_SUBSCRIPTION,
+ TELEPHONY_NOTI_NETWORK_LAC,
+ TELEPHONY_NOTI_NETWORK_TAC,
+ TELEPHONY_NOTI_NETWORK_SYSTEM_ID,
+ TELEPHONY_NOTI_NETWORK_NETWORK_ID,
+ TELEPHONY_NOTI_NETWORK_BS_ID,
+ TELEPHONY_NOTI_NETWORK_BS_LATITUDE,
+ TELEPHONY_NOTI_NETWORK_BS_LONGITUDE
+};
+
+static const char *convert_network_name_option(telephony_network_name_option_e name_option)
+{
+ switch (name_option) {
+ case TELEPHONY_NETWORK_NAME_OPTION_NETWORK:
+ return "NETWORK";
+ case TELEPHONY_NETWORK_NAME_OPTION_SPN:
+ return "SPN";
+ case TELEPHONY_NETWORK_NAME_OPTION_ANY:
+ return "ANY";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_network_service_state(telephony_network_service_state_e service_state)
+{
+ switch (service_state) {
+ case TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE:
+ return "IN_SERVICE";
+ case TELEPHONY_NETWORK_SERVICE_STATE_OUT_OF_SERVICE:
+ return "OUT_OF_SERVICE";
+ case TELEPHONY_NETWORK_SERVICE_STATE_EMERGENCY_ONLY:
+ return "EMERGENCY_ONLY";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_network_type(telephony_network_type_e network_type)
+{
+ switch (network_type) {
+ case TELEPHONY_NETWORK_TYPE_GSM:
+ return "GSM";
+ case TELEPHONY_NETWORK_TYPE_GPRS:
+ return "GPRS";
+ case TELEPHONY_NETWORK_TYPE_EDGE:
+ return "EDGE";
+ case TELEPHONY_NETWORK_TYPE_UMTS:
+ return "UMTS";
+ case TELEPHONY_NETWORK_TYPE_HSDPA:
+ return "HSDPA";
+ case TELEPHONY_NETWORK_TYPE_LTE:
+ return "LTE";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_network_ps_type(telephony_network_ps_type_e ps_type)
+{
+ switch (ps_type) {
+ case TELEPHONY_NETWORK_PS_TYPE_HSDPA:
+ return "HSDPA";
+ case TELEPHONY_NETWORK_PS_TYPE_HSUPA:
+ return "HSUPA";
+ case TELEPHONY_NETWORK_PS_TYPE_HSPA:
+ return "HSPA";
+ case TELEPHONY_NETWORK_PS_TYPE_HSPAP:
+ return "HSPAP";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_network_dds(telephony_network_default_data_subs_e dds)
+{
+ switch (dds) {
+ case TELEPHONY_NETWORK_DEFAULT_DATA_SUBS_SIM1:
+ return "SIM1";
+ case TELEPHONY_NETWORK_DEFAULT_DATA_SUBS_SIM2:
+ return "SIM2";
+ case TELEPHONY_NETWORK_DEFAULT_DATA_SUBS_UNKNOWN:
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_network_ds(telephony_network_default_subs_e ds)
+{
+ switch (ds) {
+ case TELEPHONY_NETWORK_DEFAULT_SUBS_SIM1:
+ return "SIM1";
+ case TELEPHONY_NETWORK_DEFAULT_SUBS_SIM2:
+ return "SIM2";
+ case TELEPHONY_NETWORK_DEFAULT_SUBS_UNKNOWN:
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_network_selection_mode(telephony_network_selection_mode_e mode)
+{
+ switch (mode) {
+ case TELEPHONY_NETWORK_SELECTION_MODE_AUTOMATIC:
+ return "AUTOMATIC";
+ case TELEPHONY_NETWORK_SELECTION_MODE_MANUAL:
+ return "MANUAL";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static void network_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
+{
+ msg("");
+ switch (noti_id) {
+ case TELEPHONY_NOTI_NETWORK_SERVICE_STATE:
+ msgb("NOTI_NETWORK_SERVICE_STATE received!!!");
+ msg(" - service_state = %s", convert_network_service_state(*(int *)data));
+ break;
+ case TELEPHONY_NOTI_NETWORK_CELLID:
+ msgb("NOTI_NETWORK_CELLID received!!!");
+ msg(" - cell_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_ROAMING_STATUS:
+ msgb("NOTI_NETWORK_ROAMING_STATUS received!!!");
+ msg(" - roaming_status = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL:
+ msgb("NOTI_NETWORK_SIGNALSTRENGTH_LEVEL received!!!");
+ msg(" - rssi = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_NETWORK_NAME:
+ msgb("NOTI_NETWORK_NETWORK_NAME received!!!");
+ msg(" - network_name = %s", (char *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_PS_TYPE:
+ msgb("NOTI_NETWORK_PS_TYPE received!!!");
+ msg(" - ps_type = %s", convert_network_ps_type(*(int *)data));
+ break;
+ case TELEPHONY_NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION:
+ msgb("NOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION received!!!");
+ msg(" - default_data_subscription = %s", convert_network_dds(*(int *)data));
+ break;
+ case TELEPHONY_NOTI_NETWORK_DEFAULT_SUBSCRIPTION:
+ msgb("NOTI_NETWORK_DEFAULT_SUBSCRIPTION received!!!");
+ msg(" - default_subscription = %s", convert_network_ds(*(int *)data));
+ break;
+ case TELEPHONY_NOTI_NETWORK_LAC:
+ msgb("NOTI_NETWORK_LAC received!!!");
+ msg(" - lac = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_TAC:
+ msgb("NOTI_NETWORK_TAC received!!!");
+ msg(" - tac = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_SYSTEM_ID:
+ msgb("NOTI_NETWORK_SYSTEM_ID received!!!");
+ msg(" - system_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_NETWORK_ID:
+ msgb("NOTI_NETWORK_NETWORK_ID received!!!");
+ msg(" - network_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_BS_ID:
+ msgb("NOTI_NETWORK_BS_ID received!!!");
+ msg(" - base_station_id = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_BS_LATITUDE:
+ msgb("NOTI_NETWORK_BS_LATITUDE received!!!");
+ msg(" - base_station_latitude = %d", *(int *)data);
+ break;
+ case TELEPHONY_NOTI_NETWORK_BS_LONGITUDE:
+ msgb("NOTI_NETWORK_BS_LONGITUDE received!!!");
+ msg(" - base_station_longitude = %d", *(int *)data);
+ break;
+ default:
+ msgb("Unknown notification received!!!");
+ break;
+ }
+}
+
+static int run_network_get_cell_id(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ int cell_id;
+
+ msg("call telephony_network_get_cell_id()");
+
+ ret = telephony_network_get_cell_id(handle_list->handle[subs_type], &cell_id);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_cell_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - cell_id = %d", cell_id);
+
+ return 0;
+}
+
+static int run_network_get_lac(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ int lac;
+
+ msg("call telephony_network_get_lac()");
+
+ ret = telephony_network_get_lac(handle_list->handle[subs_type], &lac);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_lac() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - lac = %d", lac);
+
+ return 0;
+}
+
+static int run_network_get_mcc(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *mcc;
+
+ msg("call telephony_network_get_mcc()");
+
+ ret = telephony_network_get_mcc(handle_list->handle[subs_type], &mcc);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_mcc() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - mcc = %s", mcc);
+
+ return 0;
+}
+
+static int run_network_get_mnc(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *mnc;
+
+ msg("call telephony_network_get_mnc()");
+
+ ret = telephony_network_get_mnc(handle_list->handle[subs_type], &mnc);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_mnc() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - mnc = %s", mnc);
+
+ return 0;
+}
+
+static int run_network_get_network_name(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *network_name;
+
+ msg("call telephony_network_get_network_name()");
+
+ ret = telephony_network_get_network_name(handle_list->handle[subs_type], &network_name);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_network_name() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - network_name = %s", network_name);
+
+ return 0;
+}
+
+static int run_network_get_network_name_option(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_network_name_option_e name_option;
+
+ msg("call telephony_network_get_network_name_option()");
+
+ ret = telephony_network_get_network_name_option(handle_list->handle[subs_type], &name_option);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_network_name_option() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - network_name_option = %s", convert_network_name_option(name_option));
+
+ return 0;
+}
+
+static int run_network_get_roaming_status(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ bool roaming_status;
+
+ msg("call telephony_network_get_roaming_status()");
+
+ ret = telephony_network_get_roaming_status(handle_list->handle[subs_type], &roaming_status);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_roaming_status() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - roaming_status = %s", roaming_status ? "TRUE" : "FALSE");
+
+ return 0;
+}
+
+static int run_network_get_rssi(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_network_rssi_e rssi;
+
+ msg("call telephony_network_get_rssi()");
+
+ ret = telephony_network_get_rssi(handle_list->handle[subs_type], &rssi);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_rssi() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - rssi = %d", rssi);
+
+ return 0;
+}
+
+static int run_network_get_service_state(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_network_service_state_e service_state;
+
+ msg("call telephony_network_get_service_state()");
+
+ ret = telephony_network_get_service_state(handle_list->handle[subs_type], &service_state);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_service_state() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - service_state = %s", convert_network_service_state(service_state));
+
+ return 0;
+}
+
+static int run_network_get_type(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_network_type_e type;
+
+ msg("call telephony_network_get_type()");
+
+ ret = telephony_network_get_type(handle_list->handle[subs_type], &type);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_type() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - type = %s", convert_network_type(type));
+
+ return 0;
+}
+
+static int run_network_get_ps_type(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_network_ps_type_e ps_type;
+
+ msg("call telephony_network_get_ps_type()");
+
+ ret = telephony_network_get_ps_type(handle_list->handle[subs_type], &ps_type);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_ps_type() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - ps_type = %s", convert_network_ps_type(ps_type));
+
+ return 0;
+}
+
+static int run_network_get_dds(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_network_default_data_subs_e dds;
+
+ msg("call telephony_network_get_default_data_subscription()");
+
+ ret = telephony_network_get_default_data_subscription(handle_list->handle[subs_type], &dds);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_default_data_subscription() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - default_data_subscription = %s", convert_network_dds(dds));
+
+ return 0;
+}
+
+static int run_network_get_ds(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_network_default_subs_e ds;
+
+ msg("call telephony_network_get_default_subscription()");
+
+ ret = telephony_network_get_default_subscription(handle_list->handle[subs_type], &ds);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_default_subscription() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - default_subscription = %s", convert_network_ds(ds));
+
+ return 0;
+}
+
+static int run_network_get_selection_mode(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_network_selection_mode_e mode;
+
+ msg("call telephony_network_get_selection_mode()");
+
+ ret = telephony_network_get_selection_mode(handle_list->handle[subs_type], &mode);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_selection_mode() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - selection_mode = %s", convert_network_selection_mode(mode));
+
+ return 0;
+}
+
+static int run_network_get_tac(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ int tac;
+
+ msg("call telephony_network_get_tac()");
+
+ ret = telephony_network_get_tac(handle_list->handle[subs_type], &tac);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_tac() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - tac = %d", tac);
+
+ return 0;
+}
+
+static int run_network_get_system_id(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ int system_id;
+
+ msg("call telephony_network_get_system_id()");
+
+ ret = telephony_network_get_system_id(handle_list->handle[subs_type], &system_id);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_system_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - system_id = %d", system_id);
+
+ return 0;
+}
+
+static int run_network_get_network_id(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ int network_id;
+
+ msg("call telephony_network_get_network_id()");
+
+ ret = telephony_network_get_network_id(handle_list->handle[subs_type], &network_id);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_network_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - network_id = %d", network_id);
+
+ return 0;
+}
+
+static int run_network_get_bs_id(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ int bs_id;
+
+ msg("call telephony_network_get_base_station_id()");
+
+ ret = telephony_network_get_base_station_id(handle_list->handle[subs_type], &bs_id);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_base_station_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - base_station_id = %d", bs_id);
+
+ return 0;
+}
+
+static int run_network_get_bs_latitude(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ int bs_latitude;
+
+ msg("call telephony_network_get_base_station_latitude()");
+
+ ret = telephony_network_get_base_station_latitude(handle_list->handle[subs_type], &bs_latitude);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_base_station_latitude() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - base_station_latitude = %d", bs_latitude);
+
+ return 0;
+}
+
+static int run_network_get_bs_longitude(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ int bs_longitude;
+
+ msg("call telephony_network_get_base_station_longitude()");
+
+ ret = telephony_network_get_base_station_longitude(handle_list->handle[subs_type], &bs_longitude);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_base_station_longitude() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - base_station_longitude = %d", bs_longitude);
+
+ return 0;
+}
+
+static int run_network_get_signal_strength(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ int dbm;
+
+ msg("call telephony_network_get_signal_strength()");
+
+ ret = telephony_network_get_signal_strength(handle_list->handle[subs_type], &dbm);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_network_get_signal_strength() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - signal strength in dBm = %d", dbm);
+
+ return 0;
+}
+
+struct menu_data menu_network[] = {
+ {"1", "telephony_network_get_cell_id", NULL, run_network_get_cell_id, NULL},
+ {"2", "telephony_network_get_lac", NULL, run_network_get_lac, NULL},
+ {"3", "telephony_network_get_mcc", NULL, run_network_get_mcc, NULL},
+ {"4", "telephony_network_get_mnc", NULL, run_network_get_mnc, NULL},
+ {"5", "telephony_network_get_network_name", NULL, run_network_get_network_name, NULL},
+ {"6", "telephony_network_get_network_name_option", NULL, run_network_get_network_name_option, NULL},
+ {"7", "telephony_network_get_roaming_status", NULL, run_network_get_roaming_status, NULL},
+ {"8", "telephony_network_get_rssi", NULL, run_network_get_rssi, NULL},
+ {"9", "telephony_network_get_service_state", NULL, run_network_get_service_state, NULL},
+ {"10", "telephony_network_get_type", NULL, run_network_get_type, NULL},
+ {"11", "telephony_network_get_ps_type", NULL, run_network_get_ps_type, NULL},
+ {"12", "telephony_network_get_default_data_subscription", NULL, run_network_get_dds, NULL},
+ {"13", "telephony_network_get_default_subscription", NULL, run_network_get_ds, NULL},
+ {"14", "telephony_network_get_selection_mode", NULL, run_network_get_selection_mode, NULL},
+ {"15", "telephony_network_get_tac", NULL, run_network_get_tac, NULL},
+ {"16", "telephony_network_get_system_id", NULL, run_network_get_system_id, NULL},
+ {"17", "telephony_network_get_network_id", NULL, run_network_get_network_id, NULL},
+ {"18", "telephony_network_get_base_station_id", NULL, run_network_get_bs_id, NULL},
+ {"19", "telephony_network_get_base_station_latitude", NULL, run_network_get_bs_latitude, NULL},
+ {"20", "telephony_network_get_base_station_longitude", NULL, run_network_get_bs_longitude, NULL},
+ {"21", "telephony_network_get_signal_strength", NULL, run_network_get_signal_strength, NULL},
+ {NULL, },
+};
+
+void register_network_event(telephony_handle_list_s *handle_list)
+{
+ int ret, i;
+
+ for (i = 0; i < (sizeof(network_noti_tbl) / sizeof(int)); i++) {
+ ret = telephony_set_noti_cb(handle_list->handle[subs_type], network_noti_tbl[i], network_noti_cb, NULL);
+ if (ret != TELEPHONY_ERROR_NONE)
+ msg("telephony_set_noti_cb() failed!!! i(%d), ret(%d,%s)", i, ret, get_error_message(ret));
+ }
+}
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __NETWORK_H__
+#define __NETWORK_H__
+
+#include <telephony.h>
+
+void register_network_event(telephony_handle_list_s *handle_list);
+
+#endif
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include <telephony.h>
+
+#include "menu.h"
+#include "sim.h"
+
+extern int subs_type;
+
+static int sim_noti_tbl[] = {
+ TELEPHONY_NOTI_SIM_STATUS,
+ TELEPHONY_NOTI_SIM_CALL_FORWARDING_INDICATOR_STATE
+};
+
+static const char *convert_sim_state(telephony_sim_state_e state)
+{
+ switch (state) {
+ case TELEPHONY_SIM_STATE_UNAVAILABLE:
+ return "UNAVAILABLE";
+ case TELEPHONY_SIM_STATE_LOCKED:
+ return "LOCKED";
+ case TELEPHONY_SIM_STATE_AVAILABLE:
+ return "AVAILABLE";
+ case TELEPHONY_SIM_STATE_UNKNOWN:
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *convert_sim_lock_state(telephony_sim_lock_state_e lock_state)
+{
+ switch (lock_state) {
+ case TELEPHONY_SIM_LOCK_STATE_PIN_REQUIRED:
+ return "PIN_REQUIRED";
+ case TELEPHONY_SIM_LOCK_STATE_PUK_REQUIRED:
+ return "PUK_REQUIRED";
+ case TELEPHONY_SIM_LOCK_STATE_PERM_LOCKED:
+ return "PERM_LOCKED";
+ case TELEPHONY_SIM_LOCK_STATE_NCK_REQUIRED:
+ return "NCK_REQUIRED";
+ case TELEPHONY_SIM_LOCK_STATE_UNKNOWN:
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static void sim_noti_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data)
+{
+ msg("");
+ switch (noti_id) {
+ case TELEPHONY_NOTI_SIM_STATUS:
+ msgb("NOTI_SIM_STATUS received!!!");
+ msg(" - state = %s", convert_sim_state(*(int *)data));
+ break;
+ case TELEPHONY_NOTI_SIM_CALL_FORWARDING_INDICATOR_STATE:
+ msgb("NOTI_CALL_FORWARDING_INDICATOR_STATE received!!!");
+ msg(" - call_forwarding_indicator_state = %s", *(int *)data ? "TRUE" : "FALSE");
+ break;
+ default:
+ msgb("Unknown notification received!!!");
+ break;
+ }
+}
+
+static int run_sim_is_changed(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ bool is_changed;
+
+ msg("call telephony_sim_is_changed()");
+
+ ret = telephony_sim_is_changed(handle_list->handle[subs_type], &is_changed);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_is_changed() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - is_changed = %s", is_changed ? "TRUE" : "FALSE");
+
+ return 0;
+}
+
+static int run_sim_get_operator(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *operator;
+
+ msg("call telephony_sim_get_operator()");
+
+ ret = telephony_sim_get_operator(handle_list->handle[subs_type], &operator);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_operator() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - operator = %s", operator);
+
+ return 0;
+}
+
+static int run_sim_get_icc_id(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *icc_id;
+
+ msg("call telephony_sim_get_icc_id()");
+
+ ret = telephony_sim_get_icc_id(handle_list->handle[subs_type], &icc_id);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_icc_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - icc_id = %s", icc_id);
+
+ return 0;
+}
+
+static int run_sim_get_msin(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *msin;
+
+ msg("call telephony_sim_get_msin()");
+
+ ret = telephony_sim_get_msin(handle_list->handle[subs_type], &msin);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_msin() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - msin = %s", msin);
+
+ return 0;
+}
+
+static int run_sim_get_spn(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *spn;
+
+ msg("call telephony_sim_get_spn()");
+
+ ret = telephony_sim_get_spn(handle_list->handle[subs_type], &spn);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_spn() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - spn = %s", spn);
+
+ return 0;
+}
+
+static int run_sim_get_state(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_sim_state_e state;
+
+ msg("call telephony_sim_get_state()");
+
+ ret = telephony_sim_get_state(handle_list->handle[subs_type], &state);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_state() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - state = %s", convert_sim_state(state));
+
+ return 0;
+}
+
+static int run_sim_get_app_list(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_sim_application_type_e app_list;
+
+ msg("call telephony_sim_get_application_list()");
+
+ ret = telephony_sim_get_application_list(handle_list->handle[subs_type], &app_list);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_application_list() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - application_list = 0x%x", app_list);
+
+ return 0;
+}
+
+static int run_sim_get_subs_number(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *subs_number;
+
+ msg("call telephony_sim_get_subscriber_number()");
+
+ ret = telephony_sim_get_subscriber_number(handle_list->handle[subs_type], &subs_number);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_subscriber_number() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - subscriber_number = %s", subs_number);
+
+ return 0;
+}
+
+static int run_sim_get_subs_id(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *subs_id;
+
+ msg("call telephony_sim_get_subscriber_id()");
+
+ ret = telephony_sim_get_subscriber_id(handle_list->handle[subs_type], &subs_id);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_subscriber_id() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - subscriber_id = %s", subs_id);
+
+ return 0;
+}
+
+static int run_sim_get_lock_state(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ telephony_sim_lock_state_e lock_state;
+
+ msg("call telephony_sim_get_lock_state()");
+
+ ret = telephony_sim_get_lock_state(handle_list->handle[subs_type], &lock_state);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_lock_state() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - lock_state = %s", convert_sim_lock_state(lock_state));
+
+ return 0;
+}
+
+static int run_sim_get_group_id1(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ char *gid1;
+
+ msg("call telephony_sim_get_group_id1()");
+
+ ret = telephony_sim_get_group_id1(handle_list->handle[subs_type], &gid1);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_group_id1() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - gid1 = %s", gid1);
+
+ return 0;
+}
+
+static int run_sim_get_call_forward_ind_state(MManager *mm, struct menu_data *menu)
+{
+ telephony_handle_list_s *handle_list = menu_manager_ref_user_data(mm);
+ int ret;
+ bool call_forward_ind_state;
+
+ msg("call telephony_sim_get_call_forwarding_indicator_state()");
+
+ ret = telephony_sim_get_call_forwarding_indicator_state(handle_list->handle[subs_type], &call_forward_ind_state);
+ if (ret != TELEPHONY_ERROR_NONE) {
+ msg("telephony_sim_get_call_forwarding_indicator_state() failed!!! (ret:%d,%s)", ret, get_error_message(ret));
+ return 0;
+ }
+
+ msg(" - call_forwarding_indicator_state = %s", call_forward_ind_state ? "TRUE" : "FALSE");
+
+ return 0;
+}
+
+struct menu_data menu_sim[] = {
+ {"1", "telephony_sim_is_changed", NULL, run_sim_is_changed, NULL},
+ {"2", "telephony_sim_get_operator", NULL, run_sim_get_operator, NULL},
+ {"3", "telephony_sim_get_icc_id", NULL, run_sim_get_icc_id, NULL},
+ {"4", "telephony_sim_get_msin", NULL, run_sim_get_msin, NULL},
+ {"5", "telephony_sim_get_spn", NULL, run_sim_get_spn, NULL},
+ {"6", "telephony_sim_get_state", NULL, run_sim_get_state, NULL},
+ {"7", "telephony_sim_get_application_list", NULL, run_sim_get_app_list, NULL},
+ {"8", "telephony_sim_get_subscriber_number", NULL, run_sim_get_subs_number, NULL},
+ {"9", "telephony_sim_get_subscriber_id", NULL, run_sim_get_subs_id, NULL},
+ {"10", "telephony_sim_get_lock_state", NULL, run_sim_get_lock_state, NULL},
+ {"11", "telephony_sim_get_group_id1", NULL, run_sim_get_group_id1, NULL},
+ {"12", "telephony_sim_get_call_forwarding_indicator_state", NULL, run_sim_get_call_forward_ind_state, NULL},
+ {NULL, },
+};
+
+void register_sim_event(telephony_handle_list_s *handle_list)
+{
+ int ret, i;
+
+ for (i = 0; i < (sizeof(sim_noti_tbl) / sizeof(int)); i++) {
+ ret = telephony_set_noti_cb(handle_list->handle[subs_type], sim_noti_tbl[i], sim_noti_cb, NULL);
+ if (ret != TELEPHONY_ERROR_NONE)
+ msg("telephony_set_noti_cb() failed!!! i(%d), ret(%d,%s)", i, ret, get_error_message(ret));
+ }
+}
+
--- /dev/null
+/*
+ * telephony
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 _SIM_H_
+#define _SIM_H_
+
+#include <telephony.h>
+
+void register_sim_event(telephony_handle_list_s *handle_list);
+
+#endif /* _SIM_H_ */
+