From: Dongchul Lim Date: Tue, 17 Mar 2015 04:47:59 +0000 (+0900) Subject: Code Sync up from tizen_2.4 X-Git-Tag: submit/tizen_mobile/20150326.075037~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F09%2F36909%2F1;p=platform%2Fcore%2Ftelephony%2Ftel-plugin-dbus_tapi.git Code Sync up from tizen_2.4 Change-Id: I3e2c237840824a011b9dc05725b317c39fb3997d --- diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 63619be..0000000 --- a/.gitignore +++ /dev/null @@ -1,100 +0,0 @@ -#Copyright (c) 2013 GitHub, Inc. -# -#Permission is hereby granted, free of charge, to any person obtaining a -#copy of this software and associated documentation files (the "Software"), -#to deal in the Software without restriction, including without limitation -#the rights to use, copy, modify, merge, publish, distribute, sublicense, -#and/or sell copies of the Software, and to permit persons to whom the -#Software is furnished to do so, subject to the following conditions: -# -#The above copyright notice and this permission notice shall be included in -#all copies or substantial portions of the Software. -# -#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -#FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -#DEALINGS IN THE SOFTWARE. -# -# https://github.com/github/gitignore - -# Object files -*.o - -# Libraries -*.lib -*.a - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app - -# CMake -CMakeCache.txt -CMakeFiles -Makefile -cmake_install.cmake -install_manifest.txt - -# Emacs -*~ -\#*\# -/.emacs.desktop -/.emacs.desktop.lock -.elc -auto-save-list -tramp -.\#* - -# Org-mode -.org-id-locations -*_archive - -# Linux -.* -!.gitignore -*~ - -# Vim -*.s[a-w][a-z] -*.un~ -Session.vim -.netrwhist -*~ - -# Eclipse -*.pydevproject -.project -.metadata -bin/** -tmp/** -tmp/**/* -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..0e9faa9 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,6 @@ +Jongman Park +Ja-young Gu +Kyeongchul Kim +DongHoo Park +Youngman Park +Inho Oh diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 4c950c3..3a61b8e --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,59 +8,94 @@ SET(LIBDIR "\${prefix}/lib") SET(INCLUDEDIR "\${prefix}/include") SET(PKGCONFIGDIR "${PREFIX}/lib/pkgconfig" CACHE PATH PKGCONFIGDIR) SET(CMAKE_INSTALL_PREFIX "${PREFIX}") +SET(INTROSPECTION "${CMAKE_SOURCE_DIR}/introspection") # Set required packages INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED glib-2.0 gobject-2.0 gio-2.0 gio-unix-2.0 tcore tel-headers aul appsvc security-server libtzplatform-config) +pkg_check_modules(pkgs REQUIRED + glib-2.0 + gio-2.0 + gio-unix-2.0 + libxml-2.0 + tcore + aul + appsvc + security-server + pkgmgr +) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -INCLUDE_DIRECTORIES( - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/include/ - ${CMAKE_SOURCE_DIR}/sat-manager/include/ -) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wcast-align") +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/ ${CMAKE_SOURCE_DIR}/src/sat_ui_support/) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wextra -fvisibility=hidden -fPIC -fdata-sections -ffunction-sections -Wl,--gc-sections") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O2 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wall -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable") +ADD_DEFINITIONS("-DENABLE_KPI_LOGS") +ADD_DEFINITIONS("-DGCF") ADD_DEFINITIONS("-DFEATURE_TLOG_DEBUG") -ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"DBUS_TAPI\"") +ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"DBUS\"") ADD_DEFINITIONS("-DPLUGIN_VERSION=${VERSION}") ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))") +#ADD_DEFINITIONS("-DTIZEN_USE_DESKTOP_FILE") +#ADD_DEFINITIONS("-DTIZEN_SUPPORT_SAT_ICON") + +IF (BOARD_PLATFORM_SPREADTRUM) +ADD_DEFINITIONS("-DTIZEN_PLATFORM_LITE") +ELSE() +ADD_DEFINITIONS("-DTIZEN_PLATFORM_USE_QCOM_QMI") +ENDIF (BOARD_PLATFORM_SPREADTRUM) MESSAGE(${CMAKE_C_FLAGS}) -MESSAGE(${CMAKE_EXE_LINKER_FLAGS}) +MESSAGE(${pkgs_LDFLAGS}) SET(SRCS - src/desc.c - src/dtapi_util.c - src/dtapi_main.c - src/dtapi_call.c - src/dtapi_gps.c - src/dtapi_manager.c - src/dtapi_modem.c - src/dtapi_network.c - src/dtapi_phonebook.c - src/dtapi_sap.c - src/dtapi_sat.c - src/dtapi_sim.c - src/dtapi_sms.c - src/dtapi_ss.c - sat-manager/src/sat_manager.c - sat-manager/src/sat_ui_support.c -# sat-manager/src/sat_util.c + src/desc-dbus.c + src/common.c + src/network.c + src/phonebook.c + src/sim.c + src/sap.c + src/sms.c + src/sat.c + src/sat_manager.c + src/sat_ui_support/sat_ui_support.c + src/ss.c + src/call.c + src/modem.c + src/gps.c + src/oem.c ) -# library build -ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) -SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" OUTPUT_NAME ${PROJECT_NAME}) +ADD_CUSTOM_COMMAND( + WORKING_DIRECTORY + OUTPUT ${CMAKE_BINARY_DIR}/generated-code.c + COMMAND gdbus-codegen --interface-prefix org.tizen.telephony. --generate-c-code generated-code --c-namespace Telephony --c-generate-object-manager --generate-docbook generated-docs + ${INTROSPECTION}/manager.xml + ${INTROSPECTION}/network.xml + ${INTROSPECTION}/sim.xml + ${INTROSPECTION}/phonebook.xml + ${INTROSPECTION}/sap.xml + ${INTROSPECTION}/sat.xml + ${INTROSPECTION}/sms.xml + ${INTROSPECTION}/call.xml + ${INTROSPECTION}/ss.xml + ${INTROSPECTION}/modem.xml + ${INTROSPECTION}/gps.xml + ${INTROSPECTION}/oem.xml + COMMENT "Generating GDBus .c/.h") -CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/res/tapi.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/res/tapi.conf) +# library build +ADD_LIBRARY(dbus-tapi-plugin SHARED ${SRCS} ${CMAKE_BINARY_DIR}/generated-code.c) +TARGET_LINK_LIBRARIES(dbus-tapi-plugin ${pkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(dbus-tapi-plugin PROPERTIES PREFIX "" OUTPUT_NAME dbus-tapi-plugin) # install -INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/tapi.conf DESTINATION ${PREFIX}/etc/dbus-1/system.d) -INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib/telephony/plugins) +INSTALL(TARGETS dbus-tapi-plugin + LIBRARY DESTINATION lib/telephony/plugins) INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME tel-plugin-dbus_tapi) diff --git a/LICENSE b/LICENSE index 3d69259..bae7f54 100644 --- a/LICENSE +++ b/LICENSE @@ -1,204 +1,204 @@ -Copyright (c) 2000 - 2012 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. - +Copyright (c) 2000 - 2012 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. + diff --git a/README b/README new file mode 100644 index 0000000..5fbf319 --- /dev/null +++ b/README @@ -0,0 +1 @@ +SLP-TAPI DBus based Client-Server plugin diff --git a/include/dtapi_call.h b/include/dtapi_call.h deleted file mode 100644 index ac0c890..0000000 --- a/include/dtapi_call.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_call_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin); -gboolean dtapi_handle_call_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data); diff --git a/include/dtapi_gps.h b/include/dtapi_gps.h deleted file mode 100644 index dc3f5b8..0000000 --- a/include/dtapi_gps.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_gps_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin); -gboolean dtapi_handle_gps_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data); diff --git a/include/dtapi_main.h b/include/dtapi_main.h deleted file mode 100644 index 78b9390..0000000 --- a/include/dtapi_main.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include -#include - -gboolean dtapi_plugin_init(TcorePlugin *plugin); -void dtapi_plugin_deinit(TcorePlugin *plugin); diff --git a/include/dtapi_manager.h b/include/dtapi_manager.h deleted file mode 100644 index edb3420..0000000 --- a/include/dtapi_manager.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -TelephonyManager *dtapi_manager_new(Server *server); \ No newline at end of file diff --git a/include/dtapi_modem.h b/include/dtapi_modem.h deleted file mode 100644 index 19081d2..0000000 --- a/include/dtapi_modem.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_modem_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin); -gboolean dtapi_handle_modem_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data); diff --git a/include/dtapi_network.h b/include/dtapi_network.h deleted file mode 100644 index 930d3a3..0000000 --- a/include/dtapi_network.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_network_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin); -gboolean dtapi_handle_network_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data); diff --git a/include/dtapi_phonebook.h b/include/dtapi_phonebook.h deleted file mode 100644 index fabc4b3..0000000 --- a/include/dtapi_phonebook.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_phonebook_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin); -gboolean dtapi_handle_phonebook_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data); diff --git a/include/dtapi_sap.h b/include/dtapi_sap.h deleted file mode 100644 index 08b229d..0000000 --- a/include/dtapi_sap.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_sap_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin); -gboolean dtapi_handle_sap_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data); diff --git a/include/dtapi_sat.h b/include/dtapi_sat.h deleted file mode 100644 index 895aff7..0000000 --- a/include/dtapi_sat.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_sat_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin, TcorePlugin *comm_plugin); -gboolean dtapi_handle_sat_notification(TelephonyObjectSkeleton *object, - TcorePlugin *plugin, TcorePlugin *comm_plugin, TcoreNotification command, - guint data_len, const void *data); diff --git a/include/dtapi_sim.h b/include/dtapi_sim.h deleted file mode 100644 index 16afb71..0000000 --- a/include/dtapi_sim.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_sim_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin); -gboolean dtapi_handle_sim_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data); diff --git a/include/dtapi_sms.h b/include/dtapi_sms.h deleted file mode 100644 index 14a20ed..0000000 --- a/include/dtapi_sms.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_sms_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin); -gboolean dtapi_handle_sms_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data); diff --git a/include/dtapi_ss.h b/include/dtapi_ss.h deleted file mode 100644 index c013df3..0000000 --- a/include/dtapi_ss.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include - -#include -#include - -gboolean dtapi_setup_ss_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin); -gboolean dtapi_handle_ss_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data); diff --git a/include/dtapi_util.h b/include/dtapi_util.h deleted file mode 100644 index 788a9c5..0000000 --- a/include/dtapi_util.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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. - */ - -#pragma once - -#include -#include -#include - -#define dtapi_return_error(ivc,error,message) \ - do { \ - err("%s", message); \ - g_dbus_method_invocation_return_error(ivc, \ - G_DBUS_ERROR, error, message); \ - } while (0) - -typedef struct { - void *interface_object; - GDBusMethodInvocation *invocation; - char user_data[0]; /* Additional user data base pointer */ -} DbusRespCbData; - -GVariant *dtapi_create_empty_variant(const gchar *format_string); /* We should free the variant after use */ -inline DbusRespCbData *dtapi_create_resp_cb_data(void *interface_object, - GDBusMethodInvocation *invocation, void *user_data, unsigned int ud_len); -inline const char *dtapi_get_cp_name_by_object_path(const char *object_path); -gboolean dtapi_check_access_control(GDBusMethodInvocation *invoc, - const char *label, const char *perm); diff --git a/introspection/call.xml b/introspection/call.xml new file mode 100755 index 0000000..19bf15f --- /dev/null +++ b/introspection/call.xml @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/convert_docbook_html.sh b/introspection/convert_docbook_html.sh new file mode 100755 index 0000000..2ac0c00 --- /dev/null +++ b/introspection/convert_docbook_html.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +mkdir output 2>/dev/null + +OUTPUT=`basename $1` + +xsltproc -o output/$OUTPUT.html /usr/share/xml/docbook/stylesheet/docbook-xsl/html/docbook.xsl $1 diff --git a/introspection/convert_gtkdoc.sh b/introspection/convert_gtkdoc.sh new file mode 100755 index 0000000..91e2dc6 --- /dev/null +++ b/introspection/convert_gtkdoc.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +mkdir output 2>/dev/null + +OUTPUT=`basename $1` + +gtkdoc-mkhtml TEST $1 diff --git a/introspection/gen.sh b/introspection/gen.sh new file mode 100755 index 0000000..1c50ece --- /dev/null +++ b/introspection/gen.sh @@ -0,0 +1,6 @@ +gdbus-codegen --interface-prefix org.tizen.telephony. \ + --generate-c-code generated-code \ + --c-namespace Telephony \ + --c-generate-object-manager \ + --generate-docbook generated-docs \ + manager.xml network.xml sim.xml phonebook.xml sat.xml sap.xml gps.xml oem.xml modem.xml ss.xml call.xml sms.xml diff --git a/introspection/gps.xml b/introspection/gps.xml new file mode 100644 index 0000000..b1f29ec --- /dev/null +++ b/introspection/gps.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/manager.xml b/introspection/manager.xml new file mode 100644 index 0000000..2d5bafc --- /dev/null +++ b/introspection/manager.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/introspection/modem.xml b/introspection/modem.xml new file mode 100644 index 0000000..c5d8106 --- /dev/null +++ b/introspection/modem.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/network.xml b/introspection/network.xml new file mode 100644 index 0000000..a2cd331 --- /dev/null +++ b/introspection/network.xml @@ -0,0 +1,507 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/oem.xml b/introspection/oem.xml new file mode 100644 index 0000000..2eaf8fc --- /dev/null +++ b/introspection/oem.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/phonebook.xml b/introspection/phonebook.xml new file mode 100644 index 0000000..e5a5b78 --- /dev/null +++ b/introspection/phonebook.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/sap.xml b/introspection/sap.xml new file mode 100644 index 0000000..1125695 --- /dev/null +++ b/introspection/sap.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/sat.xml b/introspection/sat.xml new file mode 100644 index 0000000..b646bf7 --- /dev/null +++ b/introspection/sat.xml @@ -0,0 +1,365 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/sim.xml b/introspection/sim.xml new file mode 100644 index 0000000..ebcc87b --- /dev/null +++ b/introspection/sim.xml @@ -0,0 +1,295 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/sms.xml b/introspection/sms.xml new file mode 100644 index 0000000..1557e07 --- /dev/null +++ b/introspection/sms.xml @@ -0,0 +1,428 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/introspection/ss.xml b/introspection/ss.xml new file mode 100644 index 0000000..32c7feb --- /dev/null +++ b/introspection/ss.xml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/tel-plugin-dbus_tapi.manifest b/packaging/tel-plugin-dbus_tapi.manifest deleted file mode 100644 index 017d22d..0000000 --- a/packaging/tel-plugin-dbus_tapi.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/tel-plugin-dbus_tapi.spec b/packaging/tel-plugin-dbus_tapi.spec old mode 100644 new mode 100755 index b74680e..af5ad56 --- a/packaging/tel-plugin-dbus_tapi.spec +++ b/packaging/tel-plugin-dbus_tapi.spec @@ -1,28 +1,27 @@ -%define major 3 -%define minor 0 -%define patchlevel 1 +%define major 0 +%define minor 3 +%define patchlevel 51 Name: tel-plugin-dbus_tapi Version: %{major}.%{minor}.%{patchlevel} -Release: 1 -License: Apache-2.0 +Release: 2 +License: Apache Summary: dbus-tapi plugin for telephony Group: System/Libraries Source0: tel-plugin-dbus_tapi-%{version}.tar.gz -Source1001: tel-plugin-dbus_tapi.manifest BuildRequires: cmake -BuildRequires: python BuildRequires: python-xml +BuildRequires: python BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(gobject-2.0) -BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: pkgconfig(libxml-2.0) +BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(security-server) BuildRequires: pkgconfig(tcore) -BuildRequires: pkgconfig(tel-headers) + Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -31,31 +30,25 @@ dbus-tapi plugin for telephony %prep %setup -q -cp %{SOURCE1001} . %build versionint=$[%{major} * 1000000 + %{minor} * 1000 + %{patchlevel}] -cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=$versionint -make %{?jobs:-j%jobs} -%cmake . \ --DTZ_SYS_USER_GROUP=%TZ_SYS_USER_GROUP +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=$versionint -DSYSCONFDIR=%{_sysconfdir} \ + +make %{?_smp_mflags} -%post -/sbin/ldconfig +%post -p /sbin/ldconfig %postun -p /sbin/ldconfig %install -rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}/usr/share/license -cp LICENSE %{buildroot}/usr/share/license/%{name} +mkdir -p %{buildroot}%{_datadir}/license %files -%manifest %{name}.manifest +%manifest tel-plugin-dbus_tapi.manifest %defattr(-,root,root,-) #%doc COPYING %{_libdir}/telephony/plugins/* -%{_prefix}/etc/dbus-1/system.d/* -/usr/share/license/%{name} +%{_datadir}/license/tel-plugin-dbus_tapi diff --git a/res/tapi.conf.in b/res/tapi.conf.in deleted file mode 100644 index f8a43a1..0000000 --- a/res/tapi.conf.in +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/sat-manager/include/sat_manager.h b/sat-manager/include/sat_manager.h deleted file mode 100644 index 6584970..0000000 --- a/sat-manager/include/sat_manager.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 SAT_MANAGER_H_ -#define SAT_MANAGER_H_ - -#include -#include - -#include "dtapi_sat.h" -#include "dtapi_util.h" - -typedef union { - TelSatDisplayTextTlv displayTextInd; /**< Parsed proactive command info from TLV to Telephony data type - display text */ - TelSatGetInkeyTlv getInkeyInd; /**< Parsed proactive command info from TLV to Telephony data type - getInkey */ - TelSatGetInputTlv getInputInd; /**< Parsed proactive command info from TLV to Telephony data type - getInput */ - TelSatPlayToneTlv play_tone; - TelSatSetupMenuTlv setupMenuInd; /**< Parsed proactive command info from TLV to Telephony data type - setup menu */ - TelSatSelectItemTlv selectItemInd; /**< Parsed proactive command info from TLV to Telephony data type - select item */ - TelSatSendSmsTlv sendSMSInd; - TelSatSendSsTlv send_ss; - TelSatSendUssdTlv send_ussd; - TelSatSetupCallTlv setup_call; - TelSatRefreshTlv refresh; - TelSatProvideLocalInfoTlv provide_local_info; - TelSatSetupIdleModeTextTlv idle_mode; - TelSatSendDtmfTlv send_dtmf; - TelSatLanguageNotificationTlv language_notification; - TelSatLaunchBrowserTlv launch_browser; - TelSatOpenChannelTlv open_channel; - TelSatCloseChannelTlv close_channel; - TelSatReceiveChannelTlv receive_data; - TelSatSendChannelTlv send_data; - TelSatGetChannelStatusTlv get_channel_status; -} TelSatManagerProactiveData; - -/** - * This structure defines the Command Queue Info. - */ -typedef struct { - TelSatProactiveCmdType cmd_type; /** -#include -#include - -#include -#include -#include -#include - -#include "dtapi_sat.h" - -gboolean sat_ui_support_terminate_sat_ui(void); -gboolean sat_ui_support_launch_call_application(TelSatProactiveCmdType cmd_type, GVariant *data); -gboolean sat_ui_support_launch_browser_application(TelSatProactiveCmdType cmd_type, GVariant *data); -gboolean sat_ui_support_launch_ciss_application(TelSatProactiveCmdType cmd_type, GVariant *data); -gboolean sat_ui_support_launch_setting_application(TelSatProactiveCmdType cmd_type, GVariant *data); -gboolean sat_ui_support_launch_sat_ui(TelSatProactiveCmdType cmd_type, GVariant *data); -gboolean sat_ui_support_create_desktop_file(const gchar *title); -gboolean sat_ui_support_remove_desktop_file(void); -gboolean sat_ui_support_exec_bip(GDBusConnection *connection, const gchar *path, TelSatProactiveCmdType cmd_type, GVariant *data); -gboolean sat_ui_support_exec_evtdw(GDBusConnection *connection, const gchar *path, TelSatProactiveCmdType cmd_type, GVariant *data); -gboolean sat_ui_support_storage_init(Server *server); - -#endif /* SAT_UI_SUPPORT_H_ */ diff --git a/sat-manager/src/sat_manager.c b/sat-manager/src/sat_manager.c deleted file mode 100644 index f74034d..0000000 --- a/sat-manager/src/sat_manager.c +++ /dev/null @@ -1,5057 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "sat_manager.h" -#include "sat_ui_support.h" - -#define TEL_SAT_DEF_CMD_Q_MAX 10 -#define TEL_SAT_TIME_OUT 30000 -#define TEL_SAT_DELAY_TO_CLEAN_MSG 15000 -#define TEL_SAT_DEF_CMD_Q_MAX 10 -#define TEL_SAT_DEF_CMD_Q_MIN 0 - -#define TEL_SAT_CMD_Q_CHECK(index) \ - if (index < TEL_SAT_DEF_CMD_Q_MIN || index > TEL_SAT_DEF_CMD_Q_MAX-1) { warn("invalid index!!"); return FALSE; } - -static SatManagerQueueData *sat_queue[TEL_SAT_DEF_CMD_Q_MAX] = {NULL, }; - -static guchar _convert_decimal_to_bcd(int dec) -{ - int tmp1, tmp0; - guchar tmp3; - - tmp1 = dec/10; - tmp0 = dec - tmp1*10; - tmp3 = tmp0 << 4; - tmp3 += tmp1; - - dbg("input decimal(%d), bcd(%d%d), endian(%x)", dec, tmp1, tmp0, tmp3); - return tmp3; -} - -static const gchar *_convert_sim_lang_to_string(TelSimLanguagePreferenceCode lang) -{ - dbg("convert lang(%d)", lang); - switch (lang) { - case TEL_SIM_LP_GERMAN: - return "de_DE.UTF-8"; - case TEL_SIM_LP_ENGLISH: - return "en_GB.UTF-8"; - case TEL_SIM_LP_ITALIAN: - return "it_IT.UTF-8"; - case TEL_SIM_LP_FRENCH: - return "fr_FR.UTF-8"; - case TEL_SIM_LP_SPANISH: - return "es_ES.UTF-8"; - case TEL_SIM_LP_DUTCH: - return "nl_NL.UTF-8"; - case TEL_SIM_LP_SWEDISH: - return "sv_SE.UTF-8"; - case TEL_SIM_LP_DANISH: - return "da_DK.UTF-8"; - case TEL_SIM_LP_PORTUGUESE: - return "pt_PT.UTF-8"; - case TEL_SIM_LP_FINNISH: - return "fi_FI.UTF-8"; - case TEL_SIM_LP_NORWEGIAN: - return "nb_NO.UTF-8"; - case TEL_SIM_LP_GREEK: - return "el_GR.UTF-8"; - case TEL_SIM_LP_TURKISH: - return "tr_TR.UTF-8"; - case TEL_SIM_LP_HUNGARIAN: - return "hu_HU.UTF-8"; - case TEL_SIM_LP_POLISH: - return "pl_PL.UTF-8"; - case TEL_SIM_LP_KOREAN: - return "ko_KR.UTF-8"; - case TEL_SIM_LP_CHINESE: - return "zh_CH.UTF-8"; - case TEL_SIM_LP_RUSSIAN: - return "ru_RU.UTF-8"; - case TEL_SIM_LP_JAPANESE: - return "ja_JP.UTF-8"; - default: - return NULL; - } - return NULL; -} - -static TelSimLanguagePreferenceCode _convert_string_to_sim_lang(const gchar* lang_str) -{ - dbg("convert lang(%s)", lang_str); - - if (g_str_equal(lang_str, "de_DE.UTF-8") == TRUE) { - return TEL_SIM_LP_GERMAN; - } - else if (g_str_equal(lang_str, "en_GB.UTF-8") == TRUE) { - return TEL_SIM_LP_ENGLISH; - } - else if (g_str_equal(lang_str, "it_IT.UTF-8") == TRUE) { - return TEL_SIM_LP_ITALIAN; - } - else if (g_str_equal(lang_str, "fr_FR.UTF-8") == TRUE) { - return TEL_SIM_LP_FRENCH; - } - else if (g_str_equal(lang_str, "es_ES.UTF-8") == TRUE) { - return TEL_SIM_LP_SPANISH; - } - else if (g_str_equal(lang_str, "nl_NL.UTF-8") == TRUE) { - return TEL_SIM_LP_DUTCH; - } - else if (g_str_equal(lang_str, "sv_SE.UTF-8") == TRUE) { - return TEL_SIM_LP_SWEDISH; - } - else if (g_str_equal(lang_str, "da_DK.UTF-8") == TRUE) { - return TEL_SIM_LP_DANISH; - } - else if (g_str_equal(lang_str, "pt_PT.UTF-8") == TRUE) { - return TEL_SIM_LP_PORTUGUESE; - } - else if (g_str_equal(lang_str, "fi_FI.UTF-8") == TRUE) { - return TEL_SIM_LP_FINNISH; - } - else if (g_str_equal(lang_str, "nb_NO.UTF-8") == TRUE) { - return TEL_SIM_LP_NORWEGIAN; - } - else if (g_str_equal(lang_str, "el_GR.UTF-8") == TRUE) { - return TEL_SIM_LP_GREEK; - } - else if (g_str_equal(lang_str, "tr_TR.UTF-8") == TRUE) { - return TEL_SIM_LP_TURKISH; - } - else if (g_str_equal(lang_str, "hu_HU.UTF-8") == TRUE) { - return TEL_SIM_LP_HUNGARIAN; - } - else if (g_str_equal(lang_str, "pl_PL.UTF-8") == TRUE) { - return TEL_SIM_LP_POLISH; - } - else if (g_str_equal(lang_str, "ko_KR.UTF-8") == TRUE) { - return TEL_SIM_LP_KOREAN; - } - else if (g_str_equal(lang_str, "zh_CH.UTF-8") == TRUE) { - return TEL_SIM_LP_CHINESE; - } - else if (g_str_equal(lang_str, "ru_RU.UTF-8") == TRUE) { - return TEL_SIM_LP_RUSSIAN; - } - else if (g_str_equal(lang_str, "ja_JP.UTF-8") == TRUE) { - return TEL_SIM_LP_JAPANESE; - } - - dbg("there is no matched language"); - return TEL_SIM_LP_LANG_UNSPECIFIED; -} - -static unsigned int _get_time_in_ms(TelSatDurationInfo *dr) -{ - switch (dr->time_unit) { - case TEL_SAT_TIME_UNIT_MINUTES: - return (unsigned int)dr->time_interval * 60000; - case TEL_SAT_TIME_UNIT_SECONDS: - return (unsigned int)dr->time_interval * 1000; - case TEL_SAT_TIME_UNIT_TENTHS_OF_SECONDS: - return (unsigned int)dr->time_interval * 100; - case TEL_SAT_TIME_UNIT_RESERVED: - default: - return 0; - } -} - -static int _get_queue_empty_index(void) -{ - int cnt = 0; - int i; - int index = -1; - - for(i =0; icmd_id; - - TEL_SAT_CMD_Q_CHECK(index); - - if (sat_queue[index]) { - err("[SAT] sat_queue[%d] is not null [%p].\n", sat_queue[index]); - return FALSE; - } - - item = g_new0(SatManagerQueueData, 1); - - if (!item) { - err("[SAT] FAILED TO ALLOC QUEUE ITEM!\n"); - return FALSE; - } - - memcpy((void*)item, (void*)cmd_obj, sizeof(SatManagerQueueData)); - sat_queue[index] = item; - dbg("push data to queue at index[%d], [%p].\n",index, item); - return TRUE; -} - -static gboolean _pop_nth_data(SatManagerQueueData *cmd_obj, int command_id) -{ - SatManagerQueueData *item; - int index = command_id; - - TEL_SAT_CMD_Q_CHECK(index); - - if (!sat_queue[index]) { - dbg("[SAT] sat_queue[%d] is null !!\n", index); - return FALSE; - } - - item = sat_queue[index]; - - memcpy((void*)cmd_obj, (void*)item, sizeof(SatManagerQueueData)); - dbg("pop data from queue at index[%d],[%p].\n",index, item); - sat_queue[index] = NULL; - g_free(item); - return TRUE; -} - -static gboolean _peek_nth_data(SatManagerQueueData *cmd_obj, int command_id) -{ - SatManagerQueueData *item = NULL; - int index = command_id; - - TEL_SAT_CMD_Q_CHECK(index); - - if (!sat_queue[index]) { - err("[SAT] sat_queue[%d] is null !!\n", index); - return FALSE; - } - - item = sat_queue[index]; - memcpy((void*)cmd_obj, (void*)item, sizeof(SatManagerQueueData)); - dbg("peek data from queue at index[%d],[%p].\n",index, item); - return TRUE; -} - -static void on_response_sat_manager_send_terminal_response - (gint result, const void *data, void *cb_data) -{ - dbg("result = [%d]", result); - - if (result != TEL_SAT_RESULT_SUCCESS) { - err("Terminal response sending failed"); - } else { - dbg("Terminal response successfully sent to SIM"); - } -} - -static TelReturn sat_manager_send_terminal_response(TcorePlugin *plugin, TelSatRequestTerminalResponseData *tr) -{ - TelReturn result; - - dbg("Entry"); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SAT_REQ_TERMINAL_RESPONSE, tr, - sizeof(TelSatRequestTerminalResponseData), on_response_sat_manager_send_terminal_response, NULL); - - if (result != TEL_RETURN_SUCCESS) { - err("Unable to dispatch request to modem plugin"); - } - - return result; -} - -void sat_manager_init_queue() -{ - int i; - dbg("Enter"); - for(i=0;icmd_id = id; - return _push_data(cmd_obj); -} - -static gboolean sat_manager_dequeue_cmd_by_id(SatManagerQueueData *cmd_obj, int cmd_id) -{ - return _pop_nth_data(cmd_obj, cmd_id); -} - -static gboolean sat_manager_queue_peek_data_by_id(SatManagerQueueData *cmd_obj, int command_id) -{ - return _peek_nth_data(cmd_obj, command_id); -} - -static gboolean sat_manager_check_availiable_event_list(TelSatSetupEventListTlv *event_list_info) -{ - gboolean rv = TRUE; - int index = 0; - - for(index = 0; index < event_list_info->event_list.event_list_cnt; index++) { - if (event_list_info->event_list.evt_list[index] == TEL_SAT_EVENT_USER_ACTIVITY) { - dbg("do user activity"); - } - else if (event_list_info->event_list.evt_list[index] == TEL_SAT_EVENT_IDLE_SCREEN_AVAILABLE) { - dbg("do idle screen"); - } - else if (event_list_info->event_list.evt_list[index] == TEL_SAT_EVENT_LANGUAGE_SELECTION) { - dbg("do language selection"); - } - else if (event_list_info->event_list.evt_list[index] == TEL_SAT_EVENT_BROWSER_TERMINATION) { - dbg("do browser termination"); - } - else if (event_list_info->event_list.evt_list[index] == TEL_SAT_EVENT_DATA_AVAILABLE) { - dbg("do data available (bip)"); - } - else if (event_list_info->event_list.evt_list[index] == TEL_SAT_EVENT_CHANNEL_STATUS) { - dbg("do channel status (bip)"); - } - else{ - dbg("unmanaged event (%d)", event_list_info->event_list.evt_list[index]); - rv = FALSE; - } - } - - return rv; -} - -gboolean sat_manager_remove_cmd_by_id(int cmd_id) -{ - SatManagerQueueData *item; - int index = cmd_id; - - if (!sat_queue[index]) { - err("[SAT] sat_queue[%d] is already null !!\n", index); - return FALSE; - } - item = sat_queue[index]; - - dbg("remove data from queue at index[%d],[%p].\n",index, item); - sat_queue[index] = NULL; - g_free(item); - return TRUE; -} - -GVariant *sat_manager_extracting_setup_menu_info(TcorePlugin *plugin, TcorePlugin *comm_plugin, TelSatSetupMenuTlv* setup_menu_tlv) -{ - GVariant *setup_menu_info = NULL; - SatManagerQueueData q_data; - DtapiSatPrivateData *sat_data = NULL; - gushort title_len = 0; - gint command_id = 0, menu_cnt = 0; - gboolean menu_present = FALSE, help_info = FALSE, updated = FALSE; - gchar main_title[TEL_SAT_ALPHA_ID_LEN_MAX]; - GVariantBuilder *v_builder = NULL; - GVariant *menu_items = NULL; - - dbg("interpreting setup menu notification"); - memset(&main_title, 0 , TEL_SAT_ALPHA_ID_LEN_MAX); - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - err("sat_data is null"); - return NULL; - } - - if ((setup_menu_tlv->icon_id.is_exist) - && (setup_menu_tlv->icon_id.icon_qualifer == TEL_SAT_ICON_QUALI_NOT_SELF_EXPLANATORY) - && (!setup_menu_tlv->alpha_id.is_exist || setup_menu_tlv->alpha_id.alpha_data_len == 0)) { - - TelSatRequestTerminalResponseData *tr = NULL; - dbg("exceptional case to fix gcf case 2.4 command not understood"); - - tr = g_new0(TelSatRequestTerminalResponseData, 1); - tr->cmd_number = setup_menu_tlv->command_detail.cmd_num; - tr->cmd_type = setup_menu_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.setup_menu.command_detail, &setup_menu_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_menu.device_id.src = setup_menu_tlv->device_id.dest; - tr->terminal_rsp_data.setup_menu.device_id.dest = setup_menu_tlv->device_id.src; - tr->terminal_rsp_data.setup_menu.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - return NULL; - } - - //check menu update - if(sat_data->data) { - if (sat_data->data->cached_sat_main_menu) { - dbg("main menu info is updated"); - updated = TRUE; - } - } - - //menu helpinfo - help_info = setup_menu_tlv->command_detail.cmd_qualifier.setup_menu.help_info; - - //menu presence - menu_present = setup_menu_tlv->command_detail.cmd_qualifier.setup_menu.select_preference; - - //menu item count - menu_cnt = setup_menu_tlv->menu_item_cnt; - - //check the validation of content - if (!menu_cnt || (setup_menu_tlv->menu_item_cnt == 1 && setup_menu_tlv->menu_item[0].text_len == 0)) { - //support GCF case 27.22.4.8.1 - 1.1 setup menu - - TelSatRequestTerminalResponseData *tr = NULL; - dbg("no menu item"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = setup_menu_tlv->command_detail.cmd_num; - tr->cmd_type = setup_menu_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.setup_menu.command_detail, &setup_menu_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_menu.device_id.src = setup_menu_tlv->device_id.dest; - tr->terminal_rsp_data.setup_menu.device_id.dest = setup_menu_tlv->device_id.src; - tr->terminal_rsp_data.setup_menu.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - //get title - if (setup_menu_tlv->alpha_id.alpha_data_len) - tcore_util_convert_str_to_utf8((guchar*)&main_title,(gushort *)&title_len, - setup_menu_tlv->alpha_id.dcs.a_format, - (guchar*)&setup_menu_tlv->alpha_id.alpha_data, - (gushort)setup_menu_tlv->alpha_id.alpha_data_len); - dbg("sat main menu title(%s)",main_title); - - v_builder = g_variant_builder_new(G_VARIANT_TYPE ("a(si)")); - - //get menu items - if (!setup_menu_tlv->next_act_ind_list.cnt) { - int index = 0; - - dbg("setup_menu_tlv->next_act_ind_list.cnt == 0"); - - for(index = 0; index < menu_cnt; index++) { - gint item_len; - gchar item_str[TEL_SAT_ITEM_TEXT_LEN_MAX + 1]; - - if (!setup_menu_tlv->alpha_id.alpha_data_len) - setup_menu_tlv->alpha_id.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_8BIT_DATA; - - memset(&item_str, 0 , TEL_SAT_ITEM_TEXT_LEN_MAX + 1); - tcore_util_convert_str_to_utf8((guchar*)&item_str, (gushort *)&item_len, - setup_menu_tlv->alpha_id.dcs.a_format, - (guchar*)&setup_menu_tlv->menu_item[index].text, - (gushort)setup_menu_tlv->menu_item[index].text_len); - - dbg( "index(%d) item_id(%d) item_string(%s)", index, setup_menu_tlv->menu_item[index].item_id, item_str); - - //g_variant_builder_add(v_builder, "(sy)", &item_str, setup_menu_tlv->menu_item[index].item_id); - g_variant_builder_add(v_builder, "(si)", item_str, (gint32)(setup_menu_tlv->menu_item[index].item_id)); - } - } - else{ - int index = 0; - - dbg("setup_menu_tlv->next_act_ind_list.cnt == 0"); - - for(index = 0; index < menu_cnt; index++) { - gint item_len; - gchar item_str[TEL_SAT_ITEM_TEXT_LEN_MAX + 1]; - - if (setup_menu_tlv->alpha_id.alpha_data_len == 0) - setup_menu_tlv->alpha_id.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_8BIT_DATA; - - memset(&item_str, '\0' , TEL_SAT_ITEM_TEXT_LEN_MAX + 1); - tcore_util_convert_str_to_utf8((guchar*)&item_str, (gushort *)&item_len, - setup_menu_tlv->alpha_id.dcs.a_format, - (guchar*)&setup_menu_tlv->menu_item[index].text, - (gushort)setup_menu_tlv->menu_item[index].text_len); - - if ( setup_menu_tlv->next_act_ind_list.indicator_list[index] == TEL_SAT_PROATV_CMD_SEND_SMS) { - g_strlcat(item_str," [Send SMS]", 11); - } - else if (setup_menu_tlv->next_act_ind_list.indicator_list[index]== TEL_SAT_PROATV_CMD_SETUP_CALL) { - g_strlcat(item_str," [Set Up Call]", 14); - } - else if (setup_menu_tlv->next_act_ind_list.indicator_list[index]== TEL_SAT_PROATV_CMD_LAUNCH_BROWSER) { - g_strlcat(item_str," [Launch Browser]", 17); - } - else if (setup_menu_tlv->next_act_ind_list.indicator_list[index]== TEL_SAT_PROATV_CMD_PROVIDE_LOCAL_INFO) { - g_strlcat(item_str," [Provide Terminal Information]", 31); - } - - dbg( "index(%d) item_id(%d) item_string(%s)", index, setup_menu_tlv->menu_item[index].item_id, item_str); - - //g_variant_builder_add(v_builder, "(sy)", g_strdup(item_str), setup_menu_tlv->menu_item[index].item_id); - g_variant_builder_add(v_builder, "(si)", item_str, (gint32)(setup_menu_tlv->menu_item[index].item_id)); - } - - } - menu_items = g_variant_builder_end(v_builder); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_SETUP_MENU; - memcpy((void*)&(q_data.cmd_data.setupMenuInd), setup_menu_tlv, sizeof(TelSatSetupMenuTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - setup_menu_info = g_variant_new("(ibsvibb)", command_id, menu_present, main_title, menu_items, - menu_cnt, help_info, updated); - - return setup_menu_info; -} - -GVariant *sat_manager_display_text_noti(TcorePlugin *plugin, TelSatDisplayTextTlv* display_text_tlv, int decode_error) -{ - GVariant *display_text = NULL; - SatManagerQueueData q_data; - - gint command_id = 0, text_len =0, duration= 0, tmp_duration = 0; - gboolean immediately_rsp = FALSE, high_priority = FALSE, user_rsp_required = FALSE; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting display text notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - if (!display_text_tlv->text.string_length || - (display_text_tlv->text.string_length > 0 && decode_error != TEL_SAT_RESULT_SUCCESS)) { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = display_text_tlv->command_detail.cmd_num; - tr->cmd_type = display_text_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.display_text.command_detail, &display_text_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.display_text.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.display_text.device_id.dest = display_text_tlv->device_id.src; - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - //user resp required & time_duration - if (display_text_tlv->command_detail.cmd_qualifier.display_text.text_clear_type == TEL_SAT_TEXT_WAIT_FOR_USER_TO_CLEAR_MSG) { - user_rsp_required = TRUE; - duration = TEL_SAT_TIME_OUT; - } - else{ - duration = TEL_SAT_DELAY_TO_CLEAN_MSG; - } - - //immediate response requested - if (display_text_tlv->immediate_response_requested) - immediately_rsp = TRUE; - - //high priority - if (display_text_tlv->command_detail.cmd_qualifier.display_text.text_priority == TEL_SAT_TEXT_PRIORITY_HIGH) - high_priority = TRUE; - dbg("user rsp required(%d), immediately rsp(%d) priority(%d)",user_rsp_required, immediately_rsp, high_priority); - - //get text - tcore_util_convert_str_to_utf8((guchar*) &text, (gushort *) &text_len, - display_text_tlv->text.dcs.a_format, - (guchar*) &display_text_tlv->text.string, - (gushort) display_text_tlv->text.string_length); - dbg("sat display text(%s)",text); - - //duration - if (!display_text_tlv->duration.time_interval) { - tmp_duration = _get_time_in_ms(&display_text_tlv->duration); - } - - if (tmp_duration > 0) - duration = tmp_duration; - -/* ETSI TS 102 223 6.4.1 DISPLAY TEXT - If help information is requested by the user, this command may be used to display help information on the screen. The - help information should be sent as high priority text and with the option that it should be cleared after a short delay.*/ - -/* if (ctx->help_requested == TRUE) { - ad->bIsPriorityHigh = TRUE; - ad->duration = 7000; - ctx->help_requested = FALSE; - }*/ - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_DISPLAY_TEXT; - memcpy((void*)&(q_data.cmd_data.displayTextInd), display_text_tlv, sizeof(TelSatDisplayTextTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - display_text = g_variant_new("(isiibbbv)", command_id, text, text_len, duration, - high_priority, user_rsp_required, immediately_rsp, icon_id); - - return display_text; -} - -GVariant *sat_manager_select_item_noti(TcorePlugin *plugin, TelSatSelectItemTlv* select_item_tlv, int decode_error) -{ - GVariant *select_item = NULL; - SatManagerQueueData q_data; - int index = 0; - gint command_id = 0, default_item_id = 0, menu_cnt = 0, text_len =0; - gboolean help_info = FALSE; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX]; - GVariantBuilder *v_builder = NULL; - GVariant *menu_items = NULL; - GVariant *icon_id = NULL; - GVariant *icon_list = NULL; - - dbg("interpreting select item notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - if (!select_item_tlv->menu_item_cnt || !select_item_tlv->menu_item[0].text_len) { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *) calloc(1, sizeof(TelSatRequestTerminalResponseData)); - - tr->cmd_number = select_item_tlv->command_detail.cmd_num; - tr->cmd_type = select_item_tlv->command_detail.cmd_type; - - memcpy((void*) &tr->terminal_rsp_data.select_item.command_detail, &select_item_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.select_item.device_id.src = select_item_tlv->device_id.dest; - tr->terminal_rsp_data.select_item.device_id.dest = select_item_tlv->device_id.src; - tr->terminal_rsp_data.select_item.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - // help info - help_info = select_item_tlv->command_detail.cmd_qualifier.select_item.help_info; - - if (!select_item_tlv->alpha_id.is_exist) { - dbg("set the item dcs value to TEL_SAT_ALPHABET_FORMAT_8BIT_DATA"); - select_item_tlv->alpha_id.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_8BIT_DATA; - } - - // select item text - if (select_item_tlv->alpha_id.is_exist && select_item_tlv->alpha_id.alpha_data_len > 0) - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - select_item_tlv->alpha_id.dcs.a_format, - (guchar*)&select_item_tlv->alpha_id.alpha_data, - (gushort)select_item_tlv->alpha_id.alpha_data_len); - dbg("select item text(%s)",text); - - //default item id - default_item_id = select_item_tlv->item_identifier; - dbg( "default item id(%d)", default_item_id); - - //item count - menu_cnt = select_item_tlv->menu_item_cnt; - dbg( "menu item count(%d)", menu_cnt); - - //items - v_builder = g_variant_builder_new(G_VARIANT_TYPE ("a(iis)")); - for(index= 0; index< menu_cnt; index++) { - gint item_len; - gchar item_str[TEL_SAT_ITEM_TEXT_LEN_MAX + 1]; - - memset(&item_str, 0 , TEL_SAT_ITEM_TEXT_LEN_MAX + 1); - - tcore_util_convert_str_to_utf8((guchar*) &item_str, (gushort *) &item_len, - select_item_tlv->alpha_id.dcs.a_format, - (guchar*) &select_item_tlv->menu_item[index].text, - (gushort) select_item_tlv->menu_item[index].text_len); - - if (select_item_tlv->item_next_act_ind_list.cnt != 0) { - if ( select_item_tlv->item_next_act_ind_list.indicator_list[index] == TEL_SAT_PROATV_CMD_SEND_SMS) { - g_strlcat(item_str," [Send SMS]", 11); - } - else if (select_item_tlv->item_next_act_ind_list.indicator_list[index]== TEL_SAT_PROATV_CMD_SETUP_CALL) { - g_strlcat(item_str," [Set Up Call]", 14); - } - else if (select_item_tlv->item_next_act_ind_list.indicator_list[index]== TEL_SAT_PROATV_CMD_LAUNCH_BROWSER) { - g_strlcat(item_str," [Launch Browser]", 17); - } - else if (select_item_tlv->item_next_act_ind_list.indicator_list[index]== TEL_SAT_PROATV_CMD_PROVIDE_LOCAL_INFO) { - g_strlcat(item_str," [Provide Terminal Information]", 31); - } - } - - item_len = strlen(item_str); - dbg( "index(%d) item_id(%d) item_len(%d) item_string(%s)", index, select_item_tlv->menu_item[index].item_id, item_len, item_str); - g_variant_builder_add(v_builder, "(iis)", (gint32)(select_item_tlv->menu_item[index].item_id), item_len, item_str); - } - menu_items = g_variant_builder_end(v_builder); - - // generate command id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_SELECT_ITEM; - memcpy((void*)&(q_data.cmd_data.selectItemInd), select_item_tlv, sizeof(TelSatSelectItemTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new_variant(menu_items); - icon_list = g_variant_new_variant(menu_items); - - select_item = g_variant_new("(ibsiiivvv)", command_id, help_info, text, text_len, - default_item_id, menu_cnt, menu_items, icon_id, icon_list); - - return select_item; -} - -GVariant *sat_manager_get_inkey_noti(TcorePlugin *plugin, TelSatGetInkeyTlv* get_inkey_tlv, int decode_error) -{ - GVariant *get_inkey = NULL; - SatManagerQueueData q_data; - gint command_id = 0, key_type = 0, input_character_mode = 0; - gint text_len = 0, duration = 0, tmp_duration = 0; - gboolean is_numeric = FALSE, is_help_info = FALSE; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting get inkey notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - if (!get_inkey_tlv->text.string_length || - (get_inkey_tlv->text.string_length > 0 && decode_error != TEL_SAT_RESULT_SUCCESS)) { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = get_inkey_tlv->command_detail.cmd_num; - tr->cmd_type = get_inkey_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.get_inkey.command_detail, &get_inkey_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.get_inkey.device_id.src = get_inkey_tlv->device_id.dest; - tr->terminal_rsp_data.get_inkey.device_id.dest = get_inkey_tlv->device_id.src; - tr->terminal_rsp_data.get_inkey.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - //key type - key_type = get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.inkey_type; - - //time duration - duration = TEL_SAT_TIME_OUT; - tmp_duration = _get_time_in_ms(&get_inkey_tlv->duration); - if (tmp_duration > 0) - duration = tmp_duration; - - //input mode - input_character_mode = get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.alphabet_type; - - //numeric - is_numeric = !get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.alphabet_set; - - //help info - is_help_info = get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.help_info; - - //text & text len - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - get_inkey_tlv->text.dcs.a_format , - (guchar*)&get_inkey_tlv->text.string, - (gushort)get_inkey_tlv->text.string_length); - - dbg("get inkey text(%s)",text); - - if (get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.immediate_rsp_required) { - dbg("get_inkey immediate_rsp_require is TRUE"); - //Send TR if UI display success - } - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_GET_INKEY; - memcpy((void*)&(q_data.cmd_data.getInkeyInd), get_inkey_tlv, sizeof(TelSatGetInkeyTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - get_inkey = g_variant_new("(iiibbsiiv)", command_id, key_type, input_character_mode, is_numeric, - is_help_info, text, text_len, duration, icon_id); - - return get_inkey; -} - -GVariant *sat_manager_get_input_noti(TcorePlugin *plugin, TelSatGetInputTlv* get_input_tlv, int decode_error) -{ - GVariant *get_input = NULL; - SatManagerQueueData q_data; - gint command_id = 0, input_character_mode = 0; - gint text_len = 0, def_text_len = 0, rsp_len_min = 0, rsp_len_max = 0; - gboolean is_numeric = FALSE, is_help_info = FALSE, is_echo_input = FALSE; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX], def_text[TEL_SAT_TEXT_STRING_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting get input notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - -#if GCF //disable the text length prb for GCF - if ( - (get_input_tlv->text.string_length > 0 && decode_error != TEL_SAT_RESULT_SUCCESS) || - (!get_input_tlv->rsp_len.max) || (get_input_tlv->rsp_len.min > get_input_tlv->rsp_len.max)) { -#else - if (!get_input_tlv->text.string_length || - (get_input_tlv->text.string_length > 0 && decode_error != TEL_SAT_RESULT_SUCCESS) || - (!get_input_tlv->rsp_len.max) || (get_input_tlv->rsp_len.min > get_input_tlv->rsp_len.max)) { -#endif - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = get_input_tlv->command_detail.cmd_num; - tr->cmd_type = get_input_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.get_input.command_detail, &get_input_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.get_input.device_id.src = get_input_tlv->device_id.dest; - tr->terminal_rsp_data.get_input.device_id.dest = get_input_tlv->device_id.src; - tr->terminal_rsp_data.get_input.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - - g_free(tr); - return NULL; - } - - dbg( "[SAT] is SMS7 packing required [%d]",get_input_tlv->command_detail.cmd_qualifier.get_input.user_input_unpacked_format); - - //input mode - input_character_mode = get_input_tlv->command_detail.cmd_qualifier.get_input.alphabet_type; - - //numeric - is_numeric = !get_input_tlv->command_detail.cmd_qualifier.get_input.alphabet_set; - - //help info - is_help_info = get_input_tlv->command_detail.cmd_qualifier.get_input.help_info; - - //echo input - is_echo_input = get_input_tlv->command_detail.cmd_qualifier.get_input.me_echo_user_input; - dbg("numeric (%d), help info(%d), echo input(%d)", is_numeric, is_help_info, is_echo_input); - - //text & text len - if (get_input_tlv->text.string_length) { - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - get_input_tlv->text.dcs.a_format , - (guchar*)&get_input_tlv->text.string, - (gushort)get_input_tlv->text.string_length); - dbg("get input text(%s)",text); - } - else{ - memcpy(text,"", 1); - text_len = 0; - } - - //response length min & max - rsp_len_min = get_input_tlv->rsp_len.min; - rsp_len_max = get_input_tlv->rsp_len.max; - - //default text & default text len - if (get_input_tlv->default_text.string_length) { - tcore_util_convert_str_to_utf8((guchar*)&def_text,(gushort *)&def_text_len, - get_input_tlv->text.dcs.a_format , - (guchar*)&get_input_tlv->default_text.string, - (gushort)get_input_tlv->default_text.string_length); - dbg("get input default text(%s)",text); - } - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_GET_INPUT; - memcpy((void*)&(q_data.cmd_data.getInputInd), get_input_tlv, sizeof(TelSatGetInputTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - get_input = g_variant_new("(iibbbsiiisiv)", command_id, input_character_mode, is_numeric, is_help_info, - is_echo_input, text, text_len, rsp_len_max, rsp_len_min, def_text, def_text_len, icon_id); - - return get_input; -} - -GVariant *sat_manager_play_tone_noti(TcorePlugin *plugin, TelSatPlayToneTlv* play_tone_tlv) -{ - GVariant *play_tone = NULL; - SatManagerQueueData q_data; - gint command_id = 0, tone_type = 0, duration = 0, tmp_duration = 0; - gint text_len = 0; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting play tone notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - if ( (play_tone_tlv->icon_id.is_exist) && ( play_tone_tlv->icon_id.icon_qualifer == TEL_SAT_ICON_QUALI_NOT_SELF_EXPLANATORY) - && (!play_tone_tlv->alpha_id.is_exist || !play_tone_tlv->alpha_id.alpha_data_len)) - { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = play_tone_tlv->command_detail.cmd_num; - tr->cmd_type = play_tone_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.play_tone.command_detail, &play_tone_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.play_tone.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.play_tone.device_id.dest = play_tone_tlv->device_id.src; - tr->terminal_rsp_data.play_tone.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - //text and text len - if ( play_tone_tlv->alpha_id.is_exist && play_tone_tlv->alpha_id.alpha_data_len) { - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - play_tone_tlv->alpha_id.dcs.a_format, - (guchar*)&play_tone_tlv->alpha_id.alpha_data, - (gushort)play_tone_tlv->alpha_id.alpha_data_len); - dbg("play tone ui display text (%s)",text); - } - - //tone type - tone_type = play_tone_tlv->tone; - - //time duration - duration = TEL_SAT_TIME_OUT; - tmp_duration = _get_time_in_ms(&play_tone_tlv->duration); - if (tmp_duration > 0) - duration = tmp_duration; - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_PLAY_TONE; - memcpy((void*)&(q_data.cmd_data.play_tone), play_tone_tlv, sizeof(TelSatPlayToneTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - play_tone = g_variant_new("(isivii)", command_id, text, text_len, icon_id, tone_type, duration); - - return play_tone; -} - -GVariant *sat_manager_send_sms_noti(TcorePlugin *plugin, TelSatSendSmsTlv* send_sms_tlv) -{ - GVariant *send_sms = NULL; - SatManagerQueueData q_data; - int index = 0; - gint command_id = 0, ton = 0, npi = 0, tpdu_type = 0; - gboolean is_packing_required = FALSE; - gint text_len = 0, number_len = 0, tpdu_data_len= 0; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX], dialling_number[TEL_SAT_DIALING_NUMBER_LEN_MAX]; - GVariantBuilder *builder = NULL; - GVariant *tpdu_data = NULL; - GVariant *icon_id = NULL; - - dbg("interpreting send sms notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&dialling_number, 0 , TEL_SAT_DIALING_NUMBER_LEN_MAX); - - if ( (send_sms_tlv->icon_id.is_exist) && ( send_sms_tlv->icon_id.icon_qualifer == TEL_SAT_ICON_QUALI_NOT_SELF_EXPLANATORY) - && (!send_sms_tlv->alpha_id.is_exist || !send_sms_tlv->alpha_id.alpha_data_len)) - { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = send_sms_tlv->command_detail.cmd_num; - tr->cmd_type = send_sms_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.send_sms.command_detail, &send_sms_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.send_sms.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_sms.device_id.dest = send_sms_tlv->device_id.src; - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - //text and text len - if ( send_sms_tlv->alpha_id.is_exist && send_sms_tlv->alpha_id.alpha_data_len) { - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - send_sms_tlv->alpha_id.dcs.a_format, - (guchar*)&send_sms_tlv->alpha_id.alpha_data, - (gushort)send_sms_tlv->alpha_id.alpha_data_len); - dbg("send sms ui display text (%s)",text); - } - else{ - memcpy(text,"",1); - text_len = 0; - } - - //packing required - is_packing_required = send_sms_tlv->command_detail.cmd_qualifier.cmd_quali_send_sms; - - //address : ton, npi, dialling number, number len - ton = send_sms_tlv->address.ton; - npi = send_sms_tlv->address.npi; - number_len = send_sms_tlv->address.dialing_number_len; - memcpy(dialling_number, send_sms_tlv->address.dialing_number, TEL_SAT_DIALING_NUMBER_LEN_MAX); - - //tpdu data : type, data, data len - tpdu_type = send_sms_tlv->sms_tpdu.tpdu_type; - tpdu_data_len = send_sms_tlv->sms_tpdu.data_len; - builder = g_variant_builder_new(G_VARIANT_TYPE ("ay")); - for (index = 0; index < tpdu_data_len; index++) { - g_variant_builder_add(builder, "y", send_sms_tlv->sms_tpdu.data[index]); - } - tpdu_data = g_variant_builder_end(builder); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_SEND_SMS; - memcpy((void*)&(q_data.cmd_data.sendSMSInd), send_sms_tlv, sizeof(TelSatSendSmsTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - send_sms = g_variant_new("(isivbiisiivi)", command_id, text, text_len, icon_id, is_packing_required, - ton, npi, dialling_number, number_len, tpdu_type, tpdu_data, tpdu_data_len); - - return send_sms; -} - -GVariant *sat_manager_send_ss_noti(TcorePlugin *plugin, TelSatSendSsTlv* send_ss_tlv) -{ - GVariant *send_ss = NULL; - SatManagerQueueData q_data; - gint command_id = 0, ton = 0, npi = 0; - gint text_len = 0, ss_str_len = 0; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX], ss_string[TEL_SAT_SS_STRING_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting send ss notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&ss_string, 0 , TEL_SAT_SS_STRING_LEN_MAX); - - if ( (send_ss_tlv->icon_id.is_exist) && ( send_ss_tlv->icon_id.icon_qualifer == TEL_SAT_ICON_QUALI_NOT_SELF_EXPLANATORY) - && (!send_ss_tlv->alpha_id.is_exist || !send_ss_tlv->alpha_id.alpha_data_len)) - { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = send_ss_tlv->command_detail.cmd_num; - tr->cmd_type = send_ss_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.send_ss.command_detail, &send_ss_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.send_ss.device_id.src = send_ss_tlv->device_id.dest; - tr->terminal_rsp_data.send_ss.device_id.dest = send_ss_tlv->device_id.src; - tr->terminal_rsp_data.send_ss.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - //text and text len - if ( send_ss_tlv->alpha_id.is_exist && send_ss_tlv->alpha_id.alpha_data_len) { - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - send_ss_tlv->alpha_id.dcs.a_format, - (guchar*)&send_ss_tlv->alpha_id.alpha_data, - (gushort)send_ss_tlv->alpha_id.alpha_data_len); - dbg("send ss ui display text (%s)",text); - } - - //ss string: ton, npi, ss string len, ss string - ton = send_ss_tlv->ss_string.ton; - npi = send_ss_tlv->ss_string.npi; - ss_str_len = send_ss_tlv->ss_string.string_len; - memcpy(ss_string, send_ss_tlv->ss_string.ss_string, TEL_SAT_SS_STRING_LEN_MAX); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_SEND_SS; - memcpy((void*)&(q_data.cmd_data.send_ss), send_ss_tlv, sizeof(TelSatSendSsTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - send_ss = g_variant_new("(isiviiis)", command_id, text, text_len, icon_id, - ton, npi, ss_str_len, ss_string); - - return send_ss; -} - -GVariant *sat_manager_send_ussd_noti(TcorePlugin *plugin, TelSatSendUssdTlv* send_ussd_tlv) -{ - GVariant *send_ussd = NULL; - SatManagerQueueData q_data; - gint command_id = 0; - guchar dcs = 0; - gint text_len = 0, ussd_str_len = 0; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX], ussd_string[TEL_SAT_USSD_STRING_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting send ussd notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&ussd_string, 0 , TEL_SAT_USSD_STRING_LEN_MAX); - - if ( (send_ussd_tlv->icon_id.is_exist) && ( send_ussd_tlv->icon_id.icon_qualifer == TEL_SAT_ICON_QUALI_NOT_SELF_EXPLANATORY) - && (!send_ussd_tlv->alpha_id.is_exist || !send_ussd_tlv->alpha_id.alpha_data_len)) - { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = send_ussd_tlv->command_detail.cmd_num; - tr->cmd_type = send_ussd_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.send_ussd.command_detail, &send_ussd_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.send_ussd.device_id.src = send_ussd_tlv->device_id.dest; - tr->terminal_rsp_data.send_ussd.device_id.dest = send_ussd_tlv->device_id.src; - tr->terminal_rsp_data.send_ussd.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - //text and text len - if ( send_ussd_tlv->alpha_id.is_exist && send_ussd_tlv->alpha_id.alpha_data_len) { - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - send_ussd_tlv->alpha_id.dcs.a_format, - (guchar*)&send_ussd_tlv->alpha_id.alpha_data, - (gushort)send_ussd_tlv->alpha_id.alpha_data_len); - dbg("send ussd ui display text (%s)",text); - } - - //ussd string - dcs = send_ussd_tlv->ussd_string.dsc.raw_dcs; - tcore_util_convert_str_to_utf8((guchar*)&ussd_string,(gushort *)&ussd_str_len, - send_ussd_tlv->ussd_string.dsc.a_format, - (guchar*)&send_ussd_tlv->ussd_string.ussd_string, - (gushort)send_ussd_tlv->ussd_string.string_len); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_SEND_USSD; - memcpy((void*)&(q_data.cmd_data.send_ussd), send_ussd_tlv, sizeof(TelSatSendUssdTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - send_ussd = g_variant_new("(isivyis)", command_id, text, text_len, icon_id, dcs, ussd_str_len, ussd_string); - - return send_ussd; -} - -GVariant *sat_manager_setup_call_noti(TcorePlugin *plugin, TelSatSetupCallTlv* setup_call_tlv) -{ - GVariant *setup_call = NULL; - SatManagerQueueData q_data; - - gint command_id = 0, call_type = 0, confirm_text_len = 0, text_len = 0, duration = 0; - gchar confirm_text[TEL_SAT_TEXT_STRING_LEN_MAX], text[TEL_SAT_TEXT_STRING_LEN_MAX], call_number[TEL_SAT_DIALING_NUMBER_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting setup call notification"); - memset(&confirm_text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&call_number, 0 , TEL_SAT_DIALING_NUMBER_LEN_MAX); - - if (setup_call_tlv->duration.time_interval > 0) - { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] redial is not supported.\n"); - - tr = g_new0(TelSatRequestTerminalResponseData, 1); - tr->cmd_number = setup_call_tlv->command_detail.cmd_num; - tr->cmd_type = setup_call_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.setup_call.command_detail, &setup_call_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_call.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.setup_call.device_id.dest = setup_call_tlv->device_id.src; - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_BEYOND_ME_CAPABILITIES; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - return NULL; - } - - //check for subaddress field - if (setup_call_tlv->subaddress.subaddress_len > 0) - { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] Sub address is not supported > 0)"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = setup_call_tlv->command_detail.cmd_num; - tr->cmd_type = setup_call_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.setup_call.command_detail, &setup_call_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_call.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.setup_call.device_id.dest = setup_call_tlv->device_id.src; - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_BEYOND_ME_CAPABILITIES; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - return NULL; - } - - //call type - call_type = setup_call_tlv->command_detail.cmd_qualifier.setup_call; - - //call display data - if (setup_call_tlv->call_setup_alpha_id.alpha_data_len != 0) { - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - setup_call_tlv->call_setup_alpha_id.dcs.a_format, - (guchar*)&setup_call_tlv->call_setup_alpha_id.alpha_data, - (gushort)setup_call_tlv->call_setup_alpha_id.alpha_data_len); - } - else{ - memcpy(text, setup_call_tlv->address.dialing_number, setup_call_tlv->address.dialing_number_len); - text_len = setup_call_tlv->address.dialing_number_len; - } - dbg("setup call display text (%s)",text); - - if (setup_call_tlv->user_confirm_alpha_id.alpha_data_len != 0) { - tcore_util_convert_str_to_utf8((guchar*)&confirm_text,(gushort *)&confirm_text_len, - setup_call_tlv->user_confirm_alpha_id.dcs.a_format, - (guchar*)&setup_call_tlv->user_confirm_alpha_id.alpha_data, - (gushort)setup_call_tlv->user_confirm_alpha_id.alpha_data_len); - } - - //call number - if (setup_call_tlv->address.ton == TEL_SAT_TON_INTERNATIONAL) { - call_number[0] = '+'; - memcpy(&call_number[1],setup_call_tlv->address.dialing_number, setup_call_tlv->address.dialing_number_len); - } - else{ - memcpy(call_number,setup_call_tlv->address.dialing_number, setup_call_tlv->address.dialing_number_len); - } - dbg("setup call call number(%s)",setup_call_tlv->address.dialing_number); - - //duration - if (setup_call_tlv->duration.time_interval > 0) - duration = _get_time_in_ms(&setup_call_tlv->duration); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_SETUP_CALL; - memcpy((void*)&(q_data.cmd_data.setup_call), setup_call_tlv, sizeof(TelSatSetupCallTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - setup_call = g_variant_new("(isisivisi)", command_id, confirm_text, confirm_text_len, text, text_len, icon_id, call_type, call_number, duration); - - return setup_call; -} - -GVariant *sat_manager_setup_event_list_noti(TcorePlugin *plugin, TelSatSetupEventListTlv *event_list_tlv) -{ - GVariant *event_list = NULL; - int index = 0; - gboolean rv = FALSE; - gint event_cnt = 0; - GVariantBuilder *builder = NULL; - GVariant *evt_list = NULL; - TelSatRequestTerminalResponseData *tr = NULL; - - dbg("interpreting event list notification"); - - //event cnt - event_cnt = event_list_tlv->event_list.event_list_cnt; - dbg("event cnt(%d)", event_cnt); - - //get event - builder = g_variant_builder_new(G_VARIANT_TYPE ("ai")); - for (index = 0; index < event_cnt; index++) { - g_variant_builder_add(builder, "i", event_list_tlv->event_list.evt_list[index]); - } - evt_list = g_variant_builder_end(builder); - - event_list = g_variant_new("(iv)", event_cnt, evt_list); - - //send TR - does not need from application's response - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = event_list_tlv->command_detail.cmd_num; - tr->cmd_type = event_list_tlv->command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.setup_event_list.command_detail, &event_list_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_event_list.device_id.src = event_list_tlv->device_id.dest; - tr->terminal_rsp_data.setup_event_list.device_id.dest = event_list_tlv->device_id.src; - tr->terminal_rsp_data.setup_event_list.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr->terminal_rsp_data.setup_event_list.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - - rv = sat_manager_check_availiable_event_list(event_list_tlv); - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return event_list; -} - -GVariant *sat_manager_setup_idle_mode_text_noti(TcorePlugin *plugin, TelSatSetupIdleModeTextTlv *idle_mode_tlv) -{ - GVariant *idle_mode = NULL; - SatManagerQueueData q_data; - gint command_id = 0; - gint text_len = 0; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting setup idle mode text notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - if ( ((idle_mode_tlv->icon_id.is_exist) && ( idle_mode_tlv->icon_id.icon_qualifer == TEL_SAT_ICON_QUALI_NOT_SELF_EXPLANATORY)) - && idle_mode_tlv->text.string_length == 0 ) - { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = idle_mode_tlv->command_detail.cmd_num; - tr->cmd_type = idle_mode_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.setup_idle_mode_text.command_detail, &idle_mode_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_idle_mode_text.device_id.src = idle_mode_tlv->device_id.dest; - tr->terminal_rsp_data.setup_idle_mode_text.device_id.dest = idle_mode_tlv->device_id.src; - tr->terminal_rsp_data.setup_idle_mode_text.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - return NULL; - } - - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - idle_mode_tlv->text.dcs.a_format, - (guchar*)&idle_mode_tlv->text.string, - (gushort)idle_mode_tlv->text.string_length); - - dbg("setup idle mode text display text (%s)",text); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT; - memcpy((void*)&(q_data.cmd_data.idle_mode), idle_mode_tlv, sizeof(TelSatSetupIdleModeTextTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - idle_mode = g_variant_new("(isiv)", command_id, text, text_len, icon_id); - - return idle_mode; -} - -GVariant *sat_manager_open_channel_noti(TcorePlugin *plugin, TelSatOpenChannelTlv *open_channel_tlv) -{ - GVariant *open_channel = NULL; - SatManagerQueueData q_data; - gint command_id = 0, bearer_type = 0, protocol_type = 0, dest_addr_type = 0; - gboolean immediate_link = FALSE, auto_reconnection = FALSE, bg_mode = FALSE; - gint text_len = 0, buffer_size = 0, port_number = 0; - gchar text[TEL_SAT_ALPHA_ID_LEN_MAX], dest_address[TEL_SAT_OTHER_ADDR_LEN_MAX]; - GVariant *icon_id = NULL; - GVariant *bearer_param = NULL; - GVariant *bearer_detail = NULL; - - dbg("interpreting open channel notification"); - memset(&text, 0 , TEL_SAT_ALPHA_ID_LEN_MAX); - memset(&dest_address, 0 , TEL_SAT_OTHER_ADDR_LEN_MAX); - - //immediate link - immediate_link = open_channel_tlv->command_detail.cmd_qualifier.open_channel.immediate_link; - - //auto reconnection - auto_reconnection = open_channel_tlv->command_detail.cmd_qualifier.open_channel.automatic_reconnection; - - //back ground mode - bg_mode = open_channel_tlv->command_detail.cmd_qualifier.open_channel.background_mode; - - //open channel text - if (open_channel_tlv->alpha_id.is_exist && open_channel_tlv->alpha_id.alpha_data_len > 0) - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - open_channel_tlv->alpha_id.dcs.a_format, - (guchar*)&open_channel_tlv->alpha_id.alpha_data, - (gushort)open_channel_tlv->alpha_id.alpha_data_len); - dbg("open channel text(%s)",text); - - //buffer size - buffer_size = open_channel_tlv->buffer_size[0]; - buffer_size = buffer_size << 8; - buffer_size += open_channel_tlv->buffer_size[1]; - //memcpy(&buffer_size, open_channel_tlv->buffer_size.size, sizeof(guchar)*2); - dbg("buffer size(%d)", buffer_size); - - //interface transport level - protocol_type = open_channel_tlv->interface_transport_level.protocol_type; - port_number = open_channel_tlv->interface_transport_level.port_number; - - //data destination address - dest_addr_type = open_channel_tlv->data_destination_address.address_type; - memcpy(dest_address, open_channel_tlv->data_destination_address.address, open_channel_tlv->data_destination_address.address_len); - dbg("destination IP address (%s)", dest_address); - - //bearer type - bearer_type = open_channel_tlv->bearer_desc.bearer_type; - - //bearer param & bearer detail - switch (bearer_type) { - case TEL_SAT_BEARER_CSD:{ - //bearer param - gint data_rate = 0, service_type = 0, conn_element_type = 0; - - //bearer detail - gint ton = 0, npi = 0, time_duration1 = 0, time_duration2 = 0, other_addr_type = 0; - gint login_len = 0, pwd_len = 0; - gchar dialling_number[TEL_SAT_DIALING_NUMBER_LEN_MAX], sub_addr[TEL_SAT_SUB_ADDR_LEN_MAX]; - gchar other_address[TEL_SAT_OTHER_ADDR_LEN_MAX]; - gchar login[TEL_SAT_TEXT_STRING_LEN_MAX], pwd[TEL_SAT_TEXT_STRING_LEN_MAX]; - - memset(&dialling_number, 0 , TEL_SAT_DIALING_NUMBER_LEN_MAX); - memset(&sub_addr, 0 , TEL_SAT_SUB_ADDR_LEN_MAX); - memset(&other_address, 0 , TEL_SAT_OTHER_ADDR_LEN_MAX); - memset(&login, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&pwd, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - //bearer parameter - data_rate = open_channel_tlv->bearer_desc.bearer_parameter.cs_bearer_param.data_rate; - service_type = open_channel_tlv->bearer_desc.bearer_parameter.cs_bearer_param.service_type; - conn_element_type = open_channel_tlv->bearer_desc.bearer_parameter.cs_bearer_param.connection_element_type; - - bearer_param = g_variant_new("(iii)", data_rate, service_type, conn_element_type); - - //bearer detail - ton = open_channel_tlv->bearer_detail.cs_bearer.address.ton; - npi = open_channel_tlv->bearer_detail.cs_bearer.address.npi; - memcpy(dialling_number, open_channel_tlv->bearer_detail.cs_bearer.address.dialing_number, open_channel_tlv->bearer_detail.cs_bearer.address.dialing_number_len); - - memcpy(sub_addr, open_channel_tlv->bearer_detail.cs_bearer.subaddress.subaddress, open_channel_tlv->bearer_detail.cs_bearer.subaddress.subaddress_len); - - time_duration1 = _get_time_in_ms(&open_channel_tlv->bearer_detail.cs_bearer.duration1); - time_duration2 = _get_time_in_ms(&open_channel_tlv->bearer_detail.cs_bearer.duration2); - - other_addr_type = open_channel_tlv->bearer_detail.cs_bearer.other_address.address_type; - memcpy(other_address, open_channel_tlv->bearer_detail.cs_bearer.other_address.address, open_channel_tlv->bearer_detail.cs_bearer.other_address.address_len); - - tcore_util_convert_str_to_utf8((guchar*) &login, (gushort *) &login_len, - open_channel_tlv->bearer_detail.cs_bearer.text_user_login.dcs.a_format, - (guchar*) &open_channel_tlv->bearer_detail.cs_bearer.text_user_login.string, - (gushort) open_channel_tlv->bearer_detail.cs_bearer.text_user_login.string_length); - - tcore_util_convert_str_to_utf8((guchar*) &pwd, (gushort *) &pwd_len, - open_channel_tlv->bearer_detail.cs_bearer.text_user_pwd.dcs.a_format, - (guchar*) &open_channel_tlv->bearer_detail.cs_bearer.text_user_pwd.string, - (gushort) open_channel_tlv->bearer_detail.cs_bearer.text_user_pwd.string_length); - - bearer_detail= g_variant_new("(iissiiisss)", ton, npi, dialling_number, sub_addr, time_duration1, time_duration2, - other_addr_type, other_address, login, pwd); - } break; - case TEL_SAT_BEARER_GPRS:{ - //bearer param - gint precedence_class = 0, delay_class = 0, reliability_class = 0; - gint peak_class = 0, mean_class = 0, pdp_type = 0; - - //bearer detail - gint other_addr_type = 0; - gint login_len = 0, pwd_len = 0; - gchar network_access_name[TEL_SAT_NET_ACC_NAM_LEN_MAX]; - gchar other_address[TEL_SAT_OTHER_ADDR_LEN_MAX]; - gchar login[TEL_SAT_TEXT_STRING_LEN_MAX], pwd[TEL_SAT_TEXT_STRING_LEN_MAX]; - - memset(&network_access_name, 0 , TEL_SAT_NET_ACC_NAM_LEN_MAX); - memset(&other_address, 0 , TEL_SAT_OTHER_ADDR_LEN_MAX); - memset(&login, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&pwd, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - //bearer parameter - precedence_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.precedence_class; - delay_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.delay_class; - reliability_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.reliability_class; - peak_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.peak_throughput_class; - mean_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.mean_throughput_class; - pdp_type = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.pdp_type; - - bearer_param = g_variant_new("(iiiiii)", precedence_class, delay_class, reliability_class, peak_class, mean_class, pdp_type); - - memcpy(network_access_name, open_channel_tlv->bearer_detail.ps_bearer.network_access_name.network_access_name, open_channel_tlv->bearer_detail.ps_bearer.network_access_name.length); - - other_addr_type = open_channel_tlv->bearer_detail.ps_bearer.other_address.address_type; - memcpy(other_address, open_channel_tlv->bearer_detail.ps_bearer.other_address.address, open_channel_tlv->bearer_detail.ps_bearer.other_address.address_len); - - tcore_util_convert_str_to_utf8((guchar*) &login, (gushort *) &login_len, - open_channel_tlv->bearer_detail.ps_bearer.text_user_login.dcs.a_format, - (guchar*) &open_channel_tlv->bearer_detail.ps_bearer.text_user_login.string, - (gushort) open_channel_tlv->bearer_detail.ps_bearer.text_user_login.string_length); - - tcore_util_convert_str_to_utf8((guchar*) &pwd, (gushort *) &pwd_len, - open_channel_tlv->bearer_detail.ps_bearer.text_user_pwd.dcs.a_format, - (guchar*) &open_channel_tlv->bearer_detail.ps_bearer.text_user_pwd.string, - (gushort) open_channel_tlv->bearer_detail.ps_bearer.text_user_pwd.string_length); - - bearer_detail= g_variant_new("(sisss)", network_access_name, other_addr_type, other_address, login, pwd); - - } break; - case TEL_SAT_BEARER_DEFAULT_BEARER_FROM_TRANSPORT_LAYER:{ - //bearer param - - //bearer detail - gint other_addr_type = 0; - gint login_len = 0, pwd_len = 0; - gchar other_address[TEL_SAT_OTHER_ADDR_LEN_MAX]; - gchar login[TEL_SAT_TEXT_STRING_LEN_MAX], pwd[TEL_SAT_TEXT_STRING_LEN_MAX]; - - memset(&other_address, 0 , TEL_SAT_OTHER_ADDR_LEN_MAX); - memset(&login, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&pwd, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - //bearer parameter - bearer_param = g_variant_new("()"); - - other_addr_type = open_channel_tlv->bearer_detail.default_bearer.other_address.address_type; - memcpy(other_address, open_channel_tlv->bearer_detail.default_bearer.other_address.address, open_channel_tlv->bearer_detail.default_bearer.other_address.address_len); - - tcore_util_convert_str_to_utf8((guchar*) &login, (gushort *) &login_len, - open_channel_tlv->bearer_detail.default_bearer.text_user_login.dcs.a_format, - (guchar*) &open_channel_tlv->bearer_detail.default_bearer.text_user_login.string, - (gushort) open_channel_tlv->bearer_detail.default_bearer.text_user_login.string_length); - - tcore_util_convert_str_to_utf8((guchar*) &pwd, (gushort *) &pwd_len, - open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.dcs.a_format, - (guchar*) &open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.string, - (gushort) open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.string_length); - - bearer_detail= g_variant_new("(isss)", other_addr_type, other_address, login, pwd); - - } break; - case TEL_SAT_BEARER_LOCAL_LINK_TECHNOLOGY_INDEPENDENT:{ - //bearer param - - //bearer detail - gint pwd_len = 0; - gint remote_address_type =0, time_duration1 = 0, time_duration2 = 0; - gchar remote_address[TEL_SAT_REMOTE_ENTITY_ADDR_LEN_MAX]; - gchar pwd[TEL_SAT_TEXT_STRING_LEN_MAX]; - - memset(&remote_address, 0 , TEL_SAT_REMOTE_ENTITY_ADDR_LEN_MAX); - memset(&pwd, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - //bearer parameter - bearer_param = g_variant_new("()"); - - time_duration1 = _get_time_in_ms(&open_channel_tlv->bearer_detail.local_bearer.duration1); - time_duration2 = _get_time_in_ms(&open_channel_tlv->bearer_detail.local_bearer.duration2); - - tcore_util_convert_str_to_utf8((guchar*) &pwd, (gushort *) &pwd_len, - open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.dcs.a_format, - (guchar*) &open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.string, - (gushort) open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.string_length); - - remote_address_type = open_channel_tlv->bearer_detail.local_bearer.remote_entity_address.coding_type; - memcpy(remote_address, open_channel_tlv->bearer_detail.local_bearer.remote_entity_address.remote_entity_address, open_channel_tlv->bearer_detail.local_bearer.remote_entity_address.length); - - bearer_detail= g_variant_new("(iisis)", time_duration1, time_duration2, pwd, remote_address_type, remote_address); - - } break; - default: - err("invalid bearer data"); - return NULL; - }//end of switch - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_OPEN_CHANNEL; - memcpy((void*)&(q_data.cmd_data.open_channel), open_channel_tlv, sizeof(TelSatOpenChannelTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - //execute bip - //sat_ui_support_exec_bip(); - - open_channel = g_variant_new("(isivbbbiviiiisv)", command_id, text, text_len, icon_id, immediate_link, auto_reconnection, bg_mode, - bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail); - - return open_channel; -} - -GVariant *sat_manager_close_channel_noti(TcorePlugin *plugin, TelSatCloseChannelTlv *close_channel_tlv) -{ - GVariant *close_channel = NULL; - SatManagerQueueData q_data; - gint command_id = 0, channel_id = 0; - gint text_len = 0; - gchar text[TEL_SAT_ALPHA_ID_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting close channel notification"); - memset(&text, 0 , TEL_SAT_ALPHA_ID_LEN_MAX); - - //channel id - channel_id = close_channel_tlv->device_id.dest; - - //close channel text - if (close_channel_tlv->alpha_id.is_exist && close_channel_tlv->alpha_id.alpha_data_len > 0) - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - close_channel_tlv->alpha_id.dcs.a_format, - (guchar*)&close_channel_tlv->alpha_id.alpha_data, - (gushort)close_channel_tlv->alpha_id.alpha_data_len); - dbg("close channel text(%s)",text); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_CLOSE_CHANNEL; - memcpy((void*)&(q_data.cmd_data.close_channel), close_channel_tlv, sizeof(TelSatCloseChannelTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - close_channel = g_variant_new("(isivi)", command_id, text, text_len, icon_id, channel_id); - - return close_channel; -} - -GVariant *sat_manager_receive_data_noti(TcorePlugin *plugin, TelSatReceiveChannelTlv *receive_data_tlv) -{ - GVariant *receive_data = NULL; - SatManagerQueueData q_data; - gint command_id = 0, channel_id = 0; - gint text_len = 0, channel_data_len = 0; - gchar text[TEL_SAT_ALPHA_ID_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting receive data notification"); - memset(&text, 0 , TEL_SAT_ALPHA_ID_LEN_MAX); - - //channel id - channel_id = receive_data_tlv->device_id.dest; - - //receive data text - if (receive_data_tlv->alpha_id.is_exist && receive_data_tlv->alpha_id.alpha_data_len > 0) - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - receive_data_tlv->alpha_id.dcs.a_format, - (guchar*)&receive_data_tlv->alpha_id.alpha_data, - (gushort)receive_data_tlv->alpha_id.alpha_data_len); - dbg("receive data text(%s)",text); - - channel_data_len = receive_data_tlv->channel_data_len; - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_RECEIVE_DATA; - memcpy((void*)&(q_data.cmd_data.receive_data), receive_data_tlv, sizeof(TelSatReceiveChannelTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - receive_data = g_variant_new("(isivii)", command_id, text, text_len, icon_id, channel_id, channel_data_len); - - return receive_data; -} - -GVariant *sat_manager_send_data_noti(TcorePlugin *plugin, TelSatSendChannelTlv *send_data_tlv) -{ - GVariant *send_data = NULL; - SatManagerQueueData q_data; - - int index = 0; - gint command_id = 0, channel_id = 0, data_len = 0; - gboolean send_data_immediately = FALSE; - gint text_len = 0; - gchar text[TEL_SAT_ALPHA_ID_LEN_MAX]; - GVariantBuilder *builder = NULL; - GVariant *channel_data = NULL; - GVariant *icon_id = NULL; - - dbg("interpreting send data notification"); - memset(&text, 0 , TEL_SAT_ALPHA_ID_LEN_MAX); - - //send data immediately - send_data_immediately = send_data_tlv->command_detail.cmd_qualifier.cmd_quali_send_data; - - //channel id - channel_id = send_data_tlv->device_id.dest; - - //send data text - if (send_data_tlv->alpha_id.is_exist && send_data_tlv->alpha_id.alpha_data_len > 0) - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - send_data_tlv->alpha_id.dcs.a_format, - (guchar*)&send_data_tlv->alpha_id.alpha_data, - (gushort)send_data_tlv->alpha_id.alpha_data_len); - dbg("send data text(%s)",text); - - //channel data, data len - data_len = send_data_tlv->channel_data.data_string_len; - builder = g_variant_builder_new(G_VARIANT_TYPE ("ay")); - for (index = 0; index < data_len; index++) { - dbg("send data index(%d) data(0x%x)",index, send_data_tlv->channel_data.data_string[index]); - g_variant_builder_add(builder, "y", send_data_tlv->channel_data.data_string[index]); - } - channel_data = g_variant_builder_end(builder); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_SEND_DATA; - memcpy((void*)&(q_data.cmd_data.send_data), send_data_tlv, sizeof(TelSatSendChannelTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - send_data = g_variant_new("(isivibvi)", command_id, text, text_len, icon_id, channel_id, send_data_immediately, channel_data, data_len); - - return send_data; -} - -GVariant *sat_manager_get_channel_status_noti(TcorePlugin *plugin, TelSatGetChannelStatusTlv *get_channel_status_tlv) -{ - GVariant *get_channel_status = NULL; - SatManagerQueueData q_data; - gint command_id = 0; - - dbg("interpreting get channel status notification"); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_GET_CHANNEL_STATUS; - memcpy((void*)&(q_data.cmd_data.get_channel_status), get_channel_status_tlv, sizeof(TelSatGetChannelStatusTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - get_channel_status = g_variant_new("(i)", command_id); - - return get_channel_status; -} - -GVariant *sat_manager_refresh_noti(TcorePlugin *plugin, TelSatRefreshTlv *refresh_tlv) -{ - GVariant *refresh = NULL; - SatManagerQueueData q_data; - gint command_id = 0; - gint refresh_type =0; - GVariantBuilder *builder = NULL; - GVariant *file_list = NULL; - - dbg("interpreting refresh notification"); - - refresh_type = refresh_tlv->command_detail.cmd_qualifier.refresh; - - builder = g_variant_builder_new(G_VARIANT_TYPE ("ai")); - /* TODO Use TelSimFileID from tel_sim.h */ - /* - for (index = 0; index < refresh_tlv->file_list.file_count; index++) { - g_variant_builder_add(builder, "i", refresh_tlv->file_list.file_id[index]); - }*/ - file_list = g_variant_builder_end(builder); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_REFRESH; - memcpy((void*)&(q_data.cmd_data.refresh), refresh_tlv, sizeof(TelSatRefreshTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - refresh = g_variant_new("(iiv)", command_id, refresh_type, file_list); - - return refresh; -} - -void sat_manager_more_time_noti(TcorePlugin *plugin, TelSatMoreTimeTlv *more_time_tlv) -{ - TelSatRequestTerminalResponseData *tr = NULL; - - dbg("interpreting more time notification"); - - //send TR - does not need from application's response - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = more_time_tlv->command_detail.cmd_num; - tr->cmd_type = more_time_tlv->command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.more_time.command_detail, &more_time_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.more_time.device_id.src = more_time_tlv->device_id.dest; - tr->terminal_rsp_data.more_time.device_id.dest = more_time_tlv->device_id.src; - tr->terminal_rsp_data.more_time.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr->terminal_rsp_data.more_time.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return; -} - -GVariant *sat_manager_send_dtmf_noti(TcorePlugin *plugin, TelSatSendDtmfTlv *send_dtmf_tlv) -{ - GVariant *send_dtmf = NULL; - SatManagerQueueData q_data; - - gint command_id = 0; - gint text_len =0, dtmf_str_len =0; - gchar text[TEL_SAT_TEXT_STRING_LEN_MAX], dtmf_str[TEL_SAT_DTMF_STRING_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting send dtmf notification"); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&dtmf_str, 0 , TEL_SAT_DTMF_STRING_LEN_MAX); - - if ( (send_dtmf_tlv->icon_id.is_exist) && ( send_dtmf_tlv->icon_id.icon_qualifer == TEL_SAT_ICON_QUALI_NOT_SELF_EXPLANATORY) - && (!send_dtmf_tlv->alpha_id.is_exist || !send_dtmf_tlv->alpha_id.alpha_data_len)) - { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = send_dtmf_tlv->command_detail.cmd_num; - tr->cmd_type = send_dtmf_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.send_dtmf.command_detail, &send_dtmf_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.send_dtmf.device_id.src = send_dtmf_tlv->device_id.dest; - tr->terminal_rsp_data.send_dtmf.device_id.dest = send_dtmf_tlv->device_id.src; - tr->terminal_rsp_data.send_dtmf.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - //text and text len - if ( send_dtmf_tlv->alpha_id.is_exist && send_dtmf_tlv->alpha_id.alpha_data_len) { - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - send_dtmf_tlv->alpha_id.dcs.a_format, - (guchar*)&send_dtmf_tlv->alpha_id.alpha_data, - (gushort)send_dtmf_tlv->alpha_id.alpha_data_len); - dbg("send dtmf ui display text (%s)",text); - } - - //dtmf string len, dtmf string - dtmf_str_len = send_dtmf_tlv->dtmf_string.dtmf_length; - memcpy(dtmf_str, send_dtmf_tlv->dtmf_string.dtmf_string, TEL_SAT_DTMF_STRING_LEN_MAX); - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_SEND_DTMF; - memcpy((void*)&(q_data.cmd_data.send_dtmf), send_dtmf_tlv, sizeof(TelSatSendDtmfTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - send_dtmf = g_variant_new("(isivis)", command_id, text, text_len, icon_id, - dtmf_str_len, dtmf_str); - - return send_dtmf; -} - -GVariant *sat_manager_launch_browser_noti(TcorePlugin *plugin, TelSatLaunchBrowserTlv *launch_browser_tlv) -{ - GVariant *launch_browser = NULL; - SatManagerQueueData q_data; - gint command_id = 0; - gint browser_launch_type = 0, browser_id = 0; - gint url_len =0, text_len =0, gateway_proxy_len =0; - gchar url[TEL_SAT_URL_LEN_MAX], text[TEL_SAT_TEXT_STRING_LEN_MAX], gateway_proxy[TEL_SAT_TEXT_STRING_LEN_MAX]; - GVariant *icon_id = NULL; - - dbg("interpreting launch browser notification"); - memset(&url, 0 , TEL_SAT_URL_LEN_MAX); - memset(&text, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - memset(&gateway_proxy, 0 , TEL_SAT_TEXT_STRING_LEN_MAX); - - if ( (launch_browser_tlv->user_confirm_icon_id.is_exist) && ( launch_browser_tlv->user_confirm_icon_id.icon_qualifer == TEL_SAT_ICON_QUALI_NOT_SELF_EXPLANATORY) - && (!launch_browser_tlv->user_confirm_alpha_id.is_exist || !launch_browser_tlv->user_confirm_alpha_id.alpha_data_len)) - { - TelSatRequestTerminalResponseData *tr = NULL; - dbg("[SAT] exceptional case to fix gcf case 2.4 command not understood"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = launch_browser_tlv->command_detail.cmd_num; - tr->cmd_type = launch_browser_tlv->command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.launch_browser.command_detail, &launch_browser_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.launch_browser.device_id.src = launch_browser_tlv->device_id.dest; - tr->terminal_rsp_data.launch_browser.device_id.dest = launch_browser_tlv->device_id.src; - tr->terminal_rsp_data.launch_browser.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return NULL; - } - - //browser launch type - browser_launch_type = launch_browser_tlv->command_detail.cmd_qualifier.launch_browser; - - //browser id - browser_id = launch_browser_tlv->browser_id; - - //url and url len - if ( launch_browser_tlv->url.url_length) { - url_len = launch_browser_tlv->url.url_length; - memcpy(url, launch_browser_tlv->url.url, launch_browser_tlv->url.url_length); - dbg("launch browser url (%s)",url); - } - - //gateway_proxy_text - if (launch_browser_tlv->gateway_proxy_text.is_digit_only) { - memcpy(gateway_proxy, launch_browser_tlv->gateway_proxy_text.string, launch_browser_tlv->gateway_proxy_text.string_length); - dbg("launch browser gateway_proxy digit type string (%s)",gateway_proxy); - } else { - if ( launch_browser_tlv->gateway_proxy_text.string_length) { - tcore_util_convert_str_to_utf8((guchar*)&gateway_proxy,(gushort *)&gateway_proxy_len, - launch_browser_tlv->gateway_proxy_text.dcs.a_format, - (guchar*)&launch_browser_tlv->gateway_proxy_text.string, - (gushort)launch_browser_tlv->gateway_proxy_text.string_length); - dbg("launch browser gateway_proxy_text (%s)",gateway_proxy); - } - } - - //user confirm text and user confirm text len - if ( launch_browser_tlv->user_confirm_alpha_id.is_exist && launch_browser_tlv->user_confirm_alpha_id.alpha_data_len) { - tcore_util_convert_str_to_utf8((guchar*)&text,(gushort *)&text_len, - launch_browser_tlv->user_confirm_alpha_id.dcs.a_format, - (guchar*)&launch_browser_tlv->user_confirm_alpha_id.alpha_data, - (gushort)launch_browser_tlv->user_confirm_alpha_id.alpha_data_len); - dbg("launch browser user confirm text (%s)",text); - } - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_LAUNCH_BROWSER; - memcpy((void*)&(q_data.cmd_data.launch_browser), launch_browser_tlv, sizeof(TelSatLaunchBrowserTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - icon_id = g_variant_new("()"); - - launch_browser = g_variant_new("(iiisisisiv)", - command_id, browser_launch_type, browser_id, url, url_len, gateway_proxy, gateway_proxy_len, text, text_len, icon_id); - - return launch_browser; -} - -GVariant *sat_manager_provide_local_info_noti(TcorePlugin *plugin, TcorePlugin *comm_plugin, TelSatProvideLocalInfoTlv *provide_local_info_tlv) -{ - GVariant *provide_info = NULL; - gint info_type =0; - TelSatRequestTerminalResponseData *tr = NULL; - - dbg("interpreting provide local info notification"); - - provide_info = g_variant_new("(i)", info_type); - - //send TR - does not need from application's response - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = provide_local_info_tlv->command_detail.cmd_num; - tr->cmd_type = provide_local_info_tlv->command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.provide_local_info.command_detail, &provide_local_info_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.provide_local_info.device_id.src = provide_local_info_tlv->device_id.dest; - tr->terminal_rsp_data.provide_local_info.device_id.dest = provide_local_info_tlv->device_id.src; - tr->terminal_rsp_data.provide_local_info.other_info = TRUE; - - info_type = provide_local_info_tlv->command_detail.cmd_qualifier.provide_local_info; - - switch (info_type) { - case TEL_SAT_LOCAL_INFO_DATE_TIME_AND_TIMEZONE:{ - int err = 0; int gmt = 0, n_flg = 0; - /* TODO confirm timezone and timeval struct types */ - struct timezone c_tz; - struct timeval c_time; - - time_t time_val; - struct tm time_info; - - time(&time_val); - - tzset(); - err = gettimeofday(&c_time, &c_tz); - localtime_r(&time_val, &time_info); - - //set the time information - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.year = - _convert_decimal_to_bcd(time_info.tm_year+1900-2000); - - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.month = - _convert_decimal_to_bcd(time_info.tm_mon+1); - - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.day = - _convert_decimal_to_bcd(time_info.tm_mday); - - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.hour = - _convert_decimal_to_bcd(time_info.tm_hour); - - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.minute = - _convert_decimal_to_bcd(time_info.tm_min); - - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.second = - _convert_decimal_to_bcd(time_info.tm_sec); - - gmt = c_tz.tz_minuteswest/60; - if (gmt < 0) { - gmt = gmt * -1; - n_flg = 1; - } - - if (err != 0) { - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.time_zone = 0xFF; - } - else{ - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.time_zone = - _convert_decimal_to_bcd(gmt); - - if (n_flg == 1) { - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.time_zone += 0x80; - } - - if (time_info.tm_isdst > 0) { - tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.time_zone += 0x40; - } - } - - tr->terminal_rsp_data.provide_local_info.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr->terminal_rsp_data.provide_local_info.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - } break; - case TEL_SAT_LOCAL_INFO_LANGUAGE:{ - DtapiSatPrivateData *sat_data; - static TcoreStorage *strg; - gchar *lang_str = NULL; - TelSimLanguagePreferenceCode lang_type = TEL_SIM_LP_LANG_UNSPECIFIED; - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - err("sat_data is null"); - g_free(tr); - return NULL; - } - - tr->terminal_rsp_data.provide_local_info.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr->terminal_rsp_data.provide_local_info.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - - strg = tcore_server_find_storage(sat_data->server, "vconf"); - lang_str = tcore_storage_get_string(strg, STORAGE_KEY_LANGUAGE_SET); - if (lang_str) - lang_type = _convert_string_to_sim_lang(lang_str); - - tr->terminal_rsp_data.provide_local_info.other.language = lang_type; - } break; - default :{ - tr->terminal_rsp_data.provide_local_info.other_info = FALSE; - tr->terminal_rsp_data.provide_local_info.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.provide_local_info.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - } break; - } - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return provide_info; -} - -GVariant *sat_manager_language_notification_noti(TcorePlugin *plugin, TelSatLanguageNotificationTlv *language_notification_tlv) -{ - GVariant *language_noti = NULL; - SatManagerQueueData q_data; - gint command_id = 0; - gint language =0; - gboolean is_specified = FALSE; - - dbg("interpreting langauge notification"); - - if (language_notification_tlv->command_detail.cmd_qualifier.cmd_quali_language_notification == TRUE) { - is_specified = TRUE; - language = language_notification_tlv->language; - } else { - is_specified = FALSE; - language = TEL_SIM_LP_LANG_UNSPECIFIED; - } - - //enqueue data and generate cmd_id - memset(&q_data, 0x00, sizeof(SatManagerQueueData)); - q_data.cmd_type = TEL_SAT_PROATV_CMD_LANGUAGE_NOTIFICATION; - memcpy((void*)&(q_data.cmd_data.language_notification), language_notification_tlv, sizeof(TelSatLanguageNotificationTlv)); - sat_manager_enqueue_cmd(&q_data); - command_id = q_data.cmd_id; - - language_noti = g_variant_new("(iib)", command_id, language, is_specified); - - return language_noti; -} - -gboolean sat_manager_processing_unsupport_proactive_command(TcorePlugin *plugin, TelSatUnsupportCommandTlv *unsupport_tlv) -{ - TelSatRequestTerminalResponseData tr; - - dbg("[SAT] unsupport proactive command (%d)", unsupport_tlv->command_detail.cmd_type); - - memset(&tr, 0x00, sizeof(TelSatRequestTerminalResponseData)); - tr.cmd_number = unsupport_tlv->command_detail.cmd_num; - tr.cmd_type = unsupport_tlv->command_detail.cmd_type; - - memcpy((void*)&tr.terminal_rsp_data.unsupport_cmd.command_detail, &unsupport_tlv->command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.unsupport_cmd.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.unsupport_cmd.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.unsupport_cmd.result_type = TEL_SAT_RESULT_BEYOND_ME_CAPABILITIES; - - sat_manager_send_terminal_response(plugin, &tr); - - return TRUE; -} - -gboolean sat_manager_handle_sat_ui_launch_fail(TcorePlugin *plugin, TelSatNotiProactiveData *p_ind) -{ - TelReturn rv = TEL_RETURN_FAILURE; - TelSatRequestTerminalResponseData tr; - - dbg("[SAT] proactive command (%d)", p_ind->cmd_type); - - memset(&tr, 0x00, sizeof(TelSatRequestTerminalResponseData)); - tr.cmd_number = p_ind->cmd_number; - tr.cmd_type = p_ind->cmd_type; - - switch (p_ind->cmd_type) { - case TEL_SAT_PROATV_CMD_DISPLAY_TEXT: { - memcpy((void*)&tr.terminal_rsp_data.display_text.command_detail, &p_ind->proactive_ind_data.display_text.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.display_text.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.display_text.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_SELECT_ITEM: { - memcpy((void*)&tr.terminal_rsp_data.select_item.command_detail, &p_ind->proactive_ind_data.select_item.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.select_item.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.select_item.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.select_item.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_GET_INKEY: { - memcpy((void*)&tr.terminal_rsp_data.get_inkey.command_detail, &p_ind->proactive_ind_data.get_inkey.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.get_inkey.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.get_inkey.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.get_inkey.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_GET_INPUT: { - memcpy((void*)&tr.terminal_rsp_data.get_input.command_detail, &p_ind->proactive_ind_data.get_input.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.get_input.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.get_input.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.get_input.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_PLAY_TONE: { - memcpy((void*)&tr.terminal_rsp_data.play_tone.command_detail, &p_ind->proactive_ind_data.play_tone.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.play_tone.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.play_tone.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.play_tone.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_SEND_SMS: { - memcpy((void*)&tr.terminal_rsp_data.send_sms.command_detail, &p_ind->proactive_ind_data.send_sms.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.send_sms.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.send_sms.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_SEND_SS: { - memcpy((void*)&tr.terminal_rsp_data.send_ss.command_detail, &p_ind->proactive_ind_data.send_ss.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.send_ss.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.send_ss.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.send_ss.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_SEND_USSD: { - memcpy((void*)&tr.terminal_rsp_data.send_ussd.command_detail, &p_ind->proactive_ind_data.send_ussd.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.send_ussd.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.send_ussd.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.send_ussd.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_SETUP_CALL: { - memcpy((void*)&tr.terminal_rsp_data.setup_call.command_detail, &p_ind->proactive_ind_data.setup_call.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.setup_call.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.setup_call.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: { - memcpy((void*)&tr.terminal_rsp_data.setup_idle_mode_text.command_detail, &p_ind->proactive_ind_data.setup_idle_mode_text.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.setup_idle_mode_text.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.setup_idle_mode_text.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.setup_idle_mode_text.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_OPEN_CHANNEL: { - memcpy((void*)&tr.terminal_rsp_data.open_channel.command_detail, &p_ind->proactive_ind_data.open_channel.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.open_channel.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.open_channel.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.open_channel.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - case TEL_SAT_PROATV_CMD_LAUNCH_BROWSER: { - memcpy((void*)&tr.terminal_rsp_data.launch_browser.command_detail, &p_ind->proactive_ind_data.launch_browser.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.launch_browser.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr.terminal_rsp_data.launch_browser.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr.terminal_rsp_data.launch_browser.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } break; - default: - dbg("unsupported command."); - break; - } - - rv = sat_manager_send_terminal_response(plugin, &tr); - if (rv != TEL_RETURN_SUCCESS) - return FALSE; - - return TRUE; -} - -static gboolean _sat_manager_handle_setup_menu_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - dbg("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] setup menu result data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(i)", &resp); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.setupMenuInd.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.setupMenuInd.command_detail.cmd_type; - - memcpy((void*)&tr->terminal_rsp_data.setup_menu.command_detail, - &q_data.cmd_data.setupMenuInd.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.setup_menu.device_id.src = q_data.cmd_data.setupMenuInd.device_id.dest; - tr->terminal_rsp_data.setup_menu.device_id.dest = q_data.cmd_data.setupMenuInd.device_id.src; - - dbg("[SAT] Response: [0x%02x]", resp); - - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - tr->terminal_rsp_data.setup_menu.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - if (q_data.cmd_data.setupMenuInd.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.setup_menu.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - tr->terminal_rsp_data.setup_menu.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.setup_menu.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.setup_menu.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - default: - //check the default case - tr->terminal_rsp_data.setup_menu.result_type = resp; - tr->terminal_rsp_data.setup_menu.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - err("[SAT] wrong result from app exec resp(%d)", resp); - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - - return result; -} - -static gboolean _sat_manager_handle_display_text_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] display text result data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(ii)",&resp, &me_problem); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.displayTextInd.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.displayTextInd.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.display_text.command_detail, &q_data.cmd_data.displayTextInd.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.display_text.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.display_text.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr->terminal_rsp_data.display_text.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.display_text.me_problem_type = me_problem; - break; - - default: - tr->terminal_rsp_data.display_text.result_type = resp; - tr->terminal_rsp_data.display_text.me_problem_type = me_problem; - err("[SAT] wrong result from app exec resp(%d) me_problem(%d)", resp, me_problem); - break; - } - - if (q_data.cmd_data.displayTextInd.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - - return result; -} - -static gboolean _sat_manager_handle_play_tone_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] display text result data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(ii)",&resp, &me_problem); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.play_tone.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.play_tone.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.play_tone.command_detail, &q_data.cmd_data.play_tone.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.play_tone.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.play_tone.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - tr->terminal_rsp_data.play_tone.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - if (q_data.cmd_data.play_tone.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.play_tone.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - tr->terminal_rsp_data.play_tone.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.play_tone.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.play_tone.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER: - tr->terminal_rsp_data.play_tone.result_type = TEL_SAT_RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; - tr->terminal_rsp_data.play_tone.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - default: - tr->terminal_rsp_data.play_tone.result_type = resp; - tr->terminal_rsp_data.play_tone.me_problem_type = me_problem; - err("[SAT] wrong result from app exec resp(%d) me_problem(%d)", resp, me_problem); - break; - } - - if (q_data.cmd_data.displayTextInd.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -static gboolean _sat_manager_handle_send_sms_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] send sms data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(i)",&resp); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.sendSMSInd.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.sendSMSInd.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_sms.command_detail, &q_data.cmd_data.sendSMSInd.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.send_sms.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_sms.device_id.dest = q_data.cmd_data.sendSMSInd.device_id.src; - - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - if (q_data.cmd_data.sendSMSInd.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - break; - - case TEL_SAT_RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM: - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM; - tr->terminal_rsp_data.send_sms.cc_problem_type = TEL_SAT_CC_PROBLEM_ACTION_NOT_ALLOWED; - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.send_sms.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_BEYOND_ME_CAPABILITIES: - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_BEYOND_ME_CAPABILITIES; - tr->terminal_rsp_data.send_sms.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME: - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME; - tr->terminal_rsp_data.send_sms.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME: - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; - tr->terminal_rsp_data.send_sms.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_SMS_RP_ERROR: - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_SMS_RP_ERROR; - tr->terminal_rsp_data.send_sms.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - default: - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.send_sms.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - -/* if ( q_data.cmd_data.sendSMSInd.alpha_id.alpha_data_len && q_data.cmd_data.sendSMSInd.alpha_id.is_exist) - sat_ui_support_terminate_sat_ui();*/ - - return result; -} - -static gboolean _sat_manager_handle_send_ss_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem, ss_cause, call_ctrl_problem, ss_str_len; - gchar *ss_string; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - //call ctrl action, result data object, text - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] send ss data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(iiisii)", &resp, &me_problem, &ss_cause, &ss_string, &ss_str_len, &call_ctrl_problem); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.send_ss.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.send_ss.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_ss.command_detail, &q_data.cmd_data.send_ss.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.send_ss.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_ss.device_id.dest = q_data.cmd_data.send_ss.device_id.src; - - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - tr->terminal_rsp_data.send_ss.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - if (q_data.cmd_data.send_ss.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.send_ss.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - if (ss_str_len > 0 && ss_string != NULL) { - memcpy(&tr->terminal_rsp_data.send_ss.text.dcs, &q_data.cmd_data.send_ss.alpha_id.dcs, sizeof(TelSatDataCodingSchemeInfo)); - memcpy((void*)tr->terminal_rsp_data.send_ss.text.string, ss_string, ss_str_len); - tr->terminal_rsp_data.send_ss.text.string_length = ss_str_len; - } - break; - - case TEL_SAT_RESULT_SS_RETURN_ERROR: - tr->terminal_rsp_data.send_ss.result_type = TEL_SAT_RESULT_SS_RETURN_ERROR; - tr->terminal_rsp_data.send_ss.ss_problem = ss_cause; - break; - - case TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.send_ss.result_type = TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.send_ss.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - default: - tr->terminal_rsp_data.send_ss.result_type = TEL_SAT_RESULT_SS_RETURN_ERROR; - tr->terminal_rsp_data.send_ss.ss_problem = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - g_free(tr); - - if ( q_data.cmd_data.send_ss.alpha_id.alpha_data_len && q_data.cmd_data.send_ss.alpha_id.is_exist ) - sat_ui_support_terminate_sat_ui(); - - return result; -} - -static gboolean _sat_manager_handle_send_ussd_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem, ss_cause, ussd_str_len; - GVariant *ussd_str = NULL; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - //call ctrl action, result data object, text, result2, text2 - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] send ss data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(iii@vi)", &resp, &me_problem, &ss_cause, &ussd_str, &ussd_str_len); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.send_ussd.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.send_ussd.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_ussd.command_detail, &q_data.cmd_data.send_ussd.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.send_ussd.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_ussd.device_id.dest = q_data.cmd_data.send_ussd.device_id.src; - - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - tr->terminal_rsp_data.send_ussd.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - if (q_data.cmd_data.send_ussd.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.send_ussd.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - if (ussd_str_len > 0 && ussd_str) { - int index = 0; - guchar data; - GVariantIter *iter = NULL; - GVariant *intermediate = NULL; - - intermediate = g_variant_get_variant(ussd_str); - dbg("ussd string format(%s)", g_variant_get_type_string(intermediate)); - - g_variant_get(intermediate, "ay", &iter); - while ( g_variant_iter_loop (iter, "y", &data)) { - dbg("index(%d) data(%c)", index, data); - - if (index == 0) { - tr->terminal_rsp_data.send_ussd.text.dcs.raw_dcs = (data & 0x0F); - } - else{ - tr->terminal_rsp_data.send_ussd.text.string[index-1] = data; - } - - index++; - } - g_variant_iter_free(iter); - g_variant_unref(intermediate); - - tr->terminal_rsp_data.send_ussd.text.string_length = index-1; - } - break; - - case TEL_SAT_RESULT_SS_RETURN_ERROR: - case TEL_SAT_RESULT_USSD_RETURN_ERROR:{ - tr->terminal_rsp_data.send_ussd.result_type = TEL_SAT_RESULT_USSD_RETURN_ERROR; - if(ss_cause == TEL_SS_RESULT_UNKONWN_ALPHABET) - tr->terminal_rsp_data.send_ussd.ussd_problem = TEL_SAT_USSD_PROBLEM_UNKNOWN_ALPHABET; - else - tr->terminal_rsp_data.send_ussd.ussd_problem = TEL_SAT_USSD_PROBLEM_NO_SPECIFIC_CAUSE; - }break; - - case TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.send_ussd.result_type = TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.send_ussd.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.send_ussd.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.send_ussd.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - default: - tr->terminal_rsp_data.send_ussd.result_type = TEL_SAT_RESULT_USSD_RETURN_ERROR; - tr->terminal_rsp_data.send_ussd.ussd_problem = TEL_SAT_USSD_PROBLEM_NO_SPECIFIC_CAUSE; - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - g_free(tr); - - if ( q_data.cmd_data.send_ussd.alpha_id.alpha_data_len && q_data.cmd_data.send_ussd.alpha_id.is_exist ) - sat_ui_support_terminate_sat_ui(); - - return result; -} - -static gboolean _sat_manager_handle_setup_call_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem, cc_problem, call_cause; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] setup call data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(iiii)",&resp, &me_problem, &cc_problem, &call_cause); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.setup_call.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.setup_call.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.setup_call.command_detail, &q_data.cmd_data.setup_call.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_call.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.setup_call.device_id.dest = q_data.cmd_data.setup_call.device_id.src; - - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - if (q_data.cmd_data.setup_call.call_setup_icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - tr->terminal_rsp_data.setup_call.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.setup_call.cc_problem_type = TEL_SAT_CC_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.setup_call.me_problem_type = me_problem; - break; - - case TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND:{ - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND; - if(call_cause == TEL_CALL_RESULT_NETWORK_BUSY) - tr->terminal_rsp_data.setup_call.network_problem_type = TEL_SAT_NETWORK_PROBLEM_USER_BUSY; - else - tr->terminal_rsp_data.setup_call.network_problem_type = TEL_SAT_NETWORK_PROBLEM_NO_SPECIFIC_CAUSE; - }break; - - case TEL_SAT_RESULT_USER_CLEAR_DOWN_CALL_BEFORE_CONN: - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_USER_CLEAR_DOWN_CALL_BEFORE_CONN; - tr->terminal_rsp_data.setup_call.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.setup_call.cc_problem_type = TEL_SAT_CC_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_BEYOND_ME_CAPABILITIES: - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_BEYOND_ME_CAPABILITIES; - tr->terminal_rsp_data.setup_call.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.setup_call.cc_problem_type = TEL_SAT_CC_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM: - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM; - tr->terminal_rsp_data.setup_call.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.setup_call.cc_problem_type = cc_problem; - break; - - - default: - break; - } - - //TODO Other infomation set - not supported - tr->terminal_rsp_data.setup_call.other_info = FALSE; - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -static gboolean _sat_manager_handle_setup_idle_mode_text_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] send ss data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(ii)",&resp, &me_problem); - - tr = g_new0(TelSatRequestTerminalResponseData, 1); - tr->cmd_number = q_data.cmd_data.idle_mode.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.idle_mode.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.setup_idle_mode_text.command_detail, &q_data.cmd_data.idle_mode.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_idle_mode_text.device_id.src = q_data.cmd_data.idle_mode.device_id.dest; - tr->terminal_rsp_data.setup_idle_mode_text.device_id.dest = q_data.cmd_data.idle_mode.device_id.src; - - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - tr->terminal_rsp_data.setup_idle_mode_text.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - if (q_data.cmd_data.idle_mode.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.setup_idle_mode_text.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - break; - default: - tr->terminal_rsp_data.setup_idle_mode_text.result_type = resp; - tr->terminal_rsp_data.setup_idle_mode_text.me_problem_type = me_problem; - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - g_free(tr); - - sat_ui_support_terminate_sat_ui(); - - return result; -} - -static gboolean sat_manager_handle_open_channel_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem, bip_problem; - gint bearer_type, channel_id, channel_status, channel_status_info, buffer_size; - gboolean other_info; - GVariant *desc_tmp, *bearer_desc; - - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] open channel data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(iiiiiiiibv)",&resp, &me_problem, &bip_problem, - &bearer_type, &channel_id, &channel_status, &channel_status_info, &buffer_size, - &other_info, &desc_tmp); - - bearer_desc = g_variant_get_variant(desc_tmp); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.open_channel.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.open_channel.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.open_channel.command_detail, &q_data.cmd_data.open_channel.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.open_channel.device_id.src = q_data.cmd_data.open_channel.device_id.dest; - tr->terminal_rsp_data.open_channel.device_id.dest = q_data.cmd_data.open_channel.device_id.src; - - tr->terminal_rsp_data.open_channel.result_type = resp; - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - case TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: - case TEL_SAT_RESULT_SUCCESS_WITH_MISSING_INFO: - //channel status - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - case TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.open_channel.me_problem_type = me_problem; - break; - - case TEL_SAT_RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: - tr->terminal_rsp_data.open_channel.bip_problem_type = bip_problem; - break; - - default: - break; - } - - tr->terminal_rsp_data.open_channel.channel_status.channel_id = channel_id; - tr->terminal_rsp_data.open_channel.channel_status.status = channel_status; - tr->terminal_rsp_data.open_channel.channel_status.status_info = channel_status_info; - - dbg("check channel id(%d) channel status(%d) channel info(%d)", channel_id, channel_status, channel_status_info); - - //memcpy(tr->terminal_rsp_data.open_channel.buffer_size.size, &buffer_size, sizeof(guchar)*2); - tr->terminal_rsp_data.open_channel.buffer_size[0] = buffer_size >> 8; - tr->terminal_rsp_data.open_channel.buffer_size[1] = buffer_size & 0xFF; - dbg("check buffer size[0](0x%x) size[1](0x%x)", tr->terminal_rsp_data.open_channel.buffer_size[0], tr->terminal_rsp_data.open_channel.buffer_size[1]); - - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_type = bearer_type; - switch (bearer_type) { - case TEL_SAT_BEARER_CSD:{ - gint data_rate, service_type, conn_element_type; - - dbg("bearer_desc cs bearer type_format(%s)", g_variant_get_type_string(bearer_desc)); - g_variant_get(bearer_desc, "(iii)",&data_rate, &service_type, &conn_element_type); - dbg("check cs bearer data_rade(%d), service_type(%d), conn_element_type(%d)", data_rate, service_type, conn_element_type); - - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.cs_bearer_param.data_rate = data_rate; - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.cs_bearer_param.service_type = service_type; - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.cs_bearer_param.connection_element_type = conn_element_type; - }break; - case TEL_SAT_BEARER_GPRS:{ - gint precedence_class, delay_class, reliability_class; - gint peak_class, mean_class, pdp_type; - - dbg("bearer_desc ps bearer type_format(%s)", g_variant_get_type_string(bearer_desc)); - g_variant_get(bearer_desc, "(iiiiii)",&precedence_class, &delay_class, &reliability_class, - &peak_class, &mean_class, &pdp_type); - dbg("check ps bearer precedence class(%d), delay class(%d), reliability class(%d) peak class(%d) mean class(%d) pdp_type(%d)", - precedence_class, delay_class, reliability_class, peak_class, mean_class, pdp_type); - - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.precedence_class = precedence_class; - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.delay_class = delay_class; - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.reliability_class = reliability_class; - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.peak_throughput_class = peak_class; - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.mean_throughput_class = mean_class; - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.pdp_type = pdp_type; - }break; - case TEL_SAT_BEARER_LOCAL_LINK_TECHNOLOGY_INDEPENDENT:{ - gint service_type; - gchar *service_record = NULL; - - dbg("bearer_desc link local type_format(%s)", g_variant_get_type_string(bearer_desc)); - g_variant_get(bearer_desc, "(is)",&service_type, &service_record); - dbg("check link local service_type(%d), service_record(%d)", service_type, service_record); - - tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.local_link_bearer_param.service_type = service_type; - - if (service_record) - memcpy(tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.local_link_bearer_param.service_record, service_record, strlen((const gchar *)service_record)); - - }break; - default: - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -static gboolean sat_manager_handle_close_channel_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem, bip_problem; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] close channel data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(iii)",&resp, &me_problem, &bip_problem); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.close_channel.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.close_channel.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.close_channel.command_detail, &q_data.cmd_data.close_channel.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.close_channel.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.close_channel.device_id.dest = q_data.cmd_data.close_channel.device_id.src; - - tr->terminal_rsp_data.close_channel.result_type = resp; - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - case TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: - case TEL_SAT_RESULT_SUCCESS_WITH_MISSING_INFO: - //channel status - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - case TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.close_channel.me_problem_type = me_problem; - break; - - case TEL_SAT_RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: - tr->terminal_rsp_data.close_channel.bip_problem_type = bip_problem; - break; - - default: - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -static gboolean sat_manager_handle_receive_data_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem, bip_problem; - gint data_str_len, data_len; - gboolean other_info; - GVariant *received_data; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] receive data data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(iiiiibv)",&resp, &me_problem, &bip_problem, &data_str_len, &data_len, &other_info, &received_data); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.receive_data.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.receive_data.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.receive_data.command_detail, &q_data.cmd_data.receive_data.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.receive_data.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.receive_data.device_id.dest = q_data.cmd_data.receive_data.device_id.src; - - tr->terminal_rsp_data.receive_data.result_type = resp; - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - case TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: - case TEL_SAT_RESULT_SUCCESS_WITH_MISSING_INFO: - //channel status - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - case TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.receive_data.me_problem_type = me_problem; - break; - - case TEL_SAT_RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: - tr->terminal_rsp_data.receive_data.bip_problem_type = bip_problem; - break; - - default: - break; - } - - tr->terminal_rsp_data.receive_data.channel_data_len = data_len; - tr->terminal_rsp_data.receive_data.channel_data.data_string_len = data_str_len; - - if (received_data) { - int index = 0; - guchar data; - GVariantIter *iter = NULL; - - dbg("additional data exist type_format(%s)", g_variant_get_type_string(received_data)); - - g_variant_get(received_data, "ay", &iter); - while ( g_variant_iter_loop (iter, "y", &data)) { - dbg("index(%d) data(%d)", index, data); - tr->terminal_rsp_data.receive_data.channel_data.data_string[index] = data; - index++; - } - g_variant_iter_free(iter); - - dbg("the last index data(%d), data_total_len(%d)", index, data_str_len); - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -static gboolean sat_manager_handle_send_data_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem, bip_problem; - gint data_len; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] send data data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(iiii)",&resp, &me_problem, &bip_problem, &data_len); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.send_data.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.send_data.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_data.command_detail, &q_data.cmd_data.send_data.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.send_data.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_data.device_id.dest = q_data.cmd_data.send_data.device_id.src; - - tr->terminal_rsp_data.send_data.result_type = resp; - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - case TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: - case TEL_SAT_RESULT_SUCCESS_WITH_MISSING_INFO: - //channel status - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - case TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.send_data.me_problem_type = me_problem; - break; - - case TEL_SAT_RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: - tr->terminal_rsp_data.send_data.bip_problem_type = bip_problem; - break; - - default: - break; - } - - tr->terminal_rsp_data.send_data.channel_data_len = data_len; - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -static gboolean sat_manager_handle_get_channel_status_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, me_problem, bip_problem; - gint channel_id, channel_status, channel_status_info; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] get channel status data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(iiiiii)",&resp, &me_problem, &bip_problem, - &channel_id, &channel_status, &channel_status_info); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.get_channel_status.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.get_channel_status.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.get_channel_status.command_detail, &q_data.cmd_data.get_channel_status.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.get_channel_status.device_id.src = q_data.cmd_data.get_channel_status.device_id.dest; - tr->terminal_rsp_data.get_channel_status.device_id.dest = q_data.cmd_data.get_channel_status.device_id.src; - - tr->terminal_rsp_data.get_channel_status.result_type = resp; - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - case TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: - case TEL_SAT_RESULT_SUCCESS_WITH_MISSING_INFO: - //channel status - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - case TEL_SAT_RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.get_channel_status.me_problem_type = me_problem; - break; - - case TEL_SAT_RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: - tr->terminal_rsp_data.get_channel_status.bip_problem_type = bip_problem; - break; - - default: - break; - } - - tr->terminal_rsp_data.get_channel_status.channel_status.channel_id = channel_id; - tr->terminal_rsp_data.get_channel_status.channel_status.status = channel_status; - tr->terminal_rsp_data.get_channel_status.channel_status.status_info = channel_status_info; - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -static gboolean sat_manager_handle_send_dtmf_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - g_free(tr); - return result; - } - - if (!exec_result) { - err("[SAT] get channel status data is null"); - g_free(tr); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - g_free(tr); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(i)",&resp); - - tr->cmd_number = q_data.cmd_data.send_dtmf.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.send_dtmf.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_dtmf.command_detail, &q_data.cmd_data.send_dtmf.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.send_dtmf.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_dtmf.device_id.dest = q_data.cmd_data.send_dtmf.device_id.src; - - tr->terminal_rsp_data.send_dtmf.result_type = resp; - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - if (q_data.cmd_data.send_dtmf.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.send_dtmf.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - break; - - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.send_dtmf.me_problem_type = TEL_SAT_ME_PROBLEM_NOT_IN_SPEECH_CALL; - break; - - default: - tr->terminal_rsp_data.send_dtmf.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.send_dtmf.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -static gboolean sat_manager_handle_launch_browser_result(TcorePlugin *plugin, gint command_id, GVariant *exec_result) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint resp, browser_problem; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!exec_result) { - err("[SAT] get channel status data is null"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "(ii)",&resp,&browser_problem); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.launch_browser.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.launch_browser.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.launch_browser.command_detail, &q_data.cmd_data.launch_browser.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.launch_browser.device_id.src = q_data.cmd_data.launch_browser.device_id.dest; - tr->terminal_rsp_data.launch_browser.device_id.dest = q_data.cmd_data.launch_browser.device_id.src; - - tr->terminal_rsp_data.launch_browser.result_type = resp; - switch (resp) { - case TEL_SAT_RESULT_SUCCESS_RETURN: - if (q_data.cmd_data.launch_browser.user_confirm_icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.launch_browser.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - tr->terminal_rsp_data.launch_browser.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.launch_browser.browser_problem_type = TEL_SAT_BROWSER_PROBLEM_NO_SPECIFIC_CAUSE; - break; - case TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND: - tr->terminal_rsp_data.launch_browser.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.launch_browser.browser_problem_type = TEL_SAT_BROWSER_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - case TEL_SAT_RESULT_LAUNCH_BROWSER_GENERIC_ERROR_CODE: - tr->terminal_rsp_data.launch_browser.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.launch_browser.browser_problem_type = browser_problem; - break; - default: - tr->terminal_rsp_data.launch_browser.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - tr->terminal_rsp_data.launch_browser.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.launch_browser.browser_problem_type = TEL_SAT_BROWSER_PROBLEM_NO_SPECIFIC_CAUSE; - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -gboolean sat_manager_handle_app_exec_result(TcorePlugin *plugin, gint command_id, gint command_type, GVariant *exec_result) -{ - gboolean result = FALSE; - GVariant *resp = NULL; - dbg("[SAT] app exec result command id(%d) command type(%d)", command_id, command_type); - dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); - g_variant_get(exec_result, "v", &resp); - - switch (command_type) { - case TEL_SAT_PROATV_CMD_SETUP_MENU: - result = _sat_manager_handle_setup_menu_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_DISPLAY_TEXT: - result = _sat_manager_handle_display_text_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_PLAY_TONE: - result = _sat_manager_handle_play_tone_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_SEND_SMS: - result = _sat_manager_handle_send_sms_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_SEND_SS: - result = _sat_manager_handle_send_ss_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_SEND_USSD: - result = _sat_manager_handle_send_ussd_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_SETUP_CALL: - result = _sat_manager_handle_setup_call_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: - result = _sat_manager_handle_setup_idle_mode_text_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_OPEN_CHANNEL: - result = sat_manager_handle_open_channel_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_CLOSE_CHANNEL: - result = sat_manager_handle_close_channel_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_RECEIVE_DATA: - result = sat_manager_handle_receive_data_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_SEND_DATA: - result = sat_manager_handle_send_data_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_GET_CHANNEL_STATUS: - result = sat_manager_handle_get_channel_status_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_SEND_DTMF: - result = sat_manager_handle_send_dtmf_result(plugin, command_id, resp); - break; - - case TEL_SAT_PROATV_CMD_LAUNCH_BROWSER: - result = sat_manager_handle_launch_browser_result(plugin, command_id, resp); - break; - - default: - err("[SAT] invalid command type(%d)", command_type); - break; - } - - sat_ui_support_terminate_sat_ui(); - - return result; -} - -static gboolean _sat_manager_handle_menu_select_confirm(TcorePlugin *plugin, gint command_id, gint confirm_type, GVariant *addtional_data) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - gint item_id=0; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - if (addtional_data) { - int index = 0; - guchar data; - GVariantIter *iter = NULL; - GVariant *inner_gv = NULL; - - inner_gv = g_variant_get_variant(addtional_data); - dbg("additional data exist type_format(%s)", g_variant_get_type_string(inner_gv)); - - g_variant_get(inner_gv, "ay", &iter); - while ( g_variant_iter_loop (iter, "y", &data)) { - dbg("index(%d) data(%d)", index, data); - item_id = data; - index++; - } - g_variant_iter_free(iter); - g_variant_unref(inner_gv); - } - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.selectItemInd.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.selectItemInd.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.select_item.command_detail, &q_data.cmd_data.selectItemInd.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.select_item.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.select_item.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - - switch (confirm_type) { - case TEL_SAT_USER_CONFIRM_YES: - tr->terminal_rsp_data.select_item.item_identifier = item_id; - tr->terminal_rsp_data.select_item.other_info = FALSE; - tr->terminal_rsp_data.select_item.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr->terminal_rsp_data.select_item.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - - if (q_data.cmd_data.selectItemInd.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.select_item.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - break; - - case TEL_SAT_USER_CONFIRM_HELP_INFO: - tr->terminal_rsp_data.select_item.item_identifier = item_id; - tr->terminal_rsp_data.select_item.other_info = FALSE; - tr->terminal_rsp_data.select_item.result_type = TEL_SAT_RESULT_HELP_INFO_REQUIRED_BY_USER; - tr->terminal_rsp_data.select_item.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - //TODO ctx->help_requested = TRUE; - break; - - case TEL_SAT_USER_CONFIRM_END: - tr->terminal_rsp_data.select_item.result_type = TEL_SAT_RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; - break; - - case TEL_SAT_USER_CONFIRM_NO_OR_CANCEL: - tr->terminal_rsp_data.select_item.result_type = TEL_SAT_RESULT_BACKWARD_MOVE_BY_USER; - break; - - case TEL_SAT_USER_CONFIRM_TIMEOUT: - tr->terminal_rsp_data.select_item.result_type = TEL_SAT_RESULT_NO_RESPONSE_FROM_USER; - break; - - default: - err("not handled value[%d] here", confirm_type); - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - - return result; -} - -static gboolean _sat_manager_handle_display_text_confirm(TcorePlugin *plugin, gint command_id, gint confirm_type, GVariant *addtional_data) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.displayTextInd.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.displayTextInd.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.display_text.command_detail, &q_data.cmd_data.displayTextInd.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.display_text.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.display_text.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - - switch (confirm_type) { - case TEL_SAT_USER_CONFIRM_YES: { - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr->terminal_rsp_data.display_text.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - - if (q_data.cmd_data.displayTextInd.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - } break; - - case TEL_SAT_USER_CONFIRM_NO_OR_CANCEL: - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_BACKWARD_MOVE_BY_USER; - break; - - case TEL_SAT_USER_CONFIRM_TIMEOUT: - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - - if (q_data.cmd_data.displayTextInd.command_detail.cmd_qualifier.display_text.text_clear_type == TEL_SAT_TEXT_WAIT_FOR_USER_TO_CLEAR_MSG ) - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_NO_RESPONSE_FROM_USER; - - break; - - case TEL_SAT_USER_CONFIRM_END: - tr->terminal_rsp_data.display_text.result_type = TEL_SAT_RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; - break; - - case TEL_SAT_USER_CONFIRM_HELP_INFO: - default: - err("not handled value[%d] here", confirm_type); - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - - return result; -} - -static gboolean _sat_manager_handle_get_inkey_confirm(TcorePlugin *plugin, gint command_id, gint confirm_type, GVariant *addtional_data) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - guint inkey_data_len = 0; - guchar inkey_data[TEL_SAT_TEXT_STRING_LEN_MAX]; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - memset(inkey_data, 0, TEL_SAT_TEXT_STRING_LEN_MAX); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - if (addtional_data) { - int index = 0; - guchar data; - GVariantIter *iter = NULL; - GVariant *inner_gv = NULL; - - inner_gv = g_variant_get_variant(addtional_data); - dbg("additional data exist type_format(%s)", g_variant_get_type_string(inner_gv)); - - g_variant_get(inner_gv, "ay", &iter); - while ( g_variant_iter_loop (iter, "y", &data)) { - dbg("index(%d) data(%d)", index, data); - inkey_data[index] = data; - index++; - } - g_variant_iter_free(iter); - g_variant_unref(inner_gv); - inkey_data_len = index; - } - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.getInkeyInd.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.getInkeyInd.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.get_inkey.command_detail, &q_data.cmd_data.getInkeyInd.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.get_inkey.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.get_inkey.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - - switch (confirm_type) { - case TEL_SAT_USER_CONFIRM_YES: - tr->terminal_rsp_data.get_inkey.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - - if (q_data.cmd_data.getInkeyInd.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.get_inkey.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - if (q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.inkey_type == TEL_SAT_INKEY_TYPE_YES_NO_REQUESTED) { - tr->terminal_rsp_data.get_inkey.text.dcs.m_class = TEL_SAT_MSG_CLASS_RESERVED; - tr->terminal_rsp_data.get_inkey.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_8BIT_DATA; - tr->terminal_rsp_data.get_inkey.text.string_length = 1; - tr->terminal_rsp_data.get_inkey.text.string[0] = 0x01; - } - else if (inkey_data_len > 0) { - tr->terminal_rsp_data.get_inkey.text.string_length = inkey_data_len; - - if (!q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.alphabet_set) { - tr->terminal_rsp_data.get_inkey.text.is_digit_only = TRUE; - tr->terminal_rsp_data.get_inkey.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_8BIT_DATA; - tr->terminal_rsp_data.get_inkey.text.dcs.m_class = TEL_SAT_MSG_CLASS_RESERVED; - - memcpy((void*)tr->terminal_rsp_data.get_inkey.text.string, inkey_data, inkey_data_len); - } - else { - tr->terminal_rsp_data.get_inkey.text.dcs.m_class = TEL_SAT_MSG_CLASS_RESERVED; - - if (q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.alphabet_type == TEL_SAT_INPUT_ALPHABET_TYPE_SMS_DEFAULT ) { - guint tmp_len; - guchar tmp_str[TEL_SAT_TEXT_STRING_LEN_MAX + 1], *packed_data; - - dbg("sat gsm7 encoding"); - tcore_util_convert_utf8_to_gsm(tmp_str, &tmp_len, inkey_data, inkey_data_len); - - packed_data = tcore_util_pack_gsm7bit((const guchar *)tmp_str, tmp_len); - if (packed_data) { - tr->terminal_rsp_data.get_inkey.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_8BIT_DATA; - tr->terminal_rsp_data.get_inkey.text.string_length = strlen((const gchar *)packed_data); - memcpy((void*) tr->terminal_rsp_data.get_inkey.text.string, - packed_data, strlen((const gchar *)packed_data)); - - g_free(packed_data); - } - } - else if (q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.alphabet_type == TEL_SAT_INPUT_ALPHABET_TYPE_UCS2 ) { - dbg("UCS2 DATA"); - - tr->terminal_rsp_data.get_inkey.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_UCS2; - tcore_util_convert_utf8_to_ucs2((guchar*)tr->terminal_rsp_data.get_inkey.text.string, - (guint *)&tr->terminal_rsp_data.get_inkey.text.string_length, - (guchar*)inkey_data, inkey_data_len); - } - else { - tr->terminal_rsp_data.get_inkey.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_RESERVED; - dbg("[SAT] invalid DCS[%d]",tr->terminal_rsp_data.get_inkey.text.dcs.a_format); - } - } - } - break; - - case TEL_SAT_USER_CONFIRM_HELP_INFO: - tr->terminal_rsp_data.get_inkey.result_type = TEL_SAT_RESULT_HELP_INFO_REQUIRED_BY_USER; - //TODO ctx->help_requested = TRUE; - break; - - case TEL_SAT_USER_CONFIRM_NO_OR_CANCEL: - tr->terminal_rsp_data.get_inkey.result_type = TEL_SAT_RESULT_BACKWARD_MOVE_BY_USER; - - if (q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.inkey_type == TEL_SAT_INKEY_TYPE_YES_NO_REQUESTED) { - tr->terminal_rsp_data.get_inkey.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr->terminal_rsp_data.get_inkey.text.dcs.m_class = TEL_SAT_MSG_CLASS_RESERVED; - tr->terminal_rsp_data.get_inkey.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_8BIT_DATA; - tr->terminal_rsp_data.get_inkey.text.string_length = 1; - tr->terminal_rsp_data.get_inkey.text.string[0] = 0x00; - } - break; - - case TEL_SAT_USER_CONFIRM_TIMEOUT: - tr->terminal_rsp_data.get_inkey.result_type = TEL_SAT_RESULT_NO_RESPONSE_FROM_USER; - break; - - case TEL_SAT_USER_CONFIRM_END: - tr->terminal_rsp_data.get_inkey.result_type = TEL_SAT_RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; - break; - - default: - err("not handled value[%d] here", confirm_type); - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - - return result; -} - -static gboolean _sat_manager_handle_get_input_confirm(TcorePlugin *plugin, gint command_id, gint confirm_type, GVariant *addtional_data) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - guint input_data_len = 0; - guchar input_data[TEL_SAT_TEXT_STRING_LEN_MAX]; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - memset(input_data, 0, TEL_SAT_TEXT_STRING_LEN_MAX); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - if (addtional_data) { - int index = 0; - guchar data; - GVariantIter *iter = NULL; - GVariant *inner_gv = NULL; - - inner_gv = g_variant_get_variant(addtional_data); - dbg("additional data exist type_format(%s)", g_variant_get_type_string(inner_gv)); - - g_variant_get(inner_gv, "ay", &iter); - while ( g_variant_iter_loop (iter, "y", &data)) { - dbg("index(%d) data(%d)", index, data); - input_data[index] = data; - index++; - } - g_variant_iter_free(iter); - g_variant_unref(inner_gv); - input_data_len = index; - } - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.getInputInd.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.getInputInd.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.get_input.command_detail, &q_data.cmd_data.getInputInd.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.get_input.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.get_input.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - - switch (confirm_type) { - case TEL_SAT_USER_CONFIRM_YES: - tr->terminal_rsp_data.get_input.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr->terminal_rsp_data.get_input.text.dcs.m_class = TEL_SAT_MSG_CLASS_RESERVED; - - if (!q_data.cmd_data.getInputInd.command_detail.cmd_qualifier.get_input.alphabet_set) { - tr->terminal_rsp_data.get_input.text.is_digit_only = TRUE; - } - - if (q_data.cmd_data.getInputInd.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.get_input.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - if (!q_data.cmd_data.getInputInd.command_detail.cmd_qualifier.get_input.user_input_unpacked_format) { - dbg("[SAT] packing to SMS7 default"); - - tr->terminal_rsp_data.get_input.text.string_length = 0; - tr->terminal_rsp_data.get_input.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_SMS_DEFAULT; - - if (input_data_len > 0) { - guint tmp_len; - guchar tmp_str[TEL_SAT_TEXT_STRING_LEN_MAX + 1], *packed_data; - - dbg("sat gsm7 encoding"); - tcore_util_convert_utf8_to_gsm(tmp_str, &tmp_len, input_data, input_data_len); - - packed_data = tcore_util_pack_gsm7bit((const guchar *)tmp_str, tmp_len); - if (packed_data) { - memcpy((void*)tr->terminal_rsp_data.get_input.text.string, packed_data, strlen((const gchar *)packed_data)); - tr->terminal_rsp_data.get_input.text.string_length = strlen((const gchar *)packed_data); - - g_free(packed_data); - } - } - - } - else { - dbg("[SAT] packing not required"); - - if (q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_input.alphabet_type == TEL_SAT_INPUT_ALPHABET_TYPE_SMS_DEFAULT) { - tr->terminal_rsp_data.get_input.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_8BIT_DATA; - tcore_util_convert_utf8_to_gsm((guchar*)tr->terminal_rsp_data.get_input.text.string, - (guint *)&tr->terminal_rsp_data.get_input.text.string_length, - (guchar *)input_data, input_data_len); - - } - else if (q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_input.alphabet_type == TEL_SAT_INPUT_ALPHABET_TYPE_UCS2 ) { - tr->terminal_rsp_data.get_input.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_UCS2; - tcore_util_convert_utf8_to_ucs2((guchar*)tr->terminal_rsp_data.get_input.text.string, - (guint *)&tr->terminal_rsp_data.get_input.text.string_length, - (guchar*)input_data, input_data_len); - - } - else{ - tr->terminal_rsp_data.get_input.text.dcs.a_format = TEL_SAT_ALPHABET_FORMAT_RESERVED; - dbg("[SAT] invalid DCS[%d]",tr->terminal_rsp_data.get_input.text.dcs.a_format); - } - } - break; - - case TEL_SAT_USER_CONFIRM_HELP_INFO: - tr->terminal_rsp_data.get_input.result_type = TEL_SAT_RESULT_HELP_INFO_REQUIRED_BY_USER; - //TODO ctx->help_requested = TRUE; - break; - - case TEL_SAT_USER_CONFIRM_NO_OR_CANCEL: - tr->terminal_rsp_data.get_input.result_type = TEL_SAT_RESULT_BACKWARD_MOVE_BY_USER; - break; - - case TEL_SAT_USER_CONFIRM_TIMEOUT: - tr->terminal_rsp_data.get_input.result_type = TEL_SAT_RESULT_NO_RESPONSE_FROM_USER; - break; - - case TEL_SAT_USER_CONFIRM_END: - tr->terminal_rsp_data.get_input.result_type = TEL_SAT_RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; - break; - - default: - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - - return result; -} - -static gboolean _sat_manager_handle_setup_call_confirm(TcorePlugin *plugin, TcorePlugin *comm_plugin, gint command_id, gint confirm_type, GVariant *addtional_data) -{ - TelReturn rv = TEL_RETURN_FAILURE; - DtapiSatPrivateData *sat_data = NULL; - gboolean result = FALSE; - gint input_data_len = 0; - gchar input_data[TEL_SAT_TEXT_STRING_LEN_MAX]; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - memset(input_data, 0, TEL_SAT_TEXT_STRING_LEN_MAX); - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - err("sat_data is null"); - return result; - } - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - if (addtional_data) { - int index = 0; - guchar data; - GVariantIter *iter = NULL; - GVariant *inner_gv = NULL; - - inner_gv = g_variant_get_variant(addtional_data); - dbg("additional data exist type_format(%s)", g_variant_get_type_string(inner_gv)); - - g_variant_get(inner_gv, "ay", &iter); - while ( g_variant_iter_loop (iter, "y", &data)) { - dbg("index(%d) data(%d)", index, data); - input_data[index] = data; - index++; - } - g_variant_iter_free(iter); - g_variant_unref(inner_gv); - input_data_len = index; - } - - tr = g_new0(TelSatRequestTerminalResponseData, 1); - tr->cmd_number = q_data.cmd_data.setup_call.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.setup_call.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.setup_call.command_detail, &q_data.cmd_data.setup_call.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_call.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.setup_call.device_id.dest = q_data.cmd_data.setup_call.device_id.src; - - switch (confirm_type) { - case TEL_SAT_USER_CONFIRM_YES:{ - char *path; - TelephonySat *sat; - TelephonyObjectSkeleton *object; - gchar *plg_name = NULL; - GVariant *setup_call = NULL; - gint command_id, call_type, confirmed_text_len, text_len, duration; - gchar *confirmed_text, *text, *call_number; - GVariant *icon_id; - - plg_name = (gchar *)tcore_server_get_cp_name_by_plugin(plugin); - if (plg_name) { - path = g_strdup_printf("%s/%s", TELEPHONY_OBJECT_PATH, plg_name); - } - else { - path = g_strdup_printf("%s", TELEPHONY_OBJECT_PATH); - } - dbg("path = [%s]", path); - - object = g_hash_table_lookup(sat_data->objects, path); - sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); - - setup_call = sat_manager_setup_call_noti(plugin, &q_data.cmd_data.setup_call); - - dbg("setup call type_format(%s)", g_variant_get_type_string(setup_call)); - g_variant_get(setup_call, "(isisi@visi)", &command_id, &confirmed_text, &confirmed_text_len, &text, &text_len, &icon_id, &call_type, &call_number, &duration); - - telephony_sat_emit_setup_call(sat, command_id, confirmed_text, confirmed_text_len, text, text_len, call_type, - call_number, duration); - - sat_ui_support_launch_call_application(q_data.cmd_data.setup_call.command_detail.cmd_type, setup_call); - g_free(tr); - return TRUE; - }break; - - case TEL_SAT_USER_CONFIRM_NO_OR_CANCEL:{ - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_USER_DID_NOT_ACCEPT_CALL_SETUP_REQ; - tr->terminal_rsp_data.setup_call.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.setup_call.cc_problem_type = TEL_SAT_CC_PROBLEM_NO_SPECIFIC_CAUSE; - }break; - - case TEL_SAT_USER_CONFIRM_END:{ - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; - }break; - - case TEL_SAT_USER_CONFIRM_HELP_INFO: - default: - tr->terminal_rsp_data.setup_call.result_type = TEL_SAT_RESULT_NO_RESPONSE_FROM_USER; - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - g_free(tr); - return result; -} - -static gboolean _sat_manager_handle_send_dtmf_confirm(TcorePlugin *plugin, gint command_id, gint confirm_type, GVariant *addtional_data) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - tr = g_new0(TelSatRequestTerminalResponseData, 1); - tr->cmd_number = q_data.cmd_data.send_dtmf.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.send_dtmf.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_dtmf.command_detail, &q_data.cmd_data.send_dtmf.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.send_dtmf.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_dtmf.device_id.dest = q_data.cmd_data.send_dtmf.device_id.src; - - dbg("confirm_type[%d]", confirm_type); - - switch (confirm_type) { - case TEL_SAT_USER_CONFIRM_NO_OR_CANCEL: - case TEL_SAT_USER_CONFIRM_END: - tr->terminal_rsp_data.send_dtmf.result_type = TEL_SAT_RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; - tr->terminal_rsp_data.send_dtmf.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - break; - default: - tr->terminal_rsp_data.send_dtmf.result_type = TEL_SAT_RESULT_NO_RESPONSE_FROM_USER; - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - g_free(tr); - - return result; -} - -static gboolean _sat_manager_handle_launch_browser_confirm(TcorePlugin *plugin, TcorePlugin *comm_plugin, gint command_id, gint confirm_type, GVariant *addtional_data) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.launch_browser.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.launch_browser.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.launch_browser.command_detail, &q_data.cmd_data.launch_browser.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.launch_browser.device_id.src = q_data.cmd_data.launch_browser.device_id.dest; - tr->terminal_rsp_data.launch_browser.device_id.dest = q_data.cmd_data.launch_browser.device_id.src; - - dbg("confirm_type[%d]", confirm_type); - - switch (confirm_type) { - case TEL_SAT_USER_CONFIRM_YES:{ - char *path; - TelephonySat *sat; - TelephonyObjectSkeleton *object; - gchar *plg_name = NULL; - GVariant *launch_browser = NULL; - gint command_id = 0; - gint browser_launch_type = 0, browser_id = 0; - gint url_len = 0, text_len = 0, gateway_proxy_len =0; - gchar *url = NULL; - gchar *text = NULL; - gchar *gateway_proxy = NULL; - GVariant *icon_id = NULL; - DtapiSatPrivateData *sat_data = NULL; - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - err("sat_data is null"); - g_free(tr); - return result; - } - - plg_name = (gchar *)tcore_server_get_cp_name_by_plugin(plugin); - if (plg_name) { - path = g_strdup_printf("%s/%s", TELEPHONY_OBJECT_PATH, plg_name); - } else { - path = g_strdup_printf("%s", TELEPHONY_OBJECT_PATH); - } - dbg("path = [%s]", path); - - object = g_hash_table_lookup(sat_data->objects, path); - sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); - - launch_browser = sat_manager_launch_browser_noti(plugin, &q_data.cmd_data.launch_browser); - - dbg("launch_browser type_format(%s)", g_variant_get_type_string(launch_browser)); - g_variant_get(launch_browser, "(iiisisisi@v)", &command_id, &browser_launch_type, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len, &icon_id); - - telephony_sat_emit_launch_browser(sat, command_id, browser_launch_type, browser_id, url, url_len, gateway_proxy, gateway_proxy_len, text, text_len); - - sat_ui_support_launch_browser_application(q_data.cmd_data.launch_browser.command_detail.cmd_type, launch_browser); - - g_free(path); - g_free(tr); - - return TRUE; - }break; - - case TEL_SAT_USER_CONFIRM_NO_OR_CANCEL: - case TEL_SAT_USER_CONFIRM_END: - tr->terminal_rsp_data.launch_browser.result_type = TEL_SAT_RESULT_BACKWARD_MOVE_BY_USER; - tr->terminal_rsp_data.launch_browser.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - tr->terminal_rsp_data.launch_browser.browser_problem_type = TEL_SAT_BROWSER_PROBLEM_NO_SPECIFIC_CAUSE; - break; - - default: - tr->terminal_rsp_data.launch_browser.result_type = TEL_SAT_RESULT_NO_RESPONSE_FROM_USER; - break; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - g_free(tr); - - return result; -} - -static gboolean _sat_manager_handle_open_channel_confirm(TcorePlugin *plugin, TcorePlugin *comm_plugin, gint command_id, gint confirm_type, GVariant *addtional_data) -{ - TelReturn rv = TEL_RETURN_FAILURE; - DtapiSatPrivateData *sat_data = NULL; - gboolean result = FALSE; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - err("sat_data is null"); - return result; - } - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - tr->cmd_number = q_data.cmd_data.open_channel.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.open_channel.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.open_channel.command_detail, &q_data.cmd_data.open_channel.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.open_channel.device_id.src = q_data.cmd_data.send_dtmf.device_id.dest; - tr->terminal_rsp_data.open_channel.device_id.dest = q_data.cmd_data.send_dtmf.device_id.src; - - dbg("confirm_type[%d]", confirm_type); - - switch (confirm_type) { - case TEL_SAT_USER_CONFIRM_YES:{ - char *path; - TelephonyObjectSkeleton *object; - - gchar *plg_name = NULL; - - GVariant *open_channel = NULL; - - gint command_id, bearer_type, protocol_type, dest_addr_type; - gboolean immediate_link, auto_reconnection, bg_mode; - gint text_len, buffer_size, port_number; - gchar *text, *dest_address; - GVariant *icon_id; - GVariant *bearer_param; - GVariant *bearer_detail; - - //emit send_dtmf signal - plg_name = (gchar *)tcore_server_get_cp_name_by_plugin(plugin); - if (plg_name) { - path = g_strdup_printf("%s/%s", TELEPHONY_OBJECT_PATH, plg_name); - } else { - path = g_strdup_printf("%s", TELEPHONY_OBJECT_PATH); - } - dbg("path = [%s]", path); - - object = g_hash_table_lookup(sat_data->objects, path); - - open_channel = sat_manager_open_channel_noti(plugin, &q_data.cmd_data.open_channel); - - dbg("open channel type_format(%s)", g_variant_get_type_string(open_channel)); - g_variant_get(open_channel,"(isi@vbbbi@viiiis@v)", &command_id, &text, &text_len, &icon_id, &immediate_link, &auto_reconnection, &bg_mode, - &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); - - /*telephony_sat_emit_open_channel(sat, command_id, text, text_len, immediate_link, auto_reconnection, bg_mode, - bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail);*/ - - //BIP Manager - { - gboolean is_sig = FALSE; - GDBusConnection *conn = NULL; - const gchar *g_path = NULL; - - conn = g_dbus_object_manager_server_get_connection(sat_data->manager); - g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); - - is_sig = sat_ui_support_exec_bip(conn, g_path, TEL_SAT_PROATV_CMD_OPEN_CHANNEL, open_channel); - } - - g_free(path); - g_free(tr); - - return TRUE; - }break; - - case TEL_SAT_USER_CONFIRM_NO_OR_CANCEL: - case TEL_SAT_USER_CONFIRM_END: - tr->terminal_rsp_data.open_channel.result_type = TEL_SAT_RESULT_USER_DID_NOT_ACCEPT_CALL_SETUP_REQ; - break; - default: - tr->terminal_rsp_data.open_channel.result_type = TEL_SAT_RESULT_NO_RESPONSE_FROM_USER; - break; - } - - memcpy((void*)&tr->terminal_rsp_data.open_channel.bearer_desc, &q_data.cmd_data.open_channel.bearer_desc, sizeof(TelSatBearerDescriptionInfo)); - memcpy((void*)&tr->terminal_rsp_data.open_channel.buffer_size, &q_data.cmd_data.open_channel.buffer_size, (2*sizeof(guchar))); - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - g_free(tr); - - return result; -} - -gboolean sat_manager_handle_user_confirm(DtapiSatPluginsInfo *plugins_info, GVariant *user_confirm_data) -{ - gboolean rv = FALSE; - gboolean result = FALSE; - SatManagerQueueData q_data; - TcorePlugin *plugin = NULL; - TcorePlugin *comm_plugin = NULL; - - gint command_id, command_type, confirm_type; - GVariant *additional_data = NULL; - - dbg("user_confirm_data type_format(%s)", g_variant_get_type_string(user_confirm_data)); - g_variant_get(user_confirm_data, "(iiv)", &command_id, &confirm_type, &additional_data); - - dbg("[SAT] user confirm data command id(%d), confirm_type(%d)", command_id, confirm_type); - - rv = sat_manager_queue_peek_data_by_id(&q_data, command_id); - if (!rv) { - err("[SAT] no commands in queue"); - return result; - } - - command_type = (gint)q_data.cmd_type; - dbg("[SAT] command type(%d)", command_type); - - plugin = plugins_info->plugin; - comm_plugin = plugins_info->comm_plugin; - - switch (command_type) { - case TEL_SAT_PROATV_CMD_SELECT_ITEM: - result = _sat_manager_handle_menu_select_confirm(plugin, command_id, confirm_type, additional_data); - break; - case TEL_SAT_PROATV_CMD_DISPLAY_TEXT: - result = _sat_manager_handle_display_text_confirm(plugin, command_id, confirm_type, additional_data); - break; - case TEL_SAT_PROATV_CMD_GET_INKEY: - result = _sat_manager_handle_get_inkey_confirm(plugin, command_id, confirm_type, additional_data); - break; - case TEL_SAT_PROATV_CMD_GET_INPUT: - result = _sat_manager_handle_get_input_confirm(plugin, command_id, confirm_type, additional_data); - break; - case TEL_SAT_PROATV_CMD_SETUP_CALL: - result = _sat_manager_handle_setup_call_confirm(plugin, comm_plugin,command_id, confirm_type, additional_data); - break; - case TEL_SAT_PROATV_CMD_SEND_DTMF: - result = _sat_manager_handle_send_dtmf_confirm(plugin, command_id, confirm_type, additional_data); - break; - case TEL_SAT_PROATV_CMD_LAUNCH_BROWSER: - result = _sat_manager_handle_launch_browser_confirm(plugin, comm_plugin, command_id, confirm_type, additional_data); - break; - case TEL_SAT_PROATV_CMD_OPEN_CHANNEL: - result = _sat_manager_handle_open_channel_confirm(plugin, comm_plugin, command_id, confirm_type, additional_data); - break; - default: - err("[SAT] cannot handle user confirm command(0x%x)", command_type); - break; - } - - return result; -} - -static gboolean _sat_manager_handle_play_tone_ui_display_status(TelephonySat *sat, TcorePlugin *plugin, SatManagerQueueData *q_data, gboolean display_status) -{ - GVariant *play_tone = NULL; - gint command_id, tone_type, duration; - gint text_len; - gchar* text; - GVariant *icon_id; - - if (!display_status) { - TelSatRequestTerminalResponseData *tr = NULL; - err("[SAT] fail to show ui display for play tone"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - - tr->cmd_number = q_data->cmd_data.play_tone.command_detail.cmd_num; - tr->cmd_type = q_data->cmd_data.play_tone.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.play_tone.command_detail, &q_data->cmd_data.play_tone.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.play_tone.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.play_tone.device_id.dest = q_data->cmd_data.play_tone.device_id.src; - tr->terminal_rsp_data.play_tone.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return TRUE; - } - - //emit play tone signal - play_tone = sat_manager_play_tone_noti(plugin, &q_data->cmd_data.play_tone); - - dbg("play tone type_format(%s)", g_variant_get_type_string(play_tone)); - g_variant_get(play_tone, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &tone_type, &duration); - - telephony_sat_emit_play_tone(sat, command_id, text, text_len, tone_type, duration); - return TRUE; -} - -static gboolean _sat_manager_handle_send_sms_ui_display_status(TelephonySat *sat, TcorePlugin *plugin,SatManagerQueueData *q_data, gboolean display_status) -{ - GVariant *send_sms = NULL; - gint command_id, ton, npi, tpdu_type; - gboolean is_packing_required; - gint text_len, number_len, tpdu_data_len; - gchar* text, *dialling_number; - GVariant *tpdu_data, *icon_id; - - if (!display_status) { - TelSatRequestTerminalResponseData *tr = NULL; - err("[SAT] fail to show ui display for send sms"); - - tr = g_new0(TelSatRequestTerminalResponseData, 1); - - tr->cmd_number = q_data->cmd_data.sendSMSInd.command_detail.cmd_num; - tr->cmd_type = q_data->cmd_data.sendSMSInd.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_sms.command_detail, &q_data->cmd_data.sendSMSInd.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.send_sms.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_sms.device_id.dest = q_data->cmd_data.sendSMSInd.device_id.src; - tr->terminal_rsp_data.send_sms.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - return TRUE; - } - - //emit send sms signal - send_sms = sat_manager_send_sms_noti(plugin, &q_data->cmd_data.sendSMSInd); - - dbg("send sms type_format(%s)", g_variant_get_type_string(send_sms)); - g_variant_get(send_sms, "(isi@vbiisii@vi)", &command_id, &text, &text_len, &icon_id, &is_packing_required, &ton, &npi, - &dialling_number, &number_len, &tpdu_type, &tpdu_data, &tpdu_data_len); - - telephony_sat_emit_send_sms(sat, command_id, text, text_len, is_packing_required, - ton, npi, dialling_number, number_len, tpdu_type, tpdu_data, tpdu_data_len); - - return TRUE; -} - -static gboolean _sat_manager_handle_send_ss_ui_display_status(TelephonySat *sat, TcorePlugin *plugin,SatManagerQueueData *q_data, gboolean display_status) -{ - GVariant *send_ss = NULL; - gint command_id, ton, npi; - gint text_len, ss_str_len; - gchar* text, *ss_string; - GVariant *icon_id; - - if (!display_status) { - TelSatRequestTerminalResponseData *tr = NULL; - err("[SAT] fail to show ui display for send ss"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - - tr->cmd_number = q_data->cmd_data.send_ss.command_detail.cmd_num; - tr->cmd_type = q_data->cmd_data.send_ss.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_ss.command_detail, &q_data->cmd_data.send_ss.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.send_ss.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_ss.device_id.dest = q_data->cmd_data.send_ss.device_id.src; - tr->terminal_rsp_data.send_ss.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return TRUE; - } - - //emit send ss signal - send_ss = sat_manager_send_ss_noti(plugin, &q_data->cmd_data.send_ss); - - dbg("send ss type_format(%s)", g_variant_get_type_string(send_ss)); - g_variant_get(send_ss, "(isi@viiis)", &command_id, &text, &text_len, &icon_id, - &ton, &npi, &ss_str_len, &ss_string); - - telephony_sat_emit_send_ss(sat, command_id, text, text_len, ton, npi, ss_string); - sat_ui_support_launch_ciss_application(TEL_SAT_PROATV_CMD_SEND_SS, send_ss); - - return TRUE; -} - -static gboolean _sat_manager_handle_send_ussd_ui_display_status(TelephonySat *sat, TcorePlugin *plugin,SatManagerQueueData *q_data, gboolean display_status) -{ - GVariant *send_ussd = NULL; - gint command_id; - gint text_len, ussd_str_len; - gchar* text, *ussd_string; - GVariant *icon_id; - - if (!display_status) { - TelSatRequestTerminalResponseData *tr = NULL; - err("[SAT] fail to show ui display for send ussd"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - - tr->cmd_number = q_data->cmd_data.send_ussd.command_detail.cmd_num; - tr->cmd_type = q_data->cmd_data.send_ussd.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_ussd.command_detail, &q_data->cmd_data.send_ussd.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.send_ussd.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_ussd.device_id.dest = q_data->cmd_data.send_ussd.device_id.src; - tr->terminal_rsp_data.send_ussd.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return TRUE; - } - - /* emit send ussd signal */ - send_ussd = sat_manager_send_ussd_noti(plugin, &q_data->cmd_data.send_ussd); - - dbg("send ussd type_format(%s)", g_variant_get_type_string(send_ussd)); - g_variant_get(send_ussd, "(isi@vis)", &command_id, &text, &text_len, &icon_id, &ussd_str_len, &ussd_string); - - telephony_sat_emit_setup_ussd(sat, command_id, text, text_len, ussd_string); - sat_ui_support_launch_ciss_application(TEL_SAT_PROATV_CMD_SEND_USSD, send_ussd); - - return TRUE; -} - -static gboolean _sat_manager_handle_setup_idle_mode_text_ui_display_status(TcorePlugin *plugin,SatManagerQueueData *q_data, gboolean display_status) -{ - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - TelSatRequestTerminalResponseData *tr; - - if (!plugin) { - err("there is no valid plugin at this point"); - return result; - } - - tr = g_new0(TelSatRequestTerminalResponseData, 1); - tr->cmd_number = q_data->cmd_data.idle_mode.command_detail.cmd_num; - tr->cmd_type = q_data->cmd_data.idle_mode.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.setup_idle_mode_text.command_detail, &q_data->cmd_data.idle_mode.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.setup_idle_mode_text.device_id.src = q_data->cmd_data.idle_mode.device_id.dest; - tr->terminal_rsp_data.setup_idle_mode_text.device_id.dest = q_data->cmd_data.idle_mode.device_id.src; - - tr->terminal_rsp_data.setup_idle_mode_text.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - if (q_data->cmd_data.idle_mode.icon_id.icon_info.ics == TEL_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR) - tr->terminal_rsp_data.setup_idle_mode_text.result_type = TEL_SAT_RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; - - //fail to display text - if (!display_status) { - err("[SAT] fail to show ui display for setup_idle_mode_text"); - tr->terminal_rsp_data.setup_idle_mode_text.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - g_free(tr); - - sat_ui_support_terminate_sat_ui(); - - return result; -} - -static gboolean _sat_manager_handle_refresh_ui_display_status(TcorePlugin *plugin,SatManagerQueueData *q_data, gboolean display_status) -{ - TelSatRequestTerminalResponseData tr; - - memset(&tr, 0, sizeof(TelSatRequestTerminalResponseData)); - - tr.cmd_number = q_data->cmd_data.refresh.command_detail.cmd_num; - tr.cmd_type = q_data->cmd_data.refresh.command_detail.cmd_type; - memcpy((void*)&tr.terminal_rsp_data.refresh.command_detail, &q_data->cmd_data.refresh.command_detail, sizeof(TelSatCmdDetailInfo)); - tr.terminal_rsp_data.refresh.device_id.src = q_data->cmd_data.refresh.device_id.dest; - tr.terminal_rsp_data.refresh.device_id.dest = q_data->cmd_data.refresh.device_id.src; - - if (!display_status) { - err("fail to show ui for refresh"); - tr.terminal_rsp_data.refresh.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } - else{ - dbg("success to show ui for refresh"); - tr.terminal_rsp_data.more_time.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - tr.terminal_rsp_data.more_time.me_problem_type = TEL_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE; - } - - dbg("send refresh tr"); - sat_manager_send_terminal_response(plugin, &tr); - return TRUE; -} - -static gboolean _sat_manager_handle_send_dtmf_ui_display_status(TelephonySat *sat, TcorePlugin *plugin,SatManagerQueueData *q_data, gboolean display_status) -{ - GVariant *send_dtmf = NULL; - gint command_id = 0; - gint text_len = 0, dtmf_str_len = 0; - gchar *text = NULL; - gchar *dtmf_str = NULL; - GVariant *icon_id = NULL; - - if (!display_status) { - TelSatRequestTerminalResponseData *tr = NULL; - err("[SAT] fail to show ui display for send_dtmf"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - - tr->cmd_number = q_data->cmd_data.send_dtmf.command_detail.cmd_num; - tr->cmd_type = q_data->cmd_data.send_dtmf.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.send_dtmf.command_detail, &q_data->cmd_data.send_dtmf.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.send_dtmf.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.send_dtmf.device_id.dest = q_data->cmd_data.send_dtmf.device_id.src; - tr->terminal_rsp_data.send_dtmf.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return TRUE; - } - - //emit send_dtmf signal - send_dtmf = sat_manager_send_dtmf_noti(plugin, &q_data->cmd_data.send_dtmf); - - dbg("send_dtmf type_format(%s)", g_variant_get_type_string(send_dtmf)); - g_variant_get(send_dtmf, "(isi@vis)", &command_id, &text, &text_len, &icon_id, &dtmf_str_len, &dtmf_str); - - telephony_sat_emit_send_dtmf(sat, command_id, text, text_len, dtmf_str, dtmf_str_len); - - return TRUE; -} - -static gboolean _sat_manager_handle_open_channel_ui_display_status(TcorePlugin *plugin, TcorePlugin *comm_plugin, SatManagerQueueData *q_data, gboolean display_status) -{ - char *path; - TelephonyObjectSkeleton *object; - gchar *plg_name = NULL; - GVariant *open_channel = NULL; - gint command_id, bearer_type, protocol_type, dest_addr_type; - gboolean immediate_link, auto_reconnection, bg_mode; - gint text_len, buffer_size, port_number; - gchar *text, *dest_address; - GVariant *icon_id; - GVariant *bearer_param; - GVariant *bearer_detail; - DtapiSatPrivateData *sat_data = NULL; - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - err("sat_data is null"); - return FALSE; - } - - if (!display_status) { - TelSatRequestTerminalResponseData *tr = NULL; - err("[SAT] fail to show ui display for open channel"); - - tr = (TelSatRequestTerminalResponseData *)calloc(1, sizeof(TelSatRequestTerminalResponseData)); - - tr->cmd_number = q_data->cmd_data.open_channel.command_detail.cmd_num; - tr->cmd_type = q_data->cmd_data.open_channel.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.open_channel.command_detail, &q_data->cmd_data.open_channel.command_detail, sizeof(TelSatCmdDetailInfo)); - - tr->terminal_rsp_data.open_channel.device_id.src = q_data->cmd_data.send_dtmf.device_id.dest; - tr->terminal_rsp_data.open_channel.device_id.dest = q_data->cmd_data.send_dtmf.device_id.src; - tr->terminal_rsp_data.open_channel.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - - sat_manager_send_terminal_response(plugin, tr); - g_free(tr); - - return TRUE; - } - - //emit send_dtmf signal - plg_name = (gchar *)tcore_server_get_cp_name_by_plugin(plugin); - if (plg_name) { - path = g_strdup_printf("%s/%s", TELEPHONY_OBJECT_PATH, plg_name); - } else { - path = g_strdup_printf("%s", TELEPHONY_OBJECT_PATH); - } - dbg("path = [%s]", path); - - object = g_hash_table_lookup(sat_data->objects, path); - - open_channel = sat_manager_open_channel_noti(plugin, &q_data->cmd_data.open_channel); - - dbg("open channel type_format(%s)", g_variant_get_type_string(open_channel)); - g_variant_get(open_channel,"(isi@vbbbi@viiiis@v)", &command_id, &text, &text_len, &icon_id, &immediate_link, &auto_reconnection, &bg_mode, - &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); - - /*telephony_sat_emit_open_channel(sat, command_id, text, text_len, immediate_link, auto_reconnection, bg_mode, - bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail);*/ - - //BIP Manager - { - gboolean is_sig = FALSE; - GDBusConnection *conn = NULL; - const gchar *g_path = NULL; - - conn = g_dbus_object_manager_server_get_connection(sat_data->manager); - g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); - - is_sig = sat_ui_support_exec_bip(conn, g_path, TEL_SAT_PROATV_CMD_OPEN_CHANNEL, open_channel); - } - - return TRUE; -} - -gboolean sat_manager_handle_ui_display_status(DtapiSatPluginsInfo *plugins_info, gint command_id, gboolean display_status) -{ - char *path; - gchar *plg_name = NULL; - gboolean result = FALSE; - TelephonySat *sat; - DtapiSatPrivateData *sat_data = NULL; - TelephonyObjectSkeleton *object; - SatManagerQueueData q_data; - TcorePlugin *plugin = NULL; - TcorePlugin *comm_plugin = NULL; - - dbg("[SAT] ui display status : command id(%d) display status(%d)", command_id, display_status); - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - plugin = plugins_info->plugin; - comm_plugin = plugins_info->comm_plugin; - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - err("sat_data is null"); - return FALSE; - } - - plg_name = (gchar *)tcore_server_get_cp_name_by_plugin(plugin); - if (plg_name) { - path = g_strdup_printf("%s/%s", TELEPHONY_OBJECT_PATH, plg_name); - } - else { - path = g_strdup_printf("%s", TELEPHONY_OBJECT_PATH); - } - dbg("path = [%s]", path); - - object = g_hash_table_lookup(sat_data->objects, path); - sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command peek data from queue is failed. didn't find in command Q!!"); - return result; - } - - switch (q_data.cmd_type) { - case TEL_SAT_PROATV_CMD_PLAY_TONE: - result = _sat_manager_handle_play_tone_ui_display_status(sat, plugin, &q_data, display_status); - break; - case TEL_SAT_PROATV_CMD_SEND_SMS: - result = _sat_manager_handle_send_sms_ui_display_status(sat, plugin, &q_data, display_status); - break; - case TEL_SAT_PROATV_CMD_SEND_SS: - result = _sat_manager_handle_send_ss_ui_display_status(sat, plugin, &q_data, display_status); - break; - case TEL_SAT_PROATV_CMD_SEND_USSD: - result = _sat_manager_handle_send_ussd_ui_display_status(sat, plugin, &q_data, display_status); - break; - case TEL_SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: - result = _sat_manager_handle_setup_idle_mode_text_ui_display_status(plugin, &q_data, display_status); - break; - case TEL_SAT_PROATV_CMD_REFRESH: - result = _sat_manager_handle_refresh_ui_display_status(plugin, &q_data, display_status); - break; - case TEL_SAT_PROATV_CMD_SEND_DTMF: - result = _sat_manager_handle_send_dtmf_ui_display_status(sat, plugin, &q_data, display_status); - break; - case TEL_SAT_PROATV_CMD_OPEN_CHANNEL: - result = _sat_manager_handle_open_channel_ui_display_status(plugin, comm_plugin, &q_data, display_status); - break; - default: - err("[SAT] cannot handle ui display status command(0x%x)", q_data.cmd_type); - break; - } - - return result; -} - -gboolean sat_manager_handle_event_download_envelop(int event_type, int src_dev, int dest_dev, TelSatEnvelopEventDownloadTlv *evt_download, GVariant *download_data) -{ - GVariant *data = NULL; - - dbg("download data type_format(%s)", g_variant_get_type_string(download_data)); - g_variant_get(download_data, "v", &data); - - switch (event_type) - { - case TEL_SAT_EVENT_USER_ACTIVITY: - dbg("data type_format(%s)", g_variant_get_type_string(data)); - evt_download->device_identitie.src = src_dev; - evt_download->device_identitie.dest = dest_dev; - break; - case TEL_SAT_EVENT_IDLE_SCREEN_AVAILABLE: - dbg("data type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(b)", &evt_download->idle_screen); - evt_download->device_identitie.src = TEL_SAT_DEVICE_ID_DISPLAY; - evt_download->device_identitie.dest = dest_dev; - dbg("idle screen available (%d)", evt_download->idle_screen); - break; - case TEL_SAT_EVENT_LANGUAGE_SELECTION: - dbg("data type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(i)", &evt_download->language); - evt_download->device_identitie.src = src_dev; - evt_download->device_identitie.dest = dest_dev; - dbg("selected language (%d)", evt_download->language); - break; - case TEL_SAT_EVENT_BROWSER_TERMINATION:{ - dbg("data type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(i)", &evt_download->browser_termination); - evt_download->device_identitie.src = src_dev; - evt_download->device_identitie.dest = dest_dev; - dbg("browser termination cause(%d)", evt_download->browser_termination); - } break; - case TEL_SAT_EVENT_DATA_AVAILABLE:{ - gint channel_id, channel_status, channel_info, channel_data_len; - - dbg("data type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(iiii)", &channel_id, &channel_status, &channel_info, &channel_data_len); - evt_download->device_identitie.src = src_dev; - evt_download->device_identitie.dest = dest_dev; - evt_download->channel_status.channel_id = channel_id; - evt_download->channel_status.status = channel_status; - evt_download->channel_status.status_info = channel_info; - evt_download->channel_data_len = channel_data_len; - dbg("data available channel id (%d)", evt_download->channel_status.channel_id); - } break; - case TEL_SAT_EVENT_CHANNEL_STATUS:{ - gint channel_id, channel_status, channel_info; - - dbg("data type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(iii)", &channel_id, &channel_status, &channel_info); - evt_download->device_identitie.src = src_dev; - evt_download->device_identitie.dest = dest_dev; - evt_download->channel_status.channel_id = channel_id; - evt_download->channel_status.status = channel_status; - evt_download->channel_status.status_info = channel_info; - - } break; - default : - err("not support download event (%d)", event_type); - break; - } - - return TRUE; -} - -gboolean sat_manager_update_language(TcorePlugin *plugin, TcorePlugin *comm_plugin, GVariant *language_noti) -{ - DtapiSatPrivateData *sat_data; - static TcoreStorage *strg; - TelReturn rv = TEL_RETURN_FAILURE; - gboolean result = FALSE; - const gchar *lang_str = NULL; - gint command_id, language; - gboolean is_specified; - TelSatRequestTerminalResponseData *tr; - SatManagerQueueData q_data; - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - err("sat_data is null"); - return result; - } - - strg = tcore_server_find_storage(sat_data->server, "vconf"); - - memset(&q_data, 0, sizeof(SatManagerQueueData)); - - dbg("language_noti type_format(%s)", g_variant_get_type_string(language_noti)); - g_variant_get(language_noti, "(iib)", &command_id, &language, &is_specified); - - if (sat_manager_dequeue_cmd_by_id(&q_data, command_id) == FALSE) { - err("[SAT] command dequeue failed. didn't find in command Q!!"); - return result; - } - - if (q_data.cmd_type != TEL_SAT_PROATV_CMD_LANGUAGE_NOTIFICATION) { - err("[SAT] Language Noti dequeue failed. didn't find in command Q!!"); - return result; - } - - tr = g_new0(TelSatRequestTerminalResponseData, 1); - tr->cmd_number = q_data.cmd_data.language_notification.command_detail.cmd_num; - tr->cmd_type = q_data.cmd_data.language_notification.command_detail.cmd_type; - memcpy((void*)&tr->terminal_rsp_data.language_notification.command_detail, &q_data.cmd_data.language_notification.command_detail, sizeof(TelSatCmdDetailInfo)); - tr->terminal_rsp_data.language_notification.device_id.src = TEL_SAT_DEVICE_ID_ME; - tr->terminal_rsp_data.language_notification.device_id.dest = TEL_SAT_DEVICE_ID_SIM; - tr->terminal_rsp_data.language_notification.result_type = TEL_SAT_RESULT_SUCCESS_RETURN; - - lang_str = _convert_sim_lang_to_string((TelSimLanguagePreferenceCode)language); - if (!lang_str) { - dbg("language is not exist"); - tr->terminal_rsp_data.language_notification.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } - dbg("converted lang (%s)", lang_str); - - result = tcore_storage_set_string(strg, STORAGE_KEY_LANGUAGE_SET, (const char*)lang_str); - if (!result) { - dbg("fail to update language"); - tr->terminal_rsp_data.language_notification.result_type = TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND; - } - - result = TRUE; - rv = sat_manager_send_terminal_response(plugin, tr); - if (rv != TEL_RETURN_SUCCESS) { - err("fail to send terminal response"); - result = FALSE; - } - - g_free(tr); - return result; -} - -void sat_manager_init(TcorePlugin *plugin, GHashTable *objects, Server *server, GDBusObjectManagerServer *manager) { - DtapiSatPrivateData *sat_data; - - dbg("Entry"); - - sat_data = calloc(1, sizeof(DtapiSatPrivateData)); - if (!sat_data) { - err("failed to allocate memory"); - return; - } - - sat_data->server = server; - sat_data->cached_data = NULL; - sat_data->objects = objects; - sat_data->manager = manager; - - if (tcore_plugin_link_user_data(plugin, sat_data) != TEL_RETURN_SUCCESS) { - err("Failed to link plugin private data"); - free(sat_data); - return; - } -} - -void sat_manager_deinit(TcorePlugin *plugin) { - DtapiSatPrivateData *sat_data; - - dbg("Entry"); - - sat_data = tcore_plugin_ref_user_data(plugin); - - tcore_free(sat_data); -} diff --git a/sat-manager/src/sat_ui_support.c b/sat-manager/src/sat_ui_support.c deleted file mode 100644 index 713efde..0000000 --- a/sat-manager/src/sat_ui_support.c +++ /dev/null @@ -1,1004 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sat_ui_support.h" - -#define SAT_UI_APP "org.tizen.sat-ui" -#define DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data) \ - do { \ - bundle *bundle_data = 0; \ - gint rv; \ - \ - bundle_data = bundle_create(); \ - bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); \ - bundle_add(bundle_data, "cmd_type", cmd_type); \ - bundle_add(bundle_data, "data", encoded_data); \ - \ - rv = aul_launch_app(SAT_UI_APP, bundle_data); \ - dbg("aul launch app rv: (%d)", rv); \ - bundle_free(bundle_data); \ - } while (0) - -static TcoreStorage *strg_vconf = NULL; -#if 0 -static gboolean _sat_ui_support_processing_setup_menu_ind(GVariant *data) -{ - gchar *encoded_data = NULL, *cmd_type = NULL; - TelSatSetupMenuInfo setup_menu; - gchar *title; - gint command_id, item_cnt; - gboolean is_present, is_helpinfo, is_updated; - GVariant *items = NULL, *icon_id, *icon_list; - - memset(&setup_menu, 0, sizeof(TelSatSetupMenuInfo)); - - g_variant_get(data, "(ibs@vibb@v@v)", &command_id, &is_present, &title, &items, &item_cnt, - &is_helpinfo, &is_updated, &icon_id, &icon_list); - - setup_menu.command_id = command_id; - setup_menu.is_main_menu_present = (is_present ? 1 : 0); - memcpy(setup_menu.sat_main_title, title, TEL_SAT_DEF_TITLE_LEN_MAX+1); - setup_menu.sat_main_menu_item_count = item_cnt; - if(items && item_cnt > 0){ - int index = 0; - GVariant *unbox; - GVariantIter *iter; - - gchar *item_str; - gint item_id; - unbox = g_variant_get_variant(items); - dbg("items(%p) items type_format(%s)", items, g_variant_get_type_string(unbox)); - - g_variant_get(unbox, "a(si)", &iter); - while(g_variant_iter_loop(iter,"(si)",&item_str, &item_id)){ - setup_menu.sat_main_menu_item[index].item_id = item_id; - memcpy(setup_menu.sat_main_menu_item[index].item_string, item_str, TEL_SAT_DEF_ITEM_STR_LEN_MAX + 6); - index++; - } - g_variant_iter_free(iter); - } - setup_menu.is_sat_main_menu_help_info = (is_helpinfo ? 1 : 0); - setup_menu.is_updated_sat_main_menu = (is_updated ? 1 : 0); - - cmd_type = g_strdup_printf("%d", TEL_SAT_PROATV_CMD_SETUP_MENU); - encoded_data = g_base64_encode((const guchar*)&setup_menu, sizeof(TelSatSetupMenuInfo)); - - dbg("launching SAT APP for setup menu ind"); - DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data); - - g_free(encoded_data); - g_free(cmd_type); - - return TRUE; -} -#endif -static gboolean _sat_ui_support_processing_display_text_ind(GVariant *data) -{ - gchar *encoded_data = NULL, *cmd_type = NULL; - TelSatDisplayTextInd display_text; - gchar* text; - gint command_id, text_len, duration; - gboolean high_priority, user_rsp_required, immediately_rsp; - GVariant *icon_id = NULL; - - memset(&display_text, 0, sizeof(TelSatDisplayTextInd)); - - g_variant_get(data, "(isiibbb@v)", &command_id, &text, &text_len, &duration, - &high_priority, &user_rsp_required, &immediately_rsp, &icon_id); - - display_text.command_id = command_id; - memcpy(display_text.text.string, text, TEL_SAT_TEXT_STRING_LEN_MAX+1); - display_text.text.string_len = text_len; - display_text.duration = duration; - display_text.is_priority_high = (high_priority ? 1 : 0); - display_text.is_user_resp_required = (user_rsp_required ? 1 : 0); - display_text.immediately_resp = (immediately_rsp ? 1 : 0); - dbg("duration(%d) user_rsp(%d) immediately_rsp(%d)", duration, user_rsp_required, immediately_rsp); - - cmd_type = g_strdup_printf("%d", TEL_SAT_PROATV_CMD_DISPLAY_TEXT); - encoded_data = g_base64_encode((const guchar*)&display_text, sizeof(TelSatDisplayTextInd)); - - dbg("launching SAT APP for display text ind"); - DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data); - - g_free(encoded_data); - g_free(cmd_type); - - return TRUE; -} - -static gboolean _sat_ui_support_processing_select_item_ind(GVariant *data) -{ - gchar *encoded_data = NULL, *cmd_type = NULL; - TelSatSelectItemInd select_item; - gboolean help_info ; - gchar *selected_text; - gint command_id, default_item_id, menu_cnt, text_len =0; - GVariant *menu_items, *icon_id, *icon_list; - - memset(&select_item, 0, sizeof(TelSatSelectItemInd)); - - g_variant_get(data, "(ibsiii@v@v@v)", &command_id, &help_info, &selected_text, - &text_len, &default_item_id, &menu_cnt, &menu_items, &icon_id, &icon_list); - - select_item.command_id = command_id; - select_item.is_help_info_available = (help_info ? 1 : 0); - memcpy(select_item.text.string, selected_text, TEL_SAT_DEF_TITLE_LEN_MAX+1); - select_item.text.string_len = text_len; - select_item.default_item_index = default_item_id; - select_item.menu_item_count = menu_cnt; - if(menu_items && menu_cnt > 0){ - int index = 0; - GVariant *unbox; - GVariantIter *iter; - gchar *item_str; - gint item_id, item_len; - unbox = g_variant_get_variant(menu_items); - dbg("items(%p) items type_format(%s)", menu_items, g_variant_get_type_string(unbox)); - - g_variant_get(unbox, "a(iis)", &iter); - while(g_variant_iter_loop(iter,"(iis)",&item_id, &item_len, &item_str)){ - select_item.menu_item[index].item_id = item_id; - select_item.menu_item[index].text_len = item_len; - memcpy(select_item.menu_item[index].text, item_str, TEL_SAT_ITEM_TEXT_LEN_MAX + 1); - index++; - } - g_variant_iter_free(iter); - } - - cmd_type = g_strdup_printf("%d", TEL_SAT_PROATV_CMD_SELECT_ITEM); - encoded_data = g_base64_encode((const guchar*)&select_item, sizeof(TelSatSelectItemInd)); - - dbg("launching SAT APP for select item ind"); - DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data); - - g_free(encoded_data); - g_free(cmd_type); - - return TRUE; -} - -static gboolean _sat_ui_support_processing_get_inkey_ind(GVariant *data) -{ - gchar *encoded_data = NULL, *cmd_type = NULL; - TelSatGetInkeyInd get_inkey; - gint command_id, key_type, input_character_mode; - gint text_len, duration; - gboolean is_numeric, is_help_info; - gchar *text; - GVariant *icon_id; - - memset(&get_inkey, 0, sizeof(TelSatGetInkeyInd)); - - g_variant_get(data, "(iiibbsii@v)", &command_id, &key_type, &input_character_mode, - &is_numeric,&is_help_info, &text, &text_len, &duration, &icon_id); - - get_inkey.command_id = command_id; - get_inkey.key_type = key_type; - get_inkey.input_char_mode = input_character_mode; - get_inkey.is_numeric = (is_numeric ? 1 : 0); - get_inkey.is_help_info_available = (is_help_info ? 1 : 0); - memcpy(get_inkey.text.string, text, TEL_SAT_TEXT_STRING_LEN_MAX+1); - get_inkey.text.string_len = text_len; - get_inkey.duration = duration; - - cmd_type = g_strdup_printf("%d", TEL_SAT_PROATV_CMD_GET_INKEY); - encoded_data = g_base64_encode((const guchar*)&get_inkey, sizeof(TelSatGetInkeyInd)); - - dbg("launching SAT APP for get inkey ind"); - DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data); - - g_free(encoded_data); - g_free(cmd_type); - - return TRUE; -} - -static gboolean _sat_ui_support_processing_get_input_ind(GVariant *data) -{ - gchar *encoded_data = NULL, *cmd_type = NULL; - TelSatGetInputInd get_input; - gint command_id, input_character_mode; - gint text_len, def_text_len, rsp_len_min, rsp_len_max; - gboolean is_numeric, is_help_info, is_echo_input; - gchar *text, *def_text; - GVariant *icon_id; - - memset(&get_input, 0, sizeof(TelSatGetInputInd)); - - g_variant_get(data, "(iibbbsiiisi@v)", &command_id, &input_character_mode, &is_numeric, &is_help_info, &is_echo_input, - &text, &text_len, &rsp_len_max, &rsp_len_min, &def_text, &def_text_len, &icon_id); - - get_input.command_id = command_id; - get_input.input_char_mode = input_character_mode; - get_input.is_numeric = (is_numeric ? 1 : 0); - get_input.is_help_info_available = (is_help_info ? 1 : 0); - get_input.is_echo_input = (is_echo_input ? 1 : 0); - memcpy(get_input.text.string, text, TEL_SAT_TEXT_STRING_LEN_MAX+1); - get_input.text.string_len = text_len; - get_input.resp_len.max = rsp_len_max; - get_input.resp_len.min = rsp_len_min; - memcpy(get_input.default_text.string, def_text, TEL_SAT_TEXT_STRING_LEN_MAX+1); - get_input.default_text.string_len = def_text_len; - - cmd_type = g_strdup_printf("%d", TEL_SAT_PROATV_CMD_GET_INPUT); - encoded_data = g_base64_encode((const guchar*)&get_input, sizeof(TelSatGetInputInd)); - - dbg("launching SAT APP for get input ind"); - DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data); - - g_free(encoded_data); - g_free(cmd_type); - - return TRUE; -} - -static gboolean _sat_ui_support_processing_refresh_ind(GVariant *data) -{ - gchar *encoded_data = NULL, *cmd_type = NULL; - TelSatRefreshIndUiInfo refresh_info; - gint command_id = 0; - gint refresh_type =0; - GVariant *file_list = NULL; - - memset(&refresh_info, 0, sizeof(TelSatRefreshIndUiInfo)); - - dbg("refresh type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(ii@v)", &command_id, &refresh_type, &file_list); - - refresh_info.command_id = command_id; - refresh_info.duration = 10000; - refresh_info.refresh_type = refresh_type; - - cmd_type = g_strdup_printf("%d", TEL_SAT_PROATV_CMD_REFRESH); - encoded_data = g_base64_encode((const guchar*)&refresh_info, sizeof(TelSatRefreshIndUiInfo)); - - dbg("launching SAT APP for get input ind"); - DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data); - - g_free(encoded_data); - g_free(cmd_type); - - return TRUE; -} - -static gboolean _sat_ui_support_processing_play_tone_ind(GVariant *data) -{ - gchar *encoded_data = NULL, *cmd_type = NULL; - TelSatPlayToneInd play_tone_info; - gint command_id, tone_type, duration; - gint text_len; - gchar* text; - GVariant *icon_id; - - memset(&play_tone_info, 0, sizeof(TelSatPlayToneInd)); - - g_variant_get(data, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &tone_type, &duration); - - play_tone_info.command_id = command_id; - play_tone_info.duration = duration; - play_tone_info.text.string_len = text_len; - memcpy(play_tone_info.text.string, text, TEL_SAT_TEXT_STRING_LEN_MAX+1); - play_tone_info.tone = tone_type; - - cmd_type = g_strdup_printf("%d", TEL_SAT_PROATV_CMD_PLAY_TONE); - encoded_data = g_base64_encode((const guchar*)&play_tone_info, sizeof(TelSatPlayToneInd)); - - dbg("launching SAT APP for play tone ind"); - DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data); - - g_free(encoded_data); - g_free(cmd_type); - - return TRUE; -} - -static gboolean _sat_ui_support_processing_idle_mode_text_ind(GVariant *data) -{ - gchar *encoded_data = NULL, *cmd_type = NULL; - TelSatSetupIdleModeTextInd idle_mode_text_info; - gint command_id, text_len; - gchar* text; - GVariant *icon_id; - - memset(&idle_mode_text_info, 0, sizeof(TelSatSetupIdleModeTextInd)); - - g_variant_get(data, "(isi@v)", &command_id, &text, &text_len, &icon_id); - - idle_mode_text_info.command_id = command_id; - idle_mode_text_info.text.string_len = text_len; - memcpy(idle_mode_text_info.text.string, text, TEL_SAT_TEXT_STRING_LEN_MAX+1); - - cmd_type = g_strdup_printf("%d", TEL_SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT); - encoded_data = g_base64_encode((const guchar*)&idle_mode_text_info, sizeof(TelSatSetupIdleModeTextInd)); - - dbg("launching SAT APP for setup idle mode text ind"); - DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data); - - g_free(encoded_data); - g_free(cmd_type); - - return TRUE; -} - -static gboolean _sat_ui_support_processing_ui_info_ind(TelSatProactiveCmdType cmd, GVariant *data) -{ - gchar *encoded_data = NULL, *cmd_type = NULL; - TelSatSendUiInfo ui_info; - gint command_id, text_len; - gboolean user_confirm; - gchar *text; - - memset(&ui_info, 0, sizeof(TelSatSendUiInfo)); - - g_variant_get(data, "(isib)", &command_id, &text, &text_len, &user_confirm); - dbg("command_id(%d) data(%s) len(%d) user_confirm(%d)", command_id, text, text_len, user_confirm); - - ui_info.command_id = command_id; - memcpy(ui_info.text.string, text, TEL_SAT_TEXT_STRING_LEN_MAX+1); - ui_info.text.string_len = text_len; - ui_info.user_confirm = (user_confirm ? 1 : 0); - - cmd_type = g_strdup_printf("%d", cmd); - encoded_data = g_base64_encode((const guchar*)&ui_info, sizeof(TelSatSendUiInfo)); - - dbg("launching SAT APP for ui info ind"); - DBUS_LAUNCH_SAT_APP(cmd_type, encoded_data); - - g_free(encoded_data); - g_free(cmd_type); - - return TRUE; -} - -static gboolean _sat_ui_support_create_desktop_file(const gchar *title) -{ - int rv = 0; - int b_check = 0; - FILE *f_out; - - if(!title){ - dbg("title does not exist"); - return FALSE; - } - - b_check = access("/opt/share/applications/org.tizen.sat-ui.desktop", F_OK); - if( b_check == 0 && !(g_strcmp0(title,"temp")) ){ - dbg("desktop file aleady exist"); - return FALSE; - } - - f_out = fopen("/opt/share/applications/org.tizen.sat-ui.desktop", "w"); - if(!f_out){ - dbg("fail to create sat-ui desktop file"); - return FALSE; - } - - fprintf(f_out, "Package=org.tizen.sat-ui\n"); - fprintf(f_out, "Name=%s\n",title); - fprintf(f_out, "Type=Application\n"); - fprintf(f_out, "Version=0.2.2\n"); - - if( g_strcmp0(title,"temp") == 0 ){ - fprintf(f_out, "NoDisplay=true\n"); - } - - fprintf(f_out, "Exec=/usr/apps/org.tizen.sat-ui/bin/sat-ui KEY_EXEC_TYPE 0\n"); - fprintf(f_out, "Icon=org.tizen.sat-ui.png\n"); - fprintf(f_out, "X-Tizen-TaskManage=True\n"); - fprintf(f_out, "X-Tizen-Multiple=False\n"); - fprintf(f_out, "X-Tizen-Removable=False\n"); - fprintf(f_out, "Comment=SIM Application UI\n"); - fclose(f_out); - //fflush(f_out); - - //rv = system("/bin/cp /tmp/org.tizen.sat-ui.desktop /opt/share/applications/"); - //dbg("the result to create desktop file (%d)", rv); - //rv = system("/bin/rm /tmp/org.tizen.sat-ui.desktop"); - - rv = setxattr("/opt/share/applications/org.tizen.sat-ui.desktop", "security.SMACK64","_",1,0); - dbg("the result to apply the smack value(%d)", rv); - - b_check = access("/opt/share/applications/org.tizen.sat-ui.desktop", F_OK); - dbg("access result (%d)", b_check); - - if(rv == -1 || rv == 127) { - dbg("rv (%d)", rv); - return FALSE; - } - - //rv = system("/bin/ls -al /opt/share/applications > /opt/var/log/desktop_file_list.txt"); - - return TRUE; -} - -static void _sat_ui_support_storage_key_callback(TcoreStorageKey key, void *value, void *user_data) -{ - GVariant *tmp = NULL; - gboolean type_check = FALSE; - - dbg("storage key(%d) callback", key); - tmp = (GVariant *)value; - if(!tmp || !strg_vconf){ - err("value is null"); - return; - } - - if(key == STORAGE_KEY_IDLE_SCREEN_LAUNCHED) { - int b_launched = 0; - const gchar *title = (const gchar*)user_data; - gboolean ret; - - type_check = g_variant_is_of_type(tmp, G_VARIANT_TYPE_INT32); - if(!type_check){ - dbg("wrong variant data type"); - goto EXIT; - } - - b_launched = g_variant_get_int32(tmp); - if(b_launched < 0) { - dbg("tcore_storage_get_int(VCONFKEY_IDLE_SCREEN_LAUNCHED) failed"); - goto EXIT; - } - - if(b_launched) { - dbg("idle screen is ready, create desktop file."); - ret = _sat_ui_support_create_desktop_file(title); - } - } - else { - dbg("unspported key."); - } - -EXIT: - g_variant_unref(tmp); - return; -} - -static gboolean _sat_ui_support_register_key_callback(TcoreStorageKey key, void * user_data) -{ - gboolean ret = FALSE; - - if (strg_vconf == NULL) { - err("VCONF TcoreStorage is NULL!!!"); - return ret; - } - - dbg("Set key callback - KEY: [%d]", key); - ret = tcore_storage_set_key_callback(strg_vconf, key, _sat_ui_support_storage_key_callback, user_data); - - return ret; -} - -gboolean sat_ui_support_terminate_sat_ui() -{ - gint rv; - bundle *bundle_data = 0; - gchar *cmd_type = NULL; - - cmd_type = g_strdup_printf("%d", TEL_SAT_PROATV_CMD_TYPE_END_PROACTIVE_SESSION); - - bundle_data = bundle_create(); - bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); - bundle_add(bundle_data, "cmd_type", cmd_type); - - rv = aul_launch_app(SAT_UI_APP, bundle_data); - dbg("session end aul (%d)", rv); - - bundle_free(bundle_data); - g_free(cmd_type); - - return TRUE; -} - -gboolean sat_ui_support_launch_sat_ui(TelSatProactiveCmdType cmd_type, GVariant *data) -{ - gboolean result = FALSE; - sat_ui_support_create_desktop_file("temp"); - - switch(cmd_type){ - case TEL_SAT_PROATV_CMD_NONE: - case TEL_SAT_PROATV_CMD_SEND_DTMF: - result = _sat_ui_support_processing_ui_info_ind(cmd_type, data); - break; - /* No need to launch SAT UI in case of setup menu command */ - /*case TEL_SAT_PROATV_CMD_SETUP_MENU: - result = _sat_ui_support_processing_setup_menu_ind(data); - */ - break; - case TEL_SAT_PROATV_CMD_DISPLAY_TEXT: - result = _sat_ui_support_processing_display_text_ind(data); - break; - case TEL_SAT_PROATV_CMD_SELECT_ITEM: - result = _sat_ui_support_processing_select_item_ind(data); - break; - case TEL_SAT_PROATV_CMD_GET_INKEY: - result = _sat_ui_support_processing_get_inkey_ind(data); - break; - case TEL_SAT_PROATV_CMD_GET_INPUT: - result = _sat_ui_support_processing_get_input_ind(data); - break; - case TEL_SAT_PROATV_CMD_REFRESH: - result = _sat_ui_support_processing_refresh_ind(data); - break; - case TEL_SAT_PROATV_CMD_PLAY_TONE: - result = _sat_ui_support_processing_play_tone_ind(data); - break; - case TEL_SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: - result = _sat_ui_support_processing_idle_mode_text_ind(data); - break; - case TEL_SAT_PROATV_CMD_SETUP_EVENT_LIST: - break; - default: - dbg("does not need to launch sat-ui"); - break; - } - - return result; -} - -gboolean sat_ui_support_launch_call_application(TelSatProactiveCmdType cmd_type, GVariant *data) -{ - //gint rv; - char buffer[300]; - bundle *bundle_data = 0; - - dbg("launch call application by aul"); - bundle_data = bundle_create(); - - appsvc_set_operation(bundle_data, APPSVC_OPERATION_CALL); - appsvc_set_uri(bundle_data,"tel:MT"); - - switch(cmd_type){ - case TEL_SAT_PROATV_CMD_SETUP_CALL:{ - gint command_id, call_type, confirm_text_len, text_len, duration; - gchar *confirm_text, *text, *call_number; - GVariant *icon_id; - - dbg("setup call type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(isisi@visi)", &command_id, &confirm_text, &confirm_text_len, &text, &text_len, &icon_id, &call_type, &call_number, &duration); - - appsvc_add_data(bundle_data, "launch-type","SATSETUPCALL"); - - snprintf(buffer, 300, "%d",command_id); - appsvc_add_data(bundle_data, "cmd_id",buffer); - dbg("cmd_id(%s)",buffer); - - snprintf(buffer, 300, "%d",call_type); - appsvc_add_data(bundle_data, "cmd_qual", buffer); - dbg("cmd_qual(%s)",buffer); - - snprintf(buffer, 300, "%s", text); - appsvc_add_data(bundle_data, "disp_text", buffer); - dbg("disp_text(%s)",buffer); - - snprintf(buffer, 300, "%s", call_number); - appsvc_add_data(bundle_data, "call_num", buffer); - dbg("call_num(%s)",buffer); - - snprintf(buffer, 300, "%d", duration); - appsvc_add_data(bundle_data, "dur", buffer); - dbg("dur(%s)",buffer); - } break; - - default: - bundle_free(bundle_data); - return FALSE; - break; - } - - appsvc_run_service(bundle_data, 0, NULL, NULL); - dbg("call app is called"); - //rv = aul_launch_app("com.samsung.call",bundle_data); - //dbg("call app aul (%d)", rv); - bundle_free(bundle_data); - - return TRUE; -} - -gboolean sat_ui_support_launch_browser_application(TelSatProactiveCmdType cmd_type, GVariant *data) -{ -// gint rv; - char buffer[300]; - bundle *bundle_data = 0; - - dbg("launch browser application by aul"); - bundle_data = bundle_create(); - - appsvc_set_operation(bundle_data, APPSVC_OPERATION_VIEW); - - switch(cmd_type){ - case TEL_SAT_PROATV_CMD_LAUNCH_BROWSER:{ - gint command_id, launch_type, browser_id; - gint url_len, text_len, gateway_proxy_len; - gchar *url, *text, *gateway_proxy; - GVariant *icon_id = NULL; - - dbg("launch_browser type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(iiisisisi@v)", &command_id, &launch_type, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len, &icon_id); - - appsvc_set_uri(bundle_data, url); - - snprintf(buffer, 300, "%d",command_id); - appsvc_add_data(bundle_data, "cmd_id",buffer); - dbg("cmd_id(%s)",buffer); - - snprintf(buffer, 300, "%d",launch_type); - appsvc_add_data(bundle_data, "launch_type", buffer); - dbg("launch_type(%s)",buffer); - - snprintf(buffer, 300, "%s", gateway_proxy); - appsvc_add_data(bundle_data, "proxy", buffer); - dbg("proxy(%s)",buffer); - - } break; - - default: - bundle_free(bundle_data); - return FALSE; - break; - } - - appsvc_run_service(bundle_data, 0, NULL, NULL); - dbg("browser app is called"); - //rv = aul_launch_app("com.samsung.call",bundle_data); - //dbg("call app aul (%d)", rv); - bundle_free(bundle_data); - - return TRUE; -} - -gboolean sat_ui_support_launch_ciss_application(TelSatProactiveCmdType cmd_type, GVariant *data) -{ - bundle *bundle_data = 0; - gchar *encoded_data = NULL, *cmd = NULL; - - dbg("launch ciss application by aul"); - bundle_data = bundle_create(); - - appsvc_set_operation(bundle_data, "http://tizen.org/appcontrol/operation/ciss"); - appsvc_set_pkgname(bundle_data, "com.samsung.ciss"); - - switch(cmd_type){ - case TEL_SAT_PROATV_CMD_SEND_SS:{ - TelSatSendSsIndSsData ss_info; - - gint command_id, ton, npi; - gint text_len, ss_str_len; - gchar* text, *ss_string; - GVariant *icon_id; - - dbg("launch ciss ui for send ss proactive cmd"); - - memset(&ss_info, 0, sizeof(TelSatSendSsIndSsData)); - - dbg("send ss type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(isi@viiis)", &command_id, &text, &text_len, &icon_id, &ton, &npi, &ss_str_len, &ss_string); - - ss_info.command_id = command_id; - memcpy(ss_info.ss_string, ss_string, TEL_SAT_DEF_SS_LEN_MAX+1); - ss_info.ss_string_len = ss_str_len; - - cmd = g_strdup_printf("%d", cmd_type); - encoded_data = g_base64_encode((const guchar*)&ss_info, sizeof(TelSatSendSsIndSsData)); - - } break; - - case TEL_SAT_PROATV_CMD_SEND_USSD:{ - TelSatSendUssdIndUssdData ussd_info; - - gint command_id; - gint text_len, ussd_str_len; - gchar* text, *ussd_string; - - GVariant *icon_id; - - dbg("launch ciss ui for send ussd proactive cmd"); - - memset(&ussd_info, 0, sizeof(TelSatSendUssdIndUssdData)); - - dbg("send ussd type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(isi@vis)", &command_id, &text, &text_len, &icon_id, &ussd_str_len, &ussd_string); - - ussd_info.command_id = command_id; - memcpy(ussd_info.ussd_string, ussd_string, TEL_SAT_DEF_USSD_LEN_MAX+1); - ussd_info.ussd_string_len = ussd_str_len; - - cmd = g_strdup_printf("%d", cmd_type); - encoded_data = g_base64_encode((const guchar*)&ussd_info, sizeof(TelSatSendUssdIndUssdData)); - - } break; - - default: - bundle_free(bundle_data); - return FALSE; - break; - } - - appsvc_add_data(bundle_data, "CISS_LAUNCHING_MODE", "RESP"); - appsvc_add_data(bundle_data, "KEY_EVENT_TYPE", cmd); - appsvc_add_data(bundle_data, "KEY_ENCODED_DATA", encoded_data); - - appsvc_run_service(bundle_data, 0, NULL, NULL); - dbg("ciss is called"); - bundle_free(bundle_data); - - return TRUE; -} - -gboolean sat_ui_support_launch_setting_application(TelSatProactiveCmdType cmd_type, GVariant *data) -{ - gint rv; - char buffer[300]; - bundle *bundle_data = 0; - - dbg("launch setting application by aul"); - - /*TODO : need to make a sync with app engineer*/ - - switch(cmd_type){ - case TEL_SAT_PROATV_CMD_LANGUAGE_NOTIFICATION:{ - gint command_id, call_type, text_len, duration; - gchar *text, *call_number; - GVariant *icon_id; - - dbg("setup call type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(isi@visi)", &command_id, &text, &text_len, &icon_id, &call_type, &call_number, &duration); - - bundle_add(bundle_data, "launch-type","SATSETUPCALL"); - - snprintf(buffer, 300, "%d",command_id); - bundle_add(bundle_data, "cmd_id",buffer); - dbg("cmd_id(%s)",buffer); - - snprintf(buffer, 300, "%d",call_type); - bundle_add(bundle_data, "cmd_qual", buffer); - dbg("cmd_qual(%s)",buffer); - - snprintf(buffer, 300, "%s", text); - bundle_add(bundle_data, "disp_text", buffer); - dbg("disp_text(%s)",buffer); - - snprintf(buffer, 300, "%s", call_number); - bundle_add(bundle_data, "call_num", buffer); - dbg("call_num(%s)",buffer); - - snprintf(buffer, 300, "%d", duration); - bundle_add(bundle_data, "dur", buffer); - dbg("dur(%s)",buffer); - } break; - - case TEL_SAT_PROATV_CMD_PROVIDE_LOCAL_INFO: - break; - - default: - return FALSE; - break; - } - - rv = aul_launch_app("com.samsung.call",bundle_data); - bundle_free(bundle_data); - - return TRUE; -} - -gboolean sat_ui_support_create_desktop_file(const gchar *title) -{ - gboolean ret = FALSE; - int is_launched = 0; - - dbg("check vconf if starter is ready."); - - if (strg_vconf == NULL) { - err("VCONF TcoreStorage is NULL!!!"); - return ret; - } - - is_launched = tcore_storage_get_int(strg_vconf, STORAGE_KEY_IDLE_SCREEN_LAUNCHED); - if(is_launched < 0) { - dbg("tcore_storage_get_int(VCONFKEY_IDLE_SCREEN_LAUNCHED) failed"); - return FALSE; - } - - dbg("Launch: [%s]", (is_launched ? "YES" : "NO")); - if(is_launched) { - dbg("Idle screen is Ready!!! Create Desktop file"); - ret = _sat_ui_support_create_desktop_file(title); - if (ret) - return TRUE; - } - - dbg("Idle screen is NOT launched yet!!! Register VCONF notification for Starter ready"); - ret = _sat_ui_support_register_key_callback(STORAGE_KEY_IDLE_SCREEN_LAUNCHED, (void *)title); - - return ret; -} - -gboolean sat_ui_support_remove_desktop_file(void) -{ - int rv = 0; - int is_check = 0; - - is_check = access("/opt/share/applications/org.tizen.sat-ui.desktop", F_OK); - if(is_check != 0){ - dbg("desktop file does not exist"); - return TRUE; - } - - rv = system("/bin/rm /opt/share/applications/org.tizen.sat-ui.desktop"); - dbg("the result to remove desktop file (%d)", rv); - - return TRUE; -} - -gboolean sat_ui_support_exec_bip(GDBusConnection *connection, const gchar *path, TelSatProactiveCmdType cmd_type, GVariant *data) -{ - gboolean rv = FALSE; - gchar *signal_name = NULL; - GVariant *out_param = NULL; - - switch(cmd_type){ - case TEL_SAT_PROATV_CMD_OPEN_CHANNEL:{ - gint command_id, bearer_type, protocol_type, dest_addr_type; - gboolean immediate_link, auto_reconnection, bg_mode; - gint text_len, buffer_size, port_number; - gchar *text, *dest_address; - GVariant *icon_id; - GVariant *bearer_param; - GVariant *bearer_detail; - - dbg("open channel type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data,"(isi@vbbbiviiiisv)", &command_id, &text, &text_len, &icon_id, &immediate_link, &auto_reconnection, &bg_mode, - &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); - - out_param = g_variant_new("(isibbbiviiiisv)", command_id, text, text_len, immediate_link, auto_reconnection, bg_mode, - bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail); - signal_name = g_strdup("OpenChannel"); - } break; - case TEL_SAT_PROATV_CMD_CLOSE_CHANNEL:{ - gint command_id, channel_id, text_len; - gchar *text; - GVariant *icon_id; - - dbg("close channel type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(isi@vi)", &command_id, &text, &text_len, &icon_id, &channel_id); - - out_param = g_variant_new("(isii)", command_id, text, text_len, channel_id); - signal_name = g_strdup("CloseChannel"); - } break; - case TEL_SAT_PROATV_CMD_RECEIVE_DATA:{ - gint command_id, text_len, channel_id, channel_data_len = 0; - gchar *text; - GVariant *icon_id; - - dbg("receive data type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &channel_id, &channel_data_len); - - out_param = g_variant_new("(isiii)", command_id, text, text_len, channel_id, channel_data_len); - signal_name = g_strdup("ReceiveData"); - } break; - case TEL_SAT_PROATV_CMD_SEND_DATA:{ - gint command_id, channel_id, text_len, channel_data_len; - gboolean send_data_immediately; - gchar *text; - GVariant *channel_data; - GVariant *icon_id; - - dbg("send data type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(isi@vibvi)", &command_id, &text, &text_len, &icon_id, &channel_id, &send_data_immediately, &channel_data, &channel_data_len); - - out_param = g_variant_new("(isiibvi)", command_id, text, text_len, channel_id, send_data_immediately, channel_data, channel_data_len); - signal_name = g_strdup("SendData"); - } break; - case TEL_SAT_PROATV_CMD_GET_CHANNEL_STATUS:{ - gint command_id; - - dbg("get channel status type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(i)", &command_id); - - out_param = g_variant_new("(i)", command_id); - signal_name = g_strdup("GetChannelStatus"); - } break; - case TEL_SAT_PROATV_CMD_SETUP_EVENT_LIST:{ - gint event_cnt; - GVariant *evt_list; - - dbg("setup event list type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(iv)", &event_cnt, &evt_list); - - out_param = g_variant_new("(iv)", event_cnt, evt_list); - signal_name = g_strdup("SetupEventList"); - } break; - default: - dbg("no matched command"); - return FALSE; - break; - } - - dbg("dbus conn(%p), path(%s)", connection, path); - rv = g_dbus_connection_emit_signal(connection, "org.tizen.bip-manager", path, "org.tizen.telephony.SAT", signal_name, out_param, NULL); - - dbg("send signal to bip-mananger result (%d)", rv); - - return rv; -} - -gboolean sat_ui_support_exec_evtdw(GDBusConnection *connection, const gchar *path, TelSatProactiveCmdType cmd_type, GVariant *data) -{ - gboolean rv = FALSE; - gchar *signal_name = NULL; - GVariant *out_param = NULL; - - switch(cmd_type){ - case TEL_SAT_PROATV_CMD_SETUP_EVENT_LIST:{ - gint event_cnt; - GVariant *evt_list; - - dbg("setup event list type_format(%s)", g_variant_get_type_string(data)); - g_variant_get(data, "(iv)", &event_cnt, &evt_list); - - out_param = g_variant_new("(iv)", event_cnt, evt_list); - signal_name = g_strdup("SetupEventList"); - } break; - default: - dbg("no matched command"); - return FALSE; - break; - } - - dbg("dbus conn(%p), path(%s)", connection, path); - rv = g_dbus_connection_emit_signal(connection, "org.tizen.sat-event-downloader", path, "org.tizen.telephony.SAT", signal_name, out_param, NULL); - - dbg("send signal to sat-event-downloader result (%d)", rv); - - return rv; -} - -gboolean sat_ui_support_storage_init(Server *server) -{ - TcoreStorage *strg = NULL; - - if(strg_vconf) { - dbg("vconf storage already exists!!"); - return TRUE; - } - - dbg("create vconf "); - - strg = tcore_server_find_storage(server, "vconf"); - if(!strg) { - dbg("cannot find vconf storage!!"); - return FALSE; - } - - strg_vconf = strg; - return TRUE; -} - diff --git a/src/call.c b/src/call.c new file mode 100755 index 0000000..da30ff4 --- /dev/null +++ b/src/call.c @@ -0,0 +1,1964 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + +typedef struct { + struct tnoti_call_status_incoming *incoming; + enum dbus_tapi_sim_slot_id slot_id; +} thread_cb_data; + +static gboolean __thread_dispatch(GMainContext *main_context, gint priority, GSourceFunc cb, gpointer data) +{ + GSource *request_source = NULL; + + if (main_context == NULL || cb == NULL) { + err("Failed to dispatch"); + return FALSE; + } + + request_source = g_idle_source_new(); + g_source_set_callback(request_source, cb, data, NULL); + g_source_set_priority(request_source, priority); + g_source_attach(request_source, main_context); + g_source_unref(request_source); + + return TRUE; +} + +static gboolean __thread_finish_cb(gpointer thread_data) +{ + dbg("Thread %p return is complete", thread_data); + + g_thread_join(thread_data); + + dbg("Clean up of thread %p is complete", thread_data); + + return FALSE; +} + +static gboolean __dispatch_on_new_thread(gchar *name, GThreadFunc thread_cb, gpointer thread_data) +{ + GThread *thread; + if (!name || !thread_cb) { + err("Wrong Input Parameter"); + return FALSE; + } + thread = g_thread_new(name, thread_cb, thread_data); + if (thread == NULL){ + return FALSE; + }else{ + dbg("Thread %p is created for %s", thread, name); + } + + return TRUE; +} + +static gpointer _launch_voice_call(gpointer data) +{ + GThread* selfi = g_thread_self(); + char id[2] = {0, }; + char cli[2] = {0, }; + char clicause[3] = {0, }; + char forward[2] = {0, }; + char active_line[2] = {0, }; + char cna[2] = {0, }; + char number[83] = {0, }; + char name[83] = {0, }; + char slot_info[2] = {0,}; + + bundle *kb = 0; + thread_cb_data *cb_data = (thread_cb_data *)data; + + dbg("enter"); + + snprintf( id, 2, "%d", cb_data->incoming->id ); + dbg("id : [%s]", id ); + snprintf( cli, 2, "%d", cb_data->incoming->cli.mode ); + dbg("cli : [%s]", cli ); + snprintf( clicause, 3, "%d", cb_data->incoming->cli.no_cli_cause ); + dbg("clicause : [%s]", clicause ); + snprintf( number, 83, "%s", cb_data->incoming->cli.number ); + dbg("number : [%s]", number ); + snprintf( forward, 2, "%d", cb_data->incoming->forward ); + dbg("forward : [%s]", forward ); + snprintf( active_line, 2, "%d", cb_data->incoming->active_line ); + dbg("active_line : [%s]", active_line ); + + if ( cb_data->incoming->cna.mode == CALL_CNA_MODE_PRESENT ) + snprintf( cna, 2, "%d", 0 ); + else + snprintf( cna, 2, "%d", 1 ); + + dbg("cna : [%s]", cna ); + snprintf( name, 83, "%s", cb_data->incoming->cna.name ); + dbg("name : [%s]", name ); + + snprintf(slot_info, 2, "%d", cb_data->slot_id); + dbg("slot_id : [%s]", slot_info); + + + kb = bundle_create(); + + /* AppSvc */ + //appsvc_set_operation(kb, APPSVC_OPERATION_CALL); + appsvc_set_pkgname(kb, "org.tizen.call"); + appsvc_set_uri(kb,"tel:MT"); + + appsvc_add_data(kb, "launch-type", "MT"); + appsvc_add_data(kb, "handle", id); + appsvc_add_data(kb, "number", number); + appsvc_add_data(kb, "name_mode", cna); + appsvc_add_data(kb, "name", name); + appsvc_add_data(kb, "cli", cli); + appsvc_add_data(kb, "clicause", clicause); + appsvc_add_data(kb, "fwded", forward); + appsvc_add_data(kb, "activeline", active_line); + appsvc_add_data(kb, "slot_id", slot_info); + + appsvc_run_service(kb, 0, NULL, NULL); + bundle_free(kb); + g_free(cb_data->incoming); + g_free(cb_data); + + if (TRUE == __thread_dispatch(g_main_context_default(), G_PRIORITY_LOW, (GSourceFunc)__thread_finish_cb, selfi)) { + dbg("Thread %p processing is complete", selfi); + } + + return NULL; +} + +static gpointer _launch_video_call(gpointer data) +{ + GThread* selfi = g_thread_self(); + char id[2] = {0, }; + char cli[2] = {0, }; + char forward[2] = {0, }; + char number[83] = {0, }; + char slot_info[2] = {0,}; + int ret = 0; + + bundle *kb = 0; + thread_cb_data *cb_data = (thread_cb_data *)data; + + dbg("enter"); + + snprintf( id, 2, "%d", cb_data->incoming->id ); + dbg("id : [%s]", id ); + snprintf( number, 83, "%s", cb_data->incoming->cli.number ); + dbg("number : [%s]", number ); + snprintf( cli, 2, "%d", cb_data->incoming->cli.mode ); + dbg("cli : [%s]", id ); + snprintf( forward, 2, "%d", cb_data->incoming->forward ); + dbg("forward : [%s]", forward ); + + snprintf(slot_info, 2, "%d", cb_data->slot_id); + dbg("slot_id : [%s]", slot_info); + + kb = bundle_create(); + bundle_add(kb, "KEY_CALL_TYPE", "mt"); + bundle_add(kb, "KEY_CALL_HANDLE", id); + bundle_add(kb, "KEY_CALLING_PARTY_NUMBER", number); + bundle_add(kb, "KEY_CLI_CAUSE", cli); + bundle_add(kb, "KEY_FORWARDED", forward); + bundle_add(kb, "KEY_SLOT_ID", slot_info); + + + ret = aul_launch_app("org.tizen.vtmain", kb); + bundle_free(kb); + + dbg("VT AUL return %d",ret); + + g_free(cb_data->incoming); + g_free(cb_data); + + if (TRUE == __thread_dispatch(g_main_context_default(), G_PRIORITY_LOW, (GSourceFunc)__thread_finish_cb, selfi)) { + dbg("Thread %p processing is complete", selfi); + } + + return NULL; +} + +static gboolean on_call_dial(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_type, gint call_ecc, gchar* call_number, gpointer user_data) +{ + struct treq_call_dial req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + memset(&req, 0x0,sizeof(req)); + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.type = call_type; + req.ecc = call_ecc; + + if ( call_number ){ + g_strlcpy( req.number, call_number, MAX_CALL_DIAL_NUM_LEN); + } + + dbg("dial len : %d, dial str : %s", strlen(req.number), req.number); + + tcore_user_request_set_data( ur, sizeof( struct treq_call_dial ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_DIAL ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_answer(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_id, gint answer_type, gpointer user_data) +{ + struct treq_call_answer req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + req.type = answer_type; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_answer ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_ANSWER ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_end(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_id, gint end_type, gpointer user_data) +{ + struct treq_call_end req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + req.type = end_type; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_end ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_END ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_start_cont_dtmf(TelephonyCall *call, GDBusMethodInvocation *invocation, guchar dtmf_digit, gpointer user_data) +{ + struct treq_call_start_cont_dtmf req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + memset(&req, 0x0,sizeof(req)); + + req.dtmf_digit = dtmf_digit; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_start_cont_dtmf ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_START_CONT_DTMF ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_stop_cont_dtmf(TelephonyCall *call, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + tcore_user_request_set_command( ur, TREQ_CALL_STOP_CONT_DTMF ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_send_burst_dtmf(TelephonyCall *call, GDBusMethodInvocation *invocation, gchar *dtmf_string, gint pulse_width, gint inter_digit_interval, gpointer user_data) +{ + struct treq_call_send_burst_dtmf req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + memset(&req, 0x0,sizeof(req)); + if ( dtmf_string ) { + g_strlcpy( req.dtmf_string, dtmf_string, MAX_CALL_BURST_DTMF_STRING_LEN +1 ); + } + else { + FAIL_RESPONSE (invocation, "Invalid Input"); + err("Invalid DTMF string" ); + tcore_user_request_unref(ur); + return TRUE; + } + + + req.pulse_width = pulse_width; + req.inter_digit_interval = inter_digit_interval; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_send_burst_dtmf ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SEND_BURST_DTMF ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + err("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_active(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_id, gpointer user_data) +{ + struct treq_call_active req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_active ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_ACTIVE ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_hold(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_id, gpointer user_data) +{ + struct treq_call_hold req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_hold ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_HOLD ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_swap(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_id, gpointer user_data) +{ + struct treq_call_swap req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_swap ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SWAP ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_join(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_id, gpointer user_data) +{ + struct treq_call_join req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_join ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_JOIN ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_split(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_id, gpointer user_data) +{ + struct treq_call_split req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_split ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SPLIT ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_transfer(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_id, gpointer user_data) +{ + struct treq_call_transfer req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_transfer ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_TRANSFER ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_deflect(TelephonyCall *call, GDBusMethodInvocation *invocation, gchar *call_number, gpointer user_data) +{ + struct treq_call_deflect req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + if ( call_number ){ + g_strlcpy( req.number, call_number, MAX_CALL_DIAL_NUM_LEN); + } + + tcore_user_request_set_data( ur, sizeof( struct treq_call_deflect ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_DEFLECT ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_get_privacy_mode(TelephonyCall *call, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "r")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + tcore_user_request_set_command( ur, TREQ_CALL_GET_PRIVACY_MODE ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_set_privacy_mode(TelephonyCall *call, GDBusMethodInvocation *invocation, gint privacy_mode, gpointer user_data) +{ + struct treq_call_set_voice_privacy_mode req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "w")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.privacy_mode = privacy_mode; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_set_voice_privacy_mode ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SET_PRIVACY_MODE ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_get_status(TelephonyCall *call, GDBusMethodInvocation *invocation, gint call_id, gpointer user_data ) +{ + struct custom_data *ctx = user_data; + TcorePlugin *plugin = 0; + GSList *o_list = 0; + CoreObject *o = 0; + CallObject *co = 0; + + gchar call_number[MAX_CALL_NUMBER_LEN]; + gint call_type; + gboolean call_direction; + gint call_status; + gboolean call_multiparty_state; + + if (!check_access_control (invocation, AC_CALL, "r")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + + o_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_CALL); + if ( !o_list ) { + dbg("[ error ] co_list : 0"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + + o = (CoreObject *)o_list->data; + g_slist_free(o_list); + + co = tcore_call_object_find_by_id( o, call_id ); + if ( !co ) { + dbg("[ error ] co : 0"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + + memset( call_number, 0, MAX_CALL_NUMBER_LEN ); + tcore_call_object_get_number( co, call_number ); + + call_type = tcore_call_object_get_type( co ); + call_direction = tcore_call_object_get_direction( co ); + + if ( call_direction == TCORE_CALL_DIRECTION_OUTGOING ) { + call_direction = TRUE; + } else { + call_direction = FALSE; + } + + call_status = tcore_call_object_get_status( co ); + call_multiparty_state = tcore_call_object_get_multiparty_state( co ); + telephony_call_complete_get_status(call, invocation, + call_id, call_number, call_type, call_direction, call_status, call_multiparty_state); + + return TRUE; +} + +static gboolean on_call_get_status_all(TelephonyCall *call, GDBusMethodInvocation *invocation, gpointer user_data ) +{ + struct custom_data *ctx = user_data; + TcorePlugin *plugin = 0; + GSList *list = 0; + CoreObject *o = 0; + CallObject *co = 0; + + GVariant *gv = 0; + GVariantBuilder b; + + gint call_id; + gchar call_number[MAX_CALL_NUMBER_LEN]; + gint call_type; + gboolean call_direction; + gint call_status; + gboolean call_multiparty_state; + + int len, i; + + if (!check_access_control (invocation, AC_CALL, "r")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + + list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_CALL); + if ( !list ) { + dbg("[ error ] co_list : 0"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + + o = (CoreObject *)list->data; + g_slist_free(list); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + +#define MAX_CALL_STATUS_NUM 7 + for ( i=0; idata; + if ( !co ) { + dbg("[ error ] call object : 0"); + tmp = tmp->next; + continue; + } + + call_id = tcore_call_object_get_id( co ); + + memset( call_number, 0, MAX_CALL_NUMBER_LEN ); + len = tcore_call_object_get_number( co, call_number ); + if ( !len ) { + dbg("[ check ] no number : (0x%d)", call_id); + } + + call_type = tcore_call_object_get_type( co ); + call_direction = tcore_call_object_get_direction( co ); + + if ( call_direction == TCORE_CALL_DIRECTION_OUTGOING ) { + call_direction = TRUE; + } else { + call_direction = FALSE; + } + + call_status = tcore_call_object_get_status( co ); + call_multiparty_state = tcore_call_object_get_multiparty_state( co ); + + dbg("call_id : %d", call_id); + dbg("call_number_len : %d", len); + dbg("call_number : \"%s\"", call_number); + dbg("call_type : %s (%d)", call_type==TCORE_CALL_TYPE_VOICE?"VOICE": + (call_type==TCORE_CALL_TYPE_VIDEO?"VIDEO": + (call_type==TCORE_CALL_TYPE_E911?"E911": + (call_type==TCORE_CALL_TYPE_STDOTASP?"STDOTASP": + (call_type==TCORE_CALL_TYPE_NONSTDOTASP?"NONSTDOTASP":"UNKNOWN")))), call_type); + dbg("call_direction : %s (%d)", call_direction==TRUE?"MO":"MT", call_direction); + dbg("call_status : %s (%d)", call_status== TCORE_CALL_STATUS_IDLE?"IDLE": + (call_status== TCORE_CALL_STATUS_ACTIVE?"ACTIVE": + (call_status== TCORE_CALL_STATUS_HELD?"HELD": + (call_status== TCORE_CALL_STATUS_DIALING?"DIALING": + (call_status== TCORE_CALL_STATUS_ALERT?"ALERT": + (call_status== TCORE_CALL_STATUS_INCOMING?"INCOMING": + (call_status== TCORE_CALL_STATUS_WAITING?"WAITING":"UNKNOWN")))))), call_status); + dbg("call_multiparty_state : %s (%d)", call_multiparty_state ==1?"T":"F", call_multiparty_state); + + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "call_id", g_variant_new_int32( call_id )); + g_variant_builder_add(&b, "{sv}", "call_number", g_variant_new_string( call_number )); + g_variant_builder_add(&b, "{sv}", "call_type", g_variant_new_int32( call_type )); + g_variant_builder_add(&b, "{sv}", "call_direction", g_variant_new_boolean( call_direction )); + g_variant_builder_add(&b, "{sv}", "call_state", g_variant_new_int32( call_status )); + g_variant_builder_add(&b, "{sv}", "call_multiparty_state", g_variant_new_boolean( call_multiparty_state )); + g_variant_builder_close(&b); + + tmp = g_slist_next( tmp ); + } + g_slist_free(list); + } else { + dbg("[ check ] there is no call on state %s", i== TCORE_CALL_STATUS_IDLE?"(IDLE)": + (i== TCORE_CALL_STATUS_ACTIVE?"(ACTIVE)": + (i== TCORE_CALL_STATUS_HELD?"(HELD)": + (i== TCORE_CALL_STATUS_DIALING?"(DIALING)": + (i== TCORE_CALL_STATUS_ALERT?"(ALERT)": + (i== TCORE_CALL_STATUS_INCOMING?"(INCOMING)": + (i== TCORE_CALL_STATUS_WAITING?"(WAITING)":"(UNKNOWN)"))))))); + } + + } + + gv = g_variant_builder_end(&b); + + telephony_call_complete_get_status_all(call, invocation, gv); + + return TRUE; +} + +static gboolean on_call_set_sound_path(TelephonyCall *call, GDBusMethodInvocation *invocation, gint sound_path, gboolean extra_volume_on, gpointer user_data) +{ + struct treq_call_set_sound_path req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "w")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.path = sound_path; + req.extra_volume_on = extra_volume_on; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_set_sound_path ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SET_SOUND_PATH ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_get_sound_volume_level(TelephonyCall *call, GDBusMethodInvocation *invocation, gint sound_device, gint sound_type, gpointer user_data) +{ + struct treq_call_get_sound_volume_level req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "r")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.device = sound_device; + req.sound = sound_type; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_get_sound_volume_level ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_GET_SOUND_VOLUME_LEVEL ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + + GVariantBuilder b; + GVariant *result = 0; + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "err", g_variant_new_int32(ret)); + g_variant_builder_close(&b); + result = g_variant_builder_end(&b); + + telephony_call_complete_get_sound_volume_level(call, invocation, result, ret ); + + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + return FALSE; + } + + return TRUE; +} + +static gboolean on_call_set_sound_volume_level(TelephonyCall *call, GDBusMethodInvocation *invocation, gint sound_device, gint sound_type, gint sound_volume, gpointer user_data) +{ + struct treq_call_set_sound_volume_level req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "w")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.device = sound_device; + req.sound = sound_type; + req.volume = sound_volume; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_set_sound_volume_level ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SET_SOUND_VOLUME_LEVEL ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_get_sound_mute_status(TelephonyCall *call, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "r")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + tcore_user_request_set_command( ur, TREQ_CALL_GET_SOUND_MUTE_STATUS ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_set_sound_mute_status(TelephonyCall *call, GDBusMethodInvocation *invocation, gint status, gint path, gpointer user_data) +{ + struct treq_call_set_sound_mute_status req; + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "w")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.path = path; + req.status = status; + + dbg("[ check ] path : 0x%x, status : 0x%x", path, status); + + tcore_user_request_set_data( ur, sizeof( struct treq_call_set_sound_mute_status ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SET_SOUND_MUTE_STATUS ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_set_sound_recording(TelephonyCall *call, GDBusMethodInvocation *invocation, gint recording_state, gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct treq_call_set_sound_recording req; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "w")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.state = (gboolean)recording_state; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_set_sound_recording ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SET_SOUND_RECORDING ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_set_sound_equalization(TelephonyCall *call, GDBusMethodInvocation *invocation, gint eq_mode, gint eq_direction, gchar* eq_parameter, gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct treq_call_set_sound_equalization req; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "w")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.mode = eq_mode; + req.direction = (enum telephony_call_sound_direction)eq_direction; + memcpy( (char*)req.parameter, (const char*)eq_parameter, (MAX_CALL_EQ_PARAMETER_SIZE*2) ); + + tcore_user_request_set_data( ur, sizeof( struct treq_call_set_sound_equalization ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SET_SOUND_EQUALIZATION ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_set_sound_noise_reduction(TelephonyCall *call, GDBusMethodInvocation *invocation, gint nr_state, gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct treq_call_set_sound_noise_reduction req; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "w")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.status = (gboolean)nr_state; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_set_sound_noise_reduction ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SET_SOUND_NOISE_REDUCTION ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + telephony_call_complete_set_sound_noise_reduction(call, invocation, ret ); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + return FALSE; + } + + return TRUE; +} + +static gboolean on_call_set_sound_clock_status(TelephonyCall *call, GDBusMethodInvocation *invocation, gboolean clock_status, gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct treq_call_set_sound_clock_status req; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "w")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.status = clock_status; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_set_sound_clock_status ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SET_SOUND_CLOCK_STATUS ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_set_preferred_voice_subscription(TelephonyCall *call, GDBusMethodInvocation *invocation, + gint preferred_subscription, gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct treq_call_set_preferred_voice_subscription req; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "w")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.preferred_subs = preferred_subscription; + + tcore_user_request_set_data( ur, sizeof( struct treq_call_set_preferred_voice_subscription ), &req ); + tcore_user_request_set_command( ur, TREQ_CALL_SET_PREFERRED_VOICE_SUBSCRIPTION ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_get_preferred_voice_subscription(TelephonyCall *call, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_CALL, "r")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + tcore_user_request_set_command( ur, TREQ_CALL_GET_PREFERRED_VOICE_SUBSCRIPTION ); + + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_modify(TelephonyCall *call, + GDBusMethodInvocation *invocation, + gint call_id, gint call_type, gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct treq_call_modify req = {0}; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control(invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + req.call_type = call_type; + tcore_user_request_set_data(ur, sizeof(struct treq_call_modify), &req); + tcore_user_request_set_command(ur, TREQ_CALL_MODIFY); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_call_confirm_modify(TelephonyCall *call, + GDBusMethodInvocation *invocation, + gint call_id, gint confirm_type, gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct treq_call_confirm_modify req = {0}; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control(invocation, AC_CALL, "x")) + return TRUE; + + ur = MAKE_UR(ctx, call, invocation); + + req.id = call_id; + req.confirm_type = confirm_type; + tcore_user_request_set_data(ur, sizeof(struct treq_call_confirm_modify), &req); + tcore_user_request_set_command(ur, TREQ_CALL_CONFIRM_MODIFY); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +gboolean dbus_plugin_setup_call_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonyCall *call; + + call = telephony_call_skeleton_new(); + telephony_object_skeleton_set_call(object, call); + g_object_unref(call); + + g_signal_connect (call, + "handle-dial", + G_CALLBACK (on_call_dial), + ctx); + + g_signal_connect (call, + "handle-answer", + G_CALLBACK (on_call_answer), + ctx); + + g_signal_connect (call, + "handle-end", + G_CALLBACK (on_call_end), + ctx); + + g_signal_connect (call, + "handle-start-cont-dtmf", + G_CALLBACK (on_call_start_cont_dtmf), + ctx); + + g_signal_connect (call, + "handle-stop-cont-dtmf", + G_CALLBACK (on_call_stop_cont_dtmf), + ctx); + + g_signal_connect (call, + "handle-send-burst-dtmf", + G_CALLBACK (on_call_send_burst_dtmf), + ctx); + + g_signal_connect (call, + "handle-active", + G_CALLBACK (on_call_active), + ctx); + + g_signal_connect (call, + "handle-hold", + G_CALLBACK (on_call_hold), + ctx); + + g_signal_connect (call, + "handle-swap", + G_CALLBACK (on_call_swap), + ctx); + + g_signal_connect (call, + "handle-join", + G_CALLBACK (on_call_join), + ctx); + + g_signal_connect (call, + "handle-split", + G_CALLBACK (on_call_split), + ctx); + + g_signal_connect (call, + "handle-transfer", + G_CALLBACK (on_call_transfer), + ctx); + + g_signal_connect (call, + "handle-deflect", + G_CALLBACK (on_call_deflect), + ctx); + + g_signal_connect (call, + "handle-get-privacy-mode", + G_CALLBACK (on_call_get_privacy_mode), + ctx); + + g_signal_connect (call, + "handle-set-privacy-mode", + G_CALLBACK (on_call_set_privacy_mode), + ctx); + + g_signal_connect (call, + "handle-get-status", + G_CALLBACK (on_call_get_status), + ctx); + + g_signal_connect (call, + "handle-get-status-all", + G_CALLBACK (on_call_get_status_all), + ctx); + + + g_signal_connect (call, + "handle-set-sound-path", + G_CALLBACK (on_call_set_sound_path), + ctx); + + g_signal_connect (call, + "handle-get-sound-volume-level", + G_CALLBACK (on_call_get_sound_volume_level), + ctx); + + g_signal_connect (call, + "handle-set-sound-volume-level", + G_CALLBACK (on_call_set_sound_volume_level), + ctx); + + g_signal_connect (call, + "handle-get-sound-mute-status", + G_CALLBACK (on_call_get_sound_mute_status), + ctx); + + g_signal_connect (call, + "handle-set-sound-mute-status", + G_CALLBACK (on_call_set_sound_mute_status), + ctx); + + g_signal_connect (call, + "handle-set-sound-recording", + G_CALLBACK (on_call_set_sound_recording), + ctx); + + g_signal_connect (call, + "handle-set-sound-equalization", + G_CALLBACK (on_call_set_sound_equalization), + ctx); + + g_signal_connect (call, + "handle-set-sound-noise-reduction", + G_CALLBACK (on_call_set_sound_noise_reduction), + ctx); + + g_signal_connect (call, + "handle-set-sound-clock-status", + G_CALLBACK (on_call_set_sound_clock_status), + ctx); + + g_signal_connect (call, + "handle-set-preferred-voice-subscription", + G_CALLBACK (on_call_set_preferred_voice_subscription), + ctx); + + g_signal_connect (call, + "handle-get-preferred-voice-subscription", + G_CALLBACK (on_call_get_preferred_voice_subscription), + ctx); + + g_signal_connect (call, + "handle-modify", + G_CALLBACK (on_call_modify), + ctx); + + g_signal_connect (call, + "handle-confirm-modify", + G_CALLBACK (on_call_confirm_modify), + ctx); + + return TRUE; +} + +gboolean dbus_plugin_call_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data) +{ + int i = 0; + GSList *co_list; + CoreObject *co_call; + char *modem_name = NULL; + TcorePlugin *p = NULL; + + modem_name = tcore_user_request_get_modem_name(ur); + if (!modem_name) + return FALSE; + + p = tcore_server_find_plugin(ctx->server, modem_name); + free(modem_name); + if (!p) + return FALSE; + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_CALL); + if (!co_list) { + return FALSE; + } + + co_call = (CoreObject *)co_list->data; + g_slist_free(co_list); + + if (!co_call) { + return FALSE; + } + + switch (command) { + case TRESP_CALL_DIAL: { + struct tresp_call_dial *resp = (struct tresp_call_dial*)data; + + dbg("receive TRESP_CALL_DIAL (err[%d])", resp->err); + + telephony_call_complete_dial(dbus_info->interface_object, dbus_info->invocation, resp->err); + } break; + + case TRESP_CALL_ANSWER: { + struct tresp_call_answer *resp = (struct tresp_call_answer*)data; + + dbg("receive TRESP_CALL_ANSWER (err[%d] id[%d])", resp->err, resp->id); + + telephony_call_complete_answer(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->id ); + + } break; + + case TRESP_CALL_END: { + struct tresp_call_end *resp = (struct tresp_call_end*)data; + + dbg("receive TRESP_CALL_END (err[%d] id[%d] type[%d])", resp->err, resp->id, resp->type); + + telephony_call_complete_end(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->id, resp->type ); + + } break; + + case TRESP_CALL_HOLD: { + struct tresp_call_hold *resp = (struct tresp_call_hold*)data; + + dbg("receive TRESP_CALL_HOLD (err[%d] id[%d])", resp->err, resp->id); + + telephony_call_complete_hold(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->id ); + + } break; + + case TRESP_CALL_ACTIVE: { + struct tresp_call_active *resp = (struct tresp_call_active*)data; + + dbg("receive TRESP_CALL_ACTIVE (err[%d] id[%d])", resp->err, resp->id); + + telephony_call_complete_active(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->id ); + + } break; + + case TRESP_CALL_SWAP: { + struct tresp_call_swap *resp = (struct tresp_call_swap*)data; + + dbg("receive TRESP_CALL_SWAP (err[%d] id[%d])", resp->err, resp->id); + + telephony_call_complete_swap(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->id ); + + } break; + + case TRESP_CALL_JOIN: { + struct tresp_call_join *resp = (struct tresp_call_join*)data; + + dbg("receive TRESP_CALL_JOIN (err[%d] id[%d])", resp->err, resp->id); + + telephony_call_complete_join(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->id ); + + } break; + + + case TRESP_CALL_SPLIT: { + struct tresp_call_split *resp = (struct tresp_call_split*)data; + + dbg("receive TRESP_CALL_SPLIT (err[%d] id[%d])", resp->err, resp->id); + + telephony_call_complete_split(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->id ); + + } break; + + case TRESP_CALL_DEFLECT: { + struct tresp_call_deflect *resp = (struct tresp_call_deflect*)data; + + dbg("receive TRESP_CALL_DEFLECT (err[%d] id[%d])", resp->err, resp->id); + + telephony_call_complete_deflect(dbus_info->interface_object, dbus_info->invocation, resp->err ); + + } break; + + case TRESP_CALL_TRANSFER: { + struct tresp_call_transfer *resp = (struct tresp_call_transfer*)data; + + dbg("receive TRESP_CALL_TRANSFER (err[%d] id[%d])", resp->err, resp->id); + + telephony_call_complete_transfer(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->id ); + + } break; + + case TRESP_CALL_START_CONT_DTMF: { + struct tresp_call_dtmf *resp = (struct tresp_call_dtmf*)data; + + dbg("receive TRESP_CALL_START_CONT_DTMF (err[%d])", resp->err); + + telephony_call_complete_start_cont_dtmf(dbus_info->interface_object, dbus_info->invocation, resp->err); + } break; + + case TRESP_CALL_STOP_CONT_DTMF: { + struct tresp_call_dtmf *resp = (struct tresp_call_dtmf*)data; + + dbg("receive TRESP_CALL_STOP_CONT_DTMF (err[%d])", resp->err); + + telephony_call_complete_stop_cont_dtmf(dbus_info->interface_object, dbus_info->invocation, resp->err); + } break; + + case TRESP_CALL_SEND_BURST_DTMF: { + struct tresp_call_dtmf *resp = (struct tresp_call_dtmf*)data; + + dbg("receive TRESP_CALL_SEND_BURST_DTMF (err[%d])", resp->err); + + telephony_call_complete_send_burst_dtmf(dbus_info->interface_object, dbus_info->invocation, resp->err); + } break; + + case TRESP_CALL_GET_PRIVACY_MODE: { + struct tresp_call_get_voice_privacy_mode *resp = (struct tresp_call_get_voice_privacy_mode*)data; + + dbg("receive TRESP_CALL_GET_PRIVACY_MODE (err[%d])", resp->err); + dbg("Voice call privacy mode %d",resp->privacy_mode); + + telephony_call_complete_get_privacy_mode(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->privacy_mode); + } break; + + case TRESP_CALL_SET_PRIVACY_MODE: { + struct tresp_call_set_voice_privacy_mode *resp = (struct tresp_call_set_voice_privacy_mode *)data; + + dbg("receive TRESP_CALL_SET_PRIVACY_MODE (err[%d])", resp->err); + + telephony_call_complete_set_privacy_mode(dbus_info->interface_object, dbus_info->invocation, resp->err); + } break; + + case TRESP_CALL_SET_SOUND_PATH: { + struct tresp_call_set_sound_path *resp = (struct tresp_call_set_sound_path*)data; + + dbg("receive TRESP_CALL_SET_SOUND_PATH (err[%d])", resp->err); + + telephony_call_complete_set_sound_path(dbus_info->interface_object, dbus_info->invocation, resp->err); + } break; + + case TRESP_CALL_SET_SOUND_VOLUME_LEVEL: { + struct tresp_call_set_sound_volume_level *resp = (struct tresp_call_set_sound_volume_level*)data; + + dbg("receive TRESP_CALL_SET_SOUND_VOLUME_LEVEL (err[%d])", resp->err); + + telephony_call_complete_set_sound_volume_level(dbus_info->interface_object, dbus_info->invocation, resp->err); + } break; + + case TRESP_CALL_GET_SOUND_VOLUME_LEVEL: { + struct tresp_call_get_sound_volume_level *resp = (struct tresp_call_get_sound_volume_level*)data; + GVariant *result = 0; + GVariantBuilder b; + + dbg("receive TRESP_CALL_GET_SOUND_VOLUME_LEVEL (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + + g_variant_builder_add(&b, "{sv}", "err", g_variant_new_int32(resp->err)); + + if ( !resp->err ) { + + dbg("resp->record_num : [%d]", resp->record_num); + + for ( i=0; irecord_num; i++ ) { + dbg("sound_type : [%d], level:[%d]", resp->record[i].sound, resp->record[i].volume); + g_variant_builder_add(&b, "{sv}", "type", g_variant_new_int32(resp->record[i].sound)); + g_variant_builder_add(&b, "{sv}", "level", g_variant_new_int32(resp->record[i].volume)); + } + + } + + g_variant_builder_close(&b); + + result = g_variant_builder_end(&b); + + telephony_call_complete_get_sound_volume_level(dbus_info->interface_object, dbus_info->invocation, result, resp->err ); + + } break; + + case TRESP_CALL_SET_SOUND_MUTE_STATUS: { + struct tresp_call_set_sound_mute_status *resp = (struct tresp_call_set_sound_mute_status*)data; + + dbg("receive TRESP_CALL_SET_SOUND_MUTE_STATUS (err[%d]", resp->err); + telephony_call_complete_set_sound_mute_status(dbus_info->interface_object, dbus_info->invocation, resp->err); + } break; + + case TRESP_CALL_GET_SOUND_MUTE_STATUS: { + struct tresp_call_get_sound_mute_status *resp = (struct tresp_call_get_sound_mute_status*)data; + + dbg("receive TRESP_CALL_GET_SOUND_MUTE_STATUS (err[%d] path[%d] status[%d])", + resp->err, resp->path, resp->status); + telephony_call_complete_get_sound_mute_status(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->path, resp->status ); + + } break; + + case TRESP_CALL_SET_SOUND_RECORDING: { + struct tresp_call_set_sound_recording *resp = (struct tresp_call_set_sound_recording*)data; + telephony_call_complete_set_sound_recording(dbus_info->interface_object, dbus_info->invocation, resp->err ); + + } break; + + case TRESP_CALL_SET_SOUND_EQUALIZATION: { + struct tresp_call_set_sound_equalization *resp = (struct tresp_call_set_sound_equalization*)data; + telephony_call_complete_set_sound_equalization(dbus_info->interface_object, dbus_info->invocation, resp->err ); + + } break; + + case TRESP_CALL_SET_SOUND_NOISE_REDUCTION: { + struct tresp_call_set_sound_noise_reduction *resp = (struct tresp_call_set_sound_noise_reduction*)data; + telephony_call_complete_set_sound_noise_reduction(dbus_info->interface_object, dbus_info->invocation, resp->err ); + + } break; + + case TRESP_CALL_SET_SOUND_CLOCK_STATUS: { + struct tresp_call_set_sound_clock_status *resp = (struct tresp_call_set_sound_clock_status*)data; + telephony_call_complete_set_sound_clock_status(dbus_info->interface_object, dbus_info->invocation, resp->err ); + + } break; + + case TRESP_CALL_SET_PREFERRED_VOICE_SUBSCRIPTION: { + struct tresp_call_set_preferred_voice_subscription *resp = (struct tresp_call_set_preferred_voice_subscription*)data; + telephony_call_complete_set_preferred_voice_subscription(dbus_info->interface_object, dbus_info->invocation, resp->err ); + } break; + + case TRESP_CALL_GET_PREFERRED_VOICE_SUBSCRIPTION: { + struct tresp_call_get_preferred_voice_subscription *resp = (struct tresp_call_get_preferred_voice_subscription*)data; + telephony_call_complete_get_preferred_voice_subscription(dbus_info->interface_object, dbus_info->invocation, + resp->preferred_subs, resp->err ); + } break; + + case TRESP_CALL_MODIFY: { + const struct tresp_call_modify *resp = data; + telephony_call_complete_modify(dbus_info->interface_object, + dbus_info->invocation, resp->err); + } break; + + case TRESP_CALL_CONFIRM_MODIFY: { + const struct tresp_call_confirm_modify *resp = data; + telephony_call_complete_confirm_modify(dbus_info->interface_object, + dbus_info->invocation, resp->err); + } break; + + default: + dbg("not handled command[%d]", command); + break; + + } + + return TRUE; +} + +gboolean dbus_plugin_call_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data) +{ + TelephonyCall *call; + char *cp_name; + + if (!object) { + dbg("object is 0"); + return FALSE; + } + if (!data) { + err("data is NULL"); + return FALSE; + } + cp_name = (char *)tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source)); + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, cp_name); + + call = telephony_object_peek_call(TELEPHONY_OBJECT(object)); + + switch (command) { + case TNOTI_CALL_STATUS_IDLE: { + struct tnoti_call_status_idle *idle = (struct tnoti_call_status_idle*)data; + + if ( idle->type != CALL_TYPE_VIDEO ) { + dbg("[ check ] call status : idle (voice call)"); + telephony_call_emit_voice_call_status_idle( call, idle->id, idle->cause, 0, 0 ); + } else { + dbg("[ check ] call status : idle (video call)"); + telephony_call_emit_video_call_status_idle( call, idle->id, idle->cause, 0, 0 ); + } + + } break; + case TNOTI_CALL_STATUS_DIALING: { + struct tnoti_call_status_dialing *dialing = (struct tnoti_call_status_dialing*)data; + + if ( dialing->type != CALL_TYPE_VIDEO ) { + dbg("[ check ] call status : dialing (type[%d] id[%d]) (voice call)", dialing->type, dialing->id); + telephony_call_emit_voice_call_status_dialing( call, dialing->id ); + } else { + dbg("[ check ] call status : dialing (type[%d] id[%d]) (video call)", dialing->type, dialing->id); + telephony_call_emit_video_call_status_dialing( call, dialing->id ); + } + + } break; + case TNOTI_CALL_STATUS_ALERT: { + struct tnoti_call_status_alert *alert = (struct tnoti_call_status_alert*)data; + + if ( alert->type != CALL_TYPE_VIDEO ) { + dbg("[ check ] call status : alert (voice call)"); + telephony_call_emit_voice_call_status_alert( call, alert->id ); + } else { + dbg("[ check ] call status : alert (video call)"); + telephony_call_emit_video_call_status_alert( call, alert->id ); + } + + } break; + case TNOTI_CALL_STATUS_ACTIVE: { + struct tnoti_call_status_active *active = (struct tnoti_call_status_active*)data; + + if ( active->type != CALL_TYPE_VIDEO ) { + dbg("[ check ] call status : active (voice call)"); + telephony_call_emit_voice_call_status_active( call, active->id ); + } else { + dbg("[ check ] call status : active (video call)"); + telephony_call_emit_video_call_status_active( call, active->id ); + } + + } break; + case TNOTI_CALL_STATUS_HELD: { + struct tnoti_call_status_held *held = (struct tnoti_call_status_held*)data; + + dbg("[ check ] call status : held"); + telephony_call_emit_voice_call_status_held( call, held->id ); + + } break; + case TNOTI_CALL_STATUS_INCOMING: { + thread_cb_data *cb_data; + + dbg("[ check ] call status : incoming"); + cb_data = g_try_malloc0(sizeof(thread_cb_data)); + + if (!cb_data){ + err("Memory allocation failed"); + return FALSE; + } + cb_data->slot_id = get_sim_slot_id_by_cp_name(cp_name); + cb_data->incoming = g_try_malloc0(sizeof(struct tnoti_call_status_incoming)); + + if (!cb_data->incoming){ + err("Memory allocation failed"); + g_free(cb_data); + return FALSE; + } + memcpy(cb_data->incoming, data, sizeof(struct tnoti_call_status_incoming)); + + if ( ((struct tnoti_call_status_incoming *)data)->type != CALL_TYPE_VIDEO ) { + dbg("[ check ] call status : incoming (voice call)"); + telephony_call_emit_voice_call_status_incoming( call, + cb_data->incoming->id, + cb_data->incoming->cli.mode, + cb_data->incoming->cli.no_cli_cause, + cb_data->incoming->cli.number, + cb_data->incoming->forward, + cb_data->incoming->active_line, + cb_data->incoming->cna.name ); + + if (FALSE == __dispatch_on_new_thread("Voice Call", _launch_voice_call, cb_data)) { + err("Failed to launch Voice Call App"); + g_free(cb_data->incoming); + g_free(cb_data); + } + + } else { + dbg("[ check ] call status : incoming (video call)"); + telephony_call_emit_video_call_status_incoming( call, ((struct tnoti_call_status_incoming *)data)->id ); + + if (FALSE == __dispatch_on_new_thread("Video Call", _launch_video_call, cb_data)) { + err("Failed to launch Video call App"); + g_free(cb_data->incoming); + g_free(cb_data); + } + } + } break; + + case TNOTI_CALL_INFO_WAITING: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_WAITING : (%d)", *id); + telephony_call_emit_waiting( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_FORWARDED: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_FORWARDED : (%d)", *id); + telephony_call_emit_forwarded( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_FORWARDED_CALL: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_FORWARDED_CALL : (%d)", *id); + telephony_call_emit_forwarded_call( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_BARRED_INCOMING: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_BARRED_INCOMING : (%d)", *id); + telephony_call_emit_barred_incoming( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_BARRED_OUTGOING: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_BARRED_OUTGOING : (%d)", *id); + telephony_call_emit_barred_outgoing( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_FORWARD_CONDITIONAL: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_FORWARD_CONDITIONAL : (%d)", *id); + telephony_call_emit_forward_conditional( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_FORWARD_UNCONDITIONAL: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_FORWARD_UNCONDITIONAL : (%d)", *id); + telephony_call_emit_forward_unconditional( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_HELD: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_HELD : (%d)", *id); + telephony_call_emit_call_held( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_ACTIVE: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_ACTIVE : (%d)", *id); + telephony_call_emit_call_active( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_JOINED: { + int *id = (int*)data; + + dbg("[ check ] TNOTI_CALL_INFO_JOINED : (%d)", *id); + telephony_call_emit_call_joined( call, (gint)*id ); + + } break; + + case TNOTI_CALL_INFO_PRIVACY_MODE: { + struct tnoti_call_info_voice_privacy_mode *privacy_info = (struct tnoti_call_info_voice_privacy_mode*)data; + + dbg("[ check ] TNOTI_CALL_INFO_PRIVACY_MODE : privacy mode ", privacy_info->privacy_mode); + telephony_call_emit_call_privacy_mode( call, privacy_info->privacy_mode ); + + } break; + + case TNOTI_CALL_OTASP_STATUS: { + struct tnoti_call_otasp_status *otasp = (struct tnoti_call_otasp_status *)data; + + dbg("[ check ] TNOTI_CALL_OTASP_STATUS : (%d)", otasp->otasp_status); + telephony_call_emit_call_otasp_status( call, otasp->otasp_status ); + + } break; + + case TNOTI_CALL_OTAPA_STATUS: { + struct tnoti_call_otapa_status *otapa = (struct tnoti_call_otapa_status *)data; + + dbg("[ check ] TNOTI_CALL_OTAPA_STATUS : (%d)", otapa->otapa_status); + telephony_call_emit_call_otapa_status( call, otapa->otapa_status ); + + } break; + + case TNOTI_CALL_SIGNAL_INFO: { + + struct tnoti_call_signal_info *sig_info = (struct tnoti_call_signal_info *)data; + unsigned int signal; + if (sig_info->signal_type == CALL_SIGNAL_TYPE_TONE) { + signal = sig_info->signal.sig_tone_type; + } else if(sig_info->signal_type == CALL_SIGNAL_TYPE_ISDN_ALERTING) { + signal = sig_info->signal.sig_isdn_alert_type; + } else if(sig_info->signal_type == CALL_SIGNAL_TYPE_IS54B_ALERTING) { + signal = sig_info->signal.sig_is54b_alert_type; + } else { + err("Unknown Signal type"); + return FALSE; + } + dbg("[ check ] TNOTI_CALL_SIGNAL_INFO : Signal type (%d), Pitch type (%d), Signal %d", sig_info->signal_type, sig_info->pitch_type, signal); + telephony_call_emit_call_signal_info( call, sig_info->signal_type, sig_info->pitch_type, signal); + + } break; + + case TNOTI_CALL_INFO_REC: { + struct tnoti_call_info_rec *noti = (struct tnoti_call_info_rec *)data; + gchar *param = NULL; + if (noti->rec_info.type == CALL_REC_NAME_INFO) { + param = g_strdup(noti->rec_info.data.name); + } else if (noti->rec_info.type == CALL_REC_NUMBER_INFO) { + param = g_strdup(noti->rec_info.data.number); + } else { + err("Unknown rec info type (%d)", noti->rec_info.type); + return FALSE; + } + dbg("[ check ] TNOTI_CALL_INFO_REC : id:(%d) type:(%d), param:(%s)", + noti->rec_info.id, noti->rec_info.type, param); + telephony_call_emit_call_info_rec( call, noti->rec_info.id, noti->rec_info.type, param); + g_free(param); + } break; + + case TNOTI_CALL_SOUND_PATH: { + struct tnoti_call_sound_path *noti = (struct tnoti_call_sound_path*)data; + telephony_call_emit_call_sound_path( call, noti->path ); + + + } break; + + case TNOTI_CALL_SOUND_RINGBACK_TONE: { + struct tnoti_call_sound_ringback_tone *noti = (struct tnoti_call_sound_ringback_tone*)data; + telephony_call_emit_call_sound_ringback_tone( call, (gint)noti->status ); + + } break; + + case TNOTI_CALL_SOUND_WBAMR: { + struct tnoti_call_sound_wbamr *noti = (struct tnoti_call_sound_wbamr*)data; + telephony_call_emit_call_sound_wbamr( call, (gint)noti->status ); + + } break; + + case TNOTI_CALL_SOUND_EQUALIZATION: { + struct tnoti_call_sound_equalization *noti = (struct tnoti_call_sound_equalization*)data; + telephony_call_emit_call_sound_equalization( call, (gint)noti->mode, (gint)noti->direction ); + + } break; + + case TNOTI_CALL_SOUND_NOISE_REDUCTION: { + struct tnoti_call_sound_noise_reduction *noti = (struct tnoti_call_sound_noise_reduction*)data; + telephony_call_emit_call_sound_noise_reduction( call, (gint)noti->status ); + + } break; + + case TNOTI_CALL_SOUND_CLOCK_STATUS: { + struct tnoti_call_sound_clock_status *noti = (struct tnoti_call_sound_clock_status*)data; + telephony_call_emit_call_sound_clock_status( call, noti->status ); + + } break; + + case TNOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION: { + struct tnoti_call_preferred_voice_subscription *noti = (struct tnoti_call_preferred_voice_subscription*)data; + telephony_call_emit_call_preferred_voice_subscription( call, noti->preferred_subs ); + + } break; + + case TNOTI_CALL_MODIFY_REQUEST: { + const struct tnoti_call_modify_request *noti = data; + telephony_call_emit_call_modify_request(call, noti->id, noti->call_type); + } break; + + default: + dbg("not handled command[%d]", command); + break; + } + + return TRUE; +} + diff --git a/src/common.c b/src/common.c new file mode 100755 index 0000000..fd051a9 --- /dev/null +++ b/src/common.c @@ -0,0 +1,197 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + + +static void _free_hook(UserRequest *ur) +{ + struct dbus_request_info *user_info; + + user_info = (struct dbus_request_info *)tcore_user_request_ref_user_info(ur); + if (user_info) + free(user_info); +} + +char *dbus_plugin_get_cp_name_by_object_path(const char *object_path) +{ + if (!object_path) + return NULL; + + if (!g_str_has_prefix(object_path, MY_DBUS_PATH)) { + return NULL; + } + + return (char *)object_path + strlen(MY_DBUS_PATH) + 1; +} + +UserRequest *dbus_plugin_macro_user_request_new(struct custom_data *ctx, void *object, GDBusMethodInvocation *invocation) +{ + UserRequest *ur = NULL; + char *cp_name; + struct dbus_request_info *dbus_info; + + cp_name = GET_CP_NAME(invocation); + dbg("cp_name = [%s]", cp_name); + + ur = tcore_user_request_new(ctx->comm, cp_name); + + dbus_info = calloc(1, sizeof(struct dbus_request_info)); + dbus_info->interface_object = object; + dbus_info->invocation = invocation; + + tcore_user_request_set_user_info(ur, dbus_info); + tcore_user_request_set_free_hook(ur, _free_hook); + + return ur; +} + +gboolean check_access_control (GDBusMethodInvocation *invoc, const char *label, const char *perm) +{ + GDBusConnection *conn; + GVariant *result_pid; + GVariant *param; + GError *error = NULL; + const char *sender; + unsigned int pid; + int ret; + int result = FALSE; + + conn = g_dbus_method_invocation_get_connection (invoc); + if (!conn) { + warn ("access control denied (no connection info)"); + goto OUT; + } + + sender = g_dbus_method_invocation_get_sender (invoc); + + param = g_variant_new ("(s)", sender); + if (!param) { + warn ("access control denied (sender info fail)"); + goto OUT; + } + + result_pid = g_dbus_connection_call_sync (conn, "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + "GetConnectionUnixProcessID", + param, NULL, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); + if (error) { + warn ("access control denied (dbus error: %d(%s))", + error->code, error->message); + g_error_free (error); + goto OUT; + } + + if (!result_pid) { + warn ("access control denied (fail to get pid)"); + goto OUT; + } + + g_variant_get (result_pid, "(u)", &pid); + g_variant_unref (result_pid); + + dbg ("sender: %s pid = %u", sender, pid); + + ret = security_server_check_privilege_by_pid (pid, label, perm); + if (ret != SECURITY_SERVER_API_SUCCESS) { + warn ("pid(%u) access (%s - %s) denied(%d)", pid, label, perm, ret); + } + else + result = TRUE; + +OUT: + if (result == FALSE) { + g_dbus_method_invocation_return_error (invoc, + G_DBUS_ERROR, + G_DBUS_ERROR_ACCESS_DENIED, + "No access rights"); + } + return result; +} + +enum dbus_tapi_sim_slot_id get_sim_slot_id_by_cp_name(char *cp_name) +{ + if(g_str_has_suffix(cp_name , "0")){ + return SIM_SLOT_PRIMARY; + } else if (g_str_has_suffix(cp_name , "1")){ + return SIM_SLOT_SECONDARY; + } else if(g_str_has_suffix(cp_name , "2")){ + return SIM_SLOT_TERTIARY; + } + return SIM_SLOT_PRIMARY; +} + +gboolean dbus_plugin_util_load_xml(char *docname, char *groupname, void **i_doc, void **i_root_node) +{ + xmlDocPtr *doc = (xmlDocPtr *)i_doc; + xmlNodePtr *root_node = (xmlNodePtr *)i_root_node; + + dbg("docname:%s, groupname:%s", docname, groupname); + + *doc = xmlParseFile(docname); + if (*doc) { + *root_node = xmlDocGetRootElement(*doc); + if (*root_node) { + dbg("*root_node->name:%s", (*root_node)->name); + if (0 == xmlStrcmp((*root_node)->name, (const xmlChar *) groupname)) { + *root_node = (*root_node)->xmlChildrenNode; + return TRUE; + } + *root_node = NULL; + } + } + xmlFreeDoc(*doc); + *doc = NULL; + err("Cannot parse doc(%s)", docname); + return FALSE; +} + +void dbus_plugin_util_unload_xml(void **i_doc, void **i_root_node) +{ + xmlDocPtr *doc = (xmlDocPtr *)i_doc; + xmlNodePtr *root_node = (xmlNodePtr *)i_root_node; + + dbg("unloading XML"); + if (doc && *doc) { + xmlFreeDoc(*doc); + *doc = NULL; + if (root_node) + *root_node = NULL; + } +} diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..6d5f9c5 --- /dev/null +++ b/src/common.h @@ -0,0 +1,139 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 __COMMON_H__ +#define __COMMON_H__ + +#include +#include + +#include "type/sim.h" + +#include "generated-code.h" + +#define AC_MANAGER "telephony_framework::api_manager" +#define AC_CALL "telephony_framework::api_call" +#define AC_GPS "telephony_framework::api_gps" +#define AC_MODEM "telephony_framework::api_modem" +#define AC_NETWORK "telephony_framework::api_network" +#define AC_PHONEBOOK "telephony_framework::api_phonebook" +#define AC_SAP "telephony_framework::api_sap" +#define AC_SAT "telephony_framework::api_sat" +#define AC_SIM "telephony_framework::api_sim" +#define AC_SMS "telephony_framework::api_sms" +#define AC_SS "telephony_framework::api_ss" + +#define MY_DBUS_PATH "/org/tizen/telephony" +#define MY_DBUS_SERVICE "org.tizen.telephony" + +enum dbus_tapi_sim_slot_id { + SIM_SLOT_PRIMARY, + SIM_SLOT_SECONDARY, + SIM_SLOT_TERTIARY +}; + +struct cached_data{ + char *cp_name; + gpointer cached_sat_main_menu; +}; + +struct custom_data { + TcorePlugin *plugin; + Communicator *comm; + Server *server; + + GHashTable *objects; + GDBusObjectManagerServer *manager; + TelephonyManager *mgr; + enum tel_sim_status sim1_status; + enum tel_sim_status sim2_status; + int valid_sim_count; + GSList *cached_data; + + gboolean name_acquired; + guint owner_id; +}; + +struct dbus_request_info { + void *interface_object; + GDBusMethodInvocation *invocation; +}; + +#define DEFAULT_MSG_REQ_FAILED "Request failed" + +#define GET_CP_NAME(invocation) dbus_plugin_get_cp_name_by_object_path(g_dbus_method_invocation_get_object_path(invocation)) +#define MAKE_UR(ctx,object,invocation) dbus_plugin_macro_user_request_new(ctx, object, invocation) +#define FAIL_RESPONSE(ivc,msg) g_dbus_method_invocation_return_error (ivc, \ + G_DBUS_ERROR, G_DBUS_ERROR_FAILED, msg); + +char *dbus_plugin_get_cp_name_by_object_path(const char *object_path); +UserRequest *dbus_plugin_macro_user_request_new(struct custom_data *ctx, void *object, GDBusMethodInvocation *invocation); +gboolean check_access_control (GDBusMethodInvocation *invoc, const char *label, const char *perm); + +gboolean dbus_plugin_util_load_xml(char *docname, char *groupname, void **i_doc, void **i_root_node); +void dbus_plugin_util_unload_xml(void **i_doc, void **i_root_node); + +gboolean dbus_plugin_setup_network_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_network_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_network_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_sap_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_sap_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_sap_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_phonebook_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_phonebook_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_phonebook_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_sim_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_sim_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_sim_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_sat_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_sat_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_sat_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_sms_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_sms_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_sms_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_call_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_call_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_call_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_ss_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_ss_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_ss_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_modem_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_modem_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_modem_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_gps_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_gps_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_gps_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +gboolean dbus_plugin_setup_oem_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx); +gboolean dbus_plugin_oem_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data); +gboolean dbus_plugin_oem_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data); + +enum dbus_tapi_sim_slot_id get_sim_slot_id_by_cp_name(char *cp_name); + +#endif diff --git a/src/desc-dbus.c b/src/desc-dbus.c new file mode 100755 index 0000000..d1cd8bc --- /dev/null +++ b/src/desc-dbus.c @@ -0,0 +1,653 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sat_ui_support.h" + +#ifndef PLUGIN_VERSION +#define PLUGIN_VERSION 1 +#endif + +#include "generated-code.h" +#include "common.h" + +static void add_modem(struct custom_data *ctx, TcorePlugin *p) +{ + TelephonyObjectSkeleton *object; + char *path = NULL; + GSList *co_list; + const char *cp_name; + + dbg("Entry"); + + /* Get CP Name */ + cp_name = tcore_server_get_cp_name_by_plugin(p); + if (cp_name == NULL) { + err("CP Name is NULL"); + return; + } + + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + dbg("PATH: [%s]", path); + + object = g_hash_table_lookup(ctx->objects, path); + if (object) { + dbg("DBUS interface object already created (object: %p)", object); + goto OUT; + } + + object = telephony_object_skeleton_new(path); + dbg("New DBUS object created (object: [%p])", object); + g_hash_table_insert(ctx->objects, g_strdup(path), object); + + /* Add interfaces */ + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_MODEM); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_modem_interface(object, ctx); + } + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_CALL); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_call_interface(object, ctx); + } + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_NETWORK); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_network_interface(object, ctx); + } + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_SS); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_ss_interface(object, ctx); + } + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_SMS); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_sms_interface(object, ctx); + } + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_SAT); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_sat_interface(object, ctx); + } + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_PHONEBOOK); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_phonebook_interface(object, ctx); + } + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_SAP); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_sap_interface(object, ctx); + } + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_SIM); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_sim_interface(object, ctx); + } + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_GPS); + if (co_list) { + g_slist_free(co_list); + dbus_plugin_setup_gps_interface(object, ctx); + } + dbus_plugin_setup_oem_interface(object, ctx); + /* Export the Object to Manager */ + g_dbus_object_manager_server_export (ctx->manager, G_DBUS_OBJECT_SKELETON (object)); + + +OUT: + /* Freeing memory */ + g_free(path); +} + +static void refresh_object(struct custom_data *ctx) +{ + GSList *modem_plg_list; + TcorePlugin *modem_plg; + GSList *cur; + + if (!ctx->manager) { + dbg("Telephony not ready..."); + return; + } + + modem_plg_list = tcore_server_get_modem_plugin_list(ctx->server); + for (cur = modem_plg_list; cur; cur = cur->next) { + modem_plg = cur->data; + if (modem_plg == NULL) { + dbg("No Modem Plug-in"); + continue; + } + + /* Add modem */ + add_modem(ctx, modem_plg); + } + g_slist_free(modem_plg_list); +} + +static TReturn send_response(Communicator *comm, UserRequest *ur, enum tcore_response_command command, unsigned int data_len, const void *data) +{ + struct custom_data *ctx = NULL; + struct dbus_request_info *dbus_info; + gboolean ret = FALSE; + + dbg("Response Command = [0x%x], data_len = %d", command, data_len); + + + ctx = tcore_communicator_ref_user_data(comm); + if (!ctx) { + dbg("user_data is NULL"); + return TCORE_RETURN_EINVAL; + } + + dbus_info = (struct dbus_request_info *)tcore_user_request_ref_user_info(ur); + if (!dbus_info) { + dbg("dbus_info is NULL"); + return TCORE_RETURN_EINVAL; + } + + if (!data) { + g_dbus_method_invocation_return_error (dbus_info->invocation, + G_DBUS_ERROR, + G_DBUS_ERROR_FAILED, + "Request failed"); + return TCORE_RETURN_SUCCESS; + } + + switch (command & (TCORE_RESPONSE | 0x0FF00000)) { + case TRESP_CALL: + ret = dbus_plugin_call_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_SS: + ret = dbus_plugin_ss_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_PS: + break; + + case TRESP_SIM: + ret = dbus_plugin_sim_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_SAP: + ret = dbus_plugin_sap_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_PHONEBOOK: + ret = dbus_plugin_phonebook_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_MODEM: + ret = dbus_plugin_modem_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_SMS: + ret = dbus_plugin_sms_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_SAT: + ret = dbus_plugin_sat_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_CUSTOM: + ret = dbus_plugin_oem_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_NETWORK: + ret = dbus_plugin_network_response(ctx, ur, dbus_info, command, data_len, data); + break; + + case TRESP_GPS: + ret = dbus_plugin_gps_response(ctx, ur, dbus_info, command, data_len, data); + break; + + default: + warn("unknown command (0x%x)", command); + break; + } + + if (ret == TRUE) + return TCORE_RETURN_SUCCESS; + else + return TCORE_RETURN_FAILURE; +} + +static TReturn send_notification(Communicator *comm, CoreObject *source, enum tcore_notification_command command, unsigned int data_len, const void *data) +{ + struct custom_data *ctx = NULL; + unsigned int noti = 0; + gboolean ret = FALSE; + + ctx = tcore_communicator_ref_user_data(comm); + if (ctx == NULL) { + err("user_data is NULL"); + return TCORE_RETURN_EINVAL; + } + + noti = (command & (TCORE_NOTIFICATION | 0x0FF00000)); + + /* + * Notifications are classified into - + * Server (System) notifications + * Module notifications + */ + if (noti == TNOTI_SERVER) { + dbg("Server (System) Notification"); + + switch (command) { + case TNOTI_SERVER_ADDED_MODEM_PLUGIN: { + const char *cp_name; + + cp_name = tcore_server_get_cp_name_by_plugin((TcorePlugin*)data); + dbg("Modem Plug-in (%s) is added... Exporting interfaces for the modem", cp_name); + add_modem(ctx, (TcorePlugin*)data); + + ret = TRUE; + break; + } + + case TNOTI_SERVER_ADDED_MODEM_PLUGIN_COMPLETED: { + Storage *strg; + gboolean b_set; + int *count; + + if (data == NULL) { + err("data is NULL"); + break; + } + + count = (int *)data; + dbg("[%d] Modem plug-ins are added...", *count); + + strg = tcore_server_find_storage(ctx->server, "vconf"); + + b_set = tcore_storage_set_int(strg, STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT, *count); + if (b_set == FALSE) { + err("Fail to set the sim slot count vconf"); + + /* Reset STORAGE_KEY_TELEPHONY_READY */ + b_set = tcore_storage_set_bool(strg, STORAGE_KEY_TELEPHONY_READY, FALSE); + warn("Reset TELEPHONY_READY!!!"); + } else { + if (ctx->name_acquired == TRUE + && tcore_storage_get_bool(strg, STORAGE_KEY_TELEPHONY_READY) == FALSE) { + b_set = tcore_storage_set_bool(strg, STORAGE_KEY_TELEPHONY_READY, TRUE); + if (b_set == FALSE) { + err("Fail to set telephony ready"); + + /* Reset STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT */ + b_set = tcore_storage_set_int(strg, STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT, -1); + warn("Reset STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT!!!"); + } else { +#ifdef ENABLE_KPI_LOGS + TIME_CHECK("Setting VCONFKEY_TELEPHONY_READY to TRUE"); +#else + msg("Setting VCONFKEY_TELEPHONY_READY to TRUE"); +#endif + } + } + dbg("Bus acquired...[%s]", (ctx->name_acquired)?"YES":"NO" ); + } + ret = TRUE; + break; + } + + default: + warn("Unsupported System notification: (0x%x)", command); + break; + } + } + else { + TelephonyObjectSkeleton *object; + const char *cp_name; + char *path; + + cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source)); + if (cp_name == NULL) { + err("CP name is NULL"); + return TCORE_RETURN_FAILURE; + } + + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + + dbg("[%s]:(cmd[0x%x] data[%p] len[%d] obj[%p])", + cp_name, command, data, data_len, object); + + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + return TCORE_RETURN_FAILURE; + } + + switch (noti) { + case TNOTI_CALL: + ret = dbus_plugin_call_notification(ctx, source, object, command, data_len, data); + break; + + case TNOTI_SS: + ret = dbus_plugin_ss_notification(ctx, source, object, command, data_len, data); + break; + + case TNOTI_PS: + warn("PS Notification (0x%x)... Not handled!!!", noti); + break; + + case TNOTI_SIM: + ret = dbus_plugin_sim_notification(ctx, source, object, command, data_len, data); + break; + + case TNOTI_SAP: + ret = dbus_plugin_sap_notification(ctx, source, object, command, data_len, data); + break; + + case TNOTI_PHONEBOOK: + ret = dbus_plugin_phonebook_notification(ctx, source, object, command, data_len, data); + break; + + case TNOTI_MODEM: + ret = dbus_plugin_modem_notification(ctx, source, object, command, data_len, data); + break; + + case TNOTI_SMS: + ret = dbus_plugin_sms_notification(ctx, source, object, command, data_len, data); + break; + + case TNOTI_SAT: + ret = dbus_plugin_sat_notification(ctx, source, object, command, data_len, data); + break; + + case TNOTI_NETWORK: + ret = dbus_plugin_network_notification(ctx, source, object, command, data_len, data); + break; + + case TNOTI_GPS: + ret = dbus_plugin_gps_notification(ctx, source, object, command, data_len, data); + break; + + default: + if ((command & (TCORE_NOTIFICATION | 0x0F000000)) == (TNOTI_CUSTOM)) { + dbg("Custom Notification: [0x%x]", command); + ret = dbus_plugin_oem_notification(ctx, source, object, command, data_len, data); + } else { + warn("Unknown/Unhandled Notification: [0x%x]", command); + } + + break; + } + } + + if (ret == TRUE) + return TCORE_RETURN_SUCCESS; + else + return TCORE_RETURN_FAILURE; +} + + +static gboolean +on_manager_getmodems (TelephonyManager *mgr, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + GSList *cp_name_list; + gchar **list; + const char *name = NULL; + int count; + dbg("Entry"); + + cp_name_list = tcore_server_get_cp_name_list(ctx->server); + if (cp_name_list == NULL) { + telephony_manager_complete_get_modems(mgr, invocation, &name); + return TRUE; + } + + count = g_slist_length(cp_name_list); + list = g_try_malloc0(sizeof(gchar *) * (count+1)); + + count = 0; + for ( ; cp_name_list ; cp_name_list = cp_name_list->next) { + name = cp_name_list->data; + list[count] = g_strdup(name); + dbg("list[%d]: %s", count, list[count]); + count++; + } + + telephony_manager_complete_get_modems(mgr, invocation, (const gchar **)list); + + /* Free memory */ + for (;count >= 0; count--) + g_free(list[count]); + + g_free(list); + + /* Freeing the received list of CP names */ + g_slist_free_full(cp_name_list, g_free); + + return TRUE; +} + +static void on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data) +{ + info("Lost the name %s on the session bus\n", name); +} + +static void on_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) +{ + struct custom_data *ctx = user_data; + Storage *strg; + gboolean b_set; + int count; + + ctx->name_acquired = TRUE; /* Setting Bus acquried flag after Bus name is acquired */ + + info("Acquired the name %s on the session bus", name); + strg = tcore_server_find_storage(ctx->server, "vconf"); + + count = tcore_storage_get_int(strg, STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT); + if (count < 0) { + err("SIM slot count not yet set"); + } else { + if (tcore_storage_get_bool(strg, STORAGE_KEY_TELEPHONY_READY) == FALSE) { + b_set = tcore_storage_set_bool(strg, STORAGE_KEY_TELEPHONY_READY, TRUE); + if (b_set == FALSE) { + err("Fail to set telephony ready"); + + /* Reset STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT */ + b_set = tcore_storage_set_int(strg, STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT, -1); + warn("Reset STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT!!!"); + } else { +#ifdef ENABLE_KPI_LOGS + TIME_CHECK("Setting VCONFKEY_TELEPHONY_READY to TRUE"); +#else + msg("Setting VCONFKEY_TELEPHONY_READY to TRUE"); +#endif + } + } + } +} + +static void on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) +{ + struct custom_data *ctx = user_data; + + info("dbus registered"); + + refresh_object(ctx); + + /* Add interface to default object path */ + ctx->mgr = telephony_manager_skeleton_new(); + g_signal_connect (ctx->mgr, + "handle-get-modems", + G_CALLBACK (on_manager_getmodems), + ctx); /* user_data */ + + g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(ctx->mgr), conn, MY_DBUS_PATH, NULL); + + g_dbus_object_manager_server_set_connection (ctx->manager, conn); + + dbg("Aquire DBUS - COMPLETE"); + + +} + +struct tcore_communitor_operations ops = { + .send_response = send_response, + .send_notification = send_notification, +}; + +static gboolean on_load() +{ + dbg("i'm load!"); + + return TRUE; +} + +static gboolean on_init(TcorePlugin *p) +{ + Communicator *comm; + struct custom_data *data; + guint id; + + if (!p) + return FALSE; + + dbg("i'm init!"); + + data = calloc(1, sizeof(struct custom_data)); + if (!data) { + return FALSE; + } + + data->plugin = p; + + comm = tcore_communicator_new(p, "dbus", &ops); + tcore_communicator_link_user_data(comm, data); + + data->comm = comm; + data->server = tcore_plugin_ref_server(p); + + data->objects = g_hash_table_new(g_str_hash, g_str_equal); + data->cached_data = NULL; + + dbg("data = %p", data); + + id = g_bus_own_name (G_BUS_TYPE_SYSTEM, + MY_DBUS_SERVICE, + G_BUS_NAME_OWNER_FLAGS_REPLACE, + on_bus_acquired, + on_name_acquired, on_name_lost, + data, + NULL); + + data->owner_id = id; + dbg("owner id=[%d]", data->owner_id); + + data->manager = g_dbus_object_manager_server_new (MY_DBUS_PATH); + refresh_object(data); + + return TRUE; +} + +static void on_unload(TcorePlugin *p) +{ + struct custom_data *data = 0; + Communicator *comm = 0; + Server *s = tcore_plugin_ref_server(p); + GSList *list = NULL; + struct cached_data *object = NULL; + + if (!p) + return; + + dbg("i'm unload"); + + comm = tcore_server_find_communicator(s, "dbus"); + if (!comm) + return; + + data = tcore_communicator_ref_user_data(comm); + if (!data) + return; + + if(data->owner_id > 0) { + g_bus_unown_name(data->owner_id); + } + + g_hash_table_destroy(data->objects); + + for (list = data->cached_data; list; list = list->next) { + object = (struct cached_data *)list->data; + if (object == NULL) + continue; + + g_variant_unref(object->cached_sat_main_menu); + g_free(object->cp_name); + g_free(object); + } + g_slist_free(data->cached_data); + + free(data); + + tcore_server_remove_communicator(s, comm); +} + +EXPORT_API struct tcore_plugin_define_desc plugin_define_desc = +{ + .name = "NEW_DBUS_COMMUNICATOR", + .priority = TCORE_PLUGIN_PRIORITY_HIGH, + .version = PLUGIN_VERSION, + .load = on_load, + .init = on_init, + .unload = on_unload +}; diff --git a/src/desc.c b/src/desc.c deleted file mode 100644 index 5c4eef9..0000000 --- a/src/desc.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_main.h" -#include "dtapi_util.h" - -#include -#include -#include - -/** @todo Static assert if True */ -#ifndef PLUGIN_VERSION -#define PLUGIN_VERSION 1 -#endif - -static gboolean on_load() -{ - dbg("i'm load"); - return TRUE; -} - -static gboolean on_init(TcorePlugin *plugin) -{ - gboolean result = FALSE; - tcore_check_return_value_assert(NULL != plugin, FALSE); - - result = dtapi_plugin_init(plugin); - if (result == FALSE) { - err("Failed intializing the plugin"); - } else { - dbg("dbus-tapi-plugin INIT SUCCESS"); - } - - return result; -} - -static void on_unload(TcorePlugin *plugin) -{ - tcore_check_return_assert(NULL != plugin); - - dtapi_plugin_deinit(plugin); - dbg("dbus-tapi-plugin UNLOAD COMPLETE"); -} - -/* Plugin Descriptor */ -EXPORT_API struct tcore_plugin_define_desc plugin_define_desc = { - .name = "DBUS_COMMUNICATOR", - .priority = TCORE_PLUGIN_PRIORITY_HIGH, - .version = PLUGIN_VERSION, - .load = on_load, - .init = on_init, - .unload = on_unload -}; diff --git a/src/dtapi_call.c b/src/dtapi_call.c deleted file mode 100644 index 4004c24..0000000 --- a/src/dtapi_call.c +++ /dev/null @@ -1,1542 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_call.h" -#include "dtapi_util.h" - -#include -#include -#include -#include -#include -#include -#include - -#define AC_CALL "telephony_framework::api_call" - -static void _launch_voice_call(const TelCallIncomingInfo *incoming_call_info) -{ - char id[2] = {0, }; - char cli[2] = {0, }; - char forward[2] = {0, }; - char active_line[2] = {0, }; - char cna[2] = {0, }; - char number[TEL_CALL_CALLING_NUMBER_LEN_MAX + 1] = {0, }; - char name[TEL_CALL_CALLING_NAME_LEN_MAX + 1] = {0, }; - - bundle *kb = 0; - - snprintf(id, 2, "%d", incoming_call_info->call_id); - dbg("id : [%s]", id ); - snprintf(cli, 2, "%d", incoming_call_info->cli_validity); - dbg("cli : [%s]", cli ); - snprintf(number, TEL_CALL_CALLING_NUMBER_LEN_MAX + 1, "%s", incoming_call_info->number); - dbg("number : [%s]", number ); - snprintf(forward, 2, "%d", incoming_call_info->forward); - dbg("forward : [%s]", forward ); - snprintf(active_line, 2, "%d", incoming_call_info->active_line); - dbg("active_line : [%s]", active_line ); - - if (incoming_call_info->cni_validity == TEL_CALL_CNI_VALIDITY_VALID) - snprintf(cna, 2, "%d", 0); - else - snprintf(cna, 2, "%d", 1); - - dbg("cna : [%s]", cna); - snprintf(name, TEL_CALL_CALLING_NAME_LEN_MAX + 1, "%s", incoming_call_info->name); - dbg("name : [%s]", name); - - kb = bundle_create(); - if(!kb) { - err("bundle creation failed"); - return; - } - /* AppSvc */ - appsvc_set_operation(kb, APPSVC_OPERATION_CALL); - appsvc_set_uri(kb,"tel:MT"); - - appsvc_add_data(kb, "launch-type", "MT"); - appsvc_add_data(kb, "handle", id); - appsvc_add_data(kb, "number", number); - appsvc_add_data(kb, "name_mode", cna); - appsvc_add_data(kb, "name", name); - appsvc_add_data(kb, "clicause", cli); - appsvc_add_data(kb, "fwded", forward); - appsvc_add_data(kb, "activeline", active_line); - - appsvc_run_service(kb, 0, NULL, NULL); - bundle_free(kb); -} - -static void -_launch_video_call(const TelCallIncomingInfo *incoming_call_info) -{ - char id[2] = {0, }; - char cli[2] = {0, }; - char forward[2] = {0, }; - char number[TEL_CALL_CALLING_NUMBER_LEN_MAX + 1] = {0, }; - int ret = 0; - bundle *kb = 0; - - snprintf( id, 2, "%d", incoming_call_info->call_id); - dbg("id : [%s]", id ); - snprintf( number, TEL_CALL_CALLING_NUMBER_LEN_MAX + 1, "%s", incoming_call_info->number); - dbg("number : [%s]", number ); - snprintf( cli, 2, "%d", incoming_call_info->cli_validity); - dbg("cli : [%s]", cli ); - snprintf( forward, 2, "%d", incoming_call_info->forward); - dbg("forward : [%s]", forward ); - - kb = bundle_create(); - if(!kb) { - err("bundle creation failed"); - return; - } - bundle_add(kb, "KEY_CALL_TYPE", "mt"); - bundle_add(kb, "KEY_CALL_HANDLE", id); - bundle_add(kb, "KEY_CALLING_PARTY_NUMBER", number); - bundle_add(kb, "KEY_CLI_CAUSE", cli); - bundle_add(kb, "KEY_FORWARDED", forward); - - ret = aul_launch_app("com.samsung.vtmain", kb); - bundle_free(kb); - - dbg("VT AUL return: [%d]",ret); -} - -/* To be moved inside libtcore */ -static gboolean -_check_call_type(TelCallType type) -{ - switch (type) { - case TEL_CALL_TYPE_VOICE: - case TEL_CALL_TYPE_VIDEO: - case TEL_CALL_TYPE_E911: - return TRUE; - } - - return FALSE; -} - -/* To be moved inside libtcore */ -static gboolean -_check_call_ecc(TelCallEmergencyCategory ecc) -{ - switch (ecc) { - case TEL_CALL_ECC_DEFAULT: - case TEL_CALL_ECC_POLICE: - case TEL_CALL_ECC_AMBULANCE: - case TEL_CALL_ECC_FIREBRIGADE: - case TEL_CALL_ECC_MARINEGUARD: - case TEL_CALL_ECC_MOUNTAINRESCUE: - case TEL_CALL_ECC_MANUAL_ECALL: - case TEL_CALL_ECC_AUTO_ECALL: - return TRUE; - } - - return FALSE; -} - -/* To be moved inside libtcore */ -static gboolean -_check_answer_type(TelCallAnswerType type) -{ - switch (type) { - case TEL_CALL_ANSWER_ACCEPT: - case TEL_CALL_ANSWER_REJECT: - case TEL_CALL_ANSWER_REPLACE: - case TEL_CALL_ANSWER_HOLD_AND_ACCEPT: - return TRUE; - } - - return FALSE; -} - -/* To be moved inside libtcore */ -static gboolean -_check_end_type(TelCallAnswerType type) -{ - switch (type) { - case TEL_CALL_END: - case TEL_CALL_END_ALL: - case TEL_CALL_END_ACTIVE_ALL: - case TEL_CALL_END_HOLD_ALL: - return TRUE; - } - - return FALSE; -} - -static void __add_call_status_to_builder(CallObject *co, GVariantBuilder *variant_builder) -{ - guint call_id; - TelCallType call_type; - TelCallState call_state; - gboolean mo_call; - gboolean mpty; - TelCallCliValidity cli_validity; - gchar num[TEL_CALL_CALLING_NUMBER_LEN_MAX + 1] = {0, }; - TelCallCniValidity cni_validity; - gchar name[TEL_CALL_CALLING_NAME_LEN_MAX + 1] = {0, }; - gboolean forward; - TelCallActiveLine active_line; - - g_variant_builder_open(variant_builder, G_VARIANT_TYPE("a{sv}")); - if (co != NULL) { - /* - * Ignore return values of tcore_call_object_get/set_xxx() - * as in this case return value is always TRUE. - */ - tcore_call_object_get_id(co, &call_id); - g_variant_builder_add(variant_builder, "{sv}", - "call_id", g_variant_new_uint32(call_id)); - - tcore_call_object_get_call_type(co, &call_type); - g_variant_builder_add(variant_builder, "{sv}", - "call_type", g_variant_new_int32(call_type)); - - tcore_call_object_get_direction(co, &mo_call); - g_variant_builder_add(variant_builder, "{sv}", - "mo_call", g_variant_new_boolean(mo_call)); - - tcore_call_object_get_state(co, &call_state); - g_variant_builder_add(variant_builder, "{sv}", - "call_state", g_variant_new_int32(call_state)); - - tcore_call_object_get_multiparty_state(co, &mpty); - g_variant_builder_add(variant_builder, "{sv}", - "mpty", g_variant_new_boolean(mpty)); - - tcore_call_object_get_active_line(co, &active_line); - g_variant_builder_add(variant_builder, "{sv}", - "active_line", g_variant_new_int32(active_line)); - - tcore_call_object_get_cli_validity(co, &cli_validity); - g_variant_builder_add(variant_builder, "{sv}", - "cli_validity", g_variant_new_int32(cli_validity)); - - tcore_call_object_get_number(co, num); - g_variant_builder_add(variant_builder, "{sv}", - "num", g_variant_new_string(num)); - /* the following data will be valid only in case of MT call */ - if (mo_call == FALSE) { - tcore_call_object_get_cni_validity(co, &cni_validity); - g_variant_builder_add(variant_builder, "{sv}", - "cni_validity", g_variant_new_int32(cni_validity)); - - tcore_call_object_get_name(co, name); - g_variant_builder_add(variant_builder, "{sv}", - "name", g_variant_new_string(name)); - - tcore_call_object_get_mt_forward(co, &forward); - g_variant_builder_add(variant_builder, "{sv}", - "forward", g_variant_new_boolean(forward)); - } - } - g_variant_builder_close(variant_builder); -} - -static void -on_response_dtapi_call_dial(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call dial response result: [%d]", result); - telephony_call_complete_dial(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_dial(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gint call_type, - gint ecc, - gchar* call_number, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelCallDial req; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - if ((_check_call_type(call_type) == FALSE) - || ((call_type == TEL_CALL_TYPE_E911) - && (_check_call_ecc(ecc) == FALSE)) - || ((call_type != TEL_CALL_TYPE_E911) - && (call_number == NULL || strlen(call_number) == 0 - || strlen(call_number) > TEL_CALL_CALLING_NUMBER_LEN_MAX))) { - - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid parameter"); - return TRUE; - } - - req.call_type = call_type; - req.ecc = ecc; - memcpy( req.number, call_number, strlen(call_number)); - req.number[strlen(call_number)] = '\0'; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_DIAL, - &req, sizeof(TelCallDial), on_response_dtapi_call_dial, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_answer(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call answer response result: [%d]", result); - telephony_call_complete_answer(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_answer(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gint answer_type, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - if (!_check_answer_type(answer_type)) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid answer type"); - return TRUE; - } - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_ANSWER, - &answer_type, sizeof(gint), on_response_dtapi_call_answer, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_end(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call end response result: [%d]", result); - telephony_call_complete_end(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_end(TelephonyCall *call, - GDBusMethodInvocation *invocation, - guint call_id, - gint end_type, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelCallEnd req; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - if (!_check_end_type(end_type)) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid parameter"); - return TRUE; - } - - req.call_id= call_id; - req.end_type= end_type; - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_END, - &req, sizeof(TelCallEnd), on_response_dtapi_call_end, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_send_dtmf(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call send dtmf response result: [%d]", result); - telephony_call_complete_send_dtmf(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_send_dtmf(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gchar *dtmf_str, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - if ((dtmf_str == NULL) || (strlen(dtmf_str) == 0)) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid parameter"); - return TRUE; - } - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_SEND_DTMF, - dtmf_str, strlen(dtmf_str) + 1, on_response_dtapi_call_send_dtmf, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_hold(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call hold response result: [%d]", result); - telephony_call_complete_hold(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_hold(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_CALL_HOLD, NULL, - 0, on_response_dtapi_call_hold, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_active(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call active response result: [%d]", result); - telephony_call_complete_active(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_active(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_ACTIVE, NULL, 0, - on_response_dtapi_call_active, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_swap(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call swap response result: [%d]", result); - telephony_call_complete_swap(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_swap(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_SWAP, NULL, - 0, on_response_dtapi_call_swap, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_join(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call join response result: [%d]", result); - telephony_call_complete_join(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_join(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_JOIN, - NULL, 0, on_response_dtapi_call_join, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_split(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call split response result: [%d]", result); - telephony_call_complete_split(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_split(TelephonyCall *call, - GDBusMethodInvocation *invocation, - guint call_id, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_CALL_SPLIT, &call_id, - sizeof(guint), on_response_dtapi_call_split, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_transfer(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call transfer response result: [%d]", result); - telephony_call_complete_transfer(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_transfer(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_TRANSFER, - NULL, 0, on_response_dtapi_call_transfer, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_deflect(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call deflect response result: [%d]", result); - telephony_call_complete_deflect(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_deflect(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gchar *deflect_to, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - if ((deflect_to == NULL) || ((strlen(deflect_to) == 0) - || (strlen(deflect_to) > TEL_CALL_CALLING_NUMBER_LEN_MAX))) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid parameter"); - return TRUE; - } - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_DEFLECT, - deflect_to, strlen(deflect_to) + 1, on_response_dtapi_call_deflect, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_set_active_line(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call set active line response result: [%d]", result); - telephony_call_complete_set_active_line(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_set_active_line(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gint active_line, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_SET_ACTIVE_LINE, - &active_line, sizeof(gint), on_response_dtapi_call_set_active_line, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_get_active_line(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call get active line response result : [%d]", result); - telephony_call_complete_get_active_line(rsp_cb_data->interface_object, rsp_cb_data->invocation, - result, GPOINTER_TO_INT(data)); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_get_active_line(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_GET_ACTIVE_LINE, NULL, - 0, on_response_dtapi_call_get_active_line, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static gboolean -dtapi_call_get_status(TelephonyCall *call, - GDBusMethodInvocation *invocation, - guint call_id, - gpointer user_data) -{ - TcorePlugin *plugin = user_data; - CoreObject *o = NULL; - CallObject *co = NULL; - TelCallType call_type; - TelCallState call_state; - gboolean mo_call; - gboolean mpty; - TelCallCliValidity cli_validity; - gchar num[TEL_CALL_CALLING_NUMBER_LEN_MAX + 1] = {0, }; - TelCallCniValidity cni_validity = TEL_CALL_CNI_VALIDITY_NOT_AVAILABLE; - gchar name[TEL_CALL_CALLING_NAME_LEN_MAX + 1] = {0, }; - gboolean forward = FALSE; - TelCallActiveLine active_line; - - if (dtapi_check_access_control(invocation, AC_CALL, "r") == FALSE) - return TRUE; - - o = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL); - if (!o) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid core object"); - return TRUE; - } - co = tcore_call_object_find_by_id(o, call_id); - if (!co) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "No Call Object"); - return TRUE; - } - - tcore_call_object_get_call_type(co, &call_type); - tcore_call_object_get_direction(co, &mo_call); - tcore_call_object_get_state(co, &call_state); - tcore_call_object_get_multiparty_state(co, &mpty); - tcore_call_object_get_active_line(co, &active_line); - tcore_call_object_get_cli_validity(co, &cli_validity); - tcore_call_object_get_number(co, num); - - /* the following data will be valid only in case of MT call */ - if(mo_call == FALSE){ - tcore_call_object_get_cni_validity(co, &cni_validity); - tcore_call_object_get_name(co, name); - tcore_call_object_get_mt_forward(co, &forward); - } - - telephony_call_complete_get_status(call, invocation, - TEL_RETURN_SUCCESS, call_id, call_type, - call_state, mo_call, mpty, - cli_validity, num, cni_validity, name, - forward, active_line); - - return TRUE; -} - -static gboolean -dtapi_call_get_status_all(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - TcorePlugin *plugin = user_data; - GSList *list = NULL; - CoreObject *co = NULL; - GVariant *gv = NULL; - GVariantBuilder b; - TelCallState state; - guint count = 0; - - if (dtapi_check_access_control(invocation, AC_CALL, "r") == FALSE) - return TRUE; - - /* OSP access this function already, can't modify this immediately */ - if (!plugin) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid plugin"); - return TRUE; - } - - co = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL); - if (!co) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid core object"); - return TRUE; - } - - g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); - for (state = TEL_CALL_STATE_IDLE; state <= TEL_CALL_STATE_WAITING; state++) { - list = tcore_call_object_find_by_status(co, state); - dbg("%d Calls are in [%d] state", g_slist_length(list), state); - while (list) { - /* Update builder */ - __add_call_status_to_builder((CallObject *)list->data, &b); - - list = g_slist_next( list ); - count++; - } - } - gv = g_variant_builder_end(&b); - dbg("Total Calls: [%d]", count); - - telephony_call_complete_get_status_all(call, invocation, TEL_RETURN_SUCCESS, count, gv); - g_variant_unref(gv); - - return TRUE; -} - -static void -on_response_dtapi_call_set_volume_info(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call set volume info response result: [%d]", result); - telephony_call_complete_set_volume_info(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_set_volume_info(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gint device, - guint volume, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelCallVolumeInfo req; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - memset(&req, 0x0, sizeof(TelCallVolumeInfo)); - req.device = device; - req.volume = volume; - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_SET_VOLUME_INFO, - &req, sizeof(TelCallVolumeInfo), on_response_dtapi_call_set_volume_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_get_volume_info(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call get volume info response result: [%d]", result); - telephony_call_complete_get_volume_info(rsp_cb_data->interface_object, rsp_cb_data->invocation, - result, GPOINTER_TO_UINT(data)); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_get_volume_info(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gint device, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelCallSoundDevice req; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - req = device; - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_GET_VOLUME_INFO, - &req, sizeof(TelCallSoundDevice), on_response_dtapi_call_get_volume_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_set_sound_path(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call set sound path response result: [%d]", result); - telephony_call_complete_set_sound_path(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_set_sound_path(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gint path, - gboolean ex_volume, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelCallSoundPathInfo req; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - memset(&req, 0x0, sizeof(TelCallSoundPathInfo)); - req.path = path; - req.ex_volume = ex_volume; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_SET_SOUND_PATH, - &req, sizeof(TelCallSoundPathInfo), on_response_dtapi_call_set_sound_path, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_set_mute(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call set mute response result: [%d]", result); - telephony_call_complete_set_mute(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_set_mute(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gboolean mute, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_SET_MUTE, - &mute, sizeof(gboolean), on_response_dtapi_call_set_mute, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_get_mute_status(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call get mute status response result: [%d]", result); - telephony_call_complete_get_mute_status(rsp_cb_data->interface_object, rsp_cb_data->invocation, result, GPOINTER_TO_INT(data)); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_get_mute_status(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_GET_MUTE_STATUS, - NULL, 0, on_response_dtapi_call_get_mute_status, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_set_sound_recording(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call set sound recording response result: [%d]", result); - telephony_call_complete_set_sound_recording(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_set_sound_recording(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gint recording, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_SET_SOUND_RECORDING, - &recording, sizeof(gint), on_response_dtapi_call_set_sound_recording, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_call_set_sound_equalization(gint result, - const void *data, - void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(rsp_cb_data != NULL); - dbg("Call set sound equalization response result: [%d]", result); - telephony_call_complete_set_sound_equalization(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_call_set_sound_equalization(TelephonyCall *call, - GDBusMethodInvocation *invocation, - gint equalization_mode, - gint direction, - GVariant *param, - gpointer user_data) -{ - GVariantIter *iter = NULL; - guint i = 0; - DbusRespCbData *rsp_cb_data = NULL; - TelCallSoundEqualization req; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_CALL, "x") == FALSE) - return TRUE; - - tcore_check_return_value_assert(NULL != param, TRUE); - memset(&req, 0x0,sizeof(TelCallSoundEqualization)); - req.mode = equalization_mode; - req.direction = direction; - g_variant_get(param,"aq",&iter); - while(g_variant_iter_loop(iter,"q", &(req.parameter[i]))) { - i++; - } - - rsp_cb_data = dtapi_create_resp_cb_data(call, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request( plugin, TRUE, TCORE_COMMAND_CALL_SET_SOUND_EQUALIZATION, - &req, sizeof(TelCallSoundEqualization), on_response_dtapi_call_set_sound_equalization, - rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -gboolean -dtapi_setup_call_interface(TelephonyObjectSkeleton *object, - TcorePlugin *plugin) -{ - TelephonyCall *call = telephony_call_skeleton_new(); - tcore_check_return_value_assert(call != NULL, FALSE); - - telephony_object_skeleton_set_call(object, call); - g_object_unref(call); - - dbg("call = %p", call); - - g_signal_connect(call, "handle-dial", - G_CALLBACK(dtapi_call_dial), plugin); - - g_signal_connect(call, "handle-answer", - G_CALLBACK(dtapi_call_answer), plugin); - - g_signal_connect(call, "handle-end", - G_CALLBACK(dtapi_call_end), plugin); - - g_signal_connect(call, "handle-send-dtmf", - G_CALLBACK(dtapi_call_send_dtmf), plugin); - - g_signal_connect(call, "handle-active", - G_CALLBACK(dtapi_call_active), plugin); - - g_signal_connect(call, "handle-hold", - G_CALLBACK(dtapi_call_hold), plugin); - - g_signal_connect(call, "handle-swap", - G_CALLBACK(dtapi_call_swap), plugin); - - g_signal_connect(call, "handle-join", - G_CALLBACK(dtapi_call_join), plugin); - - g_signal_connect(call, "handle-split", - G_CALLBACK(dtapi_call_split), plugin); - - g_signal_connect(call, "handle-transfer", - G_CALLBACK(dtapi_call_transfer), plugin); - - g_signal_connect(call, "handle-deflect", - G_CALLBACK(dtapi_call_deflect), plugin); - - g_signal_connect(call, "handle-set-active-line", - G_CALLBACK(dtapi_call_set_active_line), plugin); - - g_signal_connect(call, "handle-get-active-line", - G_CALLBACK(dtapi_call_get_active_line), plugin); - - g_signal_connect(call, "handle-get-status", - G_CALLBACK(dtapi_call_get_status), plugin); - - g_signal_connect(call, "handle-get-status-all", - G_CALLBACK(dtapi_call_get_status_all), plugin); - - g_signal_connect(call, "handle-set-sound-path", - G_CALLBACK(dtapi_call_set_sound_path), plugin); - - g_signal_connect(call, "handle-get-volume-info", - G_CALLBACK(dtapi_call_get_volume_info), plugin); - - g_signal_connect(call, "handle-set-volume-info", - G_CALLBACK(dtapi_call_set_volume_info), plugin); - - g_signal_connect(call, "handle-set-mute", - G_CALLBACK(dtapi_call_set_mute), plugin); - - g_signal_connect(call, "handle-get-mute-status", - G_CALLBACK(dtapi_call_get_mute_status), plugin); - - g_signal_connect(call, "handle-set-sound-recording", - G_CALLBACK(dtapi_call_set_sound_recording), plugin); - - g_signal_connect(call, "handle-set-sound-equalization", - G_CALLBACK(dtapi_call_set_sound_equalization), plugin); - - return TRUE; -} - -gboolean -dtapi_handle_call_notification(TelephonyObjectSkeleton *object, - TcorePlugin *plugin, - TcoreNotification command, - guint data_len, - const void *data) -{ - TelephonyCall *call; - - tcore_check_return_value_assert(object != NULL, FALSE); - tcore_check_return_value_assert(plugin != NULL, FALSE); - - call = telephony_object_peek_call(TELEPHONY_OBJECT(object)); - tcore_check_return_value_assert(call != NULL, FALSE); - - dbg("Call: [%p] Command: [0x%x]", call, command); - - switch (command) { - case TCORE_NOTIFICATION_CALL_STATUS_IDLE: { - const TelCallStatusIdleNoti *idle = data; - tcore_check_return_value_assert(idle != NULL, FALSE); - - dbg("[Notification] Call status idle - Call Id:[%d] Idle cause: [%d]", - idle->call_id, idle->cause); - - telephony_call_emit_voice_call_status_idle(call, idle->call_id, idle->cause); - } - break; - - case TCORE_NOTIFICATION_CALL_STATUS_ACTIVE: { - const guint *call_id = data; - tcore_check_return_value_assert(call_id != NULL, FALSE); - - dbg("[Notification] Call status active - Call Id:[%d] ", *call_id); - - telephony_call_emit_voice_call_status_active(call, *call_id); - } - break; - - case TCORE_NOTIFICATION_CALL_STATUS_HELD: { - const guint *call_id = data; - tcore_check_return_value_assert(call_id != NULL, FALSE); - - dbg("[Notification] Call status held - Call Id:[%d] ", *call_id); - - telephony_call_emit_voice_call_status_held(call, *call_id); - } - break; - - case TCORE_NOTIFICATION_CALL_STATUS_DIALING: { - const guint *call_id = data; - tcore_check_return_value_assert(call_id != NULL, FALSE); - - dbg("[Notification] Call status dialing - Call Id:[%d] ", *call_id); - - telephony_call_emit_voice_call_status_dialing(call, *call_id); - } - break; - - case TCORE_NOTIFICATION_CALL_STATUS_ALERT: { - const guint *call_id = data; - tcore_check_return_value_assert(call_id != NULL, FALSE); - - dbg("[Notification] Call status alert - Call Id:[%d] ", *call_id); - - telephony_call_emit_voice_call_status_alert(call, *call_id); - } - break; - - case TCORE_NOTIFICATION_CALL_STATUS_INCOMING: { - const TelCallIncomingInfo *incoming_call_info = (TelCallIncomingInfo *)data; - tcore_check_return_value_assert(incoming_call_info != NULL, FALSE); - - dbg("[Notification] Call Status Incoming - Call Id:[%d] ", incoming_call_info->call_id); - - telephony_call_emit_voice_call_status_incoming(call, incoming_call_info->call_id); - - _launch_voice_call(incoming_call_info); - } - break; - - case TCORE_NOTIFICATION_VIDEO_CALL_STATUS_IDLE: { - const TelCallStatusIdleNoti *idle = data; - tcore_check_return_value_assert(idle != NULL, FALSE); - - dbg("[Notification] Video call status idle notification - Call Id:[%d] Idle cause: [%d]", - idle->call_id, idle->cause); - - telephony_call_emit_video_call_status_idle(call, idle->call_id, idle->cause); - } - break; - - case TCORE_NOTIFICATION_VIDEO_CALL_STATUS_ACTIVE: { - const guint *call_id = data; - tcore_check_return_value_assert(call_id != NULL, FALSE); - - dbg("[Notification] Video call status active notification - Call Id:[%d] ", *call_id); - - telephony_call_emit_video_call_status_active(call, *call_id); - } - break; - - case TCORE_NOTIFICATION_VIDEO_CALL_STATUS_DIALING: { - const guint *call_id = data; - tcore_check_return_value_assert(call_id != NULL, FALSE); - - dbg("[Notification] Video call status dialing - Call Id:[%d] ", *call_id); - - telephony_call_emit_video_call_status_dialing(call, *call_id); - } - break; - - case TCORE_NOTIFICATION_VIDEO_CALL_STATUS_ALERT: { - const guint *call_id = data; - tcore_check_return_value_assert(call_id != NULL, FALSE); - - dbg("[Notification] Video call status alert -Call Id:[%d] ", *call_id); - - telephony_call_emit_video_call_status_alert(call, *call_id); - } - break; - - case TCORE_NOTIFICATION_VIDEO_CALL_STATUS_INCOMING: { - const TelCallIncomingInfo *incoming_call_info = (TelCallIncomingInfo *)data; - tcore_check_return_value_assert(incoming_call_info != NULL, FALSE); - - dbg("[Notification] Video call status incoming - Call Id:[%d] ", - incoming_call_info->call_id); - - telephony_call_emit_video_call_status_incoming(call, incoming_call_info->call_id); - _launch_video_call(incoming_call_info); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_MO_WAITING: { - dbg("[Notification] MO Waiting call info"); - - telephony_call_emit_mo_waiting(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_MO_FORWARDED: { - dbg("[Notification] MO Forwarded call info"); - - telephony_call_emit_mo_forwarded(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_MO_BARRED_INCOMING: { - dbg("[Notification] MO Barred incoming call info"); - - telephony_call_emit_mo_barred_incoming(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_MO_BARRED_OUTGOING: { - dbg("[Notification] MO Barred outgoing call info"); - - telephony_call_emit_mo_barred_outgoing(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_MO_FORWARD_UNCONDITIONAL: { - dbg("[Notification] MO Forward unconditional call info"); - - telephony_call_emit_mo_forward_unconditional(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_MO_FORWARD_CONDITIONAL: { - dbg("[Notification] MO Forward conditional call info"); - - telephony_call_emit_mo_forward_conditional(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_MO_DEFLECTED: { - dbg("[Notification] MO Deflected call"); - - telephony_call_emit_mo_deflected(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_MT_FORWARDED: { - dbg("[Notification] MT Forwarded call"); - - telephony_call_emit_mt_forwarded(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_MT_DEFLECTED: { - dbg("[Notification] MT Deflected call"); - - telephony_call_emit_mt_deflected(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_TRANSFERED: { - dbg("[Notification] Transfered call"); - - telephony_call_emit_transfered(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_HELD: { - dbg("[Notification] Call held info"); - - telephony_call_emit_call_held(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_ACTIVE: { - dbg("[Notification] Call active info"); - - telephony_call_emit_call_active(call); - } - break; - - case TCORE_NOTIFICATION_CALL_INFO_JOINED: { - dbg("[Notification] Call joined info"); - - telephony_call_emit_call_joined(call); - } - break; - - case TCORE_NOTIFICATION_CALL_SOUND_RINGBACK_TONE: { - const gint *status = data; - tcore_check_return_value_assert(status != NULL, FALSE); - - dbg("[Notification] Call sound ringback tone notification - Status:[%d] ", *status); - - telephony_call_emit_call_sound_ringback_tone(call, *status); - } - break; - - case TCORE_NOTIFICATION_CALL_SOUND_WBAMR: { - const gint *status = (gint *)data; - tcore_check_return_value_assert(status != NULL, FALSE); - - dbg("[Notification] Call sound WBAMR notification - Status:[%d] ", *status); - - telephony_call_emit_call_sound_wbamr(call, *status); - } - break; - - case TCORE_NOTIFICATION_CALL_SOUND_EQUALIZATION: { - const TelCallSoundEqualizationNoti *sound_eq = data; - tcore_check_return_value_assert(sound_eq != NULL, FALSE); - - dbg("[Notification] Call sound equalization notification - Mode:[%d] Direction:[%d]", - sound_eq->mode, sound_eq->direction); - - telephony_call_emit_call_sound_equalization(call, sound_eq->mode, sound_eq->direction); - } - break; - - case TCORE_NOTIFICATION_CALL_SOUND_CLOCK_STATUS: { - const gboolean *clock_status = data; - tcore_check_return_value_assert(clock_status != NULL, FALSE); - - dbg("[Notification] Call sound clock status notification - Clock status:[%d]", - *clock_status); - - telephony_call_emit_call_sound_clock_status(call, *clock_status); - } - break; - - default: - err("Unsupported Command"); - break; - } - - return TRUE; -} diff --git a/src/dtapi_gps.c b/src/dtapi_gps.c deleted file mode 100644 index 0bc7290..0000000 --- a/src/dtapi_gps.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_gps.h" -#include "dtapi_util.h" - -#include -#include - -#define AC_GPS "telephony_framework::api_gps" - -static void -on_response_dtapi_gps_confirm_measure_pos(gint result, const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result: [%d]", result); - - telephony_gps_complete_confirm_measure_pos(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static void -on_response_dtapi_gps_set_frequency_aiding(gint result, const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result: [%d]", result); - - telephony_gps_complete_set_frequency_aiding(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean -dtapi_gps_confirm_measure_pos(TelephonyGps *gps, GDBusMethodInvocation *invocation, - gchar *data, gpointer user_data) -{ - TelGpsDataInfo gps_data = {0, NULL}; - TcorePlugin *plugin = (TcorePlugin *)user_data; - DbusRespCbData *rsp_cb_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_GPS, "w") == FALSE) - return TRUE; - - gps_data.data = g_base64_decode(data, &gps_data.data_len); - - rsp_cb_data = dtapi_create_resp_cb_data(gps, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_GPS_CONFIRM_MEASURE_POS, - &gps_data, sizeof(TelGpsDataInfo), on_response_dtapi_gps_confirm_measure_pos, rsp_cb_data); - - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - tcore_free(gps_data.data); - - return TRUE; -} - -static gboolean -dtapi_gps_set_frequency_aiding(TelephonyGps *gps, GDBusMethodInvocation *invocation, - gboolean state, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_GPS, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(gps, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_GPS_SET_FREQUENCY_AIDING, - &state, sizeof(gboolean), on_response_dtapi_gps_set_frequency_aiding, rsp_cb_data); - - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -gboolean dtapi_setup_gps_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin) -{ - TelephonyGps *gps = telephony_gps_skeleton_new(); - tcore_check_return_value_assert(NULL != gps, FALSE); - - telephony_object_skeleton_set_gps(object, gps); - g_object_unref(gps); - - dbg("gps = %p", gps); - - g_signal_connect(gps, "handle-confirm-measure-pos", - G_CALLBACK(dtapi_gps_confirm_measure_pos), plugin); - - g_signal_connect(gps, "handle-set-frequency-aiding", - G_CALLBACK(dtapi_gps_set_frequency_aiding), plugin); - - return TRUE; -} - -gboolean dtapi_handle_gps_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data) -{ - TelephonyGps *gps; - - tcore_check_return_value_assert(NULL != object, FALSE); - gps = telephony_object_peek_gps(TELEPHONY_OBJECT(object)); - - switch (command) { - case TCORE_NOTIFICATION_GPS_ASSIST_DATA: { - gchar *encoded_data = NULL; - dbg("[NOTI] TCORE_NOTIFICATION_GPS_ASSIST_DATA"); - tcore_check_return_value_assert(NULL != data, FALSE); - encoded_data = g_base64_encode((const guchar *)data, data_len); - telephony_gps_emit_assist_data(gps, encoded_data); - tcore_free(encoded_data); - } break; - - case TCORE_NOTIFICATION_GPS_MEASURE_POSITION: { - gchar *encoded_data = NULL; - dbg("[NOTI] TCORE_NOTIFICATION_GPS_MEASURE_POSITION"); - tcore_check_return_value_assert(NULL != data, FALSE); - encoded_data = g_base64_encode((const guchar *)data, data_len); - telephony_gps_emit_measure_position(gps, encoded_data); - tcore_free(encoded_data); - } break; - - case TCORE_NOTIFICATION_GPS_RESET_ASSIST_DATA: { - dbg("[NOTI] TCORE_NOTIFICATION_GPS_RESET_ASSIST_DATA"); - telephony_gps_emit_reset_assist_data(gps); - } break; - - default: { - err("Unhandled command: [0x%x]", command); - } - } - - return TRUE; -} diff --git a/src/dtapi_main.c b/src/dtapi_main.c deleted file mode 100644 index a26302b..0000000 --- a/src/dtapi_main.c +++ /dev/null @@ -1,419 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_main.h" -#include "dtapi_call.h" -#include "dtapi_gps.h" -#include "dtapi_modem.h" -#include "dtapi_network.h" -#include "dtapi_phonebook.h" -#include "dtapi_sap.h" -#include "dtapi_sat.h" -#include "dtapi_sim.h" -#include "dtapi_sms.h" -#include "dtapi_ss.h" -#include "dtapi_util.h" -#include "dtapi_manager.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "sat_manager.h" - -#define DBUS_COMMUNICATOR_NAME "dbus" - -typedef struct { - TcorePlugin *plugin; - Communicator *comm; - Server *server; - guint bus_id; - - GHashTable *objects; - GDBusObjectManagerServer *manager; -} CustomData; - -static void __set_telephony_ready(Server *server) -{ - TcoreStorage *strg; - gboolean ret; - - strg = tcore_server_find_storage(server, "vconf"); - ret = tcore_storage_set_bool(strg, STORAGE_KEY_READY, TRUE); - if (ret == TRUE) { - dbg("Set Telephony Ready: [%s]", ret ? "SUCCESS" : "FAIL"); - } -} - -static gboolean __is_server_notification(gint cmd) -{ - return ((cmd & (TCORE_NOTIFICATION | 0x0FF00000)) - == TCORE_SERVER_NOTIFICATION); -} - -static void __add_modem(TcorePlugin *plugin, CustomData *ctx) -{ - TelephonyObjectSkeleton *object; - CoreObject *co; - guint co_type; - char *path = NULL; - GSList *co_list, *co_elem; - const char *cp_name; - - dbg("Entry"); - - /* Get CP Name */ - cp_name = tcore_server_get_cp_name_by_plugin(plugin); - if (cp_name == NULL) { - err("CP Name is NULL"); - return; - } - - co_list = tcore_plugin_ref_core_objects(plugin); - if (co_list == NULL) { - err("No Core Objects"); - return; - } - - path = g_strdup_printf("%s/%s", TELEPHONY_OBJECT_PATH, cp_name); - dbg("PATH: [%s]", path); - - object = g_hash_table_lookup(ctx->objects, path); - if (object == NULL) { - /* Create a new D-Bus object at path /org/tizen/telephony/ */ - object = telephony_object_skeleton_new(path); - if (object == NULL) { - err("Creation of new DBUS Interface object failed"); - goto OUT; - } - dbg("New DBUS Interface object created!!! (object = %p)", object); - g_hash_table_insert(ctx->objects, g_strdup(path), object); - } else { /* DBUS object already exists */ - dbg("DBUS Interface object already created!!! (object = %p)", object); - goto OUT; - } - - /* Export interfaces rooted at /org/tizen/telephony/ */ - for (co_elem = co_list; co_elem; co_elem = co_elem->next) { - co = co_elem->data; - co_type = tcore_object_get_type(co); - switch (co_type) { - case CORE_OBJECT_TYPE_MODEM: - dtapi_setup_modem_interface(object, plugin); - break; - - case CORE_OBJECT_TYPE_CALL: - dtapi_setup_call_interface(object, plugin); - break; - - case CORE_OBJECT_TYPE_NETWORK: - dtapi_setup_network_interface(object, plugin); - break; - - case CORE_OBJECT_TYPE_SS: - dtapi_setup_ss_interface(object, plugin); - break; - - case CORE_OBJECT_TYPE_SMS: - dtapi_setup_sms_interface(object, plugin); - break; - - case CORE_OBJECT_TYPE_SIM: - dtapi_setup_sim_interface(object, plugin); - break; - - case CORE_OBJECT_TYPE_PHONEBOOK: - dtapi_setup_phonebook_interface(object, plugin); - break; - - case CORE_OBJECT_TYPE_SAP: - dtapi_setup_sap_interface(object, plugin); - break; - - case CORE_OBJECT_TYPE_GPS: - dtapi_setup_gps_interface(object, plugin); - break; - - case CORE_OBJECT_TYPE_SAT: - dtapi_setup_sat_interface(object, plugin, ctx->plugin); - break; - - default: - msg("Skipping: [%u]", co_type); - continue; - } - } - /* Export the object */ - g_dbus_object_manager_server_export(ctx->manager, G_DBUS_OBJECT_SKELETON(object)); - - if (g_dbus_object_manager_server_get_connection (ctx->manager) != NULL) - __set_telephony_ready(ctx->server); - - g_object_unref(object); - -OUT: - /* Freeing memory */ - g_free(path); -} - -static void __refresh_modems(CustomData *ctx) -{ - GSList *mp_list; - - if (!ctx->manager) { - err("Lost Manager. Can't continue"); - return; - } - - /* Expose modem plugin interface */ - mp_list = tcore_server_get_modem_plugin_list(ctx->server); - g_slist_foreach(mp_list, (GFunc)__add_modem, ctx); - g_slist_free(mp_list); -} - -static TelReturn send_notification(Communicator *comm, - TcorePlugin *plugin, gint command, - unsigned int data_len, const void *data) -{ - CustomData *ctx = NULL; - gboolean ret = FALSE; - - dbg("Notification!!! command: [0x%x] data: [%p] data_len: [%d]", - command, data, data_len); - - if (command == TCORE_SERVER_NOTIFICATION_ADDED_COMMUNICATOR) { - /* In case of ADDED_COMMUNICATOR, do NOT progress */ - return TEL_RETURN_SUCCESS; - } - - ctx = tcore_communicator_ref_user_data(comm); - tcore_check_return_value_assert((ctx != NULL), - TEL_RETURN_INVALID_PARAMETER); - - /* - * Notifications are classified into - - * Server (System) notifications - * Module notifications - */ - if (__is_server_notification(command) == TRUE) { - dbg("Server (System) Notification"); - - switch (command) { - case TCORE_SERVER_NOTIFICATION_ADDED_MODEM_PLUGIN: - dbg("Modem Plug-in (%s) is added... " - "Exporting interfaces for the modem", - tcore_server_get_cp_name_by_plugin((TcorePlugin*)data)); - - __add_modem((TcorePlugin*)data, ctx); - - ret = TRUE; - break; - - default: - warn("Unsupported System notification: (0x%x)", command); - break; - } - } else { - TelephonyObjectSkeleton *object; - const char *cp_name; - char *path; - - cp_name = tcore_server_get_cp_name_by_plugin(plugin); - tcore_check_return_value_assert((cp_name != NULL), TEL_RETURN_FAILURE); - - dbg("CP Name: [%s]", cp_name); - path = g_strdup_printf("%s/%s", TELEPHONY_OBJECT_PATH, cp_name); - - /* Look-up Hash table for Object */ - object = g_hash_table_lookup(ctx->objects, path); - dbg("Path: [%s] Interface object: [%p]", path, object); - g_free(path); - - tcore_check_return_value((object != NULL), TEL_RETURN_FAILURE); - - switch (command & (TCORE_NOTIFICATION | 0x0FF00000)) { - case TCORE_NOTIFICATION_CALL: - ret = dtapi_handle_call_notification(object, - plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_SS: - ret = dtapi_handle_ss_notification(object, - plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_PS: - warn("PS Notification [0x%x]... Not handled!!!", command); - break; - - case TCORE_NOTIFICATION_SIM: - ret = dtapi_handle_sim_notification(object, - plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_SAP: - ret = dtapi_handle_sap_notification(object, - plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_PHONEBOOK: - ret = dtapi_handle_phonebook_notification(object, - plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_MODEM: - ret = dtapi_handle_modem_notification(object, - plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_SMS: - ret = dtapi_handle_sms_notification(object, - plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_SAT: - ret = dtapi_handle_sat_notification(object, - plugin, ctx->plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_NETWORK: - ret = dtapi_handle_network_notification(object, - plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_GPS: - ret = dtapi_handle_gps_notification(object, - plugin, command, data_len, data); - break; - - case TCORE_NOTIFICATION_CUSTOM: - warn("Custom Notification [0x%x]... Not handled!!!", command); - break; - - default: - err("Unknown command [0x%x]", command); - break; - } - } - - if (ret == TRUE) - return TEL_RETURN_SUCCESS; - else - return TEL_RETURN_FAILURE; -} - -static void on_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) -{ - dbg("Name Acquired %s", name); -} - -static void on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data) -{ - if (conn == NULL) { - err("Connection to the bus can't be made"); - return; - } - - dbg("Name Lost %s", name); - - /* TODO: unregister the objects */ -} - -static void on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) -{ - CustomData *ctx = user_data; - GError *error = NULL; - TelephonyManager *mgr = dtapi_manager_new(ctx->server); - - if (FALSE == g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(mgr), - conn, TELEPHONY_OBJECT_PATH, &error)) { - err("Unable to export Manager interface [%d] => [%s]", error->code, error->message); - g_error_free(error); - return; - } - - /* Refresh Object */ - __refresh_modems(ctx); - - /* Export all objects */ - g_dbus_object_manager_server_set_connection(ctx->manager, conn); - dbg("Aquire DBUS - COMPLETE"); -} - -TcoreCommunicatorOps ops = { - .send_notification = send_notification, -}; - -gboolean dtapi_plugin_init(TcorePlugin *plugin) -{ - Communicator *comm; - CustomData *data; - - data = tcore_malloc0(sizeof(CustomData)); - - data->plugin = plugin; - data->server = tcore_plugin_ref_server(plugin); - - comm = tcore_communicator_new(plugin, DBUS_COMMUNICATOR_NAME, &ops); - tcore_communicator_link_user_data(comm, data); - data->comm = comm; - - data->objects = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); - - /* Create Object Manager rooted at /org/tizen/telephony */ - data->manager = g_dbus_object_manager_server_new(TELEPHONY_OBJECT_PATH); - - /* Request bus name */ - data->bus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, TELEPHONY_SERVICE, - G_BUS_NAME_OWNER_FLAGS_REPLACE, - on_bus_acquired, on_name_acquired, on_name_lost, - data, NULL); - dbg("id=[%d]", data->bus_id); - - sat_manager_init(plugin, data->objects, data->server, data->manager); - - return TRUE; -} - -void dtapi_plugin_deinit(TcorePlugin *plugin) -{ - CustomData *data; - Communicator *comm; - Server *s = tcore_plugin_ref_server(plugin); - - comm = tcore_server_find_communicator(s, DBUS_COMMUNICATOR_NAME); - data = tcore_communicator_ref_user_data(comm); - if (!data) { - tcore_communicator_free(comm); - return; - } - g_hash_table_destroy(data->objects); - g_bus_unown_name(data->bus_id); - g_object_unref(data->manager); - tcore_free(data); - sat_manager_deinit(plugin); - - tcore_communicator_free(comm); -} diff --git a/src/dtapi_manager.c b/src/dtapi_manager.c deleted file mode 100644 index cde5a1b..0000000 --- a/src/dtapi_manager.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_manager.h" -#include "dtapi_util.h" - -#include - -#define AC_MANAGER "telephony_framework::api_manager" - -static void -dtapi_manager_get_modems(TelephonyManager *mgr, GDBusMethodInvocation *invocation, - Server *server) -{ - GSList *cp_name_list, *temp_list; - gchar **list; - unsigned int count; - const char *name = NULL; - dbg("Entry"); - - cp_name_list = tcore_server_get_modem_plugin_list(server); - if (cp_name_list == NULL) { - err("Modem List is NULL"); - telephony_manager_complete_get_modems(mgr, invocation, NULL); - return; - } - - count = g_slist_length(cp_name_list); - list = g_try_malloc0(sizeof(gchar *) * (count+1)); - - count = 0; - temp_list = cp_name_list; - for ( ; cp_name_list ; cp_name_list = cp_name_list->next) { - name = cp_name_list->data; - list[count] = g_strdup(name); - dbg("list[%d]: %s", count, list[count]); - count++; - } - - telephony_manager_complete_get_modems(mgr, invocation, (const gchar **)list); - - /* Free memory */ - for (;count > 0; count--) - g_free(list[count]); - - g_free(list); - - /* Freeing the received list of CP names */ - g_slist_free_full(temp_list, g_free); -} - -TelephonyManager *dtapi_manager_new(Server *server) -{ - TelephonyManager *mgr = telephony_manager_skeleton_new(); - tcore_check_return_value_assert(NULL != mgr, NULL); - - g_signal_connect(mgr, "handle-get-modems", - G_CALLBACK(dtapi_manager_get_modems), server); - - return mgr; -} diff --git a/src/dtapi_modem.c b/src/dtapi_modem.c deleted file mode 100644 index 4825ee9..0000000 --- a/src/dtapi_modem.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_modem.h" -#include "dtapi_util.h" - -#include -#include - -#define AC_MODEM "telephony_framework::api_modem" - -static void on_response_dtapi_modem_set_power_status(gint result, - const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result: [%d]", result); - - telephony_modem_complete_set_power_status(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static void on_response_dtapi_modem_set_flight_mode(gint result, - const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result: [%d]", result); - - telephony_modem_complete_set_flight_mode(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static void on_response_dtapi_modem_get_flight_mode(gint result, - const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - TelModemFlightModeStatus flight_mode_status = TEL_MODEM_FLIGHT_MODE_OFF; - gboolean enable; - - tcore_check_return_assert(NULL != rsp_cb_data && NULL != response); - - enable = *(gboolean *)response; - dbg("result: [%d] Flight mode: [%s]", result, (enable ? "ON" : "OFF")); - - telephony_modem_complete_get_flight_mode(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, enable); - - if (enable == TRUE) - flight_mode_status = TEL_MODEM_FLIGHT_MODE_ON; - - /* Update property */ - telephony_modem_set_flight_mode_status(rsp_cb_data->interface_object, flight_mode_status); - - tcore_free(rsp_cb_data); -} - -static void on_response_dtapi_modem_get_version(gint result, - const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - const TelModemVersion *version = response; - - tcore_check_return_assert(NULL != rsp_cb_data && NULL != version); - - dbg("result: [%d] SW: [%s] HW: [%s] CAL: [%s] PC: [%s]", result, - version->software_version, version->hardware_version, - version->calibration_date, version->product_code); - - /* Send response */ - telephony_modem_complete_get_version(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - (const gchar *)version->software_version, - (const gchar *)version->hardware_version, - (const gchar *)version->calibration_date, - (const gchar *)version->product_code); - - /* Update property */ - { - GVariantBuilder var_builder; - GVariant *var_version = NULL; - - g_variant_builder_init(&var_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&var_builder, "{sv}", - "software_version", g_variant_new_string(version->software_version)); - g_variant_builder_add(&var_builder, "{sv}", - "hardware_version", g_variant_new_string(version->hardware_version)); - g_variant_builder_add(&var_builder, "{sv}", - "calibration_date", g_variant_new_string(version->hardware_version)); - g_variant_builder_add(&var_builder, "{sv}", - "product_code", g_variant_new_string(version->product_code)); - - var_version = g_variant_builder_end(&var_builder); - tcore_check_return_assert(NULL != var_version); - - /* Set property */ - telephony_modem_set_version(rsp_cb_data->interface_object, var_version); - } - - tcore_free(rsp_cb_data); -} - -static void on_response_dtapi_modem_get_imei(gint result, - const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - const gchar *imei = response; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result: [%d] IMEI: [%s]", result, (imei ? imei : "\0")); - - telephony_modem_complete_get_imei(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, imei); - - /* Update property */ - telephony_modem_set_imei(rsp_cb_data->interface_object, imei); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_modem_set_power_status(TelephonyModem *modem, - GDBusMethodInvocation *invocation, - TelModemPowerStatus status, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_MODEM, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(modem, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_MODEM_SET_POWER_STATUS, - &status, sizeof(TelModemPowerStatus), - on_response_dtapi_modem_set_power_status, rsp_cb_data); - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static gboolean dtapi_modem_set_flight_mode(TelephonyModem *modem, - GDBusMethodInvocation *invocation, - gboolean enable, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_MODEM, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(modem, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_MODEM_SET_FLIGHTMODE, - &enable, sizeof(gboolean), - on_response_dtapi_modem_set_flight_mode, rsp_cb_data); - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static gboolean dtapi_modem_get_flight_mode(TelephonyModem *modem, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_MODEM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(modem, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_MODEM_GET_FLIGHTMODE, - NULL, 0, - on_response_dtapi_modem_get_flight_mode, rsp_cb_data); - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static gboolean dtapi_modem_get_version(TelephonyModem *modem, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_MODEM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(modem, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_MODEM_GET_VERSION, - NULL, 0, - on_response_dtapi_modem_get_version, rsp_cb_data); - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static gboolean dtapi_modem_get_imei(TelephonyModem *modem, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_MODEM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(modem, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_MODEM_GET_IMEI, - NULL, 0, - on_response_dtapi_modem_get_imei, rsp_cb_data); - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -gboolean dtapi_setup_modem_interface(TelephonyObjectSkeleton *object, - TcorePlugin *plugin) -{ - TelephonyModem *modem = telephony_modem_skeleton_new(); - tcore_check_return_value_assert(NULL != modem, FALSE); - - telephony_object_skeleton_set_modem(object, modem); - g_object_unref(modem); - - dbg("modem = %p", modem); - - g_signal_connect(modem, - "handle-set-power-status", - G_CALLBACK(dtapi_modem_set_power_status), plugin); - - g_signal_connect(modem, - "handle-set-flight-mode", - G_CALLBACK(dtapi_modem_set_flight_mode), plugin); - - g_signal_connect(modem, - "handle-get-flight-mode", - G_CALLBACK(dtapi_modem_get_flight_mode), plugin); - - g_signal_connect(modem, - "handle-get-version", - G_CALLBACK(dtapi_modem_get_version), plugin); - - g_signal_connect(modem, - "handle-get-imei", - G_CALLBACK(dtapi_modem_get_imei), plugin); - - /* Initialize D-Bus properties */ - telephony_modem_set_status(modem, TEL_MODEM_POWER_OFF); - telephony_modem_set_flight_mode_status(modem, TEL_MODEM_FLIGHT_MODE_UNKNOWN); - telephony_modem_set_imei(modem, NULL); - telephony_modem_set_version(modem, NULL); - - return TRUE; -} - -gboolean dtapi_handle_modem_notification(TelephonyObjectSkeleton *object, - TcorePlugin *plugin, TcoreNotification command, - guint data_len, const void *data) -{ - TelephonyModem *modem; - - tcore_check_return_value_assert(NULL != object, FALSE); - modem = telephony_object_peek_modem(TELEPHONY_OBJECT(object)); - - switch (command) { - case TCORE_NOTIFICATION_MODEM_POWER: { - guint power_status; - - tcore_check_return_value_assert(NULL != data, FALSE); - - power_status = *(guint *)data; - dbg("modem: [%p] Power status: [%d]", modem, power_status); - - /* Update property */ - telephony_modem_set_status(modem, power_status); - } - break; - - case TCORE_NOTIFICATION_MODEM_FLIGHT_MODE: { - TelModemFlightModeStatus flight_mode_status = TEL_MODEM_FLIGHT_MODE_OFF; - gboolean status; - - tcore_check_return_value_assert(NULL != data, FALSE); - - status = *(gboolean *)data; - dbg("modem: [%p] Flight Mode status: %d", - modem, (status ? "ON" : "OFF")); - - if (status == TRUE) - flight_mode_status = TEL_MODEM_FLIGHT_MODE_ON; - - /* Update property */ - telephony_modem_set_flight_mode_status(modem, flight_mode_status); - } - break; - - default: - err("Unhandled command: [0x%x]", command); - break; - } - - return TRUE; -} - diff --git a/src/dtapi_network.c b/src/dtapi_network.c deleted file mode 100644 index bf89dc8..0000000 --- a/src/dtapi_network.c +++ /dev/null @@ -1,781 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_network.h" -#include "dtapi_util.h" - -#include - -#define AC_NETWORK "telephony_framework::api_network" - -static void on_response_dtapi_network_get_identity_info(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelNetworkIdentityInfo *identity_info = data; - - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - - if ((result != TEL_NETWORK_RESULT_SUCCESS) - || (identity_info == NULL)) { - telephony_network_complete_get_identity_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, NULL, NULL, NULL); - } else { - dbg("plmn[%s] short_name[%s] long_name[%s]", - identity_info->plmn, - identity_info->short_name, - identity_info->long_name); - telephony_network_complete_get_identity_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, identity_info->plmn, - identity_info->short_name, identity_info->long_name); - } - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_get_identity_info(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_GET_IDENTITY_INFO, - NULL, 0, - on_response_dtapi_network_get_identity_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_search(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelNetworkPlmnList *plmn_list = data; - - GVariant *network_list = NULL; - GVariantBuilder variant_builder; - - guint count = 0; - - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - - g_variant_builder_init(&variant_builder, G_VARIANT_TYPE("aa{sv}")); - if ((result == TEL_SIM_RESULT_SUCCESS) - && (plmn_list != NULL)) { - GVariantBuilder variant_builder2; - GVariant *network_identity = NULL; - - dbg("Network Search PLMN List count: [%d]", plmn_list->count); - for (count = 0; count < plmn_list->count; count++) { - g_variant_builder_open(&variant_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&variant_builder, "{sv}", - "plmn_status", g_variant_new_int32(plmn_list->network_list[count].plmn_status)); - g_variant_builder_add(&variant_builder, "{sv}", - "act", g_variant_new_int32(plmn_list->network_list[count].act)); - - g_variant_builder_init(&variant_builder2, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&variant_builder2, "{sv}", - "plmn", - g_variant_new_string(plmn_list->network_list[count].network_identity.plmn)); - g_variant_builder_add(&variant_builder2, "{sv}", - "short_name", - g_variant_new_string(plmn_list->network_list[count].network_identity.short_name)); - g_variant_builder_add(&variant_builder2, "{sv}", - "long_name", - g_variant_new_string(plmn_list->network_list[count].network_identity.long_name)); - network_identity = g_variant_builder_end(&variant_builder2); - - g_variant_builder_add(&variant_builder, "{sv}", - "network_identity", network_identity); - - g_variant_builder_close(&variant_builder); - - dbg("[%d] : PLMN Status: [%d] AcT: [%d]", count, - plmn_list->network_list[count].plmn_status, - plmn_list->network_list[count].act); - } - } - network_list = g_variant_builder_end(&variant_builder); - - telephony_network_complete_search(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, count, network_list); - g_variant_unref(network_list); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_search(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_SEARCH, - NULL, 0, - on_response_dtapi_network_search, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_cancel_search(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - telephony_network_complete_cancel_search(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_cancel_search(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_CANCEL_SEARCH, - NULL, 0, - on_response_dtapi_network_cancel_search, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_select_automatic(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - telephony_network_complete_select_automatic(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_select_automatic(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_SELECT_AUTOMATIC, - NULL, 0, - on_response_dtapi_network_select_automatic, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_select_manual(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - telephony_network_complete_select_manual(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_select_manual(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, - const gchar *plmn, gint act, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result ; - TelNetworkSelectManualInfo req_data; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - - req_data.plmn = (char *)plmn; - req_data.act = act; - - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_SELECT_MANUAL, - &req_data, sizeof(TelNetworkSelectManualInfo), - on_response_dtapi_network_select_manual, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_get_selection_mode(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - TelNetworkSelectionMode selection_mode = 0; - - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - if ((result == TEL_NETWORK_RESULT_SUCCESS) - && (NULL != data)) { - selection_mode = *(TelNetworkSelectionMode *)data; - dbg("selection_mode[%d]", selection_mode); - } - - telephony_network_complete_get_selection_mode(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, selection_mode); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_get_selection_mode(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result ; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_GET_SELECTION_MODE, - NULL, 0, - on_response_dtapi_network_get_selection_mode, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_set_preferred_plmn(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - telephony_network_complete_set_preferred_plmn(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_set_preferred_plmn(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, - guint index, const gchar *plmn, gint act, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result ; - TelNetworkPreferredPlmnInfo req_data; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - req_data.index = index; - req_data.plmn = (char *)plmn; - req_data.act = act; - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_SET_PREFERRED_PLMN, - &req_data, sizeof(TelNetworkPreferredPlmnInfo), - on_response_dtapi_network_set_preferred_plmn, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_get_preferred_plmn(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelNetworkPreferredPlmnList *plmn_list = data; - - GVariant *list = NULL; - GVariantBuilder variant_builder; - - guint count = 0; - - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - - g_variant_builder_init(&variant_builder, G_VARIANT_TYPE("aa{sv}")); - if ((result == TEL_SIM_RESULT_SUCCESS) - && (NULL != plmn_list)) { - dbg("Preferred PLMN List count: [%d]", plmn_list->count); - for (count = 0; count < plmn_list->count; count++) { - g_variant_builder_open(&variant_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&variant_builder, "{sv}", - "index", g_variant_new_uint32(plmn_list->list[count].index)); - g_variant_builder_add(&variant_builder, "{sv}", - "plmn", g_variant_new_string(plmn_list->list[count].plmn)); - g_variant_builder_add(&variant_builder, "{sv}", - "act", g_variant_new_int32(plmn_list->list[count].act)); - - g_variant_builder_close(&variant_builder); - - dbg("[%d] : Index: [%d] PLMN: [%s] AcT: [%d]", count, - plmn_list->list[count].index, - plmn_list->list[count].plmn, - plmn_list->list[count].act); - } - } - list = g_variant_builder_end(&variant_builder); - - telephony_network_complete_get_preferred_plmn(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, count, list); - g_variant_unref(list); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_get_preferred_plmn(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result ; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_GET_PREFERRED_PLMN, - NULL, 0, - on_response_dtapi_network_get_preferred_plmn, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_set_mode(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - telephony_network_complete_set_mode(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_set_mode(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, - gint mode, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result ; - TelNetworkMode network_mode; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - - network_mode = mode; - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_SET_MODE, - &network_mode, sizeof(TelNetworkMode), - on_response_dtapi_network_set_mode, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_get_mode(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - TelNetworkMode network_mode = 0; - - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - if ((result == TEL_SIM_RESULT_SUCCESS) - && (data != NULL)) { - network_mode = *(TelNetworkMode *)data; - dbg("network_mode[%d]", network_mode); - } - - telephony_network_complete_get_mode(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, network_mode); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_get_mode(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_GET_MODE, - NULL, 0, - on_response_dtapi_network_get_mode, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_network_get_ngbr_cell_info(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelNetworkNeighbourCellInfo *ngbr_cell_info = data; - - GVariantBuilder gsm_var_builder; - GVariant *gsm_list = NULL; - guint gsm_count = 0; - - GVariantBuilder umts_var_builder; - GVariant *umts_list = NULL; - guint umts_count = 0; - - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("result[%d]", result); - - g_variant_builder_init(&gsm_var_builder, G_VARIANT_TYPE("aa{sv}")); - g_variant_builder_init(&umts_var_builder, G_VARIANT_TYPE("aa{sv}")); - if ((result == TEL_SIM_RESULT_SUCCESS) - && (ngbr_cell_info != NULL)) { - dbg("GSM Cell info List count: [%d]", ngbr_cell_info->gsm_list_count); - for (gsm_count = 0; gsm_count < ngbr_cell_info->gsm_list_count; gsm_count++) { - g_variant_builder_open(&gsm_var_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&gsm_var_builder, "{sv}", - "cell_id", - g_variant_new_int32(ngbr_cell_info->gsm_list[gsm_count].cell_id)); - g_variant_builder_add(&gsm_var_builder, "{sv}", - "lac", - g_variant_new_int32(ngbr_cell_info->gsm_list[gsm_count].lac)); - g_variant_builder_add(&gsm_var_builder, "{sv}", - "bcch", - g_variant_new_int32(ngbr_cell_info->gsm_list[gsm_count].bcch)); - g_variant_builder_add(&gsm_var_builder, "{sv}", - "bsic", - g_variant_new_int32(ngbr_cell_info->gsm_list[gsm_count].bsic)); - g_variant_builder_add(&gsm_var_builder, "{sv}", - "rxlev", - g_variant_new_int32(ngbr_cell_info->gsm_list[gsm_count].rxlev)); - - g_variant_builder_close(&gsm_var_builder); - } - - dbg("UMTS Cell info List count: [%d]", ngbr_cell_info->umts_list_count); - for (umts_count = 0; umts_count < ngbr_cell_info->umts_list_count; umts_count++) { - g_variant_builder_open(&gsm_var_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&gsm_var_builder, "{sv}", - "cell_id", - g_variant_new_int32(ngbr_cell_info->umts_list[umts_count].cell_id)); - g_variant_builder_add(&gsm_var_builder, "{sv}", - "lac", - g_variant_new_int32(ngbr_cell_info->umts_list[umts_count].lac)); - g_variant_builder_add(&gsm_var_builder, "{sv}", - "arfcn", - g_variant_new_int32(ngbr_cell_info->umts_list[umts_count].arfcn)); - g_variant_builder_add(&gsm_var_builder, "{sv}", - "psc", - g_variant_new_int32(ngbr_cell_info->umts_list[umts_count].psc)); - g_variant_builder_add(&gsm_var_builder, "{sv}", - "rscp", - g_variant_new_int32(ngbr_cell_info->umts_list[umts_count].rscp)); - - g_variant_builder_close(&gsm_var_builder); - } - - dbg("GSM Cell info count: [%d] UMTS Cell info count: [%d]", - gsm_count, umts_count); - } - gsm_list = g_variant_builder_end(&gsm_var_builder); - umts_list = g_variant_builder_end(&umts_var_builder); - - telephony_network_complete_get_ngbr_cell_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - gsm_count, gsm_list, umts_count, umts_list); - g_variant_unref(gsm_list); - g_variant_unref(umts_list); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_network_get_ngbr_cell_info(TelephonyNetwork *network, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TelReturn result ; - - if (dtapi_check_access_control(invocation, AC_NETWORK, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(network, invocation, NULL, 0); - result = tcore_plugin_dispatch_request(user_data, TRUE, - TCORE_COMMAND_NETWORK_GET_NEIGHBORING_CELL_INFO, - NULL, 0, - on_response_dtapi_network_get_ngbr_cell_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -gboolean dtapi_setup_network_interface(TelephonyObjectSkeleton *object, - TcorePlugin *plugin) -{ - TelephonyNetwork *network; - - tcore_check_return_value_assert(NULL != object, FALSE); - tcore_check_return_value_assert(NULL != plugin, FALSE); - - network = telephony_network_skeleton_new(); - telephony_object_skeleton_set_network(object, network); - g_object_unref(network); - - dbg("network = %p", network); - - g_signal_connect (network, - "handle-get-identity-info", - G_CALLBACK (dtapi_network_get_identity_info), - plugin); - - g_signal_connect (network, - "handle-search", - G_CALLBACK (dtapi_network_search), - plugin); - - g_signal_connect (network, - "handle-cancel-search", - G_CALLBACK (dtapi_network_cancel_search), - plugin); - - g_signal_connect (network, - "handle-select-automatic", - G_CALLBACK (dtapi_network_select_automatic), - plugin); - - g_signal_connect (network, - "handle-select-manual", - G_CALLBACK (dtapi_network_select_manual), - plugin); - - g_signal_connect (network, - "handle-get-selection-mode", - G_CALLBACK (dtapi_network_get_selection_mode), - plugin); - - g_signal_connect (network, - "handle-set-preferred-plmn", - G_CALLBACK (dtapi_network_set_preferred_plmn), - plugin); - - g_signal_connect (network, - "handle-get-preferred-plmn", - G_CALLBACK (dtapi_network_get_preferred_plmn), - plugin); - - g_signal_connect (network, - "handle-set-mode", - G_CALLBACK (dtapi_network_set_mode), - plugin); - - g_signal_connect (network, - "handle-get-mode", - G_CALLBACK (dtapi_network_get_mode), - plugin); - - g_signal_connect (network, - "handle-get-ngbr-cell-info", - G_CALLBACK (dtapi_network_get_ngbr_cell_info), - plugin); - - /* Initialize D-Bus properties */ - telephony_network_set_rssi(network, 0); - telephony_network_set_lac(network, -1); - telephony_network_set_cell_id(network, -1); - telephony_network_set_rac(network, -1); - telephony_network_set_act(network, TEL_NETWORK_ACT_UNKNOWN); - telephony_network_set_cs_status(network, TEL_NETWORK_REG_STATUS_UNKNOWN); - telephony_network_set_ps_status(network, TEL_NETWORK_REG_STATUS_UNKNOWN); - - return TRUE; -} - -gboolean dtapi_handle_network_notification(TelephonyObjectSkeleton *object, - TcorePlugin *plugin, TcoreNotification command, - guint data_len, const void *data) -{ - TelephonyNetwork *network; - - tcore_check_return_value_assert(NULL != object, FALSE); - tcore_check_return_value_assert(NULL != plugin, FALSE); - tcore_check_return_value_assert(NULL != data, FALSE); - - network = telephony_object_peek_network(TELEPHONY_OBJECT(object)); - tcore_check_return_value_assert(NULL != network, FALSE); - - dbg("Notification!!! Command: [0x%x]", command); - - switch (command) { - case TCORE_NOTIFICATION_NETWORK_REGISTRATION_STATUS: { - const TelNetworkRegStatusInfo *registration_status = data; - - /* Update properties */ - telephony_network_set_act(network, registration_status->act); - telephony_network_set_cs_status(network, registration_status->cs_status); - telephony_network_set_ps_status(network, registration_status->ps_status); - - telephony_network_emit_registration_status(network, - registration_status->cs_status, - registration_status->ps_status, - registration_status->act); - } - break; - - case TCORE_NOTIFICATION_NETWORK_LOCATION_CELLINFO: { - const TelNetworkCellInfo *cell_info = data; - - /* Update properties */ - telephony_network_set_lac(network, cell_info->lac); - telephony_network_set_cell_id(network, cell_info->cell_id); - telephony_network_set_rac(network, cell_info->rac); - - telephony_network_emit_cell_info(network, - cell_info->lac, - cell_info->cell_id, - cell_info->rac); - } - break; - - case TCORE_NOTIFICATION_NETWORK_IDENTITY: { - const TelNetworkIdentityInfo *identity = data; - - telephony_network_emit_identity(network, - identity->plmn, - identity->short_name, - identity->long_name); - } - break; - - case TCORE_NOTIFICATION_NETWORK_RSSI: { - guint rssi = *(guint *)data; - - /* Update properties */ - telephony_network_set_rssi(network, rssi); - telephony_network_emit_rssi(network, rssi); - } - break; - - case TCORE_NOTIFICATION_NETWORK_TIMEINFO: { - const TelNetworkNitzInfoNoti *time_info = data; - - telephony_network_emit_time_info(network, - time_info->year, - time_info->month, - time_info->day, - time_info->hour, - time_info->minute, - time_info->second, - time_info->gmtoff, - time_info->isdst, - time_info->dstoff, - time_info->plmn); - } - break; - - default: - err("Unsupported command"); - } - - return TRUE; -} diff --git a/src/dtapi_phonebook.c b/src/dtapi_phonebook.c deleted file mode 100644 index 4034c82..0000000 --- a/src/dtapi_phonebook.c +++ /dev/null @@ -1,656 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_phonebook.h" -#include "dtapi_util.h" - -#include -#include - -#define AC_PHONEBOOK "telephony_framework::api_phonebook" - -static gboolean __check_phonebook_status(TcorePlugin *plugin) -{ - CoreObject *co_pb; - gboolean init_status = FALSE; - - co_pb = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_PHONEBOOK); - tcore_check_return_value(co_pb != NULL, FALSE); - - if (tcore_phonebook_get_status(co_pb, &init_status) == FALSE) { - err("Get Status Failed"); - return FALSE; - } - tcore_check_return_value(init_status == TRUE, FALSE); - - return TRUE; -} - -static gboolean dtapi_phonebook_get_init_info(TelephonyPhonebook *phonebook, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TcorePlugin *plugin = user_data; - gboolean pb_status = FALSE; - CoreObject *co_pb = NULL; - TelPbList *list = NULL; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_PHONEBOOK, "r") == FALSE) - return TRUE; - - co_pb = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_PHONEBOOK); - tcore_check_return_value(co_pb != NULL, TRUE); - - if (tcore_phonebook_get_support_list(co_pb, &list) == FALSE) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Get Support List Failed"); - return TRUE; - } - tcore_check_return_value(list != NULL, TRUE); - - dbg("FDN: [%s], ADN: [%s], SDN: [%s], USIM: [%s]", - list->fdn ? "TRUE" : "FALSE", list->adn ? "TRUE" : "FALSE", - list->sdn ? "TRUE" : "FALSE", list->usim ? "TRUE" : "FALSE"); - - if (tcore_phonebook_get_status(co_pb, &pb_status) == FALSE) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Get Status Failed"); - tcore_free(list); - return TRUE; - } - - telephony_phonebook_complete_get_init_info(phonebook, invocation, - TEL_RETURN_SUCCESS, pb_status, - list->fdn, list->adn, list->sdn, list->usim); - tcore_free(list); - - return TRUE; -} - -static void on_response_dtapi_phonebook_get_info(gint result, - const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - const TelPbInfo *pb_info = response; - GVariant *var_info = NULL; - GVariantBuilder builder; - tcore_check_return_assert(rsp_cb_data != NULL); - - dbg("Result: [%d]", result); - - g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}")); - if (TEL_PB_RESULT_SUCCESS != result || pb_info == NULL) { - err("[DBUS]Get Info Response Failed"); - var_info = g_variant_builder_end(&builder); - telephony_phonebook_complete_get_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, -1, var_info); - g_variant_unref(var_info); - - tcore_free(rsp_cb_data); - return; - } - - if (TEL_PB_USIM == pb_info->pb_type) { - TelPbUsimInfo *usim = (TelPbUsimInfo *)(&pb_info->info_u.usim); - - g_variant_builder_add(&builder, "{sv}", - "max_count", g_variant_new_uint32(usim->max_count)); - g_variant_builder_add(&builder, "{sv}", - "used_count", g_variant_new_uint32(usim->used_count)); - g_variant_builder_add(&builder, "{sv}", - "max_num_len", g_variant_new_uint32(usim->max_num_len)); - g_variant_builder_add(&builder, "{sv}", - "max_text_len", g_variant_new_uint32(usim->max_text_len)); - g_variant_builder_add(&builder, "{sv}", - "max_anr_count", g_variant_new_byte(usim->max_anr_count)); - g_variant_builder_add(&builder, "{sv}", - "max_anr_len", g_variant_new_uint32(usim->max_anr_len)); - g_variant_builder_add(&builder, "{sv}", - "max_email_count", g_variant_new_byte(usim->max_email_count)); - g_variant_builder_add(&builder, "{sv}", - "max_email_len", g_variant_new_uint32(usim->max_email_len)); - g_variant_builder_add(&builder, "{sv}", - "max_sne_len", g_variant_new_uint32(usim->max_sne_len)); - g_variant_builder_add(&builder, "{sv}", - "max_gas_count", g_variant_new_uint32(usim->max_gas_count)); - g_variant_builder_add(&builder, "{sv}", - "max_gas_len", g_variant_new_uint32(usim->max_gas_len)); - g_variant_builder_add(&builder, "{sv}", - "max_aas_count", g_variant_new_uint32(usim->max_aas_count)); - g_variant_builder_add(&builder, "{sv}", - "max_aas_len", g_variant_new_uint32(usim->max_aas_len)); - - dbg("pb_type: [%d] \n\tmax_count: [%d] used_count: [%d] " \ - "max_num_len: [%d] max_text_len: [%d] \n\tmax_anr_count: [%d] " \ - "max_anr_len: [%d] max_email_count: [%d] max_email_len: [%d] " \ - "max_sne_len: [%d] \n\tmax_gas_count: [%d] max_gas_len: [%d] " \ - "max_aas_count: [%d] max_aas_len: [%d]", - pb_info->pb_type, - usim->max_count, usim->used_count, - usim->max_num_len, usim->max_text_len, - usim->max_anr_count, usim->max_anr_len, - usim->max_email_count, usim->max_email_len, - usim->max_sne_len, - usim->max_gas_count, usim->max_gas_len, - usim->max_aas_count, usim->max_aas_len); - } - else { - TelPbSimInfo *sim = (TelPbSimInfo *)(&pb_info->info_u.sim); - - g_variant_builder_add(&builder, "{sv}", - "max_count", g_variant_new_uint32(sim->max_count)); - g_variant_builder_add(&builder, "{sv}", - "used_count", g_variant_new_uint32(sim->used_count)); - g_variant_builder_add(&builder, "{sv}", - "max_num_len", g_variant_new_uint32(sim->max_num_len)); - g_variant_builder_add(&builder, "{sv}", - "max_text_len", g_variant_new_uint32(sim->max_text_len)); - - dbg("pb_type: [%d] max_count: [%d] used_count: [%d] " \ - "max_num_len: [%d] max_text_len: [%d]", - pb_info->pb_type, - sim->max_count, sim->used_count, - sim->max_num_len, sim->max_text_len); - } - var_info = g_variant_builder_end(&builder); - - telephony_phonebook_complete_get_info(rsp_cb_data->interface_object, rsp_cb_data->invocation, - result, pb_info->pb_type, var_info); - - tcore_free(rsp_cb_data); - g_variant_unref(var_info); -} - -static gboolean dtapi_phonebook_get_info(TelephonyPhonebook *phonebook, - GDBusMethodInvocation *invocation, - gint req_type, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_PHONEBOOK, "r") == FALSE) - return TRUE; - - if (__check_phonebook_status(plugin) == FALSE) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid Phonebook Status"); - return TRUE; - } - - rsp_cb_data = dtapi_create_resp_cb_data(phonebook, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_PHONEBOOK_GET_INFO, - &req_type, sizeof(gint), - on_response_dtapi_phonebook_get_info, rsp_cb_data); - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_phonebook_read_record(gint result, - const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - const TelPbReadRecord *read_record = response; - - GVariantBuilder read_builder; - GVariant *var_read = NULL; - - dbg("Result: [%d]", result); - - tcore_check_return_assert(NULL != rsp_cb_data); - tcore_check_return_assert(NULL != read_record); - - g_variant_builder_init(&read_builder, G_VARIANT_TYPE("a{sv}")); - if (TEL_PB_RESULT_SUCCESS == result) { - if (read_record->pb_type == TEL_PB_USIM) { - GVariant *var_anr = NULL, *var_email = NULL; - GVariantBuilder anr_builder, email_builder; - - TelPbUsimRecord *usim = (TelPbUsimRecord *)(&read_record->rec_u.usim); - guint count = 0; - - g_variant_builder_add(&read_builder, "{sv}", - "name", g_variant_new_string(usim->name)); - g_variant_builder_add(&read_builder, "{sv}", - "number", g_variant_new_string(usim->number)); - g_variant_builder_add(&read_builder, "{sv}", - "sne", g_variant_new_string(usim->sne)); - g_variant_builder_add(&read_builder, "{sv}", - "grp_name", g_variant_new_string(usim->grp_name)); - - dbg("Phonebook type: [%d] Name: [%s] Number: [%s] "\ - "SNE: [%s] Group Name: [%s]", - read_record->pb_type, usim->name, - usim->number, usim->sne, usim->grp_name); - - /* ANR */ - g_variant_builder_add(&read_builder, "{sv}", - "anr_count", g_variant_new_byte(usim->anr_count)); - dbg("ANR Count: [%d]", usim->anr_count); - - g_variant_builder_init(&anr_builder, G_VARIANT_TYPE("aa{sv}")); - for (count = 0; count < usim->anr_count; count++) { - g_variant_builder_open(&anr_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&anr_builder, "{sv}", - "number", g_variant_new_string(usim->anr[count].number)); - g_variant_builder_add(&anr_builder, "{sv}", - "description", g_variant_new_boolean(usim->anr[count].description)); - g_variant_builder_add(&anr_builder, "{sv}", - "aas", g_variant_new_string(usim->anr[count].aas)); - - g_variant_builder_close(&anr_builder); - - dbg("ANR[%d] - Number: [%s] Description: [%s] AAS: [%s]", count, - usim->anr[count].number, - usim->anr[count].description ? "YES" : "NO", - usim->anr[count].aas); - } - var_anr = g_variant_builder_end(&anr_builder); - g_variant_builder_add(&read_builder, "{sv}", - "anr", var_anr); - - /* e-mail */ - g_variant_builder_add(&read_builder, "{sv}", - "email_count", g_variant_new_byte(usim->email_count)); - dbg("e-mail Count: [%d]", usim->email_count); - g_variant_builder_init(&email_builder, G_VARIANT_TYPE("a{sv}")); - if (usim->email_count && usim->email_count <= TEL_PB_EMAIL_MAX_COUNT) { - for (count = 0; count < usim->email_count; count++) { - char *tmp = g_strdup_printf("%d", count); - - dbg("e-mail[%s] - [%s]", tmp, usim->email[count]); - g_variant_builder_add(&email_builder, "{sv}", - tmp, - g_variant_new_from_data(G_VARIANT_TYPE("ay"), - usim->email[count], strlen(usim->email[count]), - TRUE, NULL, NULL)); - g_free(tmp); - } - } - var_email = g_variant_builder_end(&email_builder); - g_variant_builder_add(&read_builder, "{sv}", - "email", var_email); - - g_variant_builder_add(&read_builder, "{sv}", - "hidden", g_variant_new_boolean(usim->hidden)); - dbg("Hidden: [%s]", usim->hidden ? "YES" : "NO"); - } - else { - TelPbSimRecord *sim = (TelPbSimRecord *)&(read_record->rec_u.sim); - - g_variant_builder_add(&read_builder, "{sv}", - "name", g_variant_new_string(sim->name)); - g_variant_builder_add(&read_builder, "{sv}", - "number", g_variant_new_string(sim->number)); - - dbg("Phonebook type: [%d] Name: [%s] Number: [%s]", - read_record->pb_type, sim->name, sim->number); - } - } - var_read = g_variant_builder_end(&read_builder); - - telephony_phonebook_complete_read_record(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - read_record->index, read_record->next_index, - read_record->pb_type, var_read); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_phonebook_read_record(TelephonyPhonebook *phonebook, - GDBusMethodInvocation *invocation, - gint req_type, gint index, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn ret; - TelPbRecordInfo pb_record; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_PHONEBOOK, "r") == FALSE) - return TRUE; - - if (__check_phonebook_status(plugin) == FALSE) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid Phonebook Status"); - return TRUE; - } - - pb_record.pb_type = req_type; - pb_record.index = index; - - dbg("Phonebook Type: [%d] Index: [%d]", pb_record.pb_type, pb_record.index); - - rsp_cb_data = dtapi_create_resp_cb_data(phonebook, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_PHONEBOOK_READ_RECORD, - &pb_record, sizeof(TelPbRecordInfo), - on_response_dtapi_phonebook_read_record, rsp_cb_data); - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_phonebook_update_record(gint result, - const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - - dbg("Result: [%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_phonebook_complete_update_record(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_phonebook_update_record(TelephonyPhonebook *phonebook, - GDBusMethodInvocation *invocation, - gint pb_type, guint index, GVariant *update_rec, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - - TelPbUpdateRecord pb_update; - GVariantIter *iter; - - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_PHONEBOOK, "w") == FALSE) - return TRUE; - - if (__check_phonebook_status(plugin) == FALSE) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid Phonebook Status"); - return TRUE; - } - - memset(&pb_update, 0, sizeof(TelPbUpdateRecord)); - - pb_update.index = index; - pb_update.pb_type = pb_type; - - g_variant_get(update_rec, "a{sv}", &iter); - if (pb_update.pb_type == TEL_PB_USIM) { - GVariant *key_value; - const gchar *key; - - TelPbUsimRecord *usim = (TelPbUsimRecord *)&(pb_update.rec_u.usim); - - while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "name") == 0) { - g_strlcpy(usim->name, - g_variant_get_string(key_value, NULL), - TEL_PB_TEXT_MAX_LEN + 1); - } - else if (g_strcmp0(key, "number") == 0) { - g_strlcpy(usim->number, - g_variant_get_string(key_value, NULL), - TEL_PB_NUMBER_MAX_LEN + 1); - } - else if (g_strcmp0(key, "sne") == 0) { - g_strlcpy(usim->sne, - g_variant_get_string(key_value, NULL), - TEL_PB_TEXT_MAX_LEN + 1); - } - else if (g_strcmp0(key, "grp_name") == 0) { - g_strlcpy(usim->grp_name, - g_variant_get_string(key_value, NULL), - TEL_PB_TEXT_MAX_LEN + 1); - } - else if (g_strcmp0(key, "anr_count") == 0) { - usim->anr_count = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "anr") == 0) { - GVariantIter *iter2 = NULL, *iter_row2= NULL; - GVariant *key_value2; - const gchar *key2; - guint count = 0; - - g_variant_get(key_value, "aa{sv}", &iter2); - while (g_variant_iter_next(iter2, "a{sv}", &iter_row2)) { - while (g_variant_iter_loop(iter_row2, "{sv}", &key2, &key_value2)) { - if (g_strcmp0(key2, "number") == 0) { - g_strlcpy(usim->anr[count].number, - g_variant_get_string(key_value2, NULL), - TEL_PB_NUMBER_MAX_LEN + 1); - } - else if (g_strcmp0(key2, "description") == 0) { - usim->anr[count].description = - g_variant_get_boolean(key_value2); - } - else if (g_strcmp0(key2, "aas") == 0) { - g_strlcpy(usim->anr[count].aas, - g_variant_get_string(key_value2, NULL), - TEL_PB_TEXT_MAX_LEN + 1); - } - } - g_variant_iter_free(iter_row2); - } - g_variant_iter_free(iter2); - } - else if (g_strcmp0(key, "email_count") == 0) { - usim->email_count = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "email") == 0) { - GVariantIter *iter2 = NULL; - GVariant *key_value2; - const gchar *key2; - guint count = 0; - char *tmp; - - g_variant_get(key_value, "a{sv}", &iter2); - while (g_variant_iter_loop(iter2, "{sv}", &key2, &key_value2)) { - gconstpointer email; - - for (count = 0; count < usim->email_count; count++) { - tmp = g_strdup_printf("%d", count); - if (g_strcmp0(key2, tmp) == 0) { - email = g_variant_get_data(key_value2); - g_strlcpy(usim->email[count], email, strlen(email)+1); - dbg("email[%s] - [%s]", tmp, email); - } - g_free(tmp); - } - } - g_variant_iter_free(iter2); - } - else if (g_strcmp0(key, "hidden") == 0) { - usim->hidden = g_variant_get_boolean(key_value); - } - } - } - else { - GVariant *key_value; - const gchar *key; - - TelPbSimRecord *sim = (TelPbSimRecord *)&(pb_update.rec_u.sim); - - while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "name") == 0) { - g_strlcpy(sim->name, - g_variant_get_string(key_value, NULL), - TEL_PB_TEXT_MAX_LEN + 1); - } - else if (g_strcmp0(key, "number") == 0) { - g_strlcpy(sim->number, - g_variant_get_string(key_value, NULL), - TEL_PB_NUMBER_MAX_LEN + 1); - } - } - } - g_variant_iter_free(iter); - g_variant_unref(update_rec); - - rsp_cb_data = dtapi_create_resp_cb_data(phonebook, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_PHONEBOOK_UPDATE_RECORD, - &pb_update, sizeof(TelPbUpdateRecord), - on_response_dtapi_phonebook_update_record, rsp_cb_data); - if (TEL_RETURN_SUCCESS != ret) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_phonebook_delete_record(gint result, - const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - - dbg("Result: [%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_phonebook_complete_delete_record(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_phonebook_delete_record(TelephonyPhonebook *phonebook, - GDBusMethodInvocation *invocation, - gint pb_type, guint index, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn ret; - TelPbRecordInfo pb_record; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_PHONEBOOK, "w") == FALSE) - return TRUE; - - if (__check_phonebook_status(plugin) == FALSE) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid Phonebook Status"); - return TRUE; - } - - pb_record.pb_type = pb_type; - pb_record.index = index; - - dbg("Phonebook_type: [%d], index: [%d]", pb_record.pb_type, pb_record.index); - - rsp_cb_data = dtapi_create_resp_cb_data(phonebook, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_PHONEBOOK_DELETE_RECORD, - &pb_record, sizeof(TelPbRecordInfo), - on_response_dtapi_phonebook_delete_record, rsp_cb_data); - if (TEL_RETURN_SUCCESS != ret) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -gboolean dtapi_setup_phonebook_interface(TelephonyObjectSkeleton *object, - TcorePlugin *plugin) -{ - TelephonyPhonebook *phonebook = telephony_phonebook_skeleton_new(); - tcore_check_return_value_assert(phonebook != NULL, FALSE); - - telephony_object_skeleton_set_phonebook(object, phonebook); - g_object_unref(phonebook); - - dbg("phonebook = %p", phonebook); - - g_signal_connect(phonebook, - "handle-get-init-info", - G_CALLBACK(dtapi_phonebook_get_init_info), - plugin); - - g_signal_connect(phonebook, - "handle-get-info", - G_CALLBACK(dtapi_phonebook_get_info), - plugin); - - g_signal_connect(phonebook, - "handle-read-record", - G_CALLBACK(dtapi_phonebook_read_record), - plugin); - - g_signal_connect(phonebook, - "handle-update-record", - G_CALLBACK(dtapi_phonebook_update_record), - plugin); - - g_signal_connect(phonebook, - "handle-delete-record", - G_CALLBACK(dtapi_phonebook_delete_record), - plugin); - - return TRUE; -} - -gboolean dtapi_handle_phonebook_notification(TelephonyObjectSkeleton *object, - TcorePlugin *plugin, TcoreNotification command, - guint data_len, const void *data) -{ - TelephonyPhonebook *phonebook; - - tcore_check_return_value_assert(object != NULL, FALSE); - tcore_check_return_value_assert(plugin != NULL, FALSE); - tcore_check_return_value_assert(data != NULL, FALSE); - - phonebook = telephony_object_peek_phonebook(TELEPHONY_OBJECT(object)); - - tcore_check_return_value_assert(phonebook != NULL, FALSE); - - switch (command) { - case TCORE_NOTIFICATION_PHONEBOOK_STATUS: { - const TelPbInitInfo *init_info = data; - dbg("Phonebook: [%p], init_status: [%d], " - "FDN: [%d], ADN: [%d], SDN: [%d], USIM: [%d]", - phonebook, init_info->init_status, - init_info->pb_list.fdn, init_info->pb_list.adn, - init_info->pb_list.sdn, init_info->pb_list.usim); - - telephony_phonebook_emit_status(phonebook, init_info->init_status, - init_info->pb_list.fdn, init_info->pb_list.adn, - init_info->pb_list.sdn, init_info->pb_list.usim); - } - break; - - default: - err("not handled cmd[0x%x]", command); - } - - return TRUE; -} diff --git a/src/dtapi_sap.c b/src/dtapi_sap.c deleted file mode 100644 index 03460bd..0000000 --- a/src/dtapi_sap.c +++ /dev/null @@ -1,405 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_sap.h" -#include "dtapi_util.h" - -#include -#include - -#define AC_SAP "telephony_framework::api_sap" - -static void on_response_dtapi_sap_req_connect(gint result, const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - guint max_msg_size = 0; - - tcore_check_return_assert(NULL != rsp_cb_data); - tcore_check_return_assert(NULL != response); - - if (result == TEL_SAP_RESULT_SUCCESS) - max_msg_size = *(guint *)response; - - dbg("result = [%d], resp_max_size[%d]", result, max_msg_size); - - telephony_sap_complete_req_connect(rsp_cb_data->interface_object, rsp_cb_data->invocation, - result, max_msg_size); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sap_req_connect(TelephonySap *sap, GDBusMethodInvocation *invocation, - guint req_max_size, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAP, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sap, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SAP_REQ_CONNECT, &req_max_size, - sizeof(req_max_size), on_response_dtapi_sap_req_connect, rsp_cb_data); - - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sap_req_disconnect(gint result, const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result = [%d]", result); - - telephony_sap_complete_req_disconnect(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sap_req_disconnect(TelephonySap *sap, GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAP, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sap, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SAP_REQ_DISCONNECT, NULL, 0, - on_response_dtapi_sap_req_disconnect, rsp_cb_data); - - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sap_get_atr(gint result, const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - const TelSapAtr *sap_atr = response; - gchar *encoded_atr = NULL; - - tcore_check_return_assert(NULL != rsp_cb_data); - tcore_check_return_assert(NULL != sap_atr); - tcore_check_return_assert(sap_atr->atr_len <= TEL_SAP_ATR_LEN_MAX); - - dbg("result = [%d]", result); - - if (result == TEL_SAP_RESULT_SUCCESS) { - encoded_atr = g_base64_encode(sap_atr->atr, sap_atr->atr_len); - dbg("encoded_atr: [%s] encoded_atr_len: [%d]", encoded_atr, strlen(encoded_atr)); - } - - telephony_sap_complete_get_atr(rsp_cb_data->interface_object, rsp_cb_data->invocation, - result, encoded_atr); - tcore_free(encoded_atr); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sap_get_atr(TelephonySap *sap, GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAP, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sap, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SAP_GET_ATR, NULL, 0, - on_response_dtapi_sap_get_atr, rsp_cb_data); - - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sap_req_transfer_apdu(gint result, const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - const TelSapApduResp *resp_apdu = response; - gchar *encoded_apdu = NULL; - - tcore_check_return_assert(NULL != rsp_cb_data); - tcore_check_return_assert(NULL != resp_apdu); - tcore_check_return_assert(resp_apdu->apdu_resp_len <= TEL_SAP_APDU_RESP_LEN_MAX); - - dbg("result = [%d]", result); - - if (result == TEL_SAP_RESULT_SUCCESS) { - encoded_apdu = g_base64_encode(resp_apdu->apdu_resp, resp_apdu->apdu_resp_len); - dbg("encoded_apdu: [%s] encoded_apdu_len: [%d]", encoded_apdu, strlen(encoded_apdu)); - } - - telephony_sap_complete_req_transfer_apdu(rsp_cb_data->interface_object, rsp_cb_data->invocation, - result, encoded_apdu); - tcore_free(encoded_apdu); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sap_req_transfer_apdu(TelephonySap *sap, GDBusMethodInvocation *invocation, - gchar *apdu, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - TelSapApdu req_apdu; - guchar *decoded_apdu = NULL; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAP, "x") == FALSE) - return TRUE; - - memset(&req_apdu, 0, sizeof(TelSapApdu)); - - decoded_apdu = g_base64_decode(apdu, &req_apdu.apdu_len); - if ((decoded_apdu != NULL) && (req_apdu.apdu_len <= TEL_SAP_APDU_LEN_MAX)) { - memcpy(req_apdu.apdu, decoded_apdu, req_apdu.apdu_len); - } else { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Decoding APDU request failed"); - tcore_free(decoded_apdu); - return TRUE; - } - - rsp_cb_data = dtapi_create_resp_cb_data(sap, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SAP_REQ_TRANSFER_APDU, - &req_apdu, sizeof(TelSapApdu), on_response_dtapi_sap_req_transfer_apdu, rsp_cb_data); - - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - tcore_free(decoded_apdu); - - return TRUE; -} - -static void on_response_dtapi_sap_req_transport_protocol(gint result, const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result = [%d]", result); - - telephony_sap_complete_req_transport_protocol(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sap_req_transport_protocol(TelephonySap *sap, GDBusMethodInvocation *invocation, - gint req_protocol, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - TelSimSapProtocol sap_protocoal; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAP, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sap, invocation, NULL, 0); - - sap_protocoal = req_protocol; - - ret = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SAP_REQ_TRANSPORT_PROTOCOL, - &sap_protocoal, sizeof(TelSimSapProtocol), on_response_dtapi_sap_req_transport_protocol, rsp_cb_data); - - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sap_req_power_operation(gint result, const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result = [%d]", result); - - telephony_sap_complete_req_power_operation(rsp_cb_data->interface_object, rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sap_req_power_operation(TelephonySap *sap, GDBusMethodInvocation *invocation, - gint req_power_mode, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - TelSapPowerMode sap_power_mode; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAP, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sap, invocation, NULL, 0); - - sap_power_mode = req_power_mode; - - ret = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SAP_REQ_POWER_OPERATION, - &sap_power_mode, sizeof(TelSapPowerMode), on_response_dtapi_sap_req_power_operation, rsp_cb_data); - - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sap_get_card_reader_status(gint result, const void *response, void *user_data) -{ - DbusRespCbData *rsp_cb_data = user_data; - gint sap_status = 0; - tcore_check_return_assert(NULL != rsp_cb_data); - tcore_check_return_assert(NULL != response); - - if(result == TEL_SAP_RESULT_SUCCESS) - sap_status = *(gint *)response; - - dbg("result = [%d] sap status = [%d]", result, sap_status); - - telephony_sap_complete_get_card_reader_status(rsp_cb_data->interface_object, rsp_cb_data->invocation, - result, sap_status); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sap_get_card_reader_status(TelephonySap *sap, GDBusMethodInvocation *invocation, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data; - TcorePlugin *plugin = (TcorePlugin *)user_data; - TelReturn ret; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAP, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sap, invocation, NULL, 0); - - ret = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SAP_GET_CARDREADER_STATUS, NULL, 0, - on_response_dtapi_sap_get_card_reader_status, rsp_cb_data); - - if (ret != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -gboolean dtapi_setup_sap_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin) -{ - TelephonySap *sap = telephony_sap_skeleton_new(); - tcore_check_return_value_assert(NULL != sap, FALSE); - - telephony_object_skeleton_set_sap(object, sap); - g_object_unref(sap); - - dbg("sap = %p", sap); - - g_signal_connect (sap, - "handle-req-connect", - G_CALLBACK (dtapi_sap_req_connect), - plugin); - - g_signal_connect (sap, - "handle-req-disconnect", - G_CALLBACK (dtapi_sap_req_disconnect), - plugin); - - g_signal_connect (sap, - "handle-get-atr", - G_CALLBACK (dtapi_sap_get_atr), - plugin); - - g_signal_connect (sap, - "handle-req-transfer-apdu", - G_CALLBACK (dtapi_sap_req_transfer_apdu), - plugin); - - g_signal_connect (sap, - "handle-req-transport-protocol", - G_CALLBACK (dtapi_sap_req_transport_protocol), - plugin); - - g_signal_connect (sap, - "handle-req-power-operation", - G_CALLBACK (dtapi_sap_req_power_operation), - plugin); - - g_signal_connect (sap, - "handle-get-card-reader-status", - G_CALLBACK (dtapi_sap_get_card_reader_status), - plugin); - - return TRUE; -} - -gboolean dtapi_handle_sap_notification(TelephonyObjectSkeleton *object, TcorePlugin *plugin, - TcoreNotification command, guint data_len, const void *data) -{ - TelephonySap *sap; - - tcore_check_return_value_assert(NULL != object, FALSE); - tcore_check_return_value_assert(NULL != data, FALSE); - sap = telephony_object_peek_sap(TELEPHONY_OBJECT(object)); - - switch (command) { - case TCORE_NOTIFICATION_SAP_STATUS: - { - int sap_status = *(int *)data; - dbg("sap(%p) : sap_status = [%d]", sap, sap_status); - telephony_sap_emit_status(sap, sap_status); - } - break; - default: - err("not handled command[0x%x]", command); - break; - } - return TRUE; -} diff --git a/src/dtapi_sat.c b/src/dtapi_sat.c deleted file mode 100644 index e787138..0000000 --- a/src/dtapi_sat.c +++ /dev/null @@ -1,1385 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_sat.h" -//#include "dtapi_util.h" -#include "plugin.h" -#include "sat-manager/include/sat_manager.h" -#include "sat-manager/include/sat_ui_support.h" - -#define AC_SAT "telephony_framework::api_sat" - -static void _util_sat_set_main_menu(DtapiSatPrivateData *sat_data, - const char *cp_name, GVariant *main_menu) -{ - GSList *list = NULL; - SatCachedData *object = NULL; - - for (list = sat_data->cached_data; list; list = list->next) { - object = (SatCachedData *) list->data; - if (object == NULL) - continue; - - if (g_strcmp0(object->cp_name, cp_name) == 0 ) { - /* need to free the previous main_menu */ - g_variant_unref(object->cached_sat_main_menu); - object->cached_sat_main_menu = main_menu; - return; - } - } - - /* If 'object' is NOT created, then create the object and add to the list */ - object = tcore_try_malloc0(sizeof(SatCachedData)); - if (NULL == object) { - err(" Malloc Failed"); - return; - } - object->cp_name = g_strdup(cp_name); - object->cached_sat_main_menu = main_menu; - - sat_data->cached_data = - g_slist_append(sat_data->cached_data, (gpointer)object); -} - -static GVariant *_util_sat_get_main_menu(DtapiSatPrivateData *sat_data, - const char *cp_name) -{ - GSList *list = NULL; - SatCachedData *object; - - dbg("Get Main menu"); - /* - * List of Objects in 'sat_data', - * compare cp_name with modem_name stored in 'sat_data' - * if matching return main_menu of that object. - */ - for (list = sat_data->cached_data; list; list = list->next) { - object = (SatCachedData *)list->data; - if (object == NULL) - continue; - - if (g_strcmp0(object->cp_name, cp_name) == 0) - return object->cached_sat_main_menu; - } - - return NULL; -} - -static gboolean dtapi_sat_get_main_menu_info(TelephonySat *sat, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DtapiSatPluginsInfo *plugins_info = (DtapiSatPluginsInfo *)user_data; - TcorePlugin *comm_plugin = plugins_info->comm_plugin; - GVariant *main_menu = NULL; - DtapiSatPrivateData *sat_data = NULL; - gchar *title; - gint command_id, item_cnt; - gboolean is_present, is_help_info, is_updated; - GVariant *items; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAT, "r") == FALSE) - return TRUE; - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid parameter"); - return TRUE; - } - - main_menu = _util_sat_get_main_menu(sat_data, - dtapi_get_cp_name_by_object_path( - g_dbus_method_invocation_get_object_path(invocation))); - if (!main_menu) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "No main menu"); - return TRUE; - } - - g_variant_get(main_menu, "(ibs@vibb)", - &command_id, &is_present, &title, &items, &item_cnt, - &is_help_info, &is_updated); - - dbg("Command ID: [%d] Menu: [%s] Title: [%s] count: [%d]", - command_id, is_present ? "PRESENT" : "NOT PRESENT", - title, item_cnt); - - telephony_sat_complete_get_main_menu_info(sat, invocation, - TEL_SAT_RESULT_SUCCESS, command_id, is_present, title, items, item_cnt, - is_help_info, is_updated); - - return TRUE; -} - -static gboolean dtapi_sat_send_display_status(TelephonySat *sat, - GDBusMethodInvocation *invocation, gint arg_command_id, - gboolean arg_display_status, gpointer user_data) -{ - DtapiSatPluginsInfo *plugins_info = (DtapiSatPluginsInfo *)user_data; - gboolean result = FALSE; - gint out_param = 1; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAT, "x") == FALSE) - return TRUE; - - result = sat_manager_handle_ui_display_status(plugins_info, - arg_command_id, arg_display_status); - if (!result) { - err("fail to send display status"); - } - - out_param = (result ? 1 : 0); - telephony_sat_complete_send_ui_display_status(sat, invocation, out_param); - - return TRUE; -} - -static gboolean dtapi_sat_send_user_confirm(TelephonySat *sat, - GDBusMethodInvocation *invocation, gint arg_command_id, - gint arg_command_type, gint arg_user_confirm_type, - GVariant *arg_additional_data, gpointer user_data) -{ - DtapiSatPluginsInfo *plugins_info = (DtapiSatPluginsInfo *)user_data; - gboolean result = FALSE; - gint out_param = 1; - GVariant *confirm_data = NULL; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAT, "x") == FALSE) - return TRUE; - - confirm_data = g_variant_new("(iiv)", - arg_command_id, arg_user_confirm_type, arg_additional_data); - - result = sat_manager_handle_user_confirm(plugins_info, confirm_data); - if (!result) { - err("fail to send user confirm"); - } - - out_param = (result ? 1 : 0); - telephony_sat_complete_send_user_confirm(sat, invocation, out_param); - - return TRUE; -} - -static gboolean dtapi_sat_send_app_exec_result(TelephonySat *sat, - GDBusMethodInvocation *invocation, gint arg_command_id, - gint arg_command_type, GVariant *arg_exec_result, - gpointer user_data) -{ - DtapiSatPluginsInfo *plugins_info = (DtapiSatPluginsInfo *)user_data; - TcorePlugin *plugin = plugins_info->plugin; - gboolean result = FALSE; - gint out_param = 1; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAT, "x") == FALSE) - return TRUE; - - dbg("processing app exec result"); - result = sat_manager_handle_app_exec_result(plugin, - arg_command_id, arg_command_type, arg_exec_result); - if (!result) { - err("fail to send exec result"); - } - - out_param = (result ? 1 : 0); - telephony_sat_complete_send_app_exec_result(sat, invocation, out_param); - - return TRUE; -} - -static void on_response_dtapi_sat_select_menu(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = (DbusRespCbData *)cb_data; - TelSatEnvelopeResp *envelop_resp = (TelSatEnvelopeResp *)data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("Select Menu Envelope Response: Result:[%d] Env Resp:[%d]", result, *envelop_resp); - telephony_sat_complete_select_menu(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, (gint)*envelop_resp); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sat_select_menu(TelephonySat *sat, - GDBusMethodInvocation *invocation, guchar arg_item_identifier, - gboolean arg_help_request, gpointer user_data) -{ - DtapiSatPluginsInfo *plugins_info = (DtapiSatPluginsInfo *)user_data; - TcorePlugin *plugin = plugins_info->plugin; - DbusRespCbData *rsp_cb_data = NULL; - TelSatRequestEnvelopCmdData envelop_req; - TelReturn result; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAT, "x") == FALSE) - return TRUE; - - memset(&envelop_req, 0, sizeof(TelSatRequestEnvelopCmdData)); - - envelop_req.sub_cmd = TEL_SAT_ENVELOP_MENU_SELECTION; - envelop_req.envelop_data.menu_select.device_identitie.src = TEL_SAT_DEVICE_ID_KEYPAD; - envelop_req.envelop_data.menu_select.device_identitie.dest = TEL_SAT_DEVICE_ID_SIM; - envelop_req.envelop_data.menu_select.item_identifier = arg_item_identifier; - envelop_req.envelop_data.menu_select.help_request = arg_help_request; - - rsp_cb_data = dtapi_create_resp_cb_data(sat, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SAT_REQ_ENVELOPE, - &envelop_req, sizeof(TelSatRequestEnvelopCmdData), - on_response_dtapi_sat_select_menu, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Request dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sat_download_event(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - TelSatEnvelopeResp *envelop_resp = (TelSatEnvelopeResp *)data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("Event Download Envelope Response: Result:[%d] Env Resp:[%d]", result, *envelop_resp); - telephony_sat_complete_download_event(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, (gint)*envelop_resp); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sat_download_event(TelephonySat *sat, - GDBusMethodInvocation *invocation, gint arg_event_download_type, - gint arg_src_device,gint arg_dest_device, - GVariant *arg_download_data, gpointer user_data) -{ - DtapiSatPluginsInfo *plugins_info = (DtapiSatPluginsInfo *)user_data; - TcorePlugin *plugin = plugins_info->plugin; - DbusRespCbData *rsp_cb_data = NULL; - TelSatRequestEnvelopCmdData envelop_req; - TelReturn result; - - dbg("Entry"); - - if (dtapi_check_access_control(invocation, AC_SAT, "x") == FALSE) - return TRUE; - - memset(&envelop_req, 0, sizeof(TelSatRequestEnvelopCmdData)); - - envelop_req.sub_cmd = TEL_SAT_ENVELOP_EVENT_DOWNLOAD; - envelop_req.envelop_data.event_download.event = arg_event_download_type; - - sat_manager_handle_event_download_envelop(arg_event_download_type, - arg_src_device, arg_dest_device, &envelop_req.envelop_data.event_download, - arg_download_data); - - rsp_cb_data = dtapi_create_resp_cb_data(sat, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SAT_REQ_ENVELOPE, - &envelop_req, sizeof(TelSatRequestEnvelopCmdData), - on_response_dtapi_sat_download_event, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Request dispatch failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -gboolean dtapi_setup_sat_interface(TelephonyObjectSkeleton *object, TcorePlugin *plugin, TcorePlugin *comm_plugin) -{ - TelephonySat *sat; - DtapiSatPluginsInfo *plugins_info; - - sat = telephony_sat_skeleton_new(); - telephony_object_skeleton_set_sat(object, sat); - g_object_unref(sat); - - dbg("sat = %p", sat); - - plugins_info = tcore_malloc0(sizeof(DtapiSatPluginsInfo)); - plugins_info->comm_plugin = comm_plugin; - plugins_info->plugin = plugin; - - g_signal_connect (sat, - "handle-get-main-menu-info", - G_CALLBACK (dtapi_sat_get_main_menu_info), - plugins_info); - - g_signal_connect (sat, - "handle-send-ui-display-status", - G_CALLBACK (dtapi_sat_send_display_status), - plugins_info); - - g_signal_connect (sat, - "handle-send-user-confirm", - G_CALLBACK (dtapi_sat_send_user_confirm), - plugins_info); - - g_signal_connect (sat, - "handle-send-app-exec-result", - G_CALLBACK (dtapi_sat_send_app_exec_result), - plugins_info); - - g_signal_connect (sat, - "handle-select-menu", - G_CALLBACK (dtapi_sat_select_menu), - plugins_info); - - g_signal_connect (sat, - "handle-download-event", - G_CALLBACK (dtapi_sat_download_event), - plugins_info); - - return TRUE; -} - -gboolean dtapi_handle_sat_notification(TelephonyObjectSkeleton *object, - TcorePlugin *plugin, TcorePlugin *comm_plugin, TcoreNotification command, - guint data_len, const void *data) -{ - TelephonySat *sat; - const char *cp_name; - DtapiSatPrivateData *sat_data = NULL; - - if (!object || !plugin) { - err("Invalid parameters"); - return FALSE; - } - cp_name = tcore_server_get_cp_name_by_plugin(plugin); - - dbg("Notification!!! Command: [0x%x] CP Name: [%s]", command, cp_name); - - sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); - dbg("sat: [%p]", sat); - - sat_data = (DtapiSatPrivateData *)tcore_plugin_ref_user_data(comm_plugin); - if (!sat_data) { - err("sat_data is null"); - return FALSE; - } - - /* SAT UI storage init */ - sat_ui_support_storage_init(sat_data->server); - - //session end notification - switch (command) { - case TCORE_NOTIFICATION_SAT_SESSION_END: { - dbg("notified sat session end evt"); - sat_manager_init_queue(); - - //sat_ui_support_terminate_sat_ui(); - telephony_sat_emit_end_proactive_session(sat, - TEL_SAT_PROATV_CMD_TYPE_END_PROACTIVE_SESSION); - - return TRUE; - } - break; - - //call control notification - case TCORE_NOTIFICATION_SAT_CALL_CTRL_RESULT: { - TelSatNotiCallControlResultInd *cc_result_noti = NULL; - gint call_ctrl_result = 0, bc_repeat_indicator = 0, ton = 0x0F, npi=0X0F; - gchar *text = NULL, *call_num = NULL, *ss_string = NULL; - gchar *sub_addr = NULL, *ccp1 = NULL, *ccp2 = NULL; - - cc_result_noti = (TelSatNotiCallControlResultInd *)data; - if (NULL == cc_result_noti) { - err("Indication data is NULL"); - return FALSE; - } - dbg("sat call control result notification"); - - call_ctrl_result = cc_result_noti->cc_result; - bc_repeat_indicator = cc_result_noti->bc_repeat_type; - - if (cc_result_noti->address.dialing_number_len > 0) { - ton = cc_result_noti->address.ton; - npi = cc_result_noti->address.npi; - call_num = g_strdup(cc_result_noti->address.dialing_number); - ss_string = g_strdup(""); - } - else if (cc_result_noti->ss_string.string_len > 0) { - ton = cc_result_noti->ss_string.ton; - npi = cc_result_noti->ss_string.npi; - call_num = g_strdup(""); - ss_string = g_strdup(cc_result_noti->ss_string.ss_string); - } - - if (cc_result_noti->alpha_id.alpha_data_len > 0) { - text = g_strdup(cc_result_noti->alpha_id.alpha_data); - } - else{ - text = g_strdup(""); - } - - if (cc_result_noti->sub_address.subaddress_len > 0) { - sub_addr = g_strdup(cc_result_noti->sub_address.subaddress); - } - else{ - sub_addr = g_strdup(""); - } - - if (cc_result_noti->ccp1.data_len > 0) { - ccp1 = g_strdup(cc_result_noti->ccp1.data); - } - else{ - ccp1 = g_strdup(""); - } - - - if (cc_result_noti->ccp2.data_len > 0) { - ccp2 = g_strdup(cc_result_noti->ccp2.data); - } - else{ - ccp2 = g_strdup(""); - } - -#if 0 /* TODO - unblock */ - telephony_sat_emit_call_control_result(sat, call_ctrl_result, text, ton, npi, call_num, - ss_string, sub_addr, ccp1, ccp2, bc_repeat_indicator); -#endif - g_free(text); g_free(call_num); g_free(ss_string); - g_free(sub_addr); g_free(ccp1); g_free(ccp2); - return TRUE; - } - break; - - case TCORE_NOTIFICATION_SAT_MO_SM_CTRL_RESULT: { - TelSatNotiMoSmControlResultInd *mo_sm_result_noti = NULL; - gint call_ctrl_result = 0; - gint rp_dst_ton = 0x0F, rp_dst_npi = 0X0F, tp_dst_ton = 0x0F, tp_dst_npi = 0X0F; - gchar *text = NULL, *rp_dst_call_num = NULL, *tp_dst_call_num = NULL; - - mo_sm_result_noti = (TelSatNotiMoSmControlResultInd *)data; - if (mo_sm_result_noti == NULL) { - err("Indication data is NULL"); - return FALSE; - } - dbg("sat mo sm control result notification"); - - call_ctrl_result = mo_sm_result_noti->cc_result; - - if (mo_sm_result_noti->rp_dst_address.dialing_number_len > 0) { - rp_dst_ton = mo_sm_result_noti->rp_dst_address.ton; - rp_dst_npi = mo_sm_result_noti->rp_dst_address.npi; - rp_dst_call_num = g_strdup(mo_sm_result_noti->rp_dst_address.dialing_number); - } else { - rp_dst_call_num = g_strdup(""); - } - - if (mo_sm_result_noti->tp_dst_address.dialing_number_len > 0) { - tp_dst_ton = mo_sm_result_noti->tp_dst_address.ton; - tp_dst_npi = mo_sm_result_noti->tp_dst_address.npi; - tp_dst_call_num = g_strdup(mo_sm_result_noti->tp_dst_address.dialing_number); - } else { - tp_dst_call_num = g_strdup(""); - } - - if (mo_sm_result_noti->alpha_id.alpha_data_len > 0) { - text = g_strdup(mo_sm_result_noti->alpha_id.alpha_data); - } - else{ - text = g_strdup(""); - } - -#if 0 /* TODO - unblock */ - telephony_sat_emit_mo_sm_control_result(sat, call_ctrl_result, text, - rp_dst_ton, rp_dst_npi, rp_dst_call_num, tp_dst_ton, tp_dst_npi, tp_dst_call_num); -#endif - g_free(text); g_free(rp_dst_call_num); g_free(tp_dst_call_num); - return TRUE; - } - break; - - //Proactive Command Notification - case TCORE_NOTIFICATION_SAT_PROACTIVE_CMD: { - TelSatNotiProactiveData *p_ind; - - if (cp_name == NULL) { - err("CP name is NULL"); - return FALSE; - } - - p_ind = (TelSatNotiProactiveData *)data; - if (p_ind == NULL) { - err("Indication data is NULL"); - return FALSE; - } - dbg("notified sat proactive command(%d)", p_ind->cmd_type); - - switch (p_ind->cmd_type) { - case TEL_SAT_PROATV_CMD_SETUP_MENU:{ - gboolean rv = FALSE; - GVariant *menu_info = NULL; - GVariant *resp = NULL; - GVariant *exec_result = NULL; - - gchar *title; - gint command_id, menu_cnt; - gboolean is_present, is_helpinfo, is_updated; - GVariant *items; - - menu_info = sat_manager_extracting_setup_menu_info(plugin, comm_plugin, (TelSatSetupMenuTlv*)&p_ind->proactive_ind_data.setup_menu); - - if (!menu_info) { - err("no main menu data"); - sat_ui_support_remove_desktop_file(); - telephony_sat_emit_end_proactive_session(sat, TEL_SAT_PROATV_CMD_TYPE_END_PROACTIVE_SESSION); - return TRUE; - } - - _util_sat_set_main_menu(sat_data, cp_name, menu_info); - - dbg("menu_info type_format(%s)", g_variant_get_type_string(menu_info)); - g_variant_get(menu_info, "(ibs@vibb)", &command_id, &is_present, &title, &items, - &menu_cnt, &is_helpinfo, &is_updated); - - rv = sat_ui_support_create_desktop_file(title); - - dbg("return value (%d)", rv); - if (rv) - resp = g_variant_new("(i)", TEL_SAT_RESULT_SUCCESS); - else - resp = g_variant_new("(i)", TEL_SAT_RESULT_ME_UNABLE_TO_PROCESS_COMMAND); - - exec_result = g_variant_new_variant(resp); - sat_manager_handle_app_exec_result(plugin, command_id, TEL_SAT_PROATV_CMD_SETUP_MENU, exec_result); - - //sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_SETUP_MENU, menu_info); - if (is_updated) - telephony_sat_emit_setup_menu(sat, command_id, is_present, title, items, menu_cnt, - is_helpinfo, is_updated); - } - break; - - case TEL_SAT_PROATV_CMD_DISPLAY_TEXT:{ - GVariant *display_text = NULL; - - gint command_id, text_len, duration; - gboolean high_priority, user_rsp_required, immediately_rsp; - gchar* text; - GVariant *icon_id = NULL; - int ret; - - display_text = sat_manager_display_text_noti(plugin, (TelSatDisplayTextTlv*) &p_ind->proactive_ind_data.display_text, p_ind->decode_err_code); - - if (!display_text) { - err("no display text data"); - return TRUE; - } - - dbg("display text type_format(%s)", g_variant_get_type_string(display_text)); - g_variant_get(display_text, "(isiibbb@v)", &command_id, &text, &text_len, &duration, - &high_priority, &user_rsp_required, &immediately_rsp, &icon_id); - - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_DISPLAY_TEXT, display_text); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - - telephony_sat_emit_display_text(sat, command_id, text, text_len, duration, - high_priority, user_rsp_required, immediately_rsp); - - } - break; - - case TEL_SAT_PROATV_CMD_SELECT_ITEM:{ - GVariant *select_menu = NULL; - - gboolean help_info ; - gchar *selected_text; - gint command_id, default_item_id, menu_cnt, text_len =0; - GVariant *menu_items, *icon_id, *icon_list; - int ret; - - select_menu = sat_manager_select_item_noti(plugin, (TelSatSelectItemTlv*) &p_ind->proactive_ind_data.select_item, p_ind->decode_err_code); - - if (!select_menu) { - err("no select menu data"); - return TRUE; - } - - dbg("select menu type_format(%s)", g_variant_get_type_string(select_menu)); - g_variant_get(select_menu, "(ibsiii@v@v@v)", &command_id, &help_info, &selected_text, - &text_len, &default_item_id, &menu_cnt, &menu_items, &icon_id, &icon_list); - - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_SELECT_ITEM, select_menu); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - - telephony_sat_emit_select_item (sat, command_id, help_info, selected_text, text_len, - default_item_id, menu_cnt, menu_items); - } - break; - - case TEL_SAT_PROATV_CMD_GET_INKEY:{ - GVariant *get_inkey = NULL; - gint command_id, key_type, input_character_mode; - gint text_len, duration; - gboolean is_numeric, is_help_info; - gchar *text; - GVariant *icon_id; - int ret; - - get_inkey = sat_manager_get_inkey_noti(plugin, (TelSatGetInkeyTlv*) &p_ind->proactive_ind_data.get_inkey, p_ind->decode_err_code); - - if (!get_inkey) { - err("no get inkey data"); - return TRUE; - } - - dbg("get inkey type_format(%s)", g_variant_get_type_string(get_inkey)); - g_variant_get(get_inkey, "(iiibbsii@v)", &command_id, &key_type, &input_character_mode, - &is_numeric,&is_help_info, &text, &text_len, &duration, &icon_id); - - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_GET_INKEY, get_inkey); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - - telephony_sat_emit_get_inkey(sat, command_id, key_type, input_character_mode, - is_numeric, is_help_info, text, text_len, duration); - } - break; - - case TEL_SAT_PROATV_CMD_GET_INPUT:{ - GVariant *get_input = NULL; - gint command_id, input_character_mode; - gint text_len, def_text_len, rsp_len_min, rsp_len_max; - gboolean is_numeric, is_help_info, is_echo_input; - gchar *text, *def_text; - GVariant *icon_id; - int ret; - - get_input = sat_manager_get_input_noti(plugin, (TelSatGetInputTlv*) &p_ind->proactive_ind_data.get_input, p_ind->decode_err_code); - - if (!get_input) { - err("no get input data"); - return TRUE; - } - - dbg("get input type_format(%s)", g_variant_get_type_string(get_input)); - g_variant_get(get_input, "(iibbbsiiisi@v)", &command_id, &input_character_mode, &is_numeric, &is_help_info, &is_echo_input, - &text, &text_len, &rsp_len_max, &rsp_len_min, &def_text, &def_text_len, &icon_id); - - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_GET_INPUT, get_input); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - - telephony_sat_emit_get_input(sat, command_id, input_character_mode, is_numeric, is_help_info, - is_echo_input, text, text_len, rsp_len_max, rsp_len_min, def_text, def_text_len); - } - break; - - case TEL_SAT_PROATV_CMD_PLAY_TONE:{ - GVariant *play_tone = NULL; - gint command_id, tone_type, duration; - gint text_len; - gchar* text; - GVariant *icon_id; - int ret; - - play_tone = sat_manager_play_tone_noti(plugin, (TelSatPlayToneTlv*) &p_ind->proactive_ind_data.play_tone); - - if (!play_tone) { - err("no play tone data"); - return TRUE; - } - - dbg("play tone type_format(%s)", g_variant_get_type_string(play_tone)); - g_variant_get(play_tone, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &tone_type, &duration); - - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_PLAY_TONE, play_tone); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - - telephony_sat_emit_play_tone(sat, command_id, text, text_len, tone_type, duration); - } - break; - - case TEL_SAT_PROATV_CMD_SEND_SMS:{ - GVariant *send_sms = NULL; - - gint command_id, ton, npi, tpdu_type; - gboolean is_packing_required; - gint text_len, number_len, tpdu_data_len; - gchar* text, *dialling_number; - GVariant *tpdu_data, *icon_id; - - send_sms = sat_manager_send_sms_noti(plugin, (TelSatSendSmsTlv*) &p_ind->proactive_ind_data.send_sms); - - if (!send_sms) { - err("no send sms data"); - return TRUE; - } - - dbg("send sms type_format(%s)", g_variant_get_type_string(send_sms)); - g_variant_get(send_sms, "(isi@vbiisii@vi)", &command_id, &text, &text_len, &icon_id, &is_packing_required, &ton, &npi, - &dialling_number, &number_len, &tpdu_type, &tpdu_data, &tpdu_data_len); - - dbg("check display text : text(%s) text len(%d)", text, text_len); - if (text_len > 1 && (g_strcmp0(text,"") != 0) ) { - GVariant *ui_info = NULL; - gboolean user_confirm = FALSE; - int ret; - dbg("text should be displayed by ui"); - dbg("send sms is pending!!!"); - - ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_NONE, ui_info); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - return TRUE; - } - telephony_sat_emit_send_sms(sat, command_id, text, text_len, is_packing_required, - ton, npi, dialling_number, number_len, tpdu_type, tpdu_data, tpdu_data_len); - } - break; - - case TEL_SAT_PROATV_CMD_SEND_SS:{ - GVariant *send_ss = NULL; - - gint command_id, ton, npi; - gint text_len, ss_str_len; - gchar* text, *ss_string; - - GVariant *icon_id; - - send_ss = sat_manager_send_ss_noti(plugin, (TelSatSendSsTlv*) &p_ind->proactive_ind_data.send_ss); - - if (!send_ss) { - err("no send ss data"); - return TRUE; - } - - dbg("send ss type_format(%s)", g_variant_get_type_string(send_ss)); - g_variant_get(send_ss, "(isi@viiis)", &command_id, &text, &text_len, &icon_id, - &ton, &npi, &ss_str_len, &ss_string); - - dbg("check display text : text(%s) text len(%d)", text, text_len); - if (text_len > 1 && (g_strcmp0(text,"") != 0) ) { - GVariant *ui_info = NULL; - gboolean user_confirm = FALSE; - int ret; - dbg("text should be displayed by ui"); - dbg("send ss is pending!!!"); - - ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_NONE, ui_info); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - return TRUE; - } - telephony_sat_emit_send_ss(sat, command_id, text, text_len, ton, npi, ss_string); - sat_ui_support_launch_ciss_application(TEL_SAT_PROATV_CMD_SEND_SS, send_ss); - } - break; - - case TEL_SAT_PROATV_CMD_SEND_USSD:{ - GVariant *send_ussd = NULL; - - gint command_id; - gint text_len, ussd_str_len; - guchar dcs; - gchar* text, *ussd_string; - - GVariant *icon_id; - - send_ussd = sat_manager_send_ussd_noti(plugin, (TelSatSendUssdTlv*) &p_ind->proactive_ind_data.send_ussd); - - if (!send_ussd) { - err("no send ussd data"); - return TRUE; - } - - dbg("send ussd type_format(%s)", g_variant_get_type_string(send_ussd)); - g_variant_get(send_ussd, "(isi@vyis)", &command_id, &text, &text_len, &icon_id, &dcs, &ussd_str_len, &ussd_string); - - dbg("check display text : text(%s) text len(%d)", text, text_len); - if (text_len > 1 && (g_strcmp0(text,"") != 0) ) { - GVariant *ui_info = NULL; - gboolean user_confirm = FALSE; - int ret; - dbg("text should be displayed by ui"); - dbg("send ussd is pending!!!"); - - ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_NONE, ui_info); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - return TRUE; - } - /*TODO: dcs is not passed here. confirm whether is required or not*/ - telephony_sat_emit_setup_ussd(sat, command_id, text, text_len, ussd_string); - sat_ui_support_launch_ciss_application(TEL_SAT_PROATV_CMD_SEND_USSD, send_ussd); - } - break; - - case TEL_SAT_PROATV_CMD_SETUP_CALL:{ - GVariant *setup_call = NULL; - - gint command_id, call_type, confirmed_text_len, text_len, duration; - gchar *confirmed_text, *text, *call_number; - GVariant *icon_id; - - setup_call = sat_manager_setup_call_noti(plugin, (TelSatSetupCallTlv*) &p_ind->proactive_ind_data.setup_call); - - if (!setup_call) { - err("no setup call data"); - return TRUE; - } - - dbg("setup call type_format(%s)", g_variant_get_type_string(setup_call)); - g_variant_get(setup_call, "(isisi@visi)", &command_id, &confirmed_text, &confirmed_text_len, &text, &text_len, &icon_id, &call_type, &call_number, &duration); - - dbg("check display text : text(%s) text len(%d)", confirmed_text, confirmed_text_len); - if (confirmed_text_len > 1 && (g_strcmp0(confirmed_text,"") != 0) ) { - GVariant *ui_info = NULL; - gboolean user_confirm = TRUE; - int ret; - dbg("text should be displayed by ui"); - dbg("setup call is pending!!!"); - - ui_info = g_variant_new("(isib)", command_id, confirmed_text, confirmed_text_len, user_confirm); - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_NONE, ui_info); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - return TRUE; - } - - telephony_sat_emit_setup_call(sat, command_id, confirmed_text, confirmed_text_len,text, text_len, call_type, call_number, duration); - sat_ui_support_launch_call_application(TEL_SAT_PROATV_CMD_SETUP_CALL, setup_call); - } - break; - - case TEL_SAT_PROATV_CMD_SETUP_EVENT_LIST:{ - GVariant *event_list = NULL; - - gint event_cnt; - GVariant *evt_list; - - event_list = sat_manager_setup_event_list_noti(plugin, (TelSatSetupEventListTlv*) &p_ind->proactive_ind_data.setup_event_list); - - if (!event_list) { - err("no setup event list data"); - return TRUE; - } - - dbg("setup event list type_format(%s)", g_variant_get_type_string(event_list)); - g_variant_get(event_list, "(i@v)", &event_cnt, &evt_list); - - telephony_sat_emit_setup_event_list(sat, event_cnt, evt_list); - - //bip proactive command is only handled by BIP Manager - { - GDBusConnection *conn = NULL; - const gchar *g_path = NULL; - - conn = g_dbus_object_manager_server_get_connection(sat_data->manager); - g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); - - /* TODO: SAT Event Downloader should execute event_list as well. */ - sat_ui_support_exec_evtdw(conn, g_path, TEL_SAT_PROATV_CMD_SETUP_EVENT_LIST, event_list); - sat_ui_support_exec_bip(conn, g_path, TEL_SAT_PROATV_CMD_SETUP_EVENT_LIST, event_list); - } - } - break; - - case TEL_SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT:{ - GVariant *setup_idle_mode = NULL; - int ret; - - gint command_id, text_len; - gchar* text; - GVariant *icon_id; - - setup_idle_mode = sat_manager_setup_idle_mode_text_noti(plugin, (TelSatSetupIdleModeTextTlv*) &p_ind->proactive_ind_data.setup_idle_mode_text); - - if (!setup_idle_mode) { - err("no setup idle mode text data"); - return TRUE; - } - - dbg("setup idle mode text type_format(%s)", g_variant_get_type_string(setup_idle_mode)); - g_variant_get(setup_idle_mode, "(isi@v)", &command_id, &text, &text_len, &icon_id); - - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT, setup_idle_mode); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - - telephony_sat_emit_setup_idle_mode_text(sat, command_id, text, text_len); - } - break; - - case TEL_SAT_PROATV_CMD_OPEN_CHANNEL:{ - GVariant *open_channel = NULL; - - gint command_id, bearer_type, protocol_type, dest_addr_type; - gboolean immediate_link, auto_reconnection, bg_mode; - gint text_len, buffer_size, port_number; - gchar *text, *dest_address; - GVariant *icon_id; - GVariant *bearer_param; - GVariant *bearer_detail; - - open_channel = sat_manager_open_channel_noti(plugin, (TelSatOpenChannelTlv*) &p_ind->proactive_ind_data.open_channel); - - if (!open_channel) { - err("no open channel data"); - return TRUE; - } - - dbg("open channel type_format(%s)", g_variant_get_type_string(open_channel)); - g_variant_get(open_channel,"(isi@vbbbi@viiiis@v)", &command_id, &text, &text_len, &icon_id, &immediate_link, &auto_reconnection, &bg_mode, - &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); - - dbg("check display text : text(%s) text len(%d)", text, text_len); - if (text_len > 1 && (g_strcmp0(text,"") != 0) ) { - GVariant *ui_info = NULL; - gboolean user_confirm = TRUE; - int ret; - dbg("text should be displayed by ui"); - dbg("open channel text is displayed!!!"); - - ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_NONE, ui_info); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - return TRUE; - } - - /*telephony_sat_emit_open_channel(sat, command_id, text, text_len, immediate_link, auto_reconnection, bg_mode, - bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail);*/ - //bip proactive command is only handled by BIP Manager - { - GDBusConnection *conn = NULL; - const gchar *g_path = NULL; - - conn = g_dbus_object_manager_server_get_connection(sat_data->manager); - g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); - - sat_ui_support_exec_bip(conn, g_path, TEL_SAT_PROATV_CMD_OPEN_CHANNEL, open_channel); - } - } - break; - - case TEL_SAT_PROATV_CMD_CLOSE_CHANNEL:{ - GVariant *close_channel = NULL; - - gint command_id, channel_id, text_len; - gchar *text; - GVariant *icon_id; - - close_channel = sat_manager_close_channel_noti(plugin, (TelSatCloseChannelTlv*) &p_ind->proactive_ind_data.close_channel); - - if (!close_channel) { - err("no close channel data"); - return TRUE; - } - - //TODO check the data for sat-ui - - dbg("close channel type_format(%s)", g_variant_get_type_string(close_channel)); - g_variant_get(close_channel, "(isi@vi)", &command_id, &text, &text_len, &icon_id, &channel_id); - - /*telephony_sat_emit_close_channel(sat, command_id, text, text_len, channel_id);*/ - - //bip proactive command is only handled by BIP Manager - { - GDBusConnection *conn = NULL; - const gchar *g_path = NULL; - - conn = g_dbus_object_manager_server_get_connection(sat_data->manager); - g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); - - sat_ui_support_exec_bip(conn, g_path, TEL_SAT_PROATV_CMD_CLOSE_CHANNEL, close_channel); - } - - } - break; - - case TEL_SAT_PROATV_CMD_RECEIVE_DATA:{ - GVariant *receive_data = NULL; - - gint command_id, text_len, channel_id, channel_data_len = 0; - gchar *text; - GVariant *icon_id; - - receive_data = sat_manager_receive_data_noti(plugin, (TelSatReceiveChannelTlv*) &p_ind->proactive_ind_data.receive_data); - - if (!receive_data) { - err("no receive data data"); - return TRUE; - } - - //TODO check the data for sat-ui - - dbg("receive data type_format(%s)", g_variant_get_type_string(receive_data)); - g_variant_get(receive_data, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &channel_id, &channel_data_len); - - /*telephony_sat_emit_receive_data(sat, command_id, text, text_len, channel_id, channel_data_len);*/ - - //bip proactive command is only handled by BIP Manager - { - GDBusConnection *conn = NULL; - const gchar *g_path = NULL; - - conn = g_dbus_object_manager_server_get_connection(sat_data->manager); - g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); - - sat_ui_support_exec_bip(conn, g_path, TEL_SAT_PROATV_CMD_RECEIVE_DATA, receive_data); - } - - } - break; - - case TEL_SAT_PROATV_CMD_SEND_DATA:{ - GVariant *send_data = NULL; - - gint command_id, channel_id, text_len, channel_data_len; - gboolean send_data_immediately; - gchar *text; - GVariant *channel_data; - GVariant *icon_id; - - send_data = sat_manager_send_data_noti(plugin, (TelSatSendChannelTlv*) &p_ind->proactive_ind_data.send_data); - - if (!send_data) { - err("no send data data"); - return TRUE; - } - - //TODO check the data for sat-ui - - dbg("send data type_format(%s)", g_variant_get_type_string(send_data)); - g_variant_get(send_data, "(isi@vib@vi)", &command_id, &text, &text_len, &icon_id, &channel_id, &send_data_immediately, &channel_data, &channel_data_len); - - /*telephony_sat_emit_send_data(sat, command_id, text, text_len, channel_id, send_data_immediately, channel_data, channel_data_len);*/ - - //bip proactive command is only handled by BIP Manager - { - GDBusConnection *conn = NULL; - const gchar *g_path = NULL; - - conn = g_dbus_object_manager_server_get_connection(sat_data->manager); - g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); - - sat_ui_support_exec_bip(conn, g_path, TEL_SAT_PROATV_CMD_SEND_DATA, send_data); - } - } - break; - - case TEL_SAT_PROATV_CMD_GET_CHANNEL_STATUS:{ - GVariant *channel_status = NULL; - - gint command_id; - - channel_status = sat_manager_get_channel_status_noti(plugin, (TelSatGetChannelStatusTlv*) &p_ind->proactive_ind_data.get_channel_status); - - if (!channel_status) { - err("no get channel status data"); - return TRUE; - } - - //TODO check the data for sat-ui - - dbg("get channel status type_format(%s)", g_variant_get_type_string(channel_status)); - g_variant_get(channel_status, "(i)", &command_id); - - /*telephony_sat_emit_get_channel_status(sat, command_id);*/ - - //bip proactive command is only handled by BIP Manager - { - GDBusConnection *conn = NULL; - const gchar *g_path = NULL; - - conn = g_dbus_object_manager_server_get_connection(sat_data->manager); - g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); - - sat_ui_support_exec_bip(conn, g_path, TEL_SAT_PROATV_CMD_GET_CHANNEL_STATUS, channel_status); - } - } - break; - - case TEL_SAT_PROATV_CMD_REFRESH:{ - GVariant *refresh = NULL; - gint command_id = 0; - gint refresh_type =0; - GVariant *file_list = NULL; - int ret; - - refresh = sat_manager_refresh_noti(plugin, (TelSatRefreshTlv*) &p_ind->proactive_ind_data.refresh); - - if (!refresh) { - err("no refresh data"); - return TRUE; - } - - dbg("refresh type_format(%s)", g_variant_get_type_string(refresh)); - g_variant_get(refresh, "(ii@v)", &command_id, &refresh_type, &file_list); - - telephony_sat_emit_refresh(sat, command_id, refresh_type, file_list); - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_REFRESH, refresh); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - } - break; - - case TEL_SAT_PROATV_CMD_MORE_TIME:{ - sat_manager_more_time_noti(plugin, (TelSatMoreTimeTlv*) &p_ind->proactive_ind_data.more_time); - telephony_sat_emit_more_time(sat); - } - break; - - case TEL_SAT_PROATV_CMD_SEND_DTMF:{ - GVariant *send_dtmf = NULL; - gint command_id = 0; - gint text_len = 0, dtmf_str_len = 0; - gchar *text = NULL; - gchar *dtmf_str = NULL; - GVariant *icon_id = NULL; - - send_dtmf = sat_manager_send_dtmf_noti(plugin, (TelSatSendDtmfTlv*) &p_ind->proactive_ind_data.send_dtmf); - if (!send_dtmf) { - err("no send_dtmf data"); - return TRUE; - } - - dbg("send_dtmf type_format(%s)", g_variant_get_type_string(send_dtmf)); - g_variant_get(send_dtmf, "(isi@vis)", &command_id, &text, &text_len, &icon_id, &dtmf_str_len, &dtmf_str); - - if (text_len > 1 && (g_strcmp0(text,"") != 0) ) { - GVariant *ui_info = NULL; - gboolean user_confirm = FALSE; - int ret; - dbg("text should be displayed by ui"); - dbg("send dtmf is displayed!!!"); - - ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_SEND_DTMF, ui_info); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - return TRUE; - } - telephony_sat_emit_send_dtmf(sat, command_id, text, text_len, dtmf_str, dtmf_str_len); - } - break; - - case TEL_SAT_PROATV_CMD_LAUNCH_BROWSER:{ - GVariant *launch_browser = NULL; - gint command_id = 0; - gint browser_launch_type = 0, browser_id = 0; - gint url_len = 0, text_len = 0, gateway_proxy_len =0; - gchar *url = NULL; - gchar *text = NULL; - gchar *gateway_proxy = NULL; - GVariant *icon_id = NULL; - - launch_browser = sat_manager_launch_browser_noti(plugin, (TelSatLaunchBrowserTlv*) &p_ind->proactive_ind_data.launch_browser); - if (!launch_browser) { - err("no launch_browser data"); - return TRUE; - } - - dbg("launch_browser type_format(%s)", g_variant_get_type_string(launch_browser)); - g_variant_get(launch_browser, "(iiisisisi@v)", &command_id, &browser_launch_type, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len, &icon_id); - - //Popup is mandatory option in browser case - { - GVariant *ui_info = NULL; - gboolean user_confirm = TRUE; - int ret; - dbg("text should be displayed by ui"); - dbg("launch browser is displayed!!!"); - - ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); - ret = sat_ui_support_launch_sat_ui(TEL_SAT_PROATV_CMD_LAUNCH_BROWSER, ui_info); - if (!ret) { - int rv; - err("fail to launch sat-ui, remove the queued data!!\n"); - if (!sat_manager_handle_sat_ui_launch_fail(plugin, p_ind)) - err("Fail to send terminal response\n"); - rv = sat_manager_remove_cmd_by_id(command_id); - if (!rv) - err("fail to dequeue data\n"); - } - return TRUE; - } - - //telephony_sat_emit_launch_browser(sat, command_id, browser_launch_type, browser_id, url, url_len, gateway_proxy, gateway_proxy_len, text, text_len); - } - break; - - case TEL_SAT_PROATV_CMD_PROVIDE_LOCAL_INFO:{ - GVariant *provide_info = NULL; - gint info_type = 0; - - provide_info = sat_manager_provide_local_info_noti(plugin, comm_plugin, (TelSatProvideLocalInfoTlv*) &p_ind->proactive_ind_data.provide_local_info); - if (!provide_info) { - err("no provide_info data"); - return TRUE; - } - - dbg("provide_info type_format(%s)", g_variant_get_type_string(provide_info)); - g_variant_get(provide_info, "(i)", &info_type); - - telephony_sat_emit_provide_local_info(sat, info_type); - } - break; - - case TEL_SAT_PROATV_CMD_LANGUAGE_NOTIFICATION:{ - GVariant *language_noti = NULL; - gint command_id = 0; - gint language = 0; - gboolean is_specified = FALSE; - - language_noti = sat_manager_language_notification_noti(plugin, (TelSatLanguageNotificationTlv*) &p_ind->proactive_ind_data.language_notification); - if (!language_noti) { - err("no language_noti data"); - return TRUE; - } - - dbg("language_noti type_format(%s)", g_variant_get_type_string(language_noti)); - g_variant_get(language_noti, "(iib)", &command_id, &language, &is_specified); - - sat_manager_update_language(plugin, comm_plugin, language_noti); - - telephony_sat_emit_language_notification(sat, command_id, language, is_specified); - } - break; - - default:{ - gboolean rv = FALSE; - rv = sat_manager_processing_unsupport_proactive_command(plugin, (TelSatUnsupportCommandTlv *)&p_ind->proactive_ind_data.unsupport_cmd); - err("not handled ind->cmd_type[0x%x] send error tr result(%d)", p_ind->cmd_type, rv); - } - break; - } - } - break; - - default: - err("Unhandled Notification: [0x%x]", command); - break; - } - - return TRUE; -} - diff --git a/src/dtapi_sim.c b/src/dtapi_sim.c deleted file mode 100644 index 8c783cf..0000000 --- a/src/dtapi_sim.c +++ /dev/null @@ -1,1663 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_sim.h" -#include "dtapi_util.h" - -#include - -#define AC_SIM "telephony_framework::api_sim" - -static void on_response_dtapi_sim_get_imsi(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimImsiInfo *imsi = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result != TEL_SIM_RESULT_SUCCESS) { - telephony_sim_complete_get_imsi(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, NULL, NULL, NULL); - } else { - tcore_check_return_assert(NULL != imsi); - dbg("mcc[%s] mnc[%s] msin[%s]", imsi->mcc, imsi->mnc, imsi->msin); - - /* Update Properties */ - telephony_sim_set_mcc(rsp_cb_data->interface_object, imsi->mcc); - telephony_sim_set_mnc(rsp_cb_data->interface_object, imsi->mnc); - telephony_sim_set_msin(rsp_cb_data->interface_object, imsi->msin); - - telephony_sim_complete_get_imsi(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - imsi->mcc, imsi->mnc, imsi->msin); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_imsi(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SIM_GET_IMSI, NULL, 0, - on_response_dtapi_sim_get_imsi, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS){ - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_get_ecc(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimEccList *sim_ecc_list = data; - GVariant *ecc_list; - GVariantBuilder variant_builder; - guint count = 0; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result: [%d] ", result); - - g_variant_builder_init(&variant_builder, G_VARIANT_TYPE("aa{sv}")); - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != sim_ecc_list); - - dbg("ECC List count: [%d]", sim_ecc_list->count); - for (count = 0; count < sim_ecc_list->count; count++) { - g_variant_builder_open(&variant_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&variant_builder, "{sv}", - "number", g_variant_new_string(sim_ecc_list->list[count].number)); - g_variant_builder_add(&variant_builder, "{sv}", - "name", g_variant_new_string(sim_ecc_list->list[count].name)); - g_variant_builder_add(&variant_builder, "{sv}", - "category", g_variant_new_int32(sim_ecc_list->list[count].category)); - - g_variant_builder_close(&variant_builder); - - dbg("[%d] : Number: [%s] Name: [%s] Category: [%d]", count, - sim_ecc_list->list[count].number, - sim_ecc_list->list[count].name, - sim_ecc_list->list[count].category); - } - } - ecc_list = g_variant_builder_end(&variant_builder); - - telephony_sim_complete_get_ecc(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, count, ecc_list); - - g_variant_unref(ecc_list); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_ecc(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - /* TBD : ECC list can be cached in sim coreobject and can be used instead of - * sending request to modem plugin - */ - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_GET_ECC, NULL, 0, - on_response_dtapi_sim_get_ecc, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS){ - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_get_iccid(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const gchar *iccid = NULL; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d] ", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - iccid = data; - dbg("iccid[%s]", iccid); - } - telephony_sim_complete_get_iccid(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, iccid); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_iccid(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - /* TBD : ICCID can be cached in sim coreobject and can be used instead of - * sending request to modem plugin - */ - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_GET_ICCID, NULL, 0, - on_response_dtapi_sim_get_iccid, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS){ - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_sim_get_language(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - TelSimLanguagePreferenceCode language = TEL_SIM_LP_LANG_UNSPECIFIED; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d] ", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != data); - language = *(TelSimLanguagePreferenceCode *)data; - dbg("language[%d]", language); - } - telephony_sim_complete_get_language(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, language); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_language(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SIM_GET_LANGUAGE, NULL, 0, - on_response_dtapi_sim_get_language, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS){ - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_sim_set_language(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - telephony_sim_complete_set_language(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_set_language(TelephonySim *sim, - GDBusMethodInvocation *invocation, - gint language, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - TelSimLanguagePreferenceCode language_preference; - - if (dtapi_check_access_control(invocation, AC_SIM, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - language_preference = language; - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_SET_LANGUAGE, - &language_preference, sizeof(TelSimLanguagePreferenceCode), - on_response_dtapi_sim_set_language, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS){ - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_get_call_forwarding_info(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimCfisList *cf_list = data; - guint count = 0; - GVariant *list; - GVariantBuilder variant_builder; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d] ", result); - - g_variant_builder_init(&variant_builder, G_VARIANT_TYPE("aa{sv}")); - if (result == TEL_SIM_RESULT_SUCCESS) { - gpointer indication; - GVariant *indication_var; - tcore_check_return_assert(cf_list != NULL); - - dbg("Call forwarding List count: [%d]", cf_list->profile_count); - for (count = 0; count < cf_list->profile_count; count++) { - g_variant_builder_open(&variant_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&variant_builder, "{sv}", - "profile_id", g_variant_new_byte(cf_list->cf[count].profile_id)); - - indication = (gpointer)cf_list->cf[count].indication; - indication_var = g_variant_new_from_data(G_VARIANT_TYPE("ai"), - indication, sizeof(cf_list->cf[count].indication), - TRUE, NULL, NULL); - g_variant_builder_add(&variant_builder, "{sv}", - "indication", indication_var); - - g_variant_builder_close(&variant_builder); - - dbg("[%d] : Profile ID: [%d]", count, - cf_list->cf[count].profile_id); - } - } - list = g_variant_builder_end(&variant_builder); - - telephony_sim_complete_get_call_forwarding_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, count, list); - g_variant_unref(list); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_call_forwarding_info(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SIM_GET_CALL_FORWARDING_INFO, NULL, 0, - on_response_dtapi_sim_get_call_forwarding_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS){ - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_get_message_waiting_info(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimMwisList *mw_list = data; - - GVariantBuilder variant_builder; - GVariant *list = NULL; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - g_variant_builder_init(&variant_builder, G_VARIANT_TYPE("aa{sv}")); - if (result == TEL_SIM_RESULT_SUCCESS) { - GVariantBuilder variant_builder2; - GVariant *list2 = NULL; - guint count, count2; - - tcore_check_return_assert(mw_list != NULL); - - dbg("Message waiting count: [%d]", mw_list->profile_count); - - for (count = 0; count < mw_list->profile_count; count++) { - g_variant_builder_open(&variant_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&variant_builder, "{sv}", - "profile_id", g_variant_new_byte(mw_list->mw[count].profile_id)); - - g_variant_builder_add(&variant_builder, "{sv}", - "count_valid", g_variant_new_boolean(mw_list->mw[count].count_valid)); - - dbg("[%d] Profile ID: [%d] Count valid: [%s]", count, - mw_list->mw[count].profile_id, - mw_list->mw[count].count_valid ? "YES" : "NO"); - - g_variant_builder_init(&variant_builder2, G_VARIANT_TYPE("aa{sv}")); - for (count2 = 0 ; count2 < TEL_SIM_MAILBOX_TYPE_MAX ; count2++) { - g_variant_builder_open(&variant_builder2, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&variant_builder2, "{sv}", "indication", - g_variant_new_boolean(mw_list->mw[count].msg_waiting[count2].indication)); - - g_variant_builder_add(&variant_builder2, "{sv}", "count", - g_variant_new_byte(mw_list->mw[count].msg_waiting[count2].count)); - - g_variant_builder_close(&variant_builder2); - } - list2 = g_variant_builder_end(&variant_builder2); - - g_variant_builder_add(&variant_builder, "{sv}", - "msg_waiting", list2); - - g_variant_builder_close(&variant_builder); - } - } - list = g_variant_builder_end(&variant_builder); - - telephony_sim_complete_get_message_waiting_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, mw_list->profile_count, list); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_message_waiting_info(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SIM_GET_MESSAGE_WAITING_INFO, NULL, 0, - on_response_dtapi_sim_get_message_waiting_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS){ - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_set_message_waiting_info(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - telephony_sim_complete_set_message_waiting_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_set_message_waiting_info(TelephonySim *sim, - GDBusMethodInvocation *invocation, - guchar profile_id, gboolean count_valid, - GVariant *mw, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - TelSimMwis req_data = {0,}; - DbusRespCbData *rsp_cb_data; - GVariantIter *iter = NULL; - unsigned int i = 0; - - if (dtapi_check_access_control(invocation, AC_SIM, "w") == FALSE) - return TRUE; - - req_data.profile_id = profile_id; - req_data.count_valid = count_valid; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - g_variant_get(mw, "a(by)", &iter); - while (g_variant_iter_next(iter, "(by)", - &(req_data.msg_waiting[i].indication), - &(req_data.msg_waiting[i].count))) { - i++; - } - - g_variant_iter_free(iter); - - result = tcore_plugin_dispatch_request(plugin, - TRUE, TCORE_COMMAND_SIM_SET_MESSAGE_WAITING_INFO, - &req_data, sizeof(TelSimMwis), - on_response_dtapi_sim_set_message_waiting_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS){ - dtapi_return_error(invocation, - G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_get_mailbox_info(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimMailboxList *mb_list = data; - guint count = 0; - GVariant *list; - GVariantBuilder variant_builder; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - g_variant_builder_init(&variant_builder, G_VARIANT_TYPE("aa{sv}")); - if (result == TEL_SIM_RESULT_SUCCESS) { - GVariant *alpha_id, *number; - - tcore_check_return_assert(mb_list != NULL); - dbg("Mailbox list count: [%d]", mb_list->count); - - for (count = 0; count < mb_list->count; count++) { - g_variant_builder_open(&variant_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&variant_builder, "{sv}", - "profile_id", g_variant_new_byte(mb_list->list[count].profile_id)); - - g_variant_builder_add(&variant_builder, "{sv}", - "mb_type", g_variant_new_int32(mb_list->list[count].mb_type)); - - g_variant_builder_add(&variant_builder, "{sv}", - "alpha_id_len", g_variant_new_uint32(mb_list->list[count].alpha_id_len)); - - alpha_id = g_variant_new_from_data(G_VARIANT_TYPE("ay"), - mb_list->list[count].alpha_id, TEL_SIM_ALPHA_ID_LEN_MAX, - TRUE, NULL, NULL); - g_variant_builder_add(&variant_builder, "{sv}", - "alpha_id", alpha_id); - - number = g_variant_new_from_data(G_VARIANT_TYPE("ay"), - mb_list->list[count].number, TEL_SIM_MBDN_NUM_LEN_MAX, - TRUE, NULL, NULL); - g_variant_builder_add(&variant_builder, "{sv}", - "number", number); - - g_variant_builder_close(&variant_builder); - } - } - list = g_variant_builder_end(&variant_builder); - - telephony_sim_complete_get_mailbox_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, mb_list->alpha_id_max_len, mb_list->count, list); - g_variant_unref(list); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_mailbox_info(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SIM_GET_MAILBOX_INFO, NULL, 0, - on_response_dtapi_sim_get_mailbox_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_set_mailbox_info(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - telephony_sim_complete_set_mailbox_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_set_mailbox_info(TelephonySim *sim, - GDBusMethodInvocation *invocation, - guchar profile_id, gint mb_type, - gint alpha_id_len, const gchar *alpha_id, - const gchar *num, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - TelSimMailBoxNumber req_data= {0,}; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - req_data.profile_id = profile_id; - req_data.mb_type = mb_type; - req_data.alpha_id_len = alpha_id_len; - memcpy(req_data.alpha_id, alpha_id, alpha_id_len); - memcpy(req_data.number, num, strlen(num)); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_SET_MAILBOX_INFO, - &req_data, sizeof(TelSimMailBoxNumber), - on_response_dtapi_sim_set_mailbox_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_get_msisdn(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimMsisdnList *msisdn_list = data; - guint count = 0; - GVariant *list; - GVariantBuilder variant_builder; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - g_variant_builder_init(&variant_builder, G_VARIANT_TYPE("aa{sv}")); - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(msisdn_list != NULL); - - dbg("MSISDN List count: [%d]", msisdn_list->count); - for (count = 0; count < msisdn_list->count; count++) { - g_variant_builder_open(&variant_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&variant_builder, "{sv}", - "alpha_id", g_variant_new_string(msisdn_list->list[count].alpha_id)); - g_variant_builder_add(&variant_builder, "{sv}", - "num", g_variant_new_string(msisdn_list->list[count].num)); - - g_variant_builder_close(&variant_builder); - - dbg("[%d] : Aplha ID: [%s] Number: [%s]", count, - msisdn_list->list[count].alpha_id, - msisdn_list->list[count].num); - } - } - list = g_variant_builder_end(&variant_builder); - - telephony_sim_complete_get_msisdn(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, count, list); - g_variant_unref(list); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_msisdn(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_GET_MSISDN, - NULL, 0, - on_response_dtapi_sim_get_msisdn, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_get_spn(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimSpn *spn = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d] ", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != spn); - dbg("display_condition[%d] spn[%s]", spn->display_condition, spn->spn); - telephony_sim_complete_get_spn(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - spn->display_condition, spn->spn); - } else { - telephony_sim_complete_get_spn(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - TEL_SIM_DISP_INVALID, NULL); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_spn(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_GET_SPN, - NULL, 0, - on_response_dtapi_sim_get_spn, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_get_cphs_net_name(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimCphsNetName *cphs_net_name = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d] ", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != cphs_net_name); - dbg("full_name[%s] short_name[%s]", - cphs_net_name->full_name, cphs_net_name->short_name); - telephony_sim_complete_get_cphs_net_name(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - cphs_net_name->full_name, cphs_net_name->short_name); - } else { - telephony_sim_complete_get_cphs_net_name(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, "", ""); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_cphs_net_name(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_GET_CPHS_NET_NAME, - NULL, 0, - on_response_dtapi_sim_get_cphs_net_name, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_get_sp_display_info(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimSpPlmnList *sp_list = data; - guint count = 0; - GVariant *list; - GVariantBuilder variant_builder; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - g_variant_builder_init(&variant_builder, G_VARIANT_TYPE("aa{sv}")); - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(sp_list != NULL); - - dbg("SPN List count: [%d]", sp_list->count); - for (count = 0; count < sp_list->count; count++) { - g_variant_builder_open(&variant_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&variant_builder, "{sv}", - "index", g_variant_new_uint32(sp_list->list[count].index)); - g_variant_builder_add(&variant_builder, "{sv}", - "plmn", g_variant_new_string(sp_list->list[count].plmn)); - - g_variant_builder_close(&variant_builder); - - dbg("[%d] : Index: [%d] PLMN: [%s]", count, - sp_list->list[count].index, - sp_list->list[count].plmn); - } - } - list = g_variant_builder_end(&variant_builder); - - telephony_sim_complete_get_sp_display_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, count, list); - g_variant_unref(list); - - tcore_free(rsp_cb_data); -} - - -static gboolean dtapi_sim_get_sp_display_info(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_GET_SP_DISPLAY_INFO, - NULL, 0, - on_response_dtapi_sim_get_sp_display_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_req_authentication(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimAuthenticationResponse *req_auth = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - gchar *encoded_resp, *encoded_autn, *encoded_cipher, *encoded_integrity; - tcore_check_return_assert(NULL != req_auth); - - dbg("auth_type[%d] detailed_result[%d] resp_length[%d] \ - authentication_key_length[%d] cipher_length[%d] integrity_length[%d]", - req_auth->auth_type, req_auth->detailed_result, req_auth->resp_length, - req_auth->authentication_key_length, req_auth->cipher_length, req_auth->integrity_length); - /* Encode Base64 - Resp data */ - encoded_resp = g_base64_encode((const guchar *)req_auth->resp_data, - req_auth->resp_length); - - /* Encode Base64 - auth data */ - encoded_autn = g_base64_encode((const guchar *)req_auth->authentication_key, - req_auth->authentication_key_length); - - /* Encode Base64 - cipher data */ - encoded_cipher = g_base64_encode((const guchar *)req_auth->cipher_data, - req_auth->cipher_length); - - /* Encode Base64 - integrity data */ - encoded_integrity = g_base64_encode((const guchar *)req_auth->integrity_data, - req_auth->integrity_length); - - telephony_sim_complete_req_authentication(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - req_auth->auth_type, encoded_resp, - encoded_autn, encoded_cipher, encoded_integrity); - /* Free resources */ - tcore_free(encoded_resp); - tcore_free(encoded_autn); - tcore_free(encoded_cipher); - tcore_free(encoded_integrity); - } else { - telephony_sim_complete_req_authentication(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - 0, NULL, NULL, NULL, NULL); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_req_authentication(TelephonySim *sim, - GDBusMethodInvocation *invocation, - gint auth_type, const gchar *rand_data, - const gchar *autn_data, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - guchar *decoded_data; - TelSimAuthenticationData req_data = {0,}; - gsize decoded_data_len; - - if (dtapi_check_access_control(invocation, AC_SIM, "x") == FALSE) - return TRUE; - - req_data.auth_type = auth_type; - - /* Decode Base64 - rand data */ - decoded_data = g_base64_decode((const gchar *)rand_data, &decoded_data_len); - if ((decoded_data_len > TEL_SIM_AUTH_MAX_REQ_DATA_LEN) ||(decoded_data_len == 0)) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Decoding Failed"); - tcore_free(decoded_data); - return TRUE; - } - - memcpy(req_data.rand_data, decoded_data, decoded_data_len); - req_data.rand_length = decoded_data_len; - - /* Free resources */ - tcore_free(decoded_data); - - /* Decode Base64 - auth data */ - decoded_data = g_base64_decode((const gchar *)autn_data, &decoded_data_len); - if (decoded_data_len > TEL_SIM_AUTH_MAX_REQ_DATA_LEN) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Decoding Failed"); - tcore_free(decoded_data); - return TRUE; - } - - if(decoded_data_len) - memcpy(req_data.autn_data, decoded_data, decoded_data_len); - req_data.autn_length = decoded_data_len; - - /* Free resources */ - tcore_free(decoded_data); - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_REQ_AUTHENTICATION, - &req_data, sizeof(TelSimAuthenticationData), - on_response_dtapi_sim_req_authentication, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_verify_pins(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimSecPinResult *verify_pins = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != verify_pins); - dbg("pin_type[%d] retry_count[%d]", - verify_pins->pin_type, verify_pins->retry_count); - telephony_sim_complete_verify_pins(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - verify_pins->pin_type, verify_pins->retry_count); - } else { - telephony_sim_complete_verify_pins(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, 0, 0); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_verify_pins(TelephonySim *sim, - GDBusMethodInvocation *invocation, - gint pin_type, const gchar *pw, - gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - TelSimSecPinPw req_data = {0,}; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - req_data.pin_type = pin_type; - req_data.pw = (char *)pw; - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_VERIFY_PINS, - &req_data, sizeof(TelSimSecPinPw), - on_response_dtapi_sim_verify_pins, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_verify_puks(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimSecPukResult *verify_puks = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != verify_puks); - dbg("puk_type[%d] retry_count[%d]", - verify_puks->puk_type, verify_puks->retry_count); - - telephony_sim_complete_verify_puks(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - verify_puks->puk_type, verify_puks->retry_count); - } else { - telephony_sim_complete_verify_puks(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, 0, 0); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_verify_puks(TelephonySim *sim, - GDBusMethodInvocation *invocation, - gint puk_type, const gchar *puk_pw, - const gchar *new_pin_pw, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - TelSimSecPukPw req_data = {0,}; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - req_data.puk_type = puk_type; - req_data.puk_pw = (char *)puk_pw; - req_data.new_pin_pw = (char *)new_pin_pw; - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_VERIFY_PUKS, - &req_data, sizeof(TelSimSecPukPw), - on_response_dtapi_sim_verify_puks, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sim_change_pins(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimSecPinResult *change_pins = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != change_pins); - dbg("pin_type[%d] retry_count[%d]", - change_pins->pin_type, change_pins->retry_count); - telephony_sim_complete_change_pins(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - change_pins->pin_type, change_pins->retry_count); - } else { - telephony_sim_complete_change_pins(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, 0, 0); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_change_pins(TelephonySim *sim, - GDBusMethodInvocation *invocation, - gint pin_type, const gchar *old_pw, - const gchar *new_pw, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - TelSimSecChangePinPw req_data = {0,}; - - if (dtapi_check_access_control(invocation, AC_SIM, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - req_data.pin_type = pin_type; - req_data.old_pw = (char *)old_pw; - req_data.new_pw = (char *)new_pw; - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_CHANGE_PINS, - &req_data, sizeof(TelSimSecChangePinPw), - on_response_dtapi_sim_change_pins, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_sim_disable_facility(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimFacilityResult *facility = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != facility); - dbg("type[%d] retry_count[%d]", facility->type, facility->retry_count); - telephony_sim_complete_disable_facility(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - facility->type, facility->retry_count); - } else { - telephony_sim_complete_disable_facility(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - 0, 0); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_disable_facility(TelephonySim *sim, - GDBusMethodInvocation *invocation, - gint lock_type, const gchar *pw, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - TelSimFacilityPw req_data= {0,}; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - req_data.lock_type = lock_type; - req_data.pw = (char *)pw; - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_DISABLE_FACILITY, - &req_data, sizeof(TelSimFacilityPw), - on_response_dtapi_sim_disable_facility, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_sim_enable_facility(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimFacilityResult *facility = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != facility); - dbg("type[%d] retry_count[%d]", facility->type, facility->retry_count); - - telephony_sim_complete_enable_facility(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - facility->type, facility->retry_count); - } else { - telephony_sim_complete_enable_facility(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - 0, 0); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_enable_facility(TelephonySim *sim, - GDBusMethodInvocation *invocation, - gint lock_type, const gchar *pw, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - TelSimFacilityPw req_data = {0,}; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - req_data.lock_type = lock_type; - req_data.pw = (char *)pw; - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_ENABLE_FACILITY, - &req_data, sizeof(TelSimFacilityPw), - on_response_dtapi_sim_enable_facility, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_sim_get_facility(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimFacilityInfo *facility = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != facility); - dbg("type[%d] f_status[%d]", facility->type, facility->f_status); - telephony_sim_complete_get_facility(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - facility->type, facility->f_status); - } else { - telephony_sim_complete_get_facility(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - 0, TEL_SIM_FACILITY_STATUS_UNKNOWN); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_facility(TelephonySim *sim, - GDBusMethodInvocation *invocation, - gint type, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - TelSimFacilityInfo req_data = {0,}; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - req_data.type = type; - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_GET_FACILITY, - &req_data, sizeof(TelSimFacilityInfo), - on_response_dtapi_sim_get_facility, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_sim_get_lock_info(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimLockInfo *lock_info = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != lock_info); - dbg("lock_type[%d] lock_status[%d] retry_count[%d]", - lock_info->lock_type, lock_info->lock_status, lock_info->retry_count); - telephony_sim_complete_get_lock_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - lock_info->lock_type, lock_info->lock_status, - lock_info->retry_count); - } else { - telephony_sim_complete_get_lock_info(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - 0, 0, 0); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_get_lock_info(TelephonySim *sim, - GDBusMethodInvocation *invocation, - gint type, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - TelSimLockInfo req_data = {0,}; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - req_data.lock_type = type; - - result = tcore_plugin_dispatch_request(plugin, TRUE, TCORE_COMMAND_SIM_GET_LOCK_INFO, &req_data, sizeof(TelSimLockInfo), - on_response_dtapi_sim_get_lock_info, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_sim_req_apdu(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimApduResp *apdu = data; - - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - gchar *encoded_apdu; - tcore_check_return_assert(NULL != apdu); - dbg("apdu_resp_len[%d]", apdu->apdu_resp_len); - /* Encode Base64 - Resp data */ - encoded_apdu = g_base64_encode((const guchar *)apdu->apdu_resp, - apdu->apdu_resp_len); - telephony_sim_complete_req_apdu(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - encoded_apdu); - - /* Free resources */ - tcore_free(encoded_apdu); - } else { - telephony_sim_complete_req_apdu(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - NULL); - } - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_req_apdu(TelephonySim *sim, - GDBusMethodInvocation *invocation, - const gchar *apdu, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - TelSimApdu req_data = {0,}; - guchar *decoded_data; - gsize decoded_data_len; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "x") == FALSE) - return TRUE; - - /* Decode Base64 - apdu */ - decoded_data = g_base64_decode((const gchar *)apdu, &decoded_data_len); - if ((decoded_data_len > TEL_SIM_APDU_LEN_MAX) || (decoded_data_len == 0)) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Decoding Failed"); - tcore_free(decoded_data); - return TRUE; - } - - memcpy(req_data.apdu, decoded_data, decoded_data_len); - req_data.apdu_len = decoded_data_len; - - /* Free resources */ - tcore_free(decoded_data); - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_REQ_APDU, - &req_data, sizeof(TelSimApdu), - on_response_dtapi_sim_req_apdu, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void -on_response_dtapi_sim_req_atr(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - const TelSimAtr *atr_resp = data; - gchar *encoded_atr = NULL; - tcore_check_return_assert(NULL != rsp_cb_data); - - dbg("result[%d]", result); - - if (result == TEL_SIM_RESULT_SUCCESS) { - tcore_check_return_assert(NULL != atr_resp); - dbg("atr_len[%d]", atr_resp->atr_len); - /* Encode Base64 - Resp data */ - encoded_atr = g_base64_encode((const guchar *)atr_resp->atr, - atr_resp->atr_len); - } else { - err("Sim atr response failed!!"); - } - - telephony_sim_complete_req_atr(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, encoded_atr); - - tcore_free(encoded_atr); - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sim_req_atr(TelephonySim *sim, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *rsp_cb_data; - - if (dtapi_check_access_control(invocation, AC_SIM, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sim, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SIM_REQ_ATR, - NULL, 0, - on_response_dtapi_sim_req_atr, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -gboolean dtapi_setup_sim_interface(TelephonyObjectSkeleton *object, - TcorePlugin *plugin) -{ - TelephonySim *sim = telephony_sim_skeleton_new(); - GVariant *var; - GVariantBuilder var_builder; - tcore_check_return_value_assert(sim != NULL, FALSE); - - telephony_object_skeleton_set_sim(object, sim); - g_object_unref(sim); - - dbg("sim = %p", sim); - - g_signal_connect (sim, - "handle-get-imsi", - G_CALLBACK (dtapi_sim_get_imsi), - plugin); - - g_signal_connect (sim, - "handle-get-ecc", - G_CALLBACK (dtapi_sim_get_ecc), - plugin); - - g_signal_connect (sim, - "handle-get-iccid", - G_CALLBACK (dtapi_sim_get_iccid), - plugin); - - g_signal_connect (sim, - "handle-get-language", - G_CALLBACK (dtapi_sim_get_language), - plugin); - - g_signal_connect (sim, - "handle-set-language", - G_CALLBACK (dtapi_sim_set_language), - plugin); - - g_signal_connect (sim, - "handle-get-call-forwarding-info", - G_CALLBACK (dtapi_sim_get_call_forwarding_info), - plugin); - - g_signal_connect (sim, - "handle-get-message-waiting-info", - G_CALLBACK (dtapi_sim_get_message_waiting_info), - plugin); - - g_signal_connect (sim, - "handle-set-message-waiting-info", - G_CALLBACK (dtapi_sim_set_message_waiting_info), - plugin); - - g_signal_connect (sim, - "handle-get-mailbox-info", - G_CALLBACK (dtapi_sim_get_mailbox_info), - plugin); - - g_signal_connect (sim, - "handle-set-mailbox-info", - G_CALLBACK (dtapi_sim_set_mailbox_info), - plugin); - - g_signal_connect (sim, - "handle-get-msisdn", - G_CALLBACK (dtapi_sim_get_msisdn), - plugin); - - g_signal_connect (sim, - "handle-get-spn", - G_CALLBACK (dtapi_sim_get_spn), - plugin); - - g_signal_connect (sim, - "handle-get-cphs-net-name", - G_CALLBACK (dtapi_sim_get_cphs_net_name), - plugin); - - g_signal_connect (sim, - "handle-get-sp-display-info", - G_CALLBACK (dtapi_sim_get_sp_display_info), - plugin); - - g_signal_connect (sim, - "handle-req-authentication", - G_CALLBACK (dtapi_sim_req_authentication), - plugin); - - g_signal_connect (sim, - "handle-verify-pins", - G_CALLBACK (dtapi_sim_verify_pins), - plugin); - - g_signal_connect (sim, - "handle-verify-puks", - G_CALLBACK (dtapi_sim_verify_puks), - plugin); - - g_signal_connect (sim, - "handle-change-pins", - G_CALLBACK (dtapi_sim_change_pins), - plugin); - - g_signal_connect (sim, - "handle-disable-facility", - G_CALLBACK (dtapi_sim_disable_facility), - plugin); - - g_signal_connect (sim, - "handle-enable-facility", - G_CALLBACK (dtapi_sim_enable_facility), - plugin); - - g_signal_connect (sim, - "handle-get-facility", - G_CALLBACK (dtapi_sim_get_facility), - plugin); - - g_signal_connect (sim, - "handle-get-lock-info", - G_CALLBACK (dtapi_sim_get_lock_info), - plugin); - - g_signal_connect (sim, - "handle-req-apdu", - G_CALLBACK (dtapi_sim_req_apdu), - plugin); - - g_signal_connect (sim, - "handle-req-atr", - G_CALLBACK (dtapi_sim_req_atr), - plugin); - - /* Initialize D-Bus properties */ - g_variant_builder_init(&var_builder, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&var_builder, "{sv}", "status", - g_variant_new_int32(TEL_SIM_STATUS_UNKNOWN)); - g_variant_builder_add(&var_builder, "{sv}", "change_status", - g_variant_new_int32(TEL_SIM_CHANGE_STATUS_UNKNOWN)); - var = g_variant_builder_end(&var_builder); - telephony_sim_set_card_status(sim, var); - - telephony_sim_set_sim_type(sim, TEL_SIM_CARD_TYPE_UNKNOWN); - telephony_sim_set_mcc(sim, NULL); - telephony_sim_set_mnc(sim, NULL); - telephony_sim_set_msin(sim, NULL); - - return TRUE; -} - -gboolean dtapi_handle_sim_notification(TelephonyObjectSkeleton *object, - TcorePlugin *plugin, TcoreNotification command, - guint data_len, const void *data) -{ - TelephonySim *sim; - - tcore_check_return_value_assert(object != NULL, FALSE); - - sim = telephony_object_peek_sim(TELEPHONY_OBJECT(object)); - - dbg("sim = %p - notification !!! (command = 0x%x, data_len = %d)", - sim, command, data_len); - - switch (command) { - case TCORE_NOTIFICATION_SIM_TYPE: { - tcore_check_return_value_assert(data != NULL, FALSE); - - const TelSimCardType sim_type = *(TelSimCardType *)data; - dbg("SIM Type: [%d]", sim_type); - - /* Update Property */ - telephony_sim_set_sim_type(sim, sim_type); - } - break; - case TCORE_NOTIFICATION_SIM_STATUS: { - const TelSimCardStatusInfo *sim_info = (TelSimCardStatusInfo *)data; - GVariant *var; - GVariantBuilder var_builder; - tcore_check_return_value_assert(data != NULL, FALSE); - - dbg("SIM Status: [%d], change_status: [%d]", - sim_info->status, sim_info->change_status); - - g_variant_builder_init(&var_builder, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&var_builder, "{sv}", "status", - g_variant_new_int32(sim_info->status)); - g_variant_builder_add(&var_builder, "{sv}", "change_status", - g_variant_new_int32(sim_info->change_status)); - var = g_variant_builder_end(&var_builder); - - telephony_sim_set_card_status(sim, var); - } - break; - default: - /* TBD : Check when other dbus properties should be updated */ - err("not handled cmd[0x%x]", command); - break; - } - - return TRUE; -} diff --git a/src/dtapi_sms.c b/src/dtapi_sms.c deleted file mode 100644 index ca2882a..0000000 --- a/src/dtapi_sms.c +++ /dev/null @@ -1,1111 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_sms.h" -#include "dtapi_util.h" - -#include -#include - -#define AC_SMS "telephony_framework::api_sms" - -static void on_response_dtapi_sms_send(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - dbg("SEND_MSG_RESPONSE RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_sms_complete_send(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_send(TelephonySms *sms, - GDBusMethodInvocation *invocation, - gboolean more_msgs, GVariant *sca, const gchar *tpdu, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - - TelSmsSendInfo send_msg; - gsize decoded_tpdu_length; - guchar *decoded_tpdu = NULL; - - GVariantIter *iter = NULL; - GVariant *key_value; - const gchar *key; - - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "x") == FALSE) - return TRUE; - - if (NULL == tpdu || NULL == sca) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid Parameter"); - return TRUE; - } - - decoded_tpdu = g_base64_decode(tpdu, &decoded_tpdu_length); - if (decoded_tpdu_length > TEL_SMS_SMDATA_SIZE_MAX) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Tpdu Decoding Failed"); - tcore_free(decoded_tpdu); - return TRUE; - } - - memset (&send_msg, 0x0, sizeof(TelSmsSendInfo)); - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - send_msg.more_msgs = more_msgs; - - g_variant_get(sca, "a{sv}", &iter); - while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "ton") == 0) { - send_msg.send_data.sca.ton = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "npi") == 0) { - send_msg.send_data.sca.npi = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "number") == 0) { - g_strlcpy(send_msg.send_data.sca.number, - g_variant_get_string(key_value, NULL), - TEL_SMS_SCA_LEN_MAX + 1); - } - } - g_variant_iter_free(iter); - - memcpy(&(send_msg.send_data.tpdu[0]), decoded_tpdu, decoded_tpdu_length); - send_msg.send_data.tpdu_length = decoded_tpdu_length; - tcore_free(decoded_tpdu); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_SEND_SMS, - &send_msg, sizeof(TelSmsSendInfo), - on_response_dtapi_sms_send, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_read_in_sim(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - gint status = 0; - gchar *tpdu = NULL; - - GVariantBuilder sca_builder; - GVariant *sca = NULL; - - dbg("READ_MSG_RESPONSE RECEIVED - result:[%d]", result); - tcore_check_return_assert(rsp_cb_data != NULL); - - g_variant_builder_init(&sca_builder, G_VARIANT_TYPE("a{sv}")); - if (TEL_SMS_RESULT_SUCCESS == result) { - const TelSmsSimDataInfo *read_sms = data; - - tcore_check_return_assert(read_sms != NULL); - tcore_check_return_assert(read_sms->data.tpdu_length <= TEL_SMS_SMDATA_SIZE_MAX); - tcore_check_return_assert(read_sms->data.tpdu_length != 0); - - g_variant_builder_add(&sca_builder, "{sv}", - "ton", g_variant_new_byte(read_sms->data.sca.ton)); - g_variant_builder_add(&sca_builder, "{sv}", - "npi", g_variant_new_byte(read_sms->data.sca.npi)); - g_variant_builder_add(&sca_builder, "{sv}", - "number", g_variant_new_string(read_sms->data.sca.number)); - - tpdu = g_base64_encode(&(read_sms->data.tpdu[0]), - read_sms->data.tpdu_length); - status = read_sms->status; - } else { - tpdu = g_strdup(" "); - } - sca = g_variant_builder_end(&sca_builder); - - telephony_sms_complete_read_in_sim(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, status, sca, tpdu); - - tcore_free(rsp_cb_data); - tcore_free(tpdu); -} - -static gboolean dtapi_sms_read_in_sim(TelephonySms *sms, - GDBusMethodInvocation *invocation, - guint index, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_READ_IN_SIM, - &index, sizeof(guint), - on_response_dtapi_sms_read_in_sim, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_write_in_sim(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - guint index = 0; - - dbg("WRITE_SMS_RESPONSE_RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - if (TEL_SMS_RESULT_SUCCESS == result) { - tcore_check_return_assert(NULL != data); - index = *(guint *)data; - dbg("SMS writen to index: [%d]", index); - } - - telephony_sms_complete_write_in_sim(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, index); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_write_in_sim(TelephonySms *sms, - GDBusMethodInvocation *invocation, - gint status, GVariant *sca, const gchar *tpdu, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - - TelSmsSimDataInfo write_data; - guchar *decoded_tpdu = NULL; - gsize decoded_tpdu_length = 0; - - GVariantIter *iter = NULL; - GVariant *key_value; - const gchar *key; - - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "w") == FALSE) - return TRUE; - - if (NULL == sca || NULL == tpdu) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid Parameter"); - return TRUE; - } - - g_variant_get(sca, "a{sv}", &iter); - while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "ton") == 0) { - write_data.data.sca.ton = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "npi") == 0) { - write_data.data.sca.npi = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "number") == 0) { - g_strlcpy(write_data.data.sca.number, - g_variant_get_string(key_value, NULL), - TEL_SMS_SCA_LEN_MAX + 1); - } - } - g_variant_iter_free(iter); - - decoded_tpdu = g_base64_decode(tpdu, &decoded_tpdu_length); - memcpy(&(write_data.data.tpdu[0]), decoded_tpdu, decoded_tpdu_length); - write_data.data.tpdu_length = decoded_tpdu_length; - write_data.status = status; - - /* Free decoded data */ - tcore_free(decoded_tpdu); - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_WRITE_IN_SIM, - &write_data, sizeof(TelSmsSimDataInfo), - on_response_dtapi_sms_write_in_sim, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_delete_in_sim(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - dbg("DELETE_SMS RESPONSE RECEIVED - result: [%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_sms_complete_delete_in_sim(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_delete_in_sim(TelephonySms *sms, - GDBusMethodInvocation *invocation, - guint index, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "x") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_DELETE_IN_SIM, - &index, sizeof(guint), - on_response_dtapi_sms_delete_in_sim, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_get_count(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - GVariant *index_list = NULL; - GVariantBuilder index; - unsigned int iter; - unsigned int total_count = 0; - unsigned int used_count = 0; - - dbg("GET_COUNT_RESPONSE RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - g_variant_builder_init(&index, G_VARIANT_TYPE("au")); - if (TEL_SMS_RESULT_SUCCESS == result) { - const TelSmsStoredMsgCountInfo *count_info = data; - tcore_check_return_assert(NULL != count_info); - - total_count = count_info->total_count; - used_count = count_info->used_count; - dbg("Total count: [%d] Used count: [%d]", - total_count, used_count); - - for (iter = 0; iter < total_count; iter++) { - dbg("count_info->index_list[%d] - %d", iter , count_info->index_list[iter]); - g_variant_builder_add(&index, "u", count_info->index_list[iter]); - } - } - else { - err("SMS get count failed!!!"); - } - index_list = g_variant_builder_end(&index); - - telephony_sms_complete_get_count(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - total_count, used_count, index_list); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_get_count(TelephonySms *sms, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_GET_COUNT, - NULL, 0, - on_response_dtapi_sms_get_count, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_set_cb_config(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - dbg("SET_CB_CONFIG RESPONSE RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_sms_complete_set_cb_config(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_set_cb_config(TelephonySms *sms, - GDBusMethodInvocation *invocation, - gboolean cb_enabled, - guint msg_id_range_cnt, GVariant *msg_ids, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - - TelSmsCbConfigInfo cb_conf; - - GVariantIter *iter = NULL, *iter_row = NULL; - GVariant *key_value; - const gchar *key; - guint count = 0; - - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - memset(&cb_conf, 0x0, sizeof(TelSmsCbConfigInfo)); - cb_conf.cb_enabled = cb_enabled; - cb_conf.msg_id_range_cnt = msg_id_range_cnt; - - g_variant_get(msg_ids, "aa{sv}", &iter); - while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { - while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "from_msg_id") == 0) { - cb_conf.msg_ids[count].from_msg_id = - g_variant_get_uint16(key_value); - } - else if (g_strcmp0(key, "to_msg_id") == 0) { - cb_conf.msg_ids[count].to_msg_id = - g_variant_get_uint16(key_value); - } - else if (g_strcmp0(key, "number") == 0) { - cb_conf.msg_ids[count].selected = - g_variant_get_boolean(key_value); - } - } - count++; - g_variant_iter_free(iter_row); - } - g_variant_iter_free(iter); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_SET_CB_CONFIG, - &cb_conf, sizeof(TelSmsCbConfigInfo), - on_response_dtapi_sms_set_cb_config, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_get_cb_config(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - - GVariantBuilder config_builder; - - GVariant *msg_ids = NULL; - gboolean cb_enabled = FALSE; - guint msg_id_range_cnt = 0; - - dbg("GET_CB_CONFIG RESPONSE RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - g_variant_builder_init(&config_builder, G_VARIANT_TYPE("aa{sv}")); - if (TEL_SMS_RESULT_SUCCESS == result) { - const TelSmsCbConfigInfo *config = data; - guint count = 0; - tcore_check_return_assert(NULL != config); - - cb_enabled = config->cb_enabled; - msg_id_range_cnt = config->msg_id_range_cnt; - - for (count = 0; count < config->msg_id_range_cnt; count++) { - g_variant_builder_open(&config_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&config_builder, "{sv}", - "from_msg_id", - g_variant_new_uint16(config->msg_ids[count].from_msg_id)); - g_variant_builder_add(&config_builder, "{sv}", - "to_msg_id", - g_variant_new_uint16(config->msg_ids[count].to_msg_id)); - g_variant_builder_add(&config_builder, "{sv}", - "selected", - g_variant_new_boolean(config->msg_ids[count].selected)); - - g_variant_builder_close(&config_builder); - } - } - msg_ids = g_variant_builder_end(&config_builder); - - telephony_sms_complete_get_cb_config(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, - cb_enabled, msg_id_range_cnt, msg_ids); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_get_cb_config(TelephonySms *sms, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_GET_CB_CONFIG, - NULL, 0, - on_response_dtapi_sms_get_cb_config, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_get_parameters(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - GVariant *params = NULL; - GVariantBuilder params_builder; - guint count = 0; - - dbg("GET_SMS_PARAMETERS RESPONSE RECEIVED - result:[%d]", result); - tcore_check_return_assert(rsp_cb_data != NULL); - - g_variant_builder_init(¶ms_builder, G_VARIANT_TYPE("aa{sv}")); - if (TEL_SMS_RESULT_SUCCESS == result) { - const TelSmsParamsInfoList *param_list = data; - GVariantBuilder sca_builder; - GVariant *sca; - - tcore_check_return_assert(param_list != NULL); - - for (count = 0; count < param_list->count; count++) { - g_variant_builder_open(¶ms_builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(¶ms_builder, "{sv}", - "index", g_variant_new_uint32(param_list->params[count].index)); - - g_variant_builder_init(&sca_builder, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&sca_builder, "{sv}", - "ton", g_variant_new_byte(param_list->params[count].sca.ton)); - g_variant_builder_add(&sca_builder, "{sv}", - "npi", g_variant_new_byte(param_list->params[count].sca.npi)); - g_variant_builder_add(&sca_builder, "{sv}", - "number", g_variant_new_string(param_list->params[count].sca.number)); - sca = g_variant_builder_end(&sca_builder); - g_variant_builder_add(¶ms_builder, "{sv}", - "sca", sca); - - g_variant_builder_add(¶ms_builder, "{sv}", - "vp", g_variant_new_uint16(param_list->params[count].vp)); - - g_variant_builder_close(¶ms_builder); - } - } - params = g_variant_builder_end(¶ms_builder); - - telephony_sms_complete_get_parameters(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, count, params); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_get_parameters(TelephonySms *sms, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_GET_PARAMETERS, - NULL, 0, - on_response_dtapi_sms_get_parameters, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_set_parameters(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - dbg("SET_SMS_PARAMETERS RESPONSE RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_sms_complete_set_parameters(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_set_parameters(TelephonySms *sms, - GDBusMethodInvocation *invocation, - guint index, GVariant *sca, guint16 vp, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - - TelSmsParamsInfo set_params = {0, }; - - GVariantIter *iter = NULL; - GVariant *key_value; - const gchar *key; - - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "w") == FALSE) - return TRUE; - - set_params.index = index; - set_params.vp = vp; - - g_variant_get(sca, "a{sv}", &iter); - while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "ton") == 0) { - set_params.sca.ton = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "npi") == 0) { - set_params.sca.npi = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "number") == 0) { - g_strlcpy(set_params.sca.number, - g_variant_get_string(key_value, NULL), - TEL_SMS_SCA_LEN_MAX + 1); - } - } - g_variant_iter_free(iter); - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_SET_PARAMETERS, - &set_params, sizeof(TelSmsParamsInfo), - on_response_dtapi_sms_set_parameters, rsp_cb_data); - - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_send_deliver_report(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - dbg("SEND_DELIVER_REPORT RESPONSE RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_sms_complete_send_deliver_report(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_send_deliver_report(TelephonySms *sms, - GDBusMethodInvocation *invocation, - gint report, GVariant *sca, const gchar *tpdu, - gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - - TelSmsDeliverReportInfo dr_info; - gsize decoded_tpdu_length; - guchar *decoded_tpdu = NULL; - - GVariantIter *iter = NULL; - GVariant *key_value; - const gchar *key; - - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "w") == FALSE) - return TRUE; - - if (NULL == sca || NULL == tpdu) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid Parameter"); - return TRUE; - } - - decoded_tpdu = g_base64_decode(tpdu, &decoded_tpdu_length); - if (decoded_tpdu_length > TEL_SMS_SMDATA_SIZE_MAX) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Tpdu Decoding Failed"); - tcore_free(decoded_tpdu); - return TRUE; - } - - memset (&dr_info, 0x0, sizeof(TelSmsDeliverReportInfo)); - dr_info.report = report; - memcpy(&(dr_info.data.tpdu[0]), decoded_tpdu, decoded_tpdu_length); - dr_info.data.tpdu_length = decoded_tpdu_length; - tcore_free(decoded_tpdu); - - g_variant_get(sca, "a{sv}", &iter); - while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "ton") == 0) { - dr_info.data.sca.ton = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "npi") == 0) { - dr_info.data.sca.npi = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "number") == 0) { - g_strlcpy(dr_info.data.sca.number, - g_variant_get_string(key_value, NULL), - TEL_SMS_SCA_LEN_MAX + 1); - } - } - g_variant_iter_free(iter); - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_SEND_DELIVER_REPORT, - &dr_info, sizeof(TelSmsDeliverReportInfo), - on_response_dtapi_sms_send_deliver_report, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_set_sca(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - dbg("SET_SCA RESPONSE RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_sms_complete_set_sca(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_set_sca(TelephonySms *sms, - GDBusMethodInvocation *invocation, - GVariant *sca, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - - TelSmsSca req_sca; - - GVariantIter *iter = NULL; - GVariant *key_value; - const gchar *key; - - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "w") == FALSE) - return TRUE; - - if (NULL == sca) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Invalid Parameter"); - return TRUE; - } - - memset(&req_sca, 0x0, sizeof(TelSmsSca)); - - g_variant_get(sca, "a{sv}", &iter); - while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) { - if (g_strcmp0(key, "ton") == 0) { - req_sca.ton = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "npi") == 0) { - req_sca.npi = g_variant_get_byte(key_value); - } - else if (g_strcmp0(key, "number") == 0) { - g_strlcpy(req_sca.number, - g_variant_get_string(key_value, NULL), - TEL_SMS_SCA_LEN_MAX + 1); - } - } - g_variant_iter_free(iter); - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_SET_SCA, - &req_sca, sizeof(TelSmsSca), - on_response_dtapi_sms_set_sca, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_get_sca(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - GVariant *sca = NULL; - GVariantBuilder sca_builder; - - dbg("GET SCA RESPONSE RECEIVED- result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - g_variant_builder_init(&sca_builder, G_VARIANT_TYPE("a{sv}")); - if (TEL_SMS_RESULT_SUCCESS == result) { - const TelSmsSca *sca_req = data; - tcore_check_return_assert(sca_req != NULL); - - g_variant_builder_add(&sca_builder, "{sv}", - "ton", g_variant_new_byte(sca_req->ton)); - g_variant_builder_add(&sca_builder, "{sv}", - "npi", g_variant_new_byte(sca_req->npi)); - g_variant_builder_add(&sca_builder, "{sv}", - "number", g_variant_new_string(sca_req->number)); - } - sca = g_variant_builder_end(&sca_builder); - - telephony_sms_complete_get_sca(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result, sca); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_get_sca(TelephonySms *sms, - GDBusMethodInvocation *invocation, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "r") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_GET_SCA, - NULL, 0, - on_response_dtapi_sms_get_sca, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_set_memory_status(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - dbg("SET_MEMORY STATUS RESPONSE RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_sms_complete_set_memory_status(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_set_memory_status(TelephonySms *sms, - GDBusMethodInvocation *invocation, - gboolean available, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - - if (dtapi_check_access_control(invocation, AC_SMS, "w") == FALSE) - return TRUE; - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_SET_MEMORY_STATUS, - &available, sizeof(gboolean), - on_response_dtapi_sms_set_memory_status, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_sms_set_message_status(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *rsp_cb_data = cb_data; - dbg("SET_MESSAGE STATUS RESPONSE RECEIVED - result:[%d]", result); - - tcore_check_return_assert(rsp_cb_data != NULL); - - telephony_sms_complete_set_message_status(rsp_cb_data->interface_object, - rsp_cb_data->invocation, result); - - tcore_free(rsp_cb_data); -} - -static gboolean dtapi_sms_set_message_status(TelephonySms *sms, - GDBusMethodInvocation *invocation, - guint index, gint status, gpointer user_data) -{ - DbusRespCbData *rsp_cb_data = NULL; - TcorePlugin *plugin = user_data; - TelReturn result; - TelSmsStatusInfo info; - - if (dtapi_check_access_control(invocation, AC_SMS, "w") == FALSE) - return TRUE; - - memset(&info, 0x0, sizeof(TelSmsStatusInfo)); - info.index = index; - info.status = status; - - rsp_cb_data = dtapi_create_resp_cb_data(sms, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SMS_SET_MEMORY_STATUS, - &info, sizeof(TelSmsStatusInfo), - on_response_dtapi_sms_set_message_status, rsp_cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch Failed"); - tcore_free(rsp_cb_data); - } - - return TRUE; -} - -gboolean dtapi_setup_sms_interface(TelephonyObjectSkeleton *object, - TcorePlugin *plugin) -{ - TelephonySms *sms; - - sms = telephony_sms_skeleton_new(); - telephony_object_skeleton_set_sms(object, sms); - g_object_unref(sms); - - dbg("sms: [%p]", sms); - - g_signal_connect(sms, - "handle-send", - G_CALLBACK (dtapi_sms_send), plugin); - g_signal_connect(sms, - "handle-read-in-sim", - G_CALLBACK (dtapi_sms_read_in_sim), plugin); - g_signal_connect(sms, - "handle-write-in-sim", - G_CALLBACK (dtapi_sms_write_in_sim), plugin); - g_signal_connect(sms, - "handle-delete-in-sim", - G_CALLBACK (dtapi_sms_delete_in_sim), plugin); - g_signal_connect(sms, - "handle-get-count", - G_CALLBACK (dtapi_sms_get_count), plugin); - g_signal_connect(sms, - "handle-set-cb-config", - G_CALLBACK (dtapi_sms_set_cb_config), plugin); - g_signal_connect(sms, - "handle-get-cb-config", - G_CALLBACK (dtapi_sms_get_cb_config), plugin); - g_signal_connect(sms, - "handle-get-parameters", - G_CALLBACK (dtapi_sms_get_parameters), plugin); - g_signal_connect(sms, - "handle-set-parameters", - G_CALLBACK (dtapi_sms_set_parameters), plugin); - g_signal_connect(sms, - "handle-send-deliver-report", - G_CALLBACK (dtapi_sms_send_deliver_report), plugin); - g_signal_connect(sms, - "handle-set-sca", - G_CALLBACK (dtapi_sms_set_sca), plugin); - g_signal_connect(sms, - "handle-get-sca", - G_CALLBACK (dtapi_sms_get_sca), plugin); - g_signal_connect(sms, - "handle-set-memory-status", - G_CALLBACK (dtapi_sms_set_memory_status), plugin); - g_signal_connect(sms, - "handle-set-message-status", - G_CALLBACK (dtapi_sms_set_message_status), plugin); - - /* Initialize D-Bus Properties */ - telephony_sms_set_sim_memory_status(sms, FALSE); - telephony_sms_set_init_status(sms, FALSE); - - return TRUE; -} - -gboolean dtapi_handle_sms_notification(TelephonyObjectSkeleton *object, - TcorePlugin *plugin, TcoreNotification command, - guint data_len, const void *data) -{ - TelephonySms *sms; - - tcore_check_return_value_assert(NULL != object, FALSE); - - sms = telephony_object_peek_sms(TELEPHONY_OBJECT(object)); - dbg("sms: [%p]", sms); - - switch (command) { - case TCORE_NOTIFICATION_SMS_INCOM_MSG: { - const TelSmsDatapackageInfo *incoming_msg = data; - GVariant *sca = NULL; - GVariantBuilder sca_builder; - gchar *tpdu = NULL; - - tcore_check_return_value_assert(NULL != incoming_msg, FALSE); - - dbg("Incoming Message Notification RECEIVED"); - - dbg("TON: [%d] NPI: [%d] SCA: [%s] TPDU Length: [%d]", - incoming_msg->sca.ton, incoming_msg->sca.npi, - incoming_msg->sca.number, incoming_msg->tpdu_length); - g_variant_builder_init(&sca_builder, G_VARIANT_TYPE("a{sv}")); - g_variant_builder_add(&sca_builder, "{sv}", - "ton", g_variant_new_byte(incoming_msg->sca.ton)); - g_variant_builder_add(&sca_builder, "{sv}", - "npi", g_variant_new_byte(incoming_msg->sca.npi)); - g_variant_builder_add(&sca_builder, "{sv}", - "number", g_variant_new_string(incoming_msg->sca.number)); - sca = g_variant_builder_end(&sca_builder); - - tpdu = g_base64_encode(&(incoming_msg->tpdu[0]), incoming_msg->tpdu_length); - - telephony_sms_emit_incoming_msg(sms, sca, tpdu); - dbg("Emitted incoming Message"); - - tcore_free(tpdu); - dbg("Exit"); - } - break; - - case TCORE_NOTIFICATION_SMS_CB_INCOM_MSG: { - gchar *cb_data = NULL; - const TelSmsCbMsgInfo *cb_noti = data; - - tcore_check_return_value_assert(NULL != cb_noti, FALSE); - - dbg("Incoming CELL BROADCAST Message Notification RECEIVED"); - - cb_data = g_base64_encode(cb_noti->cb_data, cb_noti->length); - - telephony_sms_emit_incoming_cb_msg(sms, cb_noti->cb_type, cb_data); - tcore_free(cb_data); - } - break; - - case TCORE_NOTIFICATION_SMS_ETWS_INCOM_MSG: { - gchar *etws_data = NULL; - const TelSmsEtwsMsgInfo *etws_noti = data; - - tcore_check_return_value_assert(NULL != etws_noti, FALSE); - - dbg("ETWS Message Notification RECEIVED"); - - etws_data = g_base64_encode(etws_noti->etws_data, etws_noti->length); - - telephony_sms_emit_incoming_etws_msg(sms, etws_noti->etws_type, etws_data); - tcore_free(etws_data); - } - break; - - case TCORE_NOTIFICATION_SMS_MEMORY_STATUS: { - tcore_check_return_value_assert(NULL != data, FALSE); - - const gboolean memory_status = *(gboolean *)data; - dbg("Memory Status Notification RECEIVED"); - - /* Update Property */ - telephony_sms_set_sim_memory_status(sms, memory_status); - } - break; - - case TCORE_NOTIFICATION_SMS_DEVICE_READY: { - tcore_check_return_value_assert(NULL != data, FALSE); - - const gboolean init_status = *(gboolean *)data; - dbg("Device Ready Notification RECEIVED"); - - /* Update Property */ - telephony_sms_set_init_status(sms, init_status); - } - break; - - default: - err("Unsupported Notification [0x%x]", command); - break; - } - - return TRUE; -} diff --git a/src/dtapi_ss.c b/src/dtapi_ss.c deleted file mode 100644 index 082dd67..0000000 --- a/src/dtapi_ss.c +++ /dev/null @@ -1,810 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_ss.h" -#include "dtapi_util.h" - -#include -#include -#include -#include - -#define AC_SS "telephony_framework::api_ss" -#define MAX_SS_USSD_LEN 208 - -typedef struct{ - int status; - guint length; - char data[MAX_SS_USSD_LEN + 1]; -} CissDataType; - -static void _launch_ciss(const TelSsUssdNoti *ussd) -{ - gchar *encoded_data; - CissDataType ciss_data; - - tcore_check_return_assert(NULL != ussd); - bundle *kb = bundle_create(); - if (!kb) { - err("bundle_create() failed"); - return; - } - - memset(&ciss_data, 0x00, sizeof(CissDataType)); - ciss_data.status = ussd->status; - - if(NULL == ussd->str) { - err("Empty USSD string"); - bundle_free(kb); - return; - } - ciss_data.length = strlen((const char*)ussd->str); - if(ciss_data.length > MAX_SS_USSD_LEN) { - err("USSD data length is more, Unable to launch ciss"); - bundle_free(kb); - return; - } - g_strlcpy(ciss_data.data, (gchar *)ussd->str, MAX_SS_USSD_LEN + 1); - - dbg("launch ciss application by appsvc"); - appsvc_set_operation(kb, "http://tizen.org/appcontrol/operation/ciss"); - appsvc_set_pkgname(kb, "com.samsung.ciss"); - - encoded_data = g_base64_encode((guchar *)&ciss_data, sizeof(CissDataType)); - appsvc_add_data(kb, "CISS_LAUNCHING_MODE", "RESP"); - appsvc_add_data(kb, "KEY_EVENT_TYPE", "100"); - appsvc_add_data(kb, "KEY_ENCODED_DATA", encoded_data); - - dbg("ciss appsvc run"); - appsvc_run_service(kb, 0, NULL, NULL); - - bundle_free(kb); - g_free(encoded_data); -} - -static void on_response_dtapi_ss_set_barring(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - - dbg("Barring set response result: [%d]", result); - tcore_check_return_assert(NULL != resp_cb_data); - - telephony_ss_complete_set_barring(resp_cb_data->interface_object, - resp_cb_data->invocation, result); - - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_set_barring(TelephonySs *ss, - GDBusMethodInvocation *invocation, gint class, - gboolean enable, gint type, const gchar *pwd, - gpointer user_data) -{ - TelSsBarringInfo req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "x") == FALSE) - return TRUE; - - req.class = class; - req.enable = enable; - req.type = type; - g_strlcpy(req.pwd, pwd, TEL_SS_BARRING_PASSWORD_LEN_MAX + 1 ); - dbg("barring password: [%s] class: [%d], barring type: [%d]", req.pwd, req.class, req.type); - - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_SET_BARRING, - &req, sizeof(TelSsBarringInfo), - on_response_dtapi_ss_set_barring, cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_ss_get_barring_status(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - GVariant *records = NULL; - GVariantBuilder builder; - guint count = 0; - - dbg("Barring get status response result: [%d]", result); - - tcore_check_return_assert(NULL != resp_cb_data); - - g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); - if (result == TEL_SIM_RESULT_SUCCESS) { - const TelSsBarringResp *resp = data; - tcore_check_return_assert(NULL != resp); - - dbg("Barring status List count: [%d]", resp->record_num); - for (count = 0; count < resp->record_num; count++) { - g_variant_builder_open(&builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&builder, "{sv}", - "class", g_variant_new_int32(resp->records[count].class)); - g_variant_builder_add(&builder, "{sv}", - "enable", g_variant_new_boolean(resp->records[count].enable)); - g_variant_builder_add(&builder, "{sv}", - "type", g_variant_new_int32(resp->records[count].type)); - - g_variant_builder_close(&builder); - - dbg("[%d] : Class: [%d] Enable: [%s] Type: [%d]", count, - resp->records[count].class, - (resp->records[count].enable ? "YES" : "NO"), - resp->records[count].type); - } - } - records = g_variant_builder_end(&builder); - - telephony_ss_complete_get_barring_status(resp_cb_data->interface_object, - resp_cb_data->invocation, result, count, records); - g_variant_unref(records); - - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_get_barring_status(TelephonySs *ss, - GDBusMethodInvocation *invocation, - gint class, gint type, gpointer user_data) -{ - TelSsBarringGetInfo req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "r") == FALSE) - return TRUE; - - req.class = class; - req.type = type; - - dbg("class: %d, type: %d", req.class, req.type); - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_GET_BARRING_STATUS, - &req, sizeof(TelSsBarringGetInfo), - on_response_dtapi_ss_get_barring_status, cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_ss_change_barring_password( - gint result, const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - - dbg("Barring change password response result: [%d]", result); - - tcore_check_return_assert(NULL != resp_cb_data); - - telephony_ss_complete_change_barring_password(resp_cb_data->interface_object, - resp_cb_data->invocation, result); - - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_change_barring_password(TelephonySs *ss, - GDBusMethodInvocation *invocation, - const gchar *old_pwd, const gchar *new_pwd, - gpointer user_data) -{ - TelSsBarringPwdInfo req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "x") == FALSE) - return TRUE; - - g_strlcpy(req.old_pwd, old_pwd, TEL_SS_BARRING_PASSWORD_LEN_MAX + 1); - g_strlcpy(req.new_pwd, new_pwd, TEL_SS_BARRING_PASSWORD_LEN_MAX + 1); - - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_CHANGE_BARRING_PASSWORD, - &req, sizeof(TelSsBarringPwdInfo), - on_response_dtapi_ss_change_barring_password, cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_ss_set_forwarding(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - - dbg("Forwarding set response result: [%d]", result); - tcore_check_return_assert(NULL != resp_cb_data); - - telephony_ss_complete_set_forwarding(resp_cb_data->interface_object, - resp_cb_data->invocation, result); - - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_set_forwarding(TelephonySs *ss, - GDBusMethodInvocation *invocation, - gint class, gint mode, gint condition, - const gchar *number, gint wait_time, - gpointer user_data) -{ - TelSsForwardInfo req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "x") == FALSE) - return TRUE; - - req.class = class; - req.mode = mode; - req.condition = condition; - req.wait_time = wait_time; - g_strlcpy(req.number, number, TEL_SS_NUMBER_LEN_MAX + 1); - - dbg("class: %d, mode: %d, condition: %d, wait_time: %d, number: %s", - req.class, req.mode, req.condition, req.wait_time, req.number); - - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_SET_FORWARDING, - &req, sizeof(TelSsForwardInfo), - on_response_dtapi_ss_set_forwarding, cb_data); - if (result != TEL_RETURN_SUCCESS ) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_ss_get_forwarding_status(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - GVariant *records = NULL; - GVariantBuilder builder; - guint count = 0; - - dbg("Forwarding get status response result: [%d]", result); - - tcore_check_return_assert(NULL != resp_cb_data); - - g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); - if (result == TEL_SIM_RESULT_SUCCESS) { - const TelSsForwardingResp *resp = data; - tcore_check_return_assert(NULL != resp); - - dbg("Forwarding status List count: [%d]", resp->record_num); - for (count = 0; count < resp->record_num; count++) { - g_variant_builder_open(&builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&builder, "{sv}", - "class", g_variant_new_int32(resp->records[count].class)); - g_variant_builder_add(&builder, "{sv}", - "enable", g_variant_new_boolean(resp->records[count].enable)); - g_variant_builder_add(&builder, "{sv}", - "condition", g_variant_new_int32(resp->records[count].condition)); - g_variant_builder_add(&builder, "{sv}", - "number", g_variant_new_string(resp->records[count].number)); - g_variant_builder_add(&builder, "{sv}", - "wait_time", g_variant_new_int32(resp->records[count].wait_time)); - - g_variant_builder_close(&builder); - - dbg("[%d] : Class: [%d] Enable: [%s] Condition: [%d] "\ - "Number: [%s] Wait time: [%d]", count, - resp->records[count].class, - (resp->records[count].enable ? "YES" : "NO"), - resp->records[count].condition, - resp->records[count].number, - resp->records[count].wait_time); - } - } - records = g_variant_builder_end(&builder); - - telephony_ss_complete_get_forwarding_status(resp_cb_data->interface_object, - resp_cb_data->invocation, result, count, records); - - g_variant_unref(records); - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_get_forwarding_status(TelephonySs *ss, - GDBusMethodInvocation *invocation, - gint class, gint condition, gpointer user_data) -{ - TelSsForwardGetInfo req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "r") == FALSE) - return TRUE; - - req.class = class; - req.condition = condition; - dbg("class: %d, condition: %d", req.class, req.condition); - - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_GET_FORWARDING_STATUS, - &req, sizeof(TelSsForwardGetInfo), - on_response_dtapi_ss_get_forwarding_status, cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_ss_set_waiting(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - - dbg("Waiting set response result: [%d]", result); - tcore_check_return_assert(NULL != resp_cb_data); - - telephony_ss_complete_set_waiting(resp_cb_data->interface_object, - resp_cb_data->invocation, result); - - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_set_waiting(TelephonySs *ss, - GDBusMethodInvocation *invocation, - gint class, gboolean enable, gpointer user_data) -{ - TelSsWaitingInfo req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "x") == FALSE) - return TRUE; - - req.class = class; - req.enable = enable; - dbg("class: %d, enable: %d", req.class, req.enable); - - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_SET_WAITING, - &req, sizeof(TelSsWaitingInfo), - on_response_dtapi_ss_set_waiting, cb_data); - if (result != TEL_RETURN_SUCCESS ) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_ss_get_waiting_status(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - GVariant *records = NULL; - GVariantBuilder builder; - guint count = 0; - - dbg("Waiting get status response result: [%d]", result); - - tcore_check_return_assert(NULL != resp_cb_data); - - g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}")); - if (result == TEL_SS_RESULT_SUCCESS) { - const TelSsWaitingResp *resp = data; - tcore_check_return_assert(NULL != resp); - - dbg("Waiting status List count: [%d]", resp->record_num); - for (count = 0; count < resp->record_num; count++) { - g_variant_builder_open(&builder, G_VARIANT_TYPE("a{sv}")); - - g_variant_builder_add(&builder, "{sv}", - "class", g_variant_new_int32(resp->records[count].class)); - g_variant_builder_add(&builder, "{sv}", - "enable", g_variant_new_boolean(resp->records[count].enable)); - - g_variant_builder_close(&builder); - - dbg("[%d] : Class: [%d] Enable: [%s]", count, - resp->records[count].class, - (resp->records[count].enable ? "YES" : "NO")); - } - } - records = g_variant_builder_end(&builder); - - telephony_ss_complete_get_waiting_status(resp_cb_data->interface_object, - resp_cb_data->invocation, result, count, records); - g_variant_unref(records); - - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_get_waiting_status(TelephonySs *ss, - GDBusMethodInvocation *invocation, - gint class, gpointer user_data) -{ - TelSsClass req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "r") == FALSE) - return TRUE; - - req = class; - dbg("class: %d", req); - - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_GET_WAITING_STATUS, - &req, sizeof(TelSsClass), - on_response_dtapi_ss_get_waiting_status, cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_ss_set_cli(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - - dbg("CLI set response result: [%d]", result); - tcore_check_return_assert(NULL != resp_cb_data); - - telephony_ss_complete_set_cli(resp_cb_data->interface_object, - resp_cb_data->invocation, result); - - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_set_cli(TelephonySs *ss, - GDBusMethodInvocation *invocation, - gint type, gint status, gpointer user_data) -{ - TelSsCliInfo req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "x") == FALSE) - return TRUE; - - req.type = type; - switch(req.type){ - case TEL_SS_CLI_CLIR: - req.status.clir = status; - break; - case TEL_SS_CLI_CLIP: - req.status.clip = status; - break; - case TEL_SS_CLI_COLP: - req.status.colp = status; - break; - case TEL_SS_CLI_COLR: - req.status.colr = status; - break; - case TEL_SS_CLI_CDIP: - req.status.cdip = status; - break; - case TEL_SS_CLI_CNAP: - req.status.cnap = status; - break; - } - - dbg("type: %d status: %d", req.type, status); - - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_SET_CLI, - &req, sizeof(TelSsCliInfo), - on_response_dtapi_ss_set_cli, cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_ss_get_cli_status(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - - const TelSsCliResp *resp = data; - gint net_status,dev_status; - - dbg("CLI get status response result: [%d]", result); - tcore_check_return_assert(NULL != resp_cb_data); - - if (result != TEL_RETURN_SUCCESS) { - telephony_ss_complete_get_cli_status(resp_cb_data->interface_object, - resp_cb_data->invocation, result, -1, -1, -1); - tcore_free(resp_cb_data); - return; - } - - tcore_check_return_assert(NULL != resp); - - switch(resp->type){ - case TEL_SS_CLI_CLIR: - net_status = resp->status.clir.net_status; - dev_status = resp->status.clir.dev_status; - break; - - case TEL_SS_CLI_CLIP: - net_status = resp->status.clip.net_status; - dev_status = resp->status.clip.dev_status; - break; - - case TEL_SS_CLI_COLP: - net_status = resp->status.colp.net_status; - dev_status = resp->status.colp.dev_status; - break; - - case TEL_SS_CLI_COLR: - net_status = resp->status.colr.net_status; - dev_status = resp->status.colr.dev_status; - break; - - case TEL_SS_CLI_CDIP: - net_status = resp->status.cdip.net_status; - dev_status = resp->status.cdip.dev_status; - break; - - case TEL_SS_CLI_CNAP: - net_status = resp->status.cnap.net_status; - dev_status = resp->status.cnap.dev_status; - break; - - default : - net_status = -1; - dev_status = -1; - result = TEL_SS_RESULT_FAILURE; - break; - } - - telephony_ss_complete_get_cli_status(resp_cb_data->interface_object, - resp_cb_data->invocation, result, - resp->type, net_status, dev_status); - - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_get_cli_status(TelephonySs *ss, - GDBusMethodInvocation *invocation, - gint type, gpointer user_data) -{ - TelSsCliType req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "r") == FALSE) - return TRUE; - - req = type; - dbg("type: [%d]", req); - - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_GET_CLI_STATUS, - &req, sizeof(TelSsCliType), - on_response_dtapi_ss_get_cli_status, cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - - return TRUE; -} - -static void on_response_dtapi_ss_send_ussd_request(gint result, - const void *data, void *cb_data) -{ - DbusRespCbData *resp_cb_data = cb_data; - - const TelSsUssdResp *resp = data; - - dbg("Send USSD response result: [%d]", result); - tcore_check_return_assert(NULL != resp_cb_data); - - if (result != TEL_RETURN_SUCCESS) { - telephony_ss_complete_send_ussd_request(resp_cb_data->interface_object, - resp_cb_data->invocation, result, -1, -1, NULL); - tcore_free(resp_cb_data); - return; - } - - tcore_check_return_assert(NULL != resp); - - telephony_ss_complete_send_ussd_request(resp_cb_data->interface_object, - resp_cb_data->invocation, result, - resp->type, resp->status, (const gchar *)resp->str); - - tcore_free(resp_cb_data); -} - -static gboolean dtapi_ss_send_ussd_request(TelephonySs *ss, - GDBusMethodInvocation *invocation, - gint type, const gchar *str, gpointer user_data) -{ - TelSsUssdInfo req; - TelReturn result; - TcorePlugin *plugin = user_data; - DbusRespCbData *cb_data = NULL; - - if (dtapi_check_access_control(invocation, AC_SS, "x") == FALSE) - return TRUE; - - req.type = type; - req.str = (unsigned char*)tcore_strdup(str); - dbg("type: %d, string: %s", req.type, req.str); - - cb_data = dtapi_create_resp_cb_data(ss, invocation, NULL, 0); - - result = tcore_plugin_dispatch_request(plugin, TRUE, - TCORE_COMMAND_SS_SEND_USSD_REQUEST, - &req, sizeof(TelSsUssdInfo), - on_response_dtapi_ss_send_ussd_request, cb_data); - if (result != TEL_RETURN_SUCCESS) { - dtapi_return_error(invocation, G_DBUS_ERROR_FAILED, "Dispatch failed"); - tcore_free(cb_data); - } - tcore_free(req.str); - - return TRUE; -} - -gboolean dtapi_setup_ss_interface(TelephonyObjectSkeleton *object, - TcorePlugin *plugin) -{ - TelephonySs *ss; - - tcore_check_return_value_assert(NULL != object, FALSE); - tcore_check_return_value_assert(NULL != plugin, FALSE); - - ss = telephony_ss_skeleton_new(); - telephony_object_skeleton_set_ss(object, ss); - g_object_unref(ss); - - tcore_check_return_value_assert(NULL != ss, FALSE); - dbg("ss: [%p]", ss); - - g_signal_connect (ss, - "handle-set-barring", - G_CALLBACK (dtapi_ss_set_barring), - plugin); - - g_signal_connect (ss, - "handle-get-barring-status", - G_CALLBACK (dtapi_ss_get_barring_status), - plugin); - - g_signal_connect (ss, - "handle-change-barring-password", - G_CALLBACK (dtapi_ss_change_barring_password), - plugin); - - - g_signal_connect (ss, - "handle-set-forwarding", - G_CALLBACK (dtapi_ss_set_forwarding), - plugin); - - g_signal_connect (ss, - "handle-get-forwarding-status", - G_CALLBACK (dtapi_ss_get_forwarding_status), - plugin); - - g_signal_connect (ss, - "handle-set-waiting", - G_CALLBACK (dtapi_ss_set_waiting), - plugin); - - g_signal_connect (ss, - "handle-get-waiting-status", - G_CALLBACK (dtapi_ss_get_waiting_status), - plugin); - - g_signal_connect (ss, - "handle-set-cli", - G_CALLBACK (dtapi_ss_set_cli), - plugin); - - g_signal_connect (ss, - "handle-get-cli-status", - G_CALLBACK (dtapi_ss_get_cli_status), - plugin); - - g_signal_connect (ss, - "handle-send-ussd-request", - G_CALLBACK (dtapi_ss_send_ussd_request), - plugin); - - return TRUE; -} - -gboolean dtapi_handle_ss_notification(TelephonyObjectSkeleton *object, - TcorePlugin *plugin, TcoreNotification command, - guint data_len, const void *data) -{ - TelephonySs *ss; - - tcore_check_return_value_assert(NULL != object, FALSE); - tcore_check_return_value_assert(NULL != plugin, FALSE); - - ss = telephony_object_peek_ss(TELEPHONY_OBJECT(object)); - tcore_check_return_value_assert(NULL != ss, FALSE); - dbg("ss: [%p]", ss); - - switch (command) { - case TCORE_NOTIFICATION_SS_USSD: { - TelSsUssdNoti *ussd = (TelSsUssdNoti *)data; - tcore_check_return_value_assert(NULL != ussd, FALSE); - - telephony_ss_emit_notify_ussd(ss, ussd->status, - (const gchar*)ussd->str); - - /* Launch CISS application */ - _launch_ciss(ussd); - } - break; - - default: - err("Unsupported notification: [0x%x]", command); - break; - } - return TRUE; -} diff --git a/src/dtapi_util.c b/src/dtapi_util.c deleted file mode 100644 index a09b2a0..0000000 --- a/src/dtapi_util.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * tel-plugin-dbus_tapi - * - * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved. - * Copyright (c) 2013 Intel Corporation. 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 "dtapi_util.h" - -#include - -GVariant *dtapi_create_empty_variant(const gchar *format_string) -{ - GVariantBuilder builder; - - g_variant_builder_init(&builder, G_VARIANT_TYPE(format_string)); - return g_variant_builder_end(&builder); -} - -inline DbusRespCbData *dtapi_create_resp_cb_data(void *interface_object, - GDBusMethodInvocation *invocation, void *user_data, unsigned int ud_len) -{ - DbusRespCbData *rsp_cb_data = tcore_malloc0(sizeof(DbusRespCbData) + ud_len); - rsp_cb_data->interface_object = interface_object; - rsp_cb_data->invocation = invocation; - if ((user_data != NULL) && (ud_len > 0)) - memcpy(rsp_cb_data->user_data, user_data, ud_len); - return rsp_cb_data; -} - -inline const char *dtapi_get_cp_name_by_object_path(const char *object_path) -{ - if (!object_path) - return NULL; - - if (!g_str_has_prefix(object_path, TELEPHONY_OBJECT_PATH)) { - return NULL; - } - - return object_path + strlen(TELEPHONY_OBJECT_PATH) + 1; -} - -gboolean dtapi_check_access_control(GDBusMethodInvocation *invoc, - const char *label, const char *perm) -{ - GDBusConnection *conn; - GVariant *result_pid; - GVariant *param; - GError *error = NULL; - const char *sender; - unsigned int pid; - int ret; - int result = FALSE; - - conn = g_dbus_method_invocation_get_connection(invoc); - if (conn == NULL) { - err("access control denied(no connection info)"); - goto OUT; - } - - sender = g_dbus_method_invocation_get_sender(invoc); - dbg("sender: %s", sender); - - param = g_variant_new("(s)", sender); - if (param == NULL) { - err("access control denied(sender info fail)"); - goto OUT; - } - - result_pid = g_dbus_connection_call_sync (conn, "org.freedesktop.DBus", - "/org/freedesktop/DBus", - "org.freedesktop.DBus", - "GetConnectionUnixProcessID", - param, NULL, - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error); - - if (error) { - err("access control denied (dbus error: %d(%s))", - error->code, error->message); - g_error_free (error); - goto OUT; - } - - if (result_pid == NULL) { - err("access control denied(fail to get pid)"); - goto OUT; - } - - g_variant_get(result_pid, "(u)", &pid); - g_variant_unref(result_pid); - - dbg ("pid = %u", pid); - - ret = security_server_check_privilege_by_pid(pid, label, perm); - if (ret != SECURITY_SERVER_API_SUCCESS) { -#ifdef ENABLE_CHECK_PRIVILEGE - err("access control(%s - %s) denied(%d)", label, perm, ret); -#else - dbg("access control(%s - %s) denied(%d)", label, perm, ret); - result = TRUE; -#endif - } - else - result = TRUE; - -OUT: - - if (!result) - dtapi_return_error(invoc, G_DBUS_ERROR_ACCESS_DENIED, "Access denied"); - - return result; -} diff --git a/src/gps.c b/src/gps.c new file mode 100755 index 0000000..8d7bcc7 --- /dev/null +++ b/src/gps.c @@ -0,0 +1,545 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + +static gboolean +on_gps_set_frequency_aiding (TelephonyGps *gps, + GDBusMethodInvocation *invocation, + guchar data, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_GPS, "w")) + return TRUE; + + ur = MAKE_UR(ctx, gps, invocation); + dbg("data=%d",data); + + tcore_user_request_set_data(ur, sizeof(data), (const char*)&data); + tcore_user_request_set_command(ur, TREQ_GPS_SET_FREQUENCY_AIDING); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_gps_confirm_measure_pos (TelephonyGps *gps, + GDBusMethodInvocation *invocation, + const gchar *data, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + gboolean result = TRUE; + guchar *decoded_data = NULL; + gsize length; + + if (!check_access_control (invocation, AC_GPS, "w")) + return TRUE; + + ur = MAKE_UR(ctx, gps, invocation); + + decoded_data = g_base64_decode(data, &length); + dbg("decoded length=%d", length); + tcore_user_request_set_data(ur, length, decoded_data); + tcore_user_request_set_command(ur, TREQ_GPS_CONFIRM_MEASURE_POS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + g_free(decoded_data); + return TRUE; + } + + telephony_gps_complete_confirm_measure_pos(gps, invocation, result); + g_free(decoded_data); + + return TRUE; +} + +static gboolean +on_enable_smart_assistant(TelephonyGps *gps, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_GPS, "w")) + return TRUE; + + ur = MAKE_UR(ctx, gps, invocation); + + tcore_user_request_set_command(ur, TREQ_ENABLE_SMART_ASSISTANT); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_disable_smart_assistant(TelephonyGps *gps, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_GPS, "w")) + return TRUE; + + ur = MAKE_UR(ctx, gps, invocation); + + tcore_user_request_set_command(ur, TREQ_DISABLE_SMART_ASSISTANT); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sync_smart_assistant_area_list(TelephonyGps *gps, + GDBusMethodInvocation *invocation, + gint count, + GVariant *gv, + gpointer user_data) +{ + struct tel_smart_assistant_area_list req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + GVariantIter *iter = NULL; + GVariant *b = NULL; + int i = 0; + gint item1, item2; + dbg("enter count=%d", count); + + if (!check_access_control (invocation, AC_GPS, "w")) + return TRUE; + + ur = MAKE_UR(ctx, gps, invocation); + memset(&req,0,sizeof(struct tel_smart_assistant_area_list)); + + dbg("count=%d", count); + if (count > SMART_ASSISTANT_AREA_LIST_MAX) + count = SMART_ASSISTANT_AREA_LIST_MAX; + + req.count = count; + + g_variant_get (gv, "v", &b); + g_variant_unref (gv); + + g_variant_get (b, "a(ii)", &iter); + while(g_variant_iter_loop(iter,"(ii)",&item1, &item2)){ + req.area[i].index = item1; + req.area[i].mode_state = item2; + i++; + if (i == count) + break; + } + g_variant_iter_free(iter); + + tcore_user_request_set_data(ur, sizeof(struct tel_smart_assistant_area_list), &req); + tcore_user_request_set_command(ur, TREQ_SYNC_SMART_ASSISTANT_AREA_LIST); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_del_smart_assistant_area_list(TelephonyGps *gps, + GDBusMethodInvocation *invocation, + gint count, + GVariant *gv, + gpointer user_data) +{ + struct tel_smart_assistant_area_list req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + GVariantIter *iter = NULL; + GVariant *b = NULL; + int i = 0; + gint item1, item2; + + if (!check_access_control (invocation, AC_GPS, "w")) + return TRUE; + + ur = MAKE_UR(ctx, gps, invocation); + memset(&req,0,sizeof(struct tel_smart_assistant_area_list)); + + dbg("count=%d", count); + if (count > SMART_ASSISTANT_AREA_LIST_MAX) + count = SMART_ASSISTANT_AREA_LIST_MAX; + + req.count = count; + + g_variant_get (gv, "v", &b); + g_variant_unref (gv); + + g_variant_get (b, "a(ii)", &iter); + while(g_variant_iter_loop(iter,"(ii)",&item1, &item2)){ + req.area[i].index = item1; + req.area[i].mode_state = item2; + i++; + if (i == count) + break; + } + g_variant_iter_free(iter); + + tcore_user_request_set_data(ur, sizeof(struct tel_smart_assistant_area_list), &req); + tcore_user_request_set_command(ur, TREQ_DEL_SMART_ASSISTANT_AREA_LIST); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_add_smart_assistant_area(TelephonyGps *gps, + GDBusMethodInvocation *invocation, + gint fn_index, + gint mode_state, + gpointer user_data) +{ + struct tel_smart_assistant_area req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_GPS, "w")) + return TRUE; + + ur = MAKE_UR(ctx, gps, invocation); + req.index = fn_index; + req.mode_state = mode_state; + dbg("index=%d, mode_state=%d",req.index, req.mode_state); + + tcore_user_request_set_data(ur, sizeof(struct tel_smart_assistant_area), &req); + tcore_user_request_set_command(ur, TREQ_ADD_SMART_ASSISTANT_AREA); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} +static gboolean +on_modify_smart_assistant_area(TelephonyGps *gps, + GDBusMethodInvocation *invocation, + gint fn_index, + gint mode_state, + gpointer user_data) +{ + struct tel_smart_assistant_area req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_GPS, "w")) + return TRUE; + + ur = MAKE_UR(ctx, gps, invocation); + req.index = fn_index; + req.mode_state = mode_state; + dbg("index=%d, mode_state=%d",req.index, req.mode_state); + + tcore_user_request_set_data(ur, sizeof(struct tel_smart_assistant_area), &req); + tcore_user_request_set_command(ur, TREQ_MODIFY_SMART_ASSISTANT_AREA); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_set_smart_assistant_info(TelephonyGps *gps, + GDBusMethodInvocation *invocation, + gint fn_index, + gint lpp_state, + gpointer user_data) +{ + struct treq_set_smart_assistant_info req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_GPS, "w")) + return TRUE; + + ur = MAKE_UR(ctx, gps, invocation); + req.index = fn_index; + req.lpp_state = lpp_state; + dbg("index=%d, lpp_state=%d",req.index, req.lpp_state); + + tcore_user_request_set_data(ur, sizeof(struct treq_set_smart_assistant_info), &req); + tcore_user_request_set_command(ur, TREQ_SET_SMART_ASSISTANT_INFO); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +gboolean dbus_plugin_setup_gps_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonyGps *gps; + + gps = telephony_gps_skeleton_new(); + telephony_object_skeleton_set_gps(object, gps); + + g_object_unref(gps); + + dbg("gps = %p", gps); + + g_signal_connect (gps, + "handle-set-frequency-aiding", + G_CALLBACK (on_gps_set_frequency_aiding), + ctx); + + g_signal_connect (gps, + "handle-confirm-measure-pos", + G_CALLBACK (on_gps_confirm_measure_pos), + ctx); + + g_signal_connect (gps, + "handle-enable-smart-assistant", + G_CALLBACK (on_enable_smart_assistant), + ctx); + + g_signal_connect (gps, + "handle-disable-smart-assistant", + G_CALLBACK (on_disable_smart_assistant), + ctx); + + g_signal_connect (gps, + "handle-sync-smart-assistant-area-list", + G_CALLBACK (on_sync_smart_assistant_area_list), + ctx); + + g_signal_connect (gps, + "handle-del-smart-assistant-area-list", + G_CALLBACK (on_del_smart_assistant_area_list), + ctx); + + g_signal_connect (gps, + "handle-add-smart-assistant-area", + G_CALLBACK (on_add_smart_assistant_area), + ctx); + + g_signal_connect (gps, + "handle-modify-smart-assistant-area", + G_CALLBACK (on_modify_smart_assistant_area), + ctx); + + g_signal_connect (gps, + "handle-set-smart-assistant-info", + G_CALLBACK (on_set_smart_assistant_info), + ctx); + + return TRUE; +} + +gboolean dbus_plugin_gps_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data) +{ + const struct tresp_gps_set_frequency_aiding *resp_gps_frequency_aiding = data; + const struct tresp_smart_assistant_result *resp_smart_assistant_result = data; + + GSList *co_list; + CoreObject *co_gps; + char *modem_name = NULL; + TcorePlugin *p = NULL; + + modem_name = tcore_user_request_get_modem_name(ur); + if (!modem_name) + return FALSE; + + p = tcore_server_find_plugin(ctx->server, modem_name); + free(modem_name); + if (!p) + return FALSE; + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_GPS); + if (!co_list) { + return FALSE; + } + + co_gps = (CoreObject *)co_list->data; + g_slist_free(co_list); + + if (!co_gps) { + return FALSE; + } + + switch (command) { + case TRESP_GPS_SET_FREQUENCY_AIDING: + dbg("TRESP_GPS_SET_FREQUENCY_AIDING result=%d", resp_gps_frequency_aiding->result); + telephony_gps_complete_set_frequency_aiding(dbus_info->interface_object, dbus_info->invocation, resp_gps_frequency_aiding->result); + break; + + case TRESP_ENABLE_SMART_ASSISTANT: + dbg("TRESP_ENABLE_SMART_ASSISTANT result=%d", resp_smart_assistant_result->result); + telephony_gps_complete_enable_smart_assistant(dbus_info->interface_object, dbus_info->invocation, resp_smart_assistant_result->result); + break; + + case TRESP_DISABLE_SMART_ASSISTANT: + dbg("TRESP_ENABLE_SMART_ASSISTANT result=%d", resp_smart_assistant_result->result); + telephony_gps_complete_disable_smart_assistant(dbus_info->interface_object, dbus_info->invocation, resp_smart_assistant_result->result); + break; + + case TRESP_SYNC_SMART_ASSISTANT_AREA_LIST: + dbg("TRESP_SYNC_SMART_ASSISTANT_AREA_LIST result=%d", resp_smart_assistant_result->result); + telephony_gps_complete_sync_smart_assistant_area_list(dbus_info->interface_object, dbus_info->invocation, resp_smart_assistant_result->result); + break; + + case TRESP_DEL_SMART_ASSISTANT_AREA_LIST: + dbg("TRESP_DEL_SMART_ASSISTANT_AREA_LIST result=%d", resp_smart_assistant_result->result); + telephony_gps_complete_del_smart_assistant_area_list(dbus_info->interface_object, dbus_info->invocation, resp_smart_assistant_result->result); + break; + + case TRESP_ADD_SMART_ASSISTANT_AREA: + dbg("TRESP_ADD_SMART_ASSISTANT_AREA result=%d", resp_smart_assistant_result->result); + telephony_gps_complete_add_smart_assistant_area(dbus_info->interface_object, dbus_info->invocation, resp_smart_assistant_result->result); + break; + + case TRESP_MODIFY_SMART_ASSISTANT_AREA: + dbg("TRESP_MODIFY_SMART_ASSISTANT_AREA result=%d", resp_smart_assistant_result->result); + telephony_gps_complete_modify_smart_assistant_area(dbus_info->interface_object, dbus_info->invocation, resp_smart_assistant_result->result); + break; + + case TRESP_SET_SMART_ASSISTANT_INFO: + dbg("TRESP_SET_SMART_ASSISTANT_INFO result=%d", resp_smart_assistant_result->result); + telephony_gps_complete_set_smart_assistant_info(dbus_info->interface_object, dbus_info->invocation, resp_smart_assistant_result->result); + break; + + default: + dbg("not handled cmd[0x%x]", command); + break; + } + + return TRUE; +} + +gboolean dbus_plugin_gps_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data) +{ + TelephonyGps *gps; + + if (!object) { + dbg("object is NULL"); + return FALSE; + } + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source))); + + gps = telephony_object_peek_gps(TELEPHONY_OBJECT(object)); + switch (command) { + case TNOTI_GPS_ASSIST_DATA: + { + gchar *encoded_data = NULL; + dbg("gps(%p) TNOTI_GPS_ASSIST_DATA. data=%p, data_len=%d", gps, data, data_len); + encoded_data = g_base64_encode((const guchar*)data, data_len); + telephony_gps_emit_assist_data(gps, encoded_data); + g_free(encoded_data); + } + break; + + case TNOTI_GPS_MEASURE_POSITION: + { + gchar *encoded_data = NULL; + dbg("gps(%p) TNOTI_GPS_MEASURE_POSITION. data=%p, data_len=%d", gps, data, data_len); + encoded_data = g_base64_encode((const guchar*)data, data_len); + telephony_gps_emit_measure_position(gps, encoded_data); + g_free(encoded_data); + } + break; + + case TNOTI_GPS_RESET_ASSIST_DATA: + dbg("gps(%p) TNOTI_GPS_RESET_ASSIST_DATA", gps); + telephony_gps_emit_reset_assist_data(gps); + break; + + case TNOTI_GPS_FREQUENCY_AIDING_DATA: + { + gchar *encoded_data = NULL; + dbg("gps(%p) TNOTI_GPS_FREQUENCY_AIDING_DATA. data=%p, data_len=%d", gps, data, data_len); + encoded_data = g_base64_encode((const guchar*)data, data_len); + telephony_gps_emit_frequency_aiding(gps, encoded_data); + g_free(encoded_data); + } + break; + + case TNOTI_SMART_ASSISTANT_AREA_STATUS: + { + const struct tnoti_smart_assistant_area_status *noti = data; + dbg("gps(%p) TNOTI_SMART_ASSISTANT_AREA_STATUS", gps); + telephony_gps_emit_area_status(gps, noti->area_status, noti->index); + } + break; + + case TNOTI_SMART_ASSISTANT_SYNC_STATUS: + { + const struct tnoti_smart_assistant_sync_status *noti = data; + dbg("gps(%p) TNOTI_SMART_ASSISTANT_SYNC_STATUS", gps); + telephony_gps_emit_sync_status(gps, noti->init_status, noti->init_fail_cause); + } + break; + + default: + dbg("not handled cmd[0x%x]", command); + break; + } + + return TRUE; +} + diff --git a/src/modem.c b/src/modem.c new file mode 100644 index 0000000..279a02d --- /dev/null +++ b/src/modem.c @@ -0,0 +1,523 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + + +static gboolean +on_modem_set_power (TelephonyModem *modem, GDBusMethodInvocation *invocation, + gint mode, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + enum tcore_request_command command; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_MODEM, "w")) + return TRUE; + + ur = MAKE_UR(ctx, modem, invocation); + if (ur == NULL) + goto ERR; + + switch (mode) { + case MODEM_STATE_ONLINE: + command = TREQ_MODEM_POWER_ON; + break; + case MODEM_STATE_OFFLINE: + command = TREQ_MODEM_POWER_OFF; + break; + case MODEM_STATE_RESET: + command = TREQ_MODEM_POWER_RESET; + break; + case MODEM_STATE_LOW: + command = TREQ_MODEM_POWER_LOW; + break; + default: + ret = TCORE_RETURN_EINVAL; + goto ERR; + } + + tcore_user_request_set_command(ur, command); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) + goto ERR; + + return TRUE; + +ERR: + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + + return TRUE; +} + +static gboolean +on_modem_set_flight_mode (TelephonyModem *modem, GDBusMethodInvocation *invocation, + gboolean enable, gpointer user_data) +{ + struct treq_modem_set_flightmode data; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_MODEM, "w")) + return TRUE; + + ur = MAKE_UR(ctx, modem, invocation); + if (ur == NULL) + goto ERR; + + data.enable = enable; + if (TCORE_RETURN_SUCCESS != tcore_user_request_set_data (ur, sizeof(data), &data)) + goto ERR; + tcore_user_request_set_command (ur, TREQ_MODEM_SET_FLIGHTMODE); + + ret = tcore_communicator_dispatch_request (ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) + goto ERR; + + return TRUE; + +ERR: + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + + return TRUE; +} + +static gboolean +on_modem_get_flight_mode (TelephonyModem *modem, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_MODEM, "r")) + return TRUE; + + ur = MAKE_UR(ctx, modem, invocation); + if (ur == NULL) + goto ERR; + + tcore_user_request_set_data(ur, 0, NULL); + tcore_user_request_set_command(ur, TREQ_MODEM_GET_FLIGHTMODE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) + goto ERR; + + return TRUE; + +ERR: + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + + return TRUE; +} + +static gboolean +on_modem_get_version (TelephonyModem *modem, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_MODEM, "r")) + return TRUE; + + ur = MAKE_UR(ctx, modem, invocation); + if (ur == NULL) + goto ERR; + + tcore_user_request_set_command(ur, TREQ_MODEM_GET_VERSION); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) + goto ERR; + + return TRUE; + +ERR: + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + + return TRUE; +} + +static gboolean +on_modem_get_serial_number (TelephonyModem *modem, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_MODEM, "r")) + return TRUE; + + ur = MAKE_UR(ctx, modem, invocation); + if (ur == NULL) + goto ERR; + + tcore_user_request_set_command(ur, TREQ_MODEM_GET_SN); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) + goto ERR; + + return TRUE; + +ERR: + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + + return TRUE; +} + +static gboolean +on_modem_get_imei (TelephonyModem *modem, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_MODEM, "r")) + return TRUE; + + ur = MAKE_UR(ctx, modem, invocation); + if (ur == NULL) + goto ERR; + + tcore_user_request_set_command(ur, TREQ_MODEM_GET_IMEI); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) + goto ERR; + + return TRUE; + +ERR: + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + + return TRUE; +} + +static gboolean on_modem_set_dun_pin_ctrl (TelephonyModem *modem, GDBusMethodInvocation *invocation, + gint arg_signal, gboolean arg_status, gpointer user_data) +{ + struct treq_modem_set_dun_pin_control data; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_MODEM, "w")) + return TRUE; + + ur = MAKE_UR(ctx, modem, invocation); + if (ur == NULL) + goto ERR; + + data.signal = arg_signal; + data.status = arg_status; + + if (TCORE_RETURN_SUCCESS != tcore_user_request_set_data(ur, sizeof(data), &data)) + goto ERR; + tcore_user_request_set_command(ur, TREQ_MODEM_SET_DUN_PIN_CONTROL); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) + goto ERR; + + return TRUE; + +ERR: + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + + return TRUE; +} + +gboolean dbus_plugin_setup_modem_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonyModem *modem; + + modem = telephony_modem_skeleton_new(); + telephony_object_skeleton_set_modem(object, modem); + g_object_unref(modem); + + dbg("modem: [%p]", modem); + + g_signal_connect (modem, + "handle-set-power", + G_CALLBACK (on_modem_set_power), + ctx); + + g_signal_connect (modem, + "handle-set-flight-mode", + G_CALLBACK (on_modem_set_flight_mode), + ctx); + + g_signal_connect (modem, + "handle-get-flight-mode", + G_CALLBACK (on_modem_get_flight_mode), + ctx); + + g_signal_connect (modem, + "handle-get-version", + G_CALLBACK (on_modem_get_version), + ctx); + + g_signal_connect (modem, + "handle-get-serial-number", + G_CALLBACK (on_modem_get_serial_number), + ctx); + + g_signal_connect (modem, + "handle-get-imei", + G_CALLBACK (on_modem_get_imei), + ctx); + + g_signal_connect (modem, + "handle-set-dun-pin-ctrl", + G_CALLBACK (on_modem_set_dun_pin_ctrl), + ctx); + + telephony_modem_set_power(modem, MODEM_STATE_UNKNOWN); + + return TRUE; +} + +gboolean dbus_plugin_modem_response(struct custom_data *ctx, UserRequest *ur, + struct dbus_request_info *dbus_info, enum tcore_response_command command, + unsigned int data_len, const void *data) +{ + dbg("Response!!! Command: [0x%x] CP Name: [%s]", + command, GET_CP_NAME(dbus_info->invocation)); + + switch (command) { + case TRESP_MODEM_SET_FLIGHTMODE: { + const struct tresp_modem_set_flightmode *resp_set_flight_mode = data; + int info_set_flight_mode = 3; /* TAPI_POWER_FLIGHT_MODE_RESP_FAIL */ + + dbg("TRESP_MODEM_SET_FLIGHTMODE - Result: [%s]", + (resp_set_flight_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + if (resp_set_flight_mode->result == TCORE_RETURN_SUCCESS) { + const struct treq_modem_set_flightmode *treq_data; + treq_data = tcore_user_request_ref_data(ur, NULL); + if (treq_data == NULL) { + warn("No Request data!!!"); + info_set_flight_mode = 3; /* TAPI_POWER_FLIGHT_MODE_RESP_FAIL */ + } + else if (treq_data->enable == TRUE) { + info_set_flight_mode = 1; /* TAPI_POWER_FLIGHT_MODE_RESP_ON */ + } else { + info_set_flight_mode = 2; /* TAPI_POWER_FLIGHT_MODE_RESP_OFF */ + } + } + dbg("Set Flight mode: [%s]", (info_set_flight_mode == 1 ? "ON" + : (info_set_flight_mode == 2 ? "OFF" : "Request FAIL"))); + + telephony_modem_complete_set_flight_mode(dbus_info->interface_object, dbus_info->invocation, + info_set_flight_mode); + } + break; + + case TRESP_MODEM_GET_FLIGHTMODE: { + const struct tresp_modem_get_flightmode *resp_get_flight_mode = data; + + dbg("TRESP_MODEM_GET_FLIGHTMODE - Result: [%s]", + (resp_get_flight_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_modem_complete_get_flight_mode(dbus_info->interface_object, dbus_info->invocation, + resp_get_flight_mode->enable, resp_get_flight_mode->result); + } + break; + + case TRESP_MODEM_POWER_ON: { + const struct tresp_modem_power_on *resp_modem_power_on = data; + int result = 0; + + dbg("TRESP_MODEM_POWER_ON - Result: [%s]", + (resp_modem_power_on->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + /*TBD: value should be defined in TAPI*/ + if(resp_modem_power_on->result == TCORE_RETURN_EALREADY) + result = 1; + else if(resp_modem_power_on->result == TCORE_RETURN_OPERATION_ABORTED) + result = 2; + + telephony_modem_complete_set_power(dbus_info->interface_object, dbus_info->invocation, result); + } + break; + + case TRESP_MODEM_POWER_OFF: { + dbg("TRESP_MODEM_POWER_OFF"); + + telephony_modem_complete_set_power(dbus_info->interface_object, dbus_info->invocation, 0); + } + break; + + case TRESP_MODEM_POWER_RESET: { + dbg("TRESP_MODEM_POWER_RESET"); + + telephony_modem_complete_set_power(dbus_info->interface_object, dbus_info->invocation, 0); + } + break; + + case TRESP_MODEM_POWER_LOW: { + dbg("TRESP_MODEM_POWER_LOW"); + + telephony_modem_complete_set_power(dbus_info->interface_object, dbus_info->invocation, 0); + } + break; + + case TRESP_MODEM_GET_IMEI: { + const struct tresp_modem_get_imei *resp_get_imei = data; + + dbg("TRESP_MODEM_GET_IMEI - Result: [%s]", + (resp_get_imei->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_modem_complete_get_imei(dbus_info->interface_object, dbus_info->invocation, + resp_get_imei->result, resp_get_imei->imei); + } + break; + + case TRESP_MODEM_GET_SN: { + const struct tresp_modem_get_sn *resp_get_sn = data; + + dbg("TRESP_MODEM_GET_SN - Result: [%s]", + (resp_get_sn->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_modem_complete_get_serial_number(dbus_info->interface_object, dbus_info->invocation, + resp_get_sn->result, resp_get_sn->sn, resp_get_sn->meid, resp_get_sn->imei, resp_get_sn->imeisv); + } + break; + + case TRESP_MODEM_GET_VERSION: { + const struct tresp_modem_get_version *resp_get_version = data; + + dbg("TRESP_MODEM_GET_VERSION - Result: [%s]", + (resp_get_version->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_modem_complete_get_version(dbus_info->interface_object, dbus_info->invocation, + resp_get_version->result, + resp_get_version->software, + resp_get_version->hardware, + resp_get_version->calibration, + resp_get_version->product_code, + resp_get_version->prl_version, + resp_get_version->eri_version); + } + break; + + case TRESP_MODEM_SET_DUN_PIN_CONTROL: { + const struct tresp_modem_set_dun_pin_control *resp_dun_pin_ctrl = data; + + dbg("TRESP_MODEM_SET_DUN_PIN_CONTROL - Result: [%s]", + (resp_dun_pin_ctrl->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_modem_complete_set_dun_pin_ctrl(dbus_info->interface_object, dbus_info->invocation, + resp_dun_pin_ctrl->result); + } + break; + + default: + err("Unhandled/Unknown Response!!!"); + break; + } + + return TRUE; +} + +gboolean dbus_plugin_modem_notification(struct custom_data *ctx, CoreObject *source, + TelephonyObjectSkeleton *object, enum tcore_notification_command command, + unsigned int data_len, const void *data) +{ + TelephonyModem *modem; + + if (!object) { + dbg("object is NULL"); + return FALSE; + } + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source))); + + modem = telephony_object_peek_modem(TELEPHONY_OBJECT(object)); + dbg("modem: [%p]", modem); + + switch (command) { + case TNOTI_MODEM_POWER: { + const struct tnoti_modem_power *info = data; + + dbg("TNOTI_MODEM_POWER - Modem state: [%d]", info->state); + + if (info->state > MODEM_STATE_MAX) + break; + + telephony_modem_emit_power(modem, info->state); + telephony_modem_set_power(modem, info->state); + } + break; + + case TNOTI_MODEM_DUN_PIN_CONTROL: { + const struct tnoti_modem_dun_pin_control *pin = data; + + dbg("TNOTI_MODEM_DUN_PIN_CONTROL - Signal: [0x%2x] Status: [0x%2x]", pin->signal, pin->status); + + telephony_modem_emit_dun_pin_ctrl(modem, pin->signal, pin->status); + } + break; + + case TNOTI_MODEM_DUN_EXTERNAL_CALL: { + dbg("TNOTI_MODEM_DUN_EXTERNAL_CALL"); + + telephony_modem_emit_dun_external_call(modem, TRUE); + } + break; + + default: + err("Unhandled/Unknown Notification!!!"); + break; + } + + return TRUE; +} + diff --git a/src/network.c b/src/network.c new file mode 100755 index 0000000..f219c29 --- /dev/null +++ b/src/network.c @@ -0,0 +1,1774 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + +/* Application used properties */ +#define NET_PROP_NONE 0x0000 +#define NET_PROP_SVC_TYPE 0x0001 +#define NET_PROP_ROAM 0x0002 +#define NET_PROP_PLMN 0x0004 +#define NET_PROP_NAME_OPTION 0x0100 +#define NET_PROP_SPN 0x0200 +#define NET_PROP_NWNAME 0x0400 +#define NET_PROP_EMIT 0x0FFF + +/* Extra properties */ +#define NET_PROP_CS 0x1000 +#define NET_PROP_PS 0x2000 +#define NET_PROP_ACT 0x4000 +#define NET_PROP_ALL 0xFFFF + +struct network_prop_info { + int type; + int svc_type; + int ps_type; + gboolean roaming; + int act; + int cs; + int ps; + int name_option; + char *plmn; + char *spn; + char *nwname; +}; + +static int __convert_act_to_systemtype(enum telephony_network_access_technology act) +{ + switch (act) { + case NETWORK_ACT_UNKNOWN: + return 0; + + case NETWORK_ACT_GSM: + return 1; + + case NETWORK_ACT_GPRS: + return 2; + + case NETWORK_ACT_EGPRS: + return 3; + + case NETWORK_ACT_UMTS: + return 5; + + case NETWORK_ACT_GSM_UTRAN: + return 6; + + case NETWORK_ACT_IS95A: + return 8; + + case NETWORK_ACT_IS95B: + return 9; + + case NETWORK_ACT_CDMA_1X: + return 10; + + case NETWORK_ACT_EVDO_REV0: + return 11; + + case NETWORK_ACT_CDMA_1X_EVDO_REV0: + return 12; + + case NETWORK_ACT_EVDO_REVA: + return 13; + + case NETWORK_ACT_CDMA_1X_EVDO_REVA: + return 14; + + case NETWORK_ACT_EVDO_REVB: + return 15; + + case NETWORK_ACT_CDMA_1X_EVDO_REVB: + return 16; + + case NETWORK_ACT_EVDV: + return 17; + + case NETWORK_ACT_EHRPD: + return 18; + + case NETWORK_ACT_LTE: + return 19; + + default: + break; + } + + return 0; +} + +static int __convert_name_priority_to_option(enum tcore_network_name_priority priority) +{ + switch (priority) { + case TCORE_NETWORK_NAME_PRIORITY_SPN: + return 1; // NETWORK_NAME_OPTION_SPN + case TCORE_NETWORK_NAME_PRIORITY_NETWORK: + return 2; // NETWORK_NAME_OPTION_OPERATOR + case TCORE_NETWORK_NAME_PRIORITY_ANY: + return 3; // NETWORK_NAME_OPTION_ANY + default: + break; + } + return 0; // NETWORK_NAME_OPTION_NONE +} + +static void __get_current_network_status(CoreObject *o, + struct network_prop_info *current, int req_type) +{ + if (!o || !current) + return; + + if (req_type & NET_PROP_SVC_TYPE) { + enum telephony_network_service_type svc_type; + tcore_network_get_service_type (o, &svc_type); + current->svc_type = svc_type; + } + + if (req_type & NET_PROP_ROAM) { + current->roaming = tcore_network_get_roaming_state(o); + } + + if (req_type & NET_PROP_PLMN) { + current->plmn = tcore_network_get_plmn(o); + } + + if (req_type & NET_PROP_NAME_OPTION) { + enum tcore_network_name_priority priority = TCORE_NETWORK_NAME_PRIORITY_UNKNOWN; + tcore_network_get_network_name_priority (o, &priority); + current->name_option = __convert_name_priority_to_option(priority); + } + + if (req_type & NET_PROP_SPN) { + current->spn = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_SPN); + } + + if (req_type & NET_PROP_NWNAME) { + char *nwname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_FULL); + if (!nwname || strlen(nwname) == 0) { + nwname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_SHORT); + } + current->nwname = nwname; + } + + if (req_type & NET_PROP_CS) { + enum telephony_network_service_domain_status cs; + tcore_network_get_service_status(o, TCORE_NETWORK_SERVICE_DOMAIN_TYPE_CIRCUIT, &cs); + current->cs = cs; + } + + if (req_type & NET_PROP_PS) { + enum telephony_network_service_domain_status ps; + tcore_network_get_service_status(o, TCORE_NETWORK_SERVICE_DOMAIN_TYPE_PACKET, &ps); + current->ps = ps; + } + + if (req_type & NET_PROP_ACT) { + enum telephony_network_access_technology act = NETWORK_ACT_UNKNOWN; + tcore_network_get_access_technology (o, &act); + current->act = __convert_act_to_systemtype(act); + } +} + +static int __check_property_change(TelephonyNetwork *network, CoreObject *o, + struct network_prop_info *current, int req_type) +{ + int changed_type = NET_PROP_NONE; + + if (!current || !o) + return NET_PROP_NONE; + + __get_current_network_status(o, current, req_type); + + if (req_type & NET_PROP_SVC_TYPE) { + if (telephony_network_get_service_type(network) != current->svc_type) { + changed_type |= NET_PROP_SVC_TYPE; + } + } + + if (req_type & NET_PROP_ROAM) { + if (telephony_network_get_roaming_status(network) != current->roaming) { + changed_type |= NET_PROP_ROAM; + } + } + + if (req_type & NET_PROP_PLMN) { + const gchar *prev_plmn = telephony_network_get_plmn(network); + if (current->plmn) { + if (!prev_plmn || strcmp(prev_plmn,current->plmn) !=0) { + changed_type |= NET_PROP_PLMN; + } + } + } + + if (req_type & NET_PROP_NAME_OPTION) { + if (telephony_network_get_name_option(network) != current->name_option) { + changed_type |= NET_PROP_NAME_OPTION; + } + } + + if (req_type & NET_PROP_SPN) { + const gchar *prev_spn = telephony_network_get_spn_name(network); + if (current->spn) { + if (!prev_spn || strcmp(prev_spn,current->spn) !=0) { + changed_type |= NET_PROP_SPN; + } + } + } + + if (req_type & NET_PROP_NWNAME) { + const gchar *prev_nwname = telephony_network_get_network_name(network); + if (current->nwname) { + if (!prev_nwname || strcmp(prev_nwname,current->nwname) !=0) { + changed_type |= NET_PROP_NWNAME; + } + } + } + + if (req_type & NET_PROP_CS) { + if (telephony_network_get_circuit_status(network) != current->cs) { + changed_type |= NET_PROP_CS; + } + } + + if (req_type & NET_PROP_PS) { + if (telephony_network_get_packet_status(network) != current->ps) { + changed_type |= NET_PROP_PS; + } + } + + if (req_type & NET_PROP_ACT) { + if (telephony_network_get_access_technology(network) != current->act) { + changed_type |= NET_PROP_ACT; + } + } + + return changed_type; +} + +static void __update_network_properties(TelephonyNetwork *network, + const char *cp_name, struct network_prop_info *current, int update_type) +{ + if (!current) + return; + + if (update_type & NET_PROP_SVC_TYPE) { + telephony_network_set_service_type(network, current->svc_type); + if (current->svc_type != NETWORK_SERVICE_TYPE_3G) { + telephony_network_set_ps_type (network, TELEPHONY_HSDPA_OFF); + } + } + + if (update_type & NET_PROP_ROAM) { + telephony_network_set_roaming_status(network, current->roaming); + } + + if (update_type & NET_PROP_PLMN) { + telephony_network_set_plmn(network, current->plmn); + } + + if (update_type & NET_PROP_NAME_OPTION) { + telephony_network_set_name_option(network, current->name_option); + } + + if (update_type & NET_PROP_SPN) { + telephony_network_set_spn_name(network, current->spn); + } + + if (update_type & NET_PROP_NWNAME) { + telephony_network_set_network_name(network, current->nwname); + } + + if (update_type & NET_PROP_CS) { + telephony_network_set_circuit_status(network, current->cs); + } + + if (update_type & NET_PROP_PS) { + telephony_network_set_packet_status(network, current->ps); + } + + if (update_type & NET_PROP_ACT) { + telephony_network_set_access_technology(network, current->act); + } +} + +static int __add_default_property_type(TelephonyNetwork *network, CoreObject *o, int req_type) +{ + /* If SVC_TYPE was changed, another properties (ACT,OPTION,SPN,NWNAME) may be changed together */ + if (req_type & NET_PROP_SVC_TYPE) { + struct network_prop_info current = {0,-1,-1, 0,-1,-1,-1,-1,NULL,NULL,NULL}; + if (__check_property_change(network, o, ¤t, NET_PROP_SVC_TYPE)) { + /* If SVC_TYPE was really changed, we should add anothers to default checking value */ + req_type |= (NET_PROP_ACT|NET_PROP_NAME_OPTION|NET_PROP_SPN|NET_PROP_NWNAME); + } + } + + /* If PLMN was changed, Another properties (ROAM,OPTION,SPN,NWNAME) may be changed together */ + if (req_type & NET_PROP_PLMN) { + struct network_prop_info current = {0,-1,-1, 0,-1,-1,-1,-1,NULL,NULL,NULL}; + if (__check_property_change(network, o, ¤t, NET_PROP_PLMN)) { + /* If PLMN was really changed, we should add anothers to default checking value */ + req_type |= (NET_PROP_ROAM|NET_PROP_NAME_OPTION|NET_PROP_SPN|NET_PROP_NWNAME); + } + g_free(current.plmn); + } + return req_type; +} + +static void __check_network_properties (TelephonyNetwork *network, CoreObject *o, + const char *cp_name, int req_type) +{ + int changed_type = NET_PROP_NONE; + int emit_type = NET_PROP_NONE; + struct network_prop_info current = {0,-1,-1, 0,-1,-1,-1,-1,NULL,NULL,NULL}; + + req_type = __add_default_property_type(network, o, req_type); + changed_type = __check_property_change(network, o, ¤t, req_type); + + if (changed_type) { + __update_network_properties(network, cp_name, ¤t, changed_type); + } + + emit_type = (changed_type & NET_PROP_EMIT); + if (emit_type) { + info("[DBUSINFO][%s][PROPTYPE:%04x] svc[%d] roam[%d] plmn[%s] prio[%d] spn[%s] nwname[%s]", + cp_name, emit_type, current.svc_type,current.roaming, current.plmn, + current.name_option, current.spn, current.nwname); + telephony_network_emit_property_info(network, + emit_type, + current.svc_type, + current.roaming, + current.name_option, + current.plmn, + current.spn, + current.nwname + ); + } + g_free(current.plmn); + g_free(current.spn); + g_free(current.nwname); +} + +static enum tcore_hook_return on_hook_ps_protocol_status(Server *s, + CoreObject *source, enum tcore_notification_command command, + unsigned int data_len, void *data, void *user_data) +{ + const struct tnoti_ps_protocol_status *protocol_status = data; + + TelephonyObjectSkeleton *object; + TelephonyNetwork *network = NULL; + struct custom_data *ctx = user_data; + const char *cp_name; + char *path; + + enum telephony_ps_protocol_status ps_protocol_status = TELEPHONY_HSDPA_OFF; + + cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source)); + if (cp_name == NULL) { + err("CP name is NULL"); + return TCORE_HOOK_RETURN_CONTINUE; + } + + info("[DBUSINFO][%s] PS_PROTOCOL_STATUS (status:[%d])", cp_name, protocol_status->status); + + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + return TCORE_HOOK_RETURN_CONTINUE; + } + + network = telephony_object_peek_network(TELEPHONY_OBJECT(object)); + + if (telephony_network_get_service_type (network) < NETWORK_SERVICE_TYPE_2G) { + telephony_network_set_ps_type(network, TELEPHONY_HSDPA_OFF); + return TCORE_HOOK_RETURN_CONTINUE; + } + + switch (protocol_status->status) { + case TELEPHONY_HSDPA_OFF: + ps_protocol_status = TELEPHONY_HSDPA_OFF; + break; + + case TELEPHONY_HSDPA_ON: + ps_protocol_status = TELEPHONY_HSDPA_ON; + break; + + case TELEPHONY_HSUPA_ON: + ps_protocol_status = TELEPHONY_HSUPA_ON; + break; + + case TELEPHONY_HSPA_ON: + ps_protocol_status = TELEPHONY_HSPA_ON; + break; + + case TELEPHONY_HSPAP_ON: + ps_protocol_status = TELEPHONY_HSPAP_ON; + break; + default: + err("Unhandled protocol status!"); + break; + } + + /* Check and Set - To avoid double update */ + if (telephony_network_get_ps_type(network) != (gint)ps_protocol_status) + telephony_network_set_ps_type(network, ps_protocol_status); + + return TCORE_HOOK_RETURN_CONTINUE; +} + +static gboolean +on_network_search (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "x")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_SEARCH); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_search_cancel (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "x")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_get_selection_mode (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_GET_PLMN_SELECTION_MODE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_set_selection_mode (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gint mode, const gchar *plmn, gint act, gpointer user_data) +{ + struct treq_network_set_plmn_selection_mode req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "w")) + return TRUE; + + memset(&req, 0, sizeof(struct treq_network_set_plmn_selection_mode)); + + if (mode == 0) { /* Automatic */ + req.mode = NETWORK_SELECT_MODE_AUTOMATIC; + } + else if (mode == 1) { /* Manual */ + req.mode = NETWORK_SELECT_MODE_MANUAL; + snprintf(req.plmn, 7, "%s", plmn); + req.act = act; + } + else { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + dbg("Mode: [%d] PLMN: [%s] AcT: [%d]", req.mode, req.plmn, req.act); + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_network_set_plmn_selection_mode), &req); + tcore_user_request_set_command(ur, TREQ_NETWORK_SET_PLMN_SELECTION_MODE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + + +static gboolean +on_network_set_service_domain (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gint domain, gpointer user_data) +{ + struct treq_network_set_service_domain req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "w")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + req.domain = domain; + + tcore_user_request_set_data(ur, sizeof(struct treq_network_set_service_domain), &req); + tcore_user_request_set_command(ur, TREQ_NETWORK_SET_SERVICE_DOMAIN); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_get_service_domain (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_GET_SERVICE_DOMAIN); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_set_band (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gint band, gint mode, gpointer user_data) +{ + struct treq_network_set_band req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "w")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + req.mode = mode; + req.band = band; + + tcore_user_request_set_data(ur, sizeof(struct treq_network_set_band), &req); + tcore_user_request_set_command(ur, TREQ_NETWORK_SET_BAND); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_get_band (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_GET_BAND); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_set_mode (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gint mode, gpointer user_data) +{ + struct treq_network_set_mode req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "w")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + req.mode = mode; + + tcore_user_request_set_data(ur, sizeof(struct treq_network_set_mode), &req); + tcore_user_request_set_command(ur, TREQ_NETWORK_SET_MODE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_get_mode (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_GET_MODE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_set_preferred_plmn (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gint mode, gint ef_index, gint act, const gchar *plmn, gpointer user_data) +{ + struct treq_network_set_preferred_plmn req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "w")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + req.operation = mode; + req.ef_index = ef_index; + req.act = act; + + memcpy(req.plmn, plmn, 6); + + if (strlen(plmn) <= 5) { + req.plmn[5] = '#'; + } + + tcore_user_request_set_data(ur, sizeof(struct treq_network_set_preferred_plmn), &req); + tcore_user_request_set_command(ur, TREQ_NETWORK_SET_PREFERRED_PLMN); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_get_preferred_plmn (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_GET_PREFERRED_PLMN); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_get_serving_network (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_GET_SERVING_NETWORK); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_get_neighboring_cell_info (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_GET_NEIGHBORING_CELL_INFO); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_set_default_data_subscription (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "w")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command(ur, TREQ_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_get_default_data_subscription (TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command( ur, TREQ_NETWORK_GET_DEFAULT_DATA_SUBSCRIPTION ); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_network_set_default_subs(TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_NETWORK, "w")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command( ur, TREQ_NETWORK_SET_DEFAULT_SUBSCRIPTION ); + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_network_get_default_subs(TelephonyNetwork *network, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur; + TReturn ret = 0; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + tcore_user_request_set_command( ur, TREQ_NETWORK_GET_DEFAULT_SUBSCRIPTION ); + ret = tcore_communicator_dispatch_request( ctx->comm, ur ); + if ( ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_set_emergency_callback_mode (TelephonyNetwork *network, + GDBusMethodInvocation *invocation, + gint mode, + gpointer user_data) +{ + struct treq_network_set_emergency_callback_mode req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "w")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + req.mode = mode; + + tcore_user_request_set_data(ur, sizeof(struct treq_network_set_emergency_callback_mode), &req); + tcore_user_request_set_command(ur, TREQ_NETWORK_SET_EMERGENCY_CALLBACK_MODE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_set_roaming_preference (TelephonyNetwork *network, + GDBusMethodInvocation *invocation, + gint roam_pref, + gpointer user_data) +{ + struct treq_network_set_roaming_preference req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "w")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + + req.roam_pref = roam_pref; + + tcore_user_request_set_data(ur, sizeof(struct treq_network_set_roaming_preference), &req); + tcore_user_request_set_command(ur, TREQ_NETWORK_SET_ROAMING_PREFERENCE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_network_get_roaming_preference (TelephonyNetwork *network, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_NETWORK, "r")) + return TRUE; + + ur = MAKE_UR(ctx, network, invocation); + tcore_user_request_set_data(ur, 0, NULL); + tcore_user_request_set_command(ur, TREQ_NETWORK_GET_ROAMING_PREFERENCE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +gboolean dbus_plugin_setup_network_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonyNetwork *network; + + network = telephony_network_skeleton_new(); + telephony_object_skeleton_set_network(object, network); + g_object_unref(network); + + g_signal_connect (network, + "handle-search", + G_CALLBACK (on_network_search), + ctx); + + g_signal_connect (network, + "handle-search-cancel", + G_CALLBACK (on_network_search_cancel), + ctx); + + g_signal_connect (network, + "handle-set-selection-mode", + G_CALLBACK (on_network_set_selection_mode), + ctx); + + g_signal_connect (network, + "handle-get-selection-mode", + G_CALLBACK (on_network_get_selection_mode), + ctx); + + g_signal_connect (network, + "handle-set-service-domain", + G_CALLBACK (on_network_set_service_domain), + ctx); + + g_signal_connect (network, + "handle-get-service-domain", + G_CALLBACK (on_network_get_service_domain), + ctx); + + g_signal_connect (network, + "handle-set-band", + G_CALLBACK (on_network_set_band), + ctx); + + g_signal_connect (network, + "handle-get-band", + G_CALLBACK (on_network_get_band), + ctx); + + g_signal_connect (network, + "handle-set-mode", + G_CALLBACK (on_network_set_mode), + ctx); + + g_signal_connect (network, + "handle-get-mode", + G_CALLBACK (on_network_get_mode), + ctx); + + g_signal_connect (network, + "handle-set-preferred-plmn", + G_CALLBACK (on_network_set_preferred_plmn), + ctx); + + g_signal_connect (network, + "handle-get-preferred-plmn", + G_CALLBACK (on_network_get_preferred_plmn), + ctx); + + g_signal_connect (network, + "handle-get-serving-network", + G_CALLBACK (on_network_get_serving_network), + ctx); + + g_signal_connect (network, + "handle-get-ngbr-cell-info", + G_CALLBACK (on_network_get_neighboring_cell_info), + ctx); + + g_signal_connect (network, + "handle-set-default-data-subscription", + G_CALLBACK (on_network_set_default_data_subscription), + ctx); + + g_signal_connect (network, + "handle-get-default-data-subscription", + G_CALLBACK (on_network_get_default_data_subscription), + ctx); + + g_signal_connect (network, + "handle-set-default-subscription", + G_CALLBACK (on_network_set_default_subs), + ctx); + + g_signal_connect (network, + "handle-get-default-subscription", + G_CALLBACK (on_network_get_default_subs), + ctx); + + g_signal_connect (network, + "handle-set-emergency-callback-mode", + G_CALLBACK (on_network_set_emergency_callback_mode), + ctx); + + g_signal_connect (network, + "handle-set-roaming-preference", + G_CALLBACK (on_network_set_roaming_preference), + ctx); + + g_signal_connect (network, + "handle-get-roaming-preference", + G_CALLBACK (on_network_get_roaming_preference), + ctx); + + /* initialize dbus properties */ + telephony_network_set_access_technology(network, NETWORK_ACT_UNKNOWN); + telephony_network_set_cell_id(network, 0); + telephony_network_set_ims_voice_status(network, NETWORK_IMS_VOICE_UNKNOWN); + telephony_network_set_circuit_status(network, NETWORK_SERVICE_DOMAIN_STATUS_NO); + telephony_network_set_lac(network, 0); + telephony_network_set_name_option(network, NETWORK_NAME_OPTION_NONE); + telephony_network_set_packet_status(network, NETWORK_SERVICE_DOMAIN_STATUS_NO); + telephony_network_set_sig_dbm(network, 0); + telephony_network_set_roaming_status(network, FALSE); + telephony_network_set_ps_type(network, TELEPHONY_HSDPA_OFF); + telephony_network_set_service_type(network, NETWORK_SERVICE_TYPE_UNKNOWN); + telephony_network_set_sig_level(network, 0); + telephony_network_set_plmn(network, NULL); + telephony_network_set_spn_name(network, NULL); + telephony_network_set_network_name(network, NULL); + + tcore_server_remove_notification_hook(ctx->server, on_hook_ps_protocol_status); + tcore_server_add_notification_hook(ctx->server, + TNOTI_PS_PROTOCOL_STATUS, on_hook_ps_protocol_status, ctx); + + return TRUE; +} + +gboolean dbus_plugin_network_response(struct custom_data *ctx, UserRequest *ur, + struct dbus_request_info *dbus_info, enum tcore_response_command command, + unsigned int data_len, const void *data) +{ + dbg("Response!!! Command: [0x%x] CP Name: [%s]", + command, GET_CP_NAME(dbus_info->invocation)); + + switch (command) { + case TRESP_NETWORK_SEARCH: { + const struct tresp_network_search *resp_network_search = data; + GVariant *network_search_result = NULL; + GVariantBuilder b; + int i = 0; + + dbg("TRESP_NETWORK_SEARCH - Result: [%s] Count: [%d]", + (resp_network_search->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"), + resp_network_search->list_count); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i = 0; i < resp_network_search->list_count; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + + g_variant_builder_add(&b, "{sv}", "plmn", g_variant_new_string(resp_network_search->list[i].plmn)); + g_variant_builder_add(&b, "{sv}", "act", g_variant_new_int32(resp_network_search->list[i].act)); + g_variant_builder_add(&b, "{sv}", "type", g_variant_new_int32(resp_network_search->list[i].status)); + g_variant_builder_add(&b, "{sv}", "name", g_variant_new_string(resp_network_search->list[i].name)); + + g_variant_builder_close(&b); + } + network_search_result = g_variant_builder_end(&b); + + telephony_network_complete_search(dbus_info->interface_object, dbus_info->invocation, + network_search_result, resp_network_search->result); + } + break; + + case TRESP_NETWORK_SET_PLMN_SELECTION_MODE: { + const struct tresp_network_set_plmn_selection_mode *resp_set_plmn_selection_mode = data; + + dbg("TRESP_SET_PLMN_SELECTION_MODE - Result: [%s]", + (resp_set_plmn_selection_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_network_complete_set_selection_mode(dbus_info->interface_object, dbus_info->invocation, + resp_set_plmn_selection_mode->result); + } + break; + + case TRESP_NETWORK_GET_PLMN_SELECTION_MODE: { + const struct tresp_network_get_plmn_selection_mode *resp_get_plmn_selection_mode = data; + + dbg("TRESP_GET_PLMN_SELECTION_MODE - Result: [%s] Mode: [%s]", + (resp_get_plmn_selection_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"), + (resp_get_plmn_selection_mode->mode == NETWORK_SELECT_MODE_AUTOMATIC ? "Auto" : + (resp_get_plmn_selection_mode->mode == NETWORK_SELECT_MODE_MANUAL ? "Manual" : + "Unknown"))); + + switch (resp_get_plmn_selection_mode->mode) { + case NETWORK_SELECT_MODE_AUTOMATIC: + telephony_network_complete_get_selection_mode(dbus_info->interface_object, dbus_info->invocation, + 0, resp_get_plmn_selection_mode->result); + break; + + case NETWORK_SELECT_MODE_MANUAL: + telephony_network_complete_get_selection_mode(dbus_info->interface_object, dbus_info->invocation, + 1, resp_get_plmn_selection_mode->result); + break; + + default: + telephony_network_complete_get_selection_mode(dbus_info->interface_object, dbus_info->invocation, + -1, resp_get_plmn_selection_mode->result); + break; + } + } + break; + + case TRESP_NETWORK_SET_SERVICE_DOMAIN: { + const struct tresp_network_set_service_domain *resp_set_service_domain = data; + + dbg("TRESP_NETWORK_SET_SERVICE_DOMAIN - Result: [%s]", + (resp_set_service_domain->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_network_complete_set_service_domain(dbus_info->interface_object, dbus_info->invocation, + resp_set_service_domain->result); + } + break; + + case TRESP_NETWORK_GET_SERVICE_DOMAIN: { + const struct tresp_network_get_service_domain *resp_get_service_domain = data; + + dbg("TRESP_NETWORK_GET_SERVICE_DOMAIN - Result: [%s] Domain: [%d]", + (resp_get_service_domain->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"), + resp_get_service_domain->domain); + + telephony_network_complete_get_service_domain(dbus_info->interface_object, dbus_info->invocation, + resp_get_service_domain->domain, resp_get_service_domain->result); + } + break; + + case TRESP_NETWORK_SET_BAND: { + const struct tresp_network_set_band *resp_set_band = data; + + dbg("TRESP_NETWORK_SET_BAND - Result: [%s]", + (resp_set_band->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_network_complete_set_band(dbus_info->interface_object, dbus_info->invocation, + resp_set_band->result); + } + break; + + case TRESP_NETWORK_GET_BAND: { + const struct tresp_network_get_band *resp_get_band = data; + + dbg("TRESP_NETWORK_GET_BAND - Result: [%s] Mode: [%s] Band: [%d]", + (resp_get_band->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"), + (resp_get_band->mode == NETWORK_BAND_MODE_PREFERRED ? "Preferred" : + (resp_get_band->mode == NETWORK_BAND_MODE_ONLY ? "Only" : + "Unknown")), resp_get_band->band); + + telephony_network_complete_get_band(dbus_info->interface_object, dbus_info->invocation, + resp_get_band->band, resp_get_band->mode, resp_get_band->result); + } + break; + + case TRESP_NETWORK_SET_MODE: { + const struct tresp_network_set_mode *resp_set_mode = data; + + dbg("TRESP_NETWORK_SET_MODE - Result: [%s]", + (resp_set_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_network_complete_set_mode(dbus_info->interface_object, dbus_info->invocation, + resp_set_mode->result); + } + break; + + case TRESP_NETWORK_GET_MODE: { + const struct tresp_network_get_mode *resp_get_mode = data; + + dbg("TRESP_NETWORK_GET_MODE - Result: [%s] Mode: [%d]", + (resp_get_mode->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"), + resp_get_mode->mode); + + telephony_network_complete_get_mode(dbus_info->interface_object, dbus_info->invocation, + resp_get_mode->mode, resp_get_mode->result); + } + break; + + case TRESP_NETWORK_GET_NEIGHBORING_CELL_INFO: { + const struct tresp_network_get_neighboring_cell_info *resp_get_ngbr_cell_info = data; + GVariant *neighboring_cell_info_result = NULL; + GVariant *value = NULL; + GVariantBuilder b; + enum telephony_network_access_technology act; + int i = 0; + + dbg("TRESP_NETWORK_GET_NEIGHBORING_CELL_INFO - Result: [%s]", + (resp_get_ngbr_cell_info->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + act = resp_get_ngbr_cell_info->info.serving.act; + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + /* Fill Serving cell parameter */ + value = g_variant_new("(iii)", + resp_get_ngbr_cell_info->info.serving.act, + resp_get_ngbr_cell_info->info.serving.mcc, + resp_get_ngbr_cell_info->info.serving.mnc); + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "serving", value); + g_variant_builder_close(&b); + + if (act >= NETWORK_ACT_GSM && act <= NETWORK_ACT_EGPRS) { + value = g_variant_new("(iiiii)", + resp_get_ngbr_cell_info->info.serving.cell.geran.cell_id, + resp_get_ngbr_cell_info->info.serving.cell.geran.lac, + resp_get_ngbr_cell_info->info.serving.cell.geran.bcch, + resp_get_ngbr_cell_info->info.serving.cell.geran.bsic, + resp_get_ngbr_cell_info->info.serving.cell.geran.rxlev); + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "g_serving", value); + g_variant_builder_close(&b); + + } + else if (act >= NETWORK_ACT_UMTS && act <= NETWORK_ACT_GSM_UTRAN) { + value = g_variant_new("(iiiii)", + resp_get_ngbr_cell_info->info.serving.cell.umts.cell_id, + resp_get_ngbr_cell_info->info.serving.cell.umts.lac, + resp_get_ngbr_cell_info->info.serving.cell.umts.arfcn, + resp_get_ngbr_cell_info->info.serving.cell.umts.psc, + resp_get_ngbr_cell_info->info.serving.cell.umts.rscp); + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "u_serving", value); + g_variant_builder_close(&b); + } + else if (act == NETWORK_ACT_LTE) { + value = g_variant_new("(iiiii)", + resp_get_ngbr_cell_info->info.serving.cell.lte.cell_id, + resp_get_ngbr_cell_info->info.serving.cell.lte.lac, + resp_get_ngbr_cell_info->info.serving.cell.lte.earfcn, + resp_get_ngbr_cell_info->info.serving.cell.lte.tac, + resp_get_ngbr_cell_info->info.serving.cell.lte.rssi); + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "l_serving", value); + g_variant_builder_close(&b); + } + else if(act >= NETWORK_ACT_IS95A && act <= NETWORK_ACT_EHRPD) { + value = g_variant_new("(uuuuii)", + resp_get_ngbr_cell_info->info.serving.cell.cdma.sid, + resp_get_ngbr_cell_info->info.serving.cell.cdma.nid, + resp_get_ngbr_cell_info->info.serving.cell.cdma.base_id, + resp_get_ngbr_cell_info->info.serving.cell.cdma.refpn, + resp_get_ngbr_cell_info->info.serving.cell.cdma.base_lat, + resp_get_ngbr_cell_info->info.serving.cell.cdma.base_long); + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "c_serving", value); + g_variant_builder_close(&b); + } + + /* Fill GERAN neighbor cell parameter */ + for (i = 0; i < resp_get_ngbr_cell_info->info.geran_list_count; i++) { + value = g_variant_new("(iiiii)", + resp_get_ngbr_cell_info->info.geran_list[i].cell_id, + resp_get_ngbr_cell_info->info.geran_list[i].lac, + resp_get_ngbr_cell_info->info.geran_list[i].bcch, + resp_get_ngbr_cell_info->info.geran_list[i].bsic, + resp_get_ngbr_cell_info->info.geran_list[i].rxlev); + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "geran", value); + g_variant_builder_close(&b); + } + + /* Fill UMTS neighbor cell parameter */ + for (i = 0; i < resp_get_ngbr_cell_info->info.umts_list_count; i++) { + value = g_variant_new("(iiiii)", + resp_get_ngbr_cell_info->info.umts_list[i].cell_id, + resp_get_ngbr_cell_info->info.umts_list[i].lac, + resp_get_ngbr_cell_info->info.umts_list[i].arfcn, + resp_get_ngbr_cell_info->info.umts_list[i].psc, + resp_get_ngbr_cell_info->info.umts_list[i].rscp); + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "umts", value); + g_variant_builder_close(&b); + } + neighboring_cell_info_result = g_variant_builder_end(&b); + + telephony_network_complete_get_ngbr_cell_info(dbus_info->interface_object, dbus_info->invocation, + neighboring_cell_info_result, resp_get_ngbr_cell_info->result); + } + break; + + case TRESP_NETWORK_SET_PREFERRED_PLMN: { + const struct tresp_network_set_preferred_plmn *resp_set_preferred_plmn = data; + + dbg("TRESP_NETWORK_SET_PREFERRED_PLMN - Result: [%s]", + (resp_set_preferred_plmn->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_network_complete_set_preferred_plmn(dbus_info->interface_object, dbus_info->invocation, + resp_set_preferred_plmn->result); + } + break; + + case TRESP_NETWORK_GET_PREFERRED_PLMN: { + const struct tresp_network_get_preferred_plmn *resp_get_preferred_plmn = data; + GVariant *preferred_plmn_result = NULL; + GVariantBuilder b; + int i = 0; + + dbg("TRESP_NETWORK_GET_PREFERRED_PLMN - Result: [%s] Count: [%d]", + (resp_get_preferred_plmn->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"), + resp_get_preferred_plmn->list_count); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i = 0; i < resp_get_preferred_plmn->list_count; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + + g_variant_builder_add(&b, "{sv}", "plmn", + g_variant_new_string(resp_get_preferred_plmn->list[i].plmn)); + g_variant_builder_add(&b, "{sv}", "act", g_variant_new_int32(resp_get_preferred_plmn->list[i].act)); + g_variant_builder_add(&b, "{sv}", "index", + g_variant_new_int32(resp_get_preferred_plmn->list[i].ef_index)); + g_variant_builder_add(&b, "{sv}", "name", g_variant_new_string(resp_get_preferred_plmn->list[i].name)); + + g_variant_builder_close(&b); + } + preferred_plmn_result = g_variant_builder_end(&b); + + telephony_network_complete_get_preferred_plmn(dbus_info->interface_object, dbus_info->invocation, + preferred_plmn_result, resp_get_preferred_plmn->result); + } + break; + + case TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH: { + const struct tresp_network_set_cancel_manual_search *resp_set_cancel_manual_search = data; + + dbg("TRESP_NETWORK_SET_CANCEL_MANUAL_SEARCH - Result: [%s]", + (resp_set_cancel_manual_search->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_network_complete_search_cancel(dbus_info->interface_object, dbus_info->invocation, + resp_set_cancel_manual_search->result); + } + break; + + case TRESP_NETWORK_GET_SERVING_NETWORK: { + const struct tresp_network_get_serving_network *resp_get_serving_network = data; + GVariant *serving_network = NULL; + GVariant *value = NULL; + GVariantBuilder b; + + enum telephony_network_access_technology act; + + dbg("TRESP_NETWORK_GET_SERVING_NETWORK - Result: [%s] AcT: [%d] PLMN: [%s] LAC: [%d])", + (resp_get_serving_network->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"), + resp_get_serving_network->act, resp_get_serving_network->plmn, resp_get_serving_network->gsm.lac); + + act = resp_get_serving_network->act; + g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); + + /* Fill Serving cell parameter */ + value = g_variant_new("(is)", + resp_get_serving_network->act, + resp_get_serving_network->plmn); + + g_variant_builder_add(&b, "{sv}", "serving", value); + if ((act >= NETWORK_ACT_GSM && act <= NETWORK_ACT_GSM_UTRAN) || act == NETWORK_ACT_LTE) { + dbg("lac:[%d]", resp_get_serving_network->gsm.lac); + value = g_variant_new("(i)", + resp_get_serving_network->gsm.lac); + g_variant_builder_add(&b, "{sv}", "g_serving", value); + } + else if(act >= NETWORK_ACT_IS95A && act <= NETWORK_ACT_EHRPD) { + dbg("carrier:[%d] sid:[%d] nid:[%d] bs_id:[%d] bs_lat:[%d] bs_long:[%d] reg_zone:[%d] pilot_pn:[%d]", + resp_get_serving_network->cdma.carrier, + resp_get_serving_network->cdma.sid, + resp_get_serving_network->cdma.nid, + resp_get_serving_network->cdma.bs_id, + resp_get_serving_network->cdma.bs_lat, + resp_get_serving_network->cdma.bs_long, + resp_get_serving_network->cdma.reg_zone, + resp_get_serving_network->cdma.pilot_pn); + + value = g_variant_new("(iuuuiiuu)", + resp_get_serving_network->cdma.carrier, + resp_get_serving_network->cdma.sid, + resp_get_serving_network->cdma.nid, + resp_get_serving_network->cdma.bs_id, + resp_get_serving_network->cdma.bs_lat, + resp_get_serving_network->cdma.bs_long, + resp_get_serving_network->cdma.reg_zone, + resp_get_serving_network->cdma.pilot_pn); + g_variant_builder_add(&b, "{sv}", "c_serving", value); + } + serving_network = g_variant_builder_end(&b); + telephony_network_complete_get_serving_network(dbus_info->interface_object, dbus_info->invocation, + serving_network, resp_get_serving_network->result); + } + break; + + case TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION: { + const struct tresp_network_set_default_data_subscription *resp_set_default_data_subs = data; + + dbg("TRESP_NETWORK_SET_DEFAULT_DATA_SUBSCRIPTION - Result: [%s]", + (resp_set_default_data_subs->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_network_complete_set_default_data_subscription(dbus_info->interface_object, dbus_info->invocation, + resp_set_default_data_subs->result); + } + break; + + case TRESP_NETWORK_GET_DEFAULT_DATA_SUBSCRIPTION: { + const struct tresp_network_get_default_data_subs *resp_get_default_data_subs = data; + + dbg("TRESP_NETWORK_GET_DEFAULT_DATA_SUBSCRIPTION - Result: [%s] 'default' Data subscription: [%s]", + (resp_get_default_data_subs->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"), + (resp_get_default_data_subs->default_subs == NETWORK_DEFAULT_DATA_SUBS_SIM1 ? "SIM1" : + (resp_get_default_data_subs->default_subs == NETWORK_DEFAULT_DATA_SUBS_SIM2 ? "SIM2" : + "Unknown"))); + + telephony_network_complete_get_default_data_subscription(dbus_info->interface_object, dbus_info->invocation, + resp_get_default_data_subs->default_subs, resp_get_default_data_subs->result); + } + break; + + case TRESP_NETWORK_SET_DEFAULT_SUBSCRIPTION: { + const struct tresp_network_set_default_subs *resp_set_default_subs = data; + + dbg("TRESP_NETWORK_SET_DEFAULT_SUBSCRIPTION - Result: [%s]", + (resp_set_default_subs->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail")); + + telephony_network_complete_set_default_subscription(dbus_info->interface_object, dbus_info->invocation, + resp_set_default_subs->result ); + } + break; + + case TRESP_NETWORK_GET_DEFAULT_SUBSCRIPTION: { + const struct tresp_network_get_default_subs *resp_get_default_subs = data; + + dbg("TRESP_NETWORK_GET_DEFAULT_SUBSCRIPTION - Result: [%s] 'default' subscription: [%s]", + (resp_get_default_subs->result == TCORE_RETURN_SUCCESS ? "Success" : "Fail"), + (resp_get_default_subs->default_subs == NETWORK_DEFAULT_SUBS_SIM1 ? "SIM1" : + (resp_get_default_subs->default_subs == NETWORK_DEFAULT_SUBS_SIM2 ? "SIM2" : + "Unknown"))); + + telephony_network_complete_get_default_subscription(dbus_info->interface_object, dbus_info->invocation, + resp_get_default_subs->default_subs, resp_get_default_subs->result ); + } + break; + + case TRESP_NETWORK_SET_EMERGENCY_CALLBACK_MODE: { + const struct tresp_network_set_emergency_callback_mode *resp_set_emergency_callback_mode = data; + dbg("TRESP_NETWORK_SET_EMERGENCY_CALLBACK_MODE (result:[%d])", resp_set_emergency_callback_mode->result); + telephony_network_complete_set_emergency_callback_mode(dbus_info->interface_object, dbus_info->invocation, + resp_set_emergency_callback_mode->result); + } + break; + + case TRESP_NETWORK_SET_ROAMING_PREFERENCE: { + const struct tresp_network_set_roaming_preference *resp_set_roam_pref = data; + + dbg("TRESP_NETWORK_SET_ROAMING_PREFERENCE (result:[%d])", resp_set_roam_pref->result); + + telephony_network_complete_set_roaming_preference(dbus_info->interface_object, dbus_info->invocation, resp_set_roam_pref->result); + } + break; + + case TRESP_NETWORK_GET_ROAMING_PREFERENCE: { + const struct tresp_network_get_roaming_preference *resp_get_roam_pref = data; + + dbg("TRESP_NETWORK_GET_ROAMING_PREFERENCE (roam_pref:[%d])", resp_get_roam_pref->roam_pref); + + telephony_network_complete_get_roaming_preference(dbus_info->interface_object, dbus_info->invocation, + resp_get_roam_pref->roam_pref, resp_get_roam_pref->result); + } + break; + + default: + err("Unhandled/Unknown Response!!!"); + break; + } + + return TRUE; +} + +gboolean dbus_plugin_network_notification(struct custom_data *ctx, CoreObject *source, + TelephonyObjectSkeleton *object, enum tcore_notification_command command, + unsigned int data_len, const void *data) +{ + TelephonyNetwork *network; + const char *cp_name; + + if (!object) { + err("object is NULL"); + return FALSE; + } + + if (!data) { + err("data is NULL"); + return FALSE; + } + + cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source)); + + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, cp_name); + + network = telephony_object_peek_network(TELEPHONY_OBJECT(object)); + + switch (command) { + case TNOTI_NETWORK_REGISTRATION_STATUS: { + const struct tnoti_network_registration_status *reg = data; + + info("[DBUSINFO][%s] NET_REGI_STATUS. (cs:[%d] ps:[%d] svc:[%d] roam:[%d])", + cp_name, reg->cs_domain_status, reg->ps_domain_status, reg->service_type, reg->roaming_status); + +#ifdef ENABLE_KPI_LOGS + /* We ignore No SIM present case for KPI */ + if (reg->cs_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL + && telephony_network_get_circuit_status(network) != NETWORK_SERVICE_DOMAIN_STATUS_FULL) + TIME_CHECK("[%s] CS Network Full", cp_name); + + if (reg->ps_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL + && telephony_network_get_packet_status(network) != NETWORK_SERVICE_DOMAIN_STATUS_FULL) + TIME_CHECK("[%s] PS Network Full", cp_name); +#endif + __check_network_properties(network, source, cp_name, + (NET_PROP_CS|NET_PROP_PS|NET_PROP_SVC_TYPE|NET_PROP_ROAM)); + + /* Emit Signal */ + telephony_network_emit_registration_status(network, + reg->cs_domain_status, + reg->ps_domain_status, + reg->service_type, + reg->roaming_status); + } + break; + + case TNOTI_NETWORK_CHANGE: { + const struct tnoti_network_change *change = data; + + info("[DBUSINFO][%s] NET_CHANGE. (plmn:[%s] lac:[%d])", + cp_name, change->plmn, change->gsm.lac); + + __check_network_properties(network, source, cp_name, NET_PROP_PLMN); + + /* Emit Signal */ + telephony_network_emit_change(network, + change->act, + change->plmn); + } + break; + + case TNOTI_NETWORK_TIMEINFO: { + const struct tnoti_network_timeinfo *time_info = data; + + info("[DBUSINFO][%s] NET_TIMEINFO", cp_name); + + /* Emit signal */ + telephony_network_emit_time_info(network, + time_info->year, + time_info->month, + time_info->day, + time_info->hour, + time_info->minute, + time_info->second, + time_info->wday, + time_info->gmtoff, + time_info->dstoff, + time_info->isdst, + time_info->plmn); + } + break; + + case TNOTI_NETWORK_ICON_INFO: { + const struct tnoti_network_icon_info *icon_info = data; + + /* Update property */ + if (icon_info->type & NETWORK_ICON_INFO_RSSI) { + info("[DBUSINFO][%s] NET_ICON_INFO (Ant:[%d])", cp_name, icon_info->rssi); + telephony_network_set_sig_level (network, icon_info->rssi); + } + } + break; + + case TNOTI_NETWORK_IDENTITY: { + const struct tnoti_network_identity *identity = data; + + info("[DBUSINFO][%s] NET_IDENTITY (long:[%s] short:[%s] plmn:[%s])", + cp_name, identity->full_name, identity->short_name, identity->plmn); + + __check_network_properties(network, source, cp_name, + (NET_PROP_NAME_OPTION|NET_PROP_SPN|NET_PROP_NWNAME)); + + /* Emit Signal */ + telephony_network_emit_identity(network, + identity->plmn, + identity->short_name, + identity->full_name); + } + break; + + case TNOTI_NETWORK_LOCATION_CELLINFO: { + const struct tnoti_network_location_cellinfo *location = data; + + info("[DBUSINFO][%s] NET_LOCATION_CELLINFO (lac:[%d] cell_id:[%d])", + cp_name, location->lac, location->cell_id); + + /* Update properties */ + telephony_network_set_lac (network, location->lac); + telephony_network_set_cell_id (network, location->cell_id); + + /* Emit signal */ + telephony_network_emit_cell_info(network, + location->lac, + location->cell_id); + } + break; + + case TNOTI_NETWORK_SIGNAL_STRENGTH: { + const struct tnoti_network_signal_strength *signal_strength = data; + + info("[DBUSINFO][%s] NET_SIGNAL_STRENGTH (dbm:[%d])", cp_name, signal_strength->dbm); + + /* Update properties */ + telephony_network_set_sig_dbm (network, signal_strength->dbm); + + /* Emit signal */ + telephony_network_emit_signal_strength(network, + signal_strength->dbm); + } + break; + + case TNOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION: { + const struct tnoti_network_default_data_subs *default_data_subs_info = data; + + info("[DBUSINFO][%s] NET_DEFAULT_DATA_SUBSCRIPTION (default:[%d])", cp_name, default_data_subs_info->default_subs); + + /* Emit signal */ + telephony_network_emit_default_data_subscription(network, + default_data_subs_info->default_subs); + } + break; + + case TNOTI_NETWORK_DEFAULT_SUBSCRIPTION: { + const struct tnoti_network_default_subs *default_subs_info = data; + + info("[DBUSINFO][%s] NET_DEFAULT_SUBSCRIPTION (default:[%d])", cp_name, default_subs_info->default_subs); + + /* Emit signal */ + telephony_network_emit_default_subscription(network, + default_subs_info->default_subs); + } + break; + + case TNOTI_NETWORK_IMS_VOICE_SUPPORT_STATUS: { + const struct tnoti_network_ims_voice_status *status = data; + + dbg("TNOTI_NETWORK_IMS_VOICE_SUPPORT_STATUS"); + + /* Update properties */ + telephony_network_set_ims_voice_status(network, status->status); + } + break; + + case TNOTI_NETWORK_EMERGENCY_CALLBACK_MODE: { + const struct tnoti_network_emergency_callback_mode *emergency_callback_mode = data; + + telephony_network_emit_emergency_callback_mode(network, + emergency_callback_mode->mode); + } + break; + + default: + err("Unhandled/Unknown Notification!!!"); + break; + } + + return TRUE; +} + diff --git a/src/oem.c b/src/oem.c new file mode 100644 index 0000000..3b3b20c --- /dev/null +++ b/src/oem.c @@ -0,0 +1,155 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + +#define TYPE_FACTORY 0x00020000 +#define MAKE_REQ_CMD(id) (TREQ_CUSTOM|TYPE_FACTORY|id) +#define GET_OEM_ID(cmd) (cmd&0x0000FFFF) + +static void _emit_oem_response(struct dbus_request_info *dbus_info, int oem_id, const void *data, unsigned int data_len) +{ + if (!dbus_info || !oem_id || !data || !data_len) { + dbg("Invalid Data! dbus_info=%p, oem_id=0x%x, data=%p, data_len=%d", dbus_info, oem_id, data, data_len); + return ; + } + + if (dbus_info->interface_object) { + gchar *encoded_data = g_base64_encode((const guchar*)data, data_len); + if (dbus_info->invocation) { + telephony_oem_complete_send_oem_data_with_response(dbus_info->interface_object, dbus_info->invocation, oem_id, encoded_data); + } else { + telephony_oem_emit_oem_data(dbus_info->interface_object, oem_id, encoded_data); + } + g_free(encoded_data); + } +} + +static void _emit_oem_notification(TelephonyOEM *oem, int oem_id, const void *data, unsigned int data_len) +{ + gchar *encoded_data = NULL; + + if (!oem || !oem_id || !data || !data_len) { + dbg("Invalid Data! oem=%p, oem_id=0x%x, data=%p, data_len=%d", oem, oem_id, data, data_len); + return ; + } + + encoded_data = g_base64_encode((const guchar*)data, data_len); + telephony_oem_emit_oem_data(oem, oem_id, encoded_data); + g_free(encoded_data); +} + +static gboolean +send_oem_data(TelephonyOEM *oem, + GDBusMethodInvocation *invocation, + gint arg_oem_id, + const gchar *arg_data, + gpointer user_data, + gboolean remove_invocation) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + gint result = 1; + guchar *decoded_data = NULL; + gsize length; + + if (!check_access_control (invocation, AC_MODEM, "w")) + return TRUE; + + ur = MAKE_UR(ctx, oem, invocation); + decoded_data = g_base64_decode(arg_data, &length); + + tcore_user_request_set_data(ur, length, decoded_data); + g_free(decoded_data); + + tcore_user_request_set_command(ur, MAKE_REQ_CMD(arg_oem_id)); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + return TRUE; + } + + if (remove_invocation) { + struct dbus_request_info *dbus_info = tcore_user_request_ref_user_info(ur); + if (dbus_info) + dbus_info->invocation = NULL; + + telephony_oem_complete_send_oem_data(oem, invocation, result); + } + return TRUE; +} + +static gboolean +on_send_oem_data (TelephonyOEM *oem, + GDBusMethodInvocation *invocation, + gint arg_oem_id, + const gchar *arg_data, + gpointer user_data) +{ + return send_oem_data(oem, invocation, arg_oem_id, arg_data, user_data, TRUE); +} + +static gboolean +on_send_oem_data_with_response (TelephonyOEM *oem, + GDBusMethodInvocation *invocation, + gint arg_oem_id, + const gchar *arg_data, + gpointer user_data) +{ + return send_oem_data(oem, invocation, arg_oem_id, arg_data, user_data, FALSE); +} + +gboolean dbus_plugin_setup_oem_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonyOEM *oem; + + oem = telephony_oem_skeleton_new(); + telephony_object_skeleton_set_oem(object, oem); + + g_object_unref(oem); + + dbg("oem = %p", oem); + + g_signal_connect (oem, + "handle-send-oem-data", + G_CALLBACK (on_send_oem_data), + ctx); + + g_signal_connect (oem, + "handle-send-oem-data-with-response", + G_CALLBACK (on_send_oem_data_with_response), + ctx); + + return TRUE; +} + +gboolean dbus_plugin_oem_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data) +{ + _emit_oem_response(dbus_info, GET_OEM_ID(command), data, data_len); + return TRUE; +} + +gboolean dbus_plugin_oem_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data) +{ + _emit_oem_notification(telephony_object_peek_oem(TELEPHONY_OBJECT(object)), GET_OEM_ID(command), data, data_len); + return TRUE; +} + diff --git a/src/phonebook.c b/src/phonebook.c new file mode 100755 index 0000000..30bd631 --- /dev/null +++ b/src/phonebook.c @@ -0,0 +1,696 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" +#include "sat_manager.h" + +static const char* dbg_dbus_pb_type_name[] = {"PB_TYPE_FDN", "PB_TYPE_ADN", "PB_TYPE_SDN", + "PB_TYPE_USIM", "PB_TYPE_AAS", "PB_TYPE_GAS", }; +static const char* dbg_dbus_pb_adf_field_name[] = { "NO VALUE 0", "PB_FIELD_NAME", "PB_FIELD_NUMBER", + "PB_FIELD_ANR1", "PB_FIELD_ANR2", "PB_FIELD_ANR3", "PB_FIELD_EMAIL1", + "PB_FIELD_EMAIL2", "PB_FIELD_EMAIL3", "PB_FIELD_EMAIL4", "PB_FIELD_SNE", + "PB_FIELD_GRP", "PB_FIELD_PBC" }; +static const char* dbg_dbus_pb_ton_name[] = { "PB_TON_UNKNOWN", "PB_TON_INTERNATIONAL", + "PB_TON_NATIONAL", "PB_TON_NETWORK_SPECIFIC", "PB_TON_DEDICATED_ACCESS", + "PB_TON_ALPHA_NUMERIC", "PB_TON_ABBREVIATED_NUMBER", + "PB_TON_RESERVED_FOR_EXT", }; + +static gboolean on_phonebook_get_init_status(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + gboolean pb_status = FALSE; + struct tel_phonebook_support_list *list = NULL; + GSList *co_list = NULL; + CoreObject *co_pb = NULL; + TcorePlugin *plugin = NULL; + + if (!check_access_control (invocation, AC_PHONEBOOK, "r")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK); + if (!co_list) { + dbg("error- co_list is NULL"); + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + co_pb = (CoreObject *)co_list->data; + g_slist_free(co_list); + + if (!co_pb) { + dbg("error- co_pb is NULL"); + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + + pb_status = tcore_phonebook_get_status(co_pb); + list = tcore_phonebook_get_support_list(co_pb); + + dbg("fdn[%d],adn[%d],sdn[%d],usim[%d],aas[%d],gas[%d]" + ,list->b_fdn,list->b_adn,list->b_sdn,list->b_usim,list->b_aas,list->b_gas); + + telephony_phonebook_complete_get_init_status(phonebook, invocation, + pb_status, + list->b_fdn, + list->b_adn, + list->b_sdn, + list->b_usim, + list->b_aas, + list->b_gas); + + g_free(list); + + return TRUE; +} + +static gboolean on_phonebook_get_count(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, gint arg_req_type, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_phonebook_get_count pb_count; + TcorePlugin *plugin = NULL; + GSList *co_list = NULL; + CoreObject *co_pb = NULL; + gboolean pb_status = FALSE; + + if (!check_access_control (invocation, AC_PHONEBOOK, "r")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK); + if (!co_list) { + dbg("error- co_list is NULL"); + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + co_pb = (CoreObject *)co_list->data; + g_slist_free(co_list); + + pb_status = tcore_phonebook_get_status(co_pb); + + if(pb_status == FALSE) { + dbg("pb_init is not completed yet."); + telephony_phonebook_complete_get_count(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED, 0, 0, 0); + return TRUE; + } + + ur = MAKE_UR(ctx, phonebook, invocation); + memset(&pb_count, 0, sizeof(struct treq_phonebook_get_count)); + + pb_count.phonebook_type = arg_req_type; + dbg("req phonebook_type[%d][%s]", pb_count.phonebook_type, dbg_dbus_pb_type_name[pb_count.phonebook_type]); + tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_get_count), &pb_count); + tcore_user_request_set_command(ur, TREQ_PHONEBOOK_GETCOUNT); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + return TRUE; +} + +static gboolean on_phonebook_get_info(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, gint arg_req_type, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_phonebook_get_info pb_info; + TcorePlugin *plugin = NULL; + GSList *co_list = NULL; + CoreObject *co_pb = NULL; + gboolean pb_status = FALSE; + + if (!check_access_control (invocation, AC_PHONEBOOK, "r")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK); + if (!co_list) { + dbg("error- co_list is NULL"); + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + co_pb = (CoreObject *)co_list->data; + g_slist_free(co_list); + + pb_status = tcore_phonebook_get_status(co_pb); + + if(pb_status == FALSE) { + dbg("pb_init is not completed yet."); + telephony_phonebook_complete_get_info(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED, 0, 0, 0, 0, 0, 0); + return TRUE; + } + + ur = MAKE_UR(ctx, phonebook, invocation); + memset(&pb_info, 0, sizeof(struct treq_phonebook_get_info)); + + pb_info.phonebook_type = arg_req_type; + dbg("req phonebook_type[%d][%s]", pb_info.phonebook_type, dbg_dbus_pb_type_name[pb_info.phonebook_type]); + tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_get_info), &pb_info); + tcore_user_request_set_command(ur, TREQ_PHONEBOOK_GETMETAINFO); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_phonebook_get_usim_info(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + TcorePlugin *plugin = NULL; + GSList *co_list = NULL; + CoreObject *co_pb = NULL; + gboolean pb_status = FALSE; + + if (!check_access_control (invocation, AC_PHONEBOOK, "r")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK); + if (!co_list) { + dbg("error- co_list is NULL"); + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + co_pb = (CoreObject *)co_list->data; + g_slist_free(co_list); + + pb_status = tcore_phonebook_get_status(co_pb); + + if(pb_status == FALSE) { + GVariant *gv = NULL; + GVariantBuilder b; + dbg("pb_init is not completed yet."); + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + gv = g_variant_builder_end(&b); + telephony_phonebook_complete_get_usim_meta_info (phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED, gv); + return TRUE; + } + + ur = MAKE_UR(ctx, phonebook, invocation); + tcore_user_request_set_data(ur, 0, NULL); + tcore_user_request_set_command(ur, TREQ_PHONEBOOK_GETUSIMINFO); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + return TRUE; +} + +static gboolean on_phonebook_read_record(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, + gint arg_req_type, gint arg_index, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_phonebook_read_record pb_read; + TcorePlugin *plugin = NULL; + GSList *co_list = NULL; + CoreObject *co_pb = NULL; + gboolean pb_status = FALSE; + + if (!check_access_control (invocation, AC_PHONEBOOK, "r")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK); + if (!co_list) { + dbg("error- co_list is NULL"); + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + co_pb = (CoreObject *)co_list->data; + g_slist_free(co_list); + + pb_status = tcore_phonebook_get_status(co_pb); + + if(pb_status == FALSE) { + dbg("pb_init is not completed yet."); + telephony_phonebook_complete_read_record(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED, + 0, 0, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 0); + return TRUE; + } + + ur = MAKE_UR(ctx, phonebook, invocation); + memset(&pb_read, 0, sizeof(struct treq_phonebook_read_record)); + + pb_read.index = (unsigned short)arg_index; + pb_read.phonebook_type = arg_req_type; + dbg("req phonebook_type[%d][%s] index[%d]", + pb_read.phonebook_type, dbg_dbus_pb_type_name[pb_read.phonebook_type], pb_read.index); + + tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_read_record), &pb_read); + tcore_user_request_set_command(ur, TREQ_PHONEBOOK_READRECORD); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + return TRUE; +} + +static gboolean on_phonebook_update_record(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, + gint arg_type, gint arg_index, const gchar *arg_name, gint arg_dcs, + const gchar *arg_number, gint arg_ton, + const gchar *arg_sne, gint arg_sne_dcs, + const gchar *arg_number2, gint arg_number2_ton, + const gchar *arg_number3,gint arg_number3_ton, const gchar *arg_number4, gint arg_number4_ton, + const gchar *arg_email1, const gchar *arg_email2, const gchar *arg_email3, const gchar *arg_email4, + gint arg_group_index, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_phonebook_update_record pb_update; + TcorePlugin *plugin = NULL; + GSList *co_list = NULL; + CoreObject *co_pb = NULL; + gboolean pb_status = FALSE; + int temp_len = 0; + + if (!check_access_control (invocation, AC_PHONEBOOK, "x")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK); + if (!co_list) { + dbg("error- co_list is NULL"); + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + co_pb = (CoreObject *)co_list->data; + g_slist_free(co_list); + + pb_status = tcore_phonebook_get_status(co_pb); + + if(pb_status == FALSE) { + dbg("pb_init is not completed yet."); + telephony_phonebook_complete_update_record(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED); + return TRUE; + } + + memset(&pb_update, 0, sizeof(struct treq_phonebook_update_record)); + + dbg("pb_type[%d] index[%d] name[%s] number[%s] email[%s]", + arg_type,arg_index,arg_name, arg_number, arg_email1); + + pb_update.index = (unsigned short)arg_index; + pb_update.phonebook_type = arg_type; + + if(arg_name != NULL && strlen(arg_name)){ + pb_update.dcs = PB_TEXT_ASCII; + pb_update.name_len = strlen(arg_name); + if(pb_update.name_len > PHONEBOOK_NAME_BYTE_MAX) + pb_update.name_len = PHONEBOOK_NAME_BYTE_MAX; + memcpy(pb_update.name, arg_name, pb_update.name_len); + } + if(arg_sne != NULL && strlen(arg_sne)){ + pb_update.sne_dcs = PB_TEXT_ASCII; + pb_update.sne_len = strlen(arg_sne); + if(pb_update.sne_len > PHONEBOOK_NAME_BYTE_MAX) + pb_update.sne_len = PHONEBOOK_NAME_BYTE_MAX; + memcpy(pb_update.sne, arg_sne, pb_update.sne_len); + } + if(arg_number != NULL && (temp_len=strlen(arg_number))){ + pb_update.ton = arg_ton; + if(temp_len > PHONEBOOK_NUMBER_BYTE_MAX) + temp_len = PHONEBOOK_NUMBER_BYTE_MAX; + memcpy(pb_update.number, arg_number, temp_len); + } + if(arg_number2 != NULL && (temp_len=strlen(arg_number2))){ + pb_update.anr1_ton = arg_number2_ton; + if(temp_len > PHONEBOOK_NUMBER_BYTE_MAX) + temp_len = PHONEBOOK_NUMBER_BYTE_MAX; + memcpy(pb_update.anr1, arg_number2, temp_len); + } + + if(arg_number3 != NULL && (temp_len=strlen(arg_number3))){ + pb_update.anr2_ton = arg_number3_ton; + if(temp_len > PHONEBOOK_NUMBER_BYTE_MAX) + temp_len = PHONEBOOK_NUMBER_BYTE_MAX; + memcpy(pb_update.anr2, arg_number3, temp_len); + } + + if(arg_number4 != NULL && (temp_len=strlen(arg_number4))){ + pb_update.anr3_ton = arg_number4_ton; + if(temp_len > PHONEBOOK_NUMBER_BYTE_MAX) + temp_len = PHONEBOOK_NUMBER_BYTE_MAX; + memcpy(pb_update.anr3, arg_number4, temp_len); + } + + if(arg_email1 != NULL && strlen(arg_email1)){ + pb_update.email1_len = strlen(arg_email1); + if(pb_update.email1_len > PHONEBOOK_EMAIL_BYTE_MAX) + pb_update.email1_len = PHONEBOOK_EMAIL_BYTE_MAX; + memcpy(pb_update.email1, arg_email1, pb_update.email1_len); + } + /* Additional e-mail fields (email 2,3,4) cannot be used to CP*/ + + pb_update.group_index = (unsigned short)arg_group_index; + + ur = MAKE_UR(ctx, phonebook, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_update_record), &pb_update); + tcore_user_request_set_command(ur, TREQ_PHONEBOOK_UPDATERECORD); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_phonebook_delete_record(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, + gint arg_type, gint arg_index, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_phonebook_delete_record pb_delete; + TcorePlugin *plugin = NULL; + GSList *co_list = NULL; + CoreObject *co_pb = NULL; + gboolean pb_status = FALSE; + + if (!check_access_control (invocation, AC_PHONEBOOK, "x")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK); + if (!co_list) { + dbg("error- co_list is NULL"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + co_pb = (CoreObject *)co_list->data; + g_slist_free(co_list); + + pb_status = tcore_phonebook_get_status(co_pb); + + if(pb_status == FALSE) { + dbg("pb_init is not completed yet."); + telephony_phonebook_complete_delete_record(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED); + return TRUE; + } + + ur = MAKE_UR(ctx, phonebook, invocation); + memset(&pb_delete, 0, sizeof(struct treq_phonebook_delete_record)); + + pb_delete.index = (unsigned short)arg_index; + pb_delete.phonebook_type = arg_type; + dbg("req phonebook_type[%d][%s] index[%d]", + pb_delete.phonebook_type, dbg_dbus_pb_type_name[pb_delete.phonebook_type], pb_delete.index); + + tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_delete_record), &pb_delete); + tcore_user_request_set_command(ur, TREQ_PHONEBOOK_DELETERECORD); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +gboolean dbus_plugin_setup_phonebook_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonyPhonebook *phonebook; + + phonebook = telephony_phonebook_skeleton_new(); + telephony_object_skeleton_set_phonebook(object, phonebook); + g_object_unref(phonebook); + + dbg("phonebook = %p", phonebook); + + g_signal_connect (phonebook, + "handle-get-init-status", + G_CALLBACK (on_phonebook_get_init_status), + ctx); + + g_signal_connect (phonebook, + "handle-get-count", + G_CALLBACK (on_phonebook_get_count), + ctx); + + g_signal_connect (phonebook, + "handle-get-info", + G_CALLBACK (on_phonebook_get_info), + ctx); + + g_signal_connect (phonebook, + "handle-get-usim-meta-info", + G_CALLBACK (on_phonebook_get_usim_info), + ctx); + + g_signal_connect (phonebook, + "handle-read-record", + G_CALLBACK (on_phonebook_read_record), + ctx); + + g_signal_connect (phonebook, + "handle-update-record", + G_CALLBACK (on_phonebook_update_record), + ctx); + + g_signal_connect (phonebook, + "handle-delete-record", + G_CALLBACK (on_phonebook_delete_record), + ctx); + + return TRUE; +} + +gboolean dbus_plugin_phonebook_response(struct custom_data *ctx, UserRequest *ur, + struct dbus_request_info *dbus_info, enum tcore_response_command command, + unsigned int data_len, const void *data) +{ + const struct tresp_phonebook_get_count *resp_pbcnt = data; + const struct tresp_phonebook_get_info *resp_entry = data; + const struct tresp_phonebook_get_usim_info *resp_capa = data; + const struct tresp_phonebook_read_record *resp_pbread = data; + const struct tresp_phonebook_update_record *resp_pbupdate = data; + const struct tresp_phonebook_delete_record *resp_pbdelete = data; + + switch (command) { + case TRESP_PHONEBOOK_GETCOUNT: + dbg("GETCOUNT (type[%d][%s] used[%d]total[%d])", + resp_pbcnt->type, dbg_dbus_pb_type_name[resp_pbcnt->type], + resp_pbcnt->used_count, resp_pbcnt->total_count); + telephony_phonebook_complete_get_count(dbus_info->interface_object, dbus_info->invocation, + resp_pbcnt->result, resp_pbcnt->type, resp_pbcnt->used_count, resp_pbcnt->total_count); + break; + + case TRESP_PHONEBOOK_GETMETAINFO: + dbg("GETMETAINFO (type[%d][%s])", resp_entry->type, dbg_dbus_pb_type_name[resp_entry->type]); + dbg("index(min[%d]max[%d]), num_max[%d] text(max[%d]used[%d])", + resp_entry->index_min, resp_entry->index_max, resp_entry->number_length_max, resp_entry->text_length_max, resp_entry->used_count); + telephony_phonebook_complete_get_info(dbus_info->interface_object, dbus_info->invocation, + resp_entry->result, resp_entry->type, resp_entry->index_min, resp_entry->index_max, + resp_entry->number_length_max, resp_entry->text_length_max, resp_entry->used_count); + break; + + case TRESP_PHONEBOOK_GETUSIMINFO:{ + GVariant *gv = NULL; + GVariantBuilder b; + int i; + dbg("GETUSIMINFO"); + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for(i=0;i < resp_capa->field_count; i++){ + g_variant_builder_open(&b,G_VARIANT_TYPE("a{sv}")); + dbg("type[%d][%s] index_max[%d] text_max[%d] used_count[%d]", + resp_capa->field_list[i].field, + dbg_dbus_pb_adf_field_name[resp_capa->field_list[i].field], + resp_capa->field_list[i].index_max, + resp_capa->field_list[i].text_max, + resp_capa->field_list[i].used_count); + g_variant_builder_add(&b, "{sv}", "field_type", g_variant_new_int32(resp_capa->field_list[i].field)); + g_variant_builder_add(&b, "{sv}", "index_max", g_variant_new_int32(resp_capa->field_list[i].index_max)); + g_variant_builder_add(&b, "{sv}", "text_max", g_variant_new_int32(resp_capa->field_list[i].text_max)); + g_variant_builder_add(&b, "{sv}", "used_count", g_variant_new_int32(resp_capa->field_list[i].used_count)); + g_variant_builder_close(&b); + } + gv = g_variant_builder_end(&b); + + telephony_phonebook_complete_get_usim_meta_info (dbus_info->interface_object, dbus_info->invocation, + resp_capa->result, + gv); + } + break; + + case TRESP_PHONEBOOK_READRECORD: { + unsigned char dest_pb_name[PHONEBOOK_NAME_BYTE_MAX + 1]; + unsigned char dest_pb_sne[PHONEBOOK_NAME_BYTE_MAX + 1]; + unsigned char dest_pb_email1[PHONEBOOK_EMAIL_BYTE_MAX + 1]; + memset(dest_pb_name, 0x00, PHONEBOOK_NAME_BYTE_MAX + 1); + memset(dest_pb_sne, 0x00, PHONEBOOK_NAME_BYTE_MAX + 1); + memset(dest_pb_email1, 0x00, PHONEBOOK_EMAIL_BYTE_MAX + 1); + /* Additional e-mail fields (email 2,3,4) cannot be used to CP*/ + + dbg("READRECORD (type[%d][%s] index[%d][%d])", + resp_pbread->phonebook_type, dbg_dbus_pb_type_name[resp_pbread->phonebook_type], resp_pbread->index,resp_pbread->next_index); + + if (resp_pbread->name_len > 0) { + dbg("name:[%s] len:[%d]",resp_pbread->name, resp_pbread->name_len); + memcpy(dest_pb_name,resp_pbread->name,resp_pbread->name_len); + } + + dbg("number:[%s] ton:[%d][%s])", + resp_pbread->number,resp_pbread->ton, dbg_dbus_pb_ton_name[resp_pbread->ton] ); + + if(resp_pbread->phonebook_type == PB_TYPE_USIM) { + if (resp_pbread->sne_len > 0) { + dbg("sne:[%s] sne_len:[%d]", resp_pbread->sne,resp_pbread->sne_len); + memcpy(dest_pb_sne,resp_pbread->sne,resp_pbread->sne_len); + } + + if (strlen((const char*)resp_pbread->anr1) != 0 || strlen((const char*)resp_pbread->anr2) != 0 || strlen((const char*)resp_pbread->anr3) != 0) { + dbg("anr1:([%s],ton[%d][%s])",resp_pbread->anr1,resp_pbread->anr1_ton, dbg_dbus_pb_ton_name[resp_pbread->anr1_ton]); + dbg("anr2:([%s],ton[%d][%s])",resp_pbread->anr2,resp_pbread->anr2_ton, dbg_dbus_pb_ton_name[resp_pbread->anr2_ton]); + dbg("anr3:([%s],ton[%d][%s])",resp_pbread->anr3,resp_pbread->anr3_ton, dbg_dbus_pb_ton_name[resp_pbread->anr3_ton]); + } + if (resp_pbread->email1_len > 0) { + dbg("email1:[%s] len:[%d]",resp_pbread->email1, resp_pbread->email1_len); + memcpy(dest_pb_email1, resp_pbread->email1, resp_pbread->email1_len); + } + /* Additional e-mail fields (email 2,3,4) cannot be used to CP*/ + } + + /* + * Check whether NAME, SNE string values are invalid utf-8 string or not, + * because if invalid it will be converted to "[INVALID UTF-8]" automatically by g_variant_new_string(). + */ + if (g_utf8_validate((const gchar *)dest_pb_name, -1, NULL) == FALSE) { + tcore_util_hex_dump("[INVALID_UTF8_NAME] ", strlen((const char*)dest_pb_name), dest_pb_name); + dbg("Empty NAME field."); + memset(dest_pb_name, 0x00, PHONEBOOK_NAME_BYTE_MAX + 1); + } + if(resp_pbread->phonebook_type == PB_TYPE_USIM) { + if (g_utf8_validate((const gchar *)dest_pb_sne, -1, NULL) == FALSE) { + tcore_util_hex_dump("[INVALID_UTF8_SNE] ", strlen((const char*)dest_pb_sne), dest_pb_sne); + dbg("Empty SNE field."); + memset(dest_pb_sne, 0x00, PHONEBOOK_NAME_BYTE_MAX + 1); + } + } + + telephony_phonebook_complete_read_record(dbus_info->interface_object, dbus_info->invocation, + resp_pbread->result, resp_pbread->phonebook_type, resp_pbread->index, resp_pbread->next_index, + (const gchar *)dest_pb_name, resp_pbread->dcs, + (const gchar *)resp_pbread->number, resp_pbread->ton, + (const gchar *)dest_pb_sne, resp_pbread->sne_dcs, + (const gchar *)resp_pbread->anr1, resp_pbread->anr1_ton, + (const gchar *)resp_pbread->anr2, resp_pbread->anr2_ton, + (const gchar *)resp_pbread->anr3, resp_pbread->anr3_ton, + (const gchar *)dest_pb_email1, + (const gchar *)resp_pbread->email2, + (const gchar *)resp_pbread->email3, + (const gchar *)resp_pbread->email4, + resp_pbread->group_index); + + } break; + + case TRESP_PHONEBOOK_UPDATERECORD: + dbg("UPDATERECORD (result[%d])", resp_pbupdate->result); + telephony_phonebook_complete_update_record(dbus_info->interface_object, dbus_info->invocation,resp_pbupdate->result); + break; + + case TRESP_PHONEBOOK_DELETERECORD: + dbg("DELETERECORD (result[%d])", resp_pbdelete->result); + telephony_phonebook_complete_delete_record(dbus_info->interface_object, dbus_info->invocation, resp_pbdelete->result); + break; + + default: + dbg("not handled cmd[0x%x]", command); + break; + } + + return TRUE; +} + +gboolean dbus_plugin_phonebook_notification(struct custom_data *ctx, CoreObject *source, + TelephonyObjectSkeleton *object, enum tcore_notification_command command, + unsigned int data_len, const void *data) +{ + TelephonyPhonebook *phonebook; + const struct tnoti_phonebook_status *n_pb_status = data; + const char *cp_name; + + cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source)); + + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, cp_name); + + phonebook = telephony_object_peek_phonebook(TELEPHONY_OBJECT(object)); + switch (command) { + case TNOTI_PHONEBOOK_STATUS : + +#ifdef ENABLE_KPI_LOGS + if (n_pb_status->b_init == TRUE) + TIME_CHECK("[%s] PBM Service Ready", cp_name); +#endif + + telephony_phonebook_emit_status(phonebook, + n_pb_status->b_init, + n_pb_status->support_list.b_fdn, + n_pb_status->support_list.b_adn, + n_pb_status->support_list.b_sdn, + n_pb_status->support_list.b_usim, + n_pb_status->support_list.b_aas, + n_pb_status->support_list.b_gas); + + break; + + default: + dbg("not handled cmd[0x%x]", command); + break; + } + + return TRUE; +} diff --git a/src/sap.c b/src/sap.c new file mode 100644 index 0000000..11a86f6 --- /dev/null +++ b/src/sap.c @@ -0,0 +1,445 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + +static gboolean on_sap_connect(TelephonySap *sap, GDBusMethodInvocation *invocation, + gint arg_req_max_size, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_sap_req_connect req_conn; + + if (!check_access_control (invocation, AC_SAP, "x")) + return TRUE; + + ur = MAKE_UR(ctx, sap, invocation); + memset(&req_conn, 0, sizeof(struct treq_sap_req_connect)); + + req_conn.max_msg_size = (unsigned short)arg_req_max_size; + + tcore_user_request_set_data(ur, sizeof(struct treq_sap_req_connect), &req_conn); + tcore_user_request_set_command(ur, TREQ_SAP_REQ_CONNECT); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sap_disconnect(TelephonySap *sap, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_SAP, "x")) + return TRUE; + + ur = MAKE_UR(ctx, sap, invocation); + + tcore_user_request_set_command(ur, TREQ_SAP_REQ_DISCONNECT); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sap_get_status(TelephonySap *sap, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_SAP, "r")) + return TRUE; + + ur = MAKE_UR(ctx, sap, invocation); + + tcore_user_request_set_command(ur, TREQ_SAP_REQ_STATUS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sap_get_atr(TelephonySap *sap, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_SAP, "r")) + return TRUE; + + ur = MAKE_UR(ctx, sap, invocation); + + tcore_user_request_set_command(ur, TREQ_SAP_REQ_ATR); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sap_transfer_apdu(TelephonySap *sap, GDBusMethodInvocation *invocation, + GVariant *arg_req_apdu, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + struct treq_sap_transfer_apdu t_apdu; + TReturn ret; + GVariantIter *iter = NULL; + GVariant *inner_gv = NULL; + guchar rt_i; + int i =0; + + dbg("Func Entrance"); + + if (!check_access_control (invocation, AC_SAP, "x")) + return TRUE; + + memset(&t_apdu, 0, sizeof(struct treq_sap_transfer_apdu)); + + inner_gv = g_variant_get_variant(arg_req_apdu); + + g_variant_get(inner_gv, "ay", &iter); + while ( g_variant_iter_loop (iter, "y", &rt_i)) { + t_apdu.apdu_data[i] = rt_i; + i++; + } + t_apdu.apdu_length = (unsigned int)i; + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + g_variant_unref(arg_req_apdu); + + for(i=0; i < (int)t_apdu.apdu_length; i++) + dbg("apdu[%d][0x%02x]",i, t_apdu.apdu_data[i]); + + ur = MAKE_UR(ctx, sap, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sap_transfer_apdu), &t_apdu); + tcore_user_request_set_command(ur, TREQ_SAP_TRANSFER_APDU); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sap_set_protocol(TelephonySap *sap, GDBusMethodInvocation *invocation, + gint arg_protocol, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_sap_set_protocol set_protocol; + + if (!check_access_control (invocation, AC_SAP, "w")) + return TRUE; + + ur = MAKE_UR(ctx, sap, invocation); + memset(&set_protocol, 0, sizeof(struct treq_sap_set_protocol)); + + set_protocol.protocol = arg_protocol; + + tcore_user_request_set_data(ur, sizeof(struct treq_sap_set_protocol), &set_protocol); + tcore_user_request_set_command(ur, TREQ_SAP_SET_PROTOCOL); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sap_set_power(TelephonySap *sap, GDBusMethodInvocation *invocation, + gint arg_mode, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_sap_set_power set_power; + + if (!check_access_control (invocation, AC_SAP, "w")) + return TRUE; + + ur = MAKE_UR(ctx, sap, invocation); + memset(&set_power, 0, sizeof(struct treq_sap_set_power)); + + set_power.mode = arg_mode; + + tcore_user_request_set_data(ur, sizeof(struct treq_sap_set_power), &set_power); + tcore_user_request_set_command(ur, TREQ_SAP_SET_POWER); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sap_get_card_reader_status(TelephonySap *sap, GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + + if (!check_access_control (invocation, AC_SAP, "r")) + return TRUE; + + ur = MAKE_UR(ctx, sap, invocation); + + tcore_user_request_set_command(ur, TREQ_SAP_REQ_CARDREADERSTATUS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if(ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +gboolean dbus_plugin_setup_sap_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonySap *sap; + + sap = telephony_sap_skeleton_new(); + telephony_object_skeleton_set_sap(object, sap); + g_object_unref(sap); + + dbg("sap = %p", sap); + + g_signal_connect (sap, + "handle-connect", + G_CALLBACK (on_sap_connect), + ctx); + + g_signal_connect (sap, + "handle-disconnect", + G_CALLBACK (on_sap_disconnect), + ctx); + + g_signal_connect (sap, + "handle-get-status", + G_CALLBACK (on_sap_get_status), + ctx); + + g_signal_connect (sap, + "handle-get-atr", + G_CALLBACK (on_sap_get_atr), + ctx); + + g_signal_connect (sap, + "handle-transfer-apdu", + G_CALLBACK (on_sap_transfer_apdu), + ctx); + + g_signal_connect (sap, + "handle-set-protocol", + G_CALLBACK (on_sap_set_protocol), + ctx); + + g_signal_connect (sap, + "handle-set-power", + G_CALLBACK (on_sap_set_power), + ctx); + + g_signal_connect (sap, + "handle-get-card-reader-status", + G_CALLBACK (on_sap_get_card_reader_status), + ctx); + + return TRUE; +} + +gboolean dbus_plugin_sap_response(struct custom_data *ctx, UserRequest *ur, + struct dbus_request_info *dbus_info, enum tcore_response_command command, + unsigned int data_len, const void *data) +{ + const struct tresp_sap_req_connect *sap_conn = data; + const struct tresp_sap_req_disconnect *sap_disconn = data; + const struct tresp_sap_req_status *sap_status = data; + const struct tresp_sap_req_atr *sap_atr = data; + const struct tresp_sap_transfer_apdu *sap_apdu = data; + const struct tresp_sap_set_protocol *sap_protocol = data; + const struct tresp_sap_set_power *sap_power = data; + const struct tresp_sap_req_cardreaderstatus *sap_reader = data; + + dbg("application Command = [0x%x], data_len = %d",command, data_len); + + switch (command) { + case TRESP_SAP_REQ_CONNECT: + dbg("dbus comm - TRESP_SAP_REQ_CONNECT"); + telephony_sap_complete_connect(dbus_info->interface_object, dbus_info->invocation, + sap_conn->status, sap_conn->max_msg_size); + break; + + case TRESP_SAP_REQ_DISCONNECT: + dbg("dbus comm - TRESP_SAP_REQ_DISCONNECT"); + telephony_sap_complete_disconnect(dbus_info->interface_object, dbus_info->invocation, + sap_disconn->result); + break; + + case TRESP_SAP_REQ_STATUS: + dbg("dbus comm - TRESP_SAP_REQ_STATUS"); + telephony_sap_complete_get_status(dbus_info->interface_object, dbus_info->invocation, + sap_status->status); + break; + + case TRESP_SAP_REQ_ATR: { + GVariantBuilder builder; + GVariant * atr_gv = NULL; + GVariant *inner_gv = NULL; + int i =0; + + dbg("dbus comm - TRESP_SAP_REQ_ATR"); + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay")); + for(i = 0; i < (int)sap_atr->atr_length; i++) { + dbg("sap_atr->atr[%d][0x%02x]", i,sap_atr->atr[i]); + g_variant_builder_add (&builder, "y", sap_atr->atr[i]); + } + inner_gv = g_variant_builder_end(&builder); + atr_gv = g_variant_new("v", inner_gv); + + telephony_sap_complete_get_atr(dbus_info->interface_object, dbus_info->invocation, + sap_atr->result, atr_gv); + } + break; + + case TRESP_SAP_TRANSFER_APDU: { + GVariantBuilder builder; + GVariant * apdu_gv = NULL; + GVariant *inner_gv = NULL; + int i =0; + + dbg("dbus comm - TRESP_SAP_TRANSFER_APDU"); + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay")); + for(i = 0; i < (int)sap_apdu->resp_apdu_length; i++) { + dbg("sap_apdu->resp_adpdu[%d][0x%02x]", i,sap_apdu->resp_adpdu[i]); + g_variant_builder_add (&builder, "y", sap_apdu->resp_adpdu[i]); + } + inner_gv = g_variant_builder_end(&builder); + apdu_gv = g_variant_new("v", inner_gv); + + telephony_sap_complete_transfer_apdu(dbus_info->interface_object, dbus_info->invocation, + sap_apdu->result, apdu_gv); + } + break; + + case TRESP_SAP_SET_PROTOCOL: + dbg("dbus comm - TRESP_SAP_SET_PROTOCOL"); + telephony_sap_complete_set_protocol(dbus_info->interface_object, dbus_info->invocation, + sap_protocol->result); + break; + + case TRESP_SAP_SET_POWER: + dbg("dbus comm - TRESP_SAP_SET_POWER"); + telephony_sap_complete_set_power(dbus_info->interface_object, dbus_info->invocation, + sap_power->result); + break; + + case TRESP_SAP_REQ_CARDREADERSTATUS: + dbg("dbus comm - TRESP_SAP_REQ_CARDREADERSTATUS"); + telephony_sap_complete_get_card_reader_status(dbus_info->interface_object, dbus_info->invocation, + sap_reader->result, sap_reader->reader_status); + break; + + default: + dbg("not handled command[%d]", command); + break; + } + + return TRUE; +} + +gboolean dbus_plugin_sap_notification(struct custom_data *ctx, CoreObject *source, + TelephonyObjectSkeleton *object, enum tcore_notification_command command, + unsigned int data_len, const void *data) +{ + TelephonySap *sap; + const struct tnoti_sap_status_changed *n_sap_status = data; + const struct tnoti_sap_disconnect *n_sap_disconn = data; + + if (!object) { + dbg("object is NULL"); + return FALSE; + } + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source))); + + sap = telephony_object_peek_sap(TELEPHONY_OBJECT(object)); + + switch (command) { + case TNOTI_SAP_STATUS: + dbg("notified sap_status[%d]", n_sap_status->status); + telephony_sap_emit_status(sap, n_sap_status->status); + break; + case TNOTI_SAP_DISCONNECT: + dbg("notified sap_disconnect type[%d]", n_sap_disconn->type); + telephony_sap_emit_disconnect(sap, n_sap_disconn->type); + break; + default: + dbg("not handled command[%d]", command); + break; + } + + return TRUE; +} diff --git a/src/sat.c b/src/sat.c new file mode 100755 index 0000000..d0d51be --- /dev/null +++ b/src/sat.c @@ -0,0 +1,1563 @@ +/* + * tel-plugin-dbus + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" +#include "sat_manager.h" +#include "sat_ui_support/sat_ui_support.h" +#include "package-manager.h" + +static void _sat_set_main_menu(struct custom_data *ctx, const char *cp_name, GVariant *main_menu) +{ + GSList *list = NULL; + struct cached_data *object = NULL; + + for (list = ctx->cached_data; list; list = list->next) { + object = (struct cached_data *) list->data; + if (object == NULL) + continue; + + if (g_strcmp0(object->cp_name, cp_name) == 0 ) { + /* need to free the previous main_menu */ + g_variant_unref(object->cached_sat_main_menu); + object->cached_sat_main_menu = main_menu; + return; + } + } + + /* If 'object' is NOT created, then create the object and add to the list */ + object = g_try_malloc0(sizeof(struct cached_data)); + if (NULL == object) { + err(" Malloc Failed"); + return; + } + object->cp_name = g_strdup(cp_name); + object->cached_sat_main_menu = main_menu; + + ctx->cached_data = g_slist_append(ctx->cached_data, (gpointer) object); +} + +static GVariant *_sat_get_main_menu(struct custom_data *ctx, const char *cp_name) +{ + GSList *list = NULL; + struct cached_data *object; + + /* + * List of Objects in 'ctx', + * compare cp_name with modem_name stored in 'ctx' + * if matching return main_menu of that object. + */ + for (list = ctx->cached_data; list; list = list->next) { + object = (struct cached_data *)list->data; + if (object == NULL) + continue; + + if (g_strcmp0(object->cp_name, cp_name) == 0) + return object->cached_sat_main_menu; + } + + return NULL; +} + +static gboolean on_sat_get_main_menu_info(TelephonySAT *sat, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + GVariant *main_menu = NULL; + + gchar *title; + gint result = 1, command_id, item_cnt; + gboolean b_present, b_help_info, b_updated; + GVariant *items; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariant *icon_list = NULL; +#endif + if (!check_access_control (invocation, AC_SAT, "r")) + return TRUE; + + main_menu = _sat_get_main_menu(ctx, GET_CP_NAME(invocation)); + if(!main_menu){ + dbg("no main menu"); + return FALSE; + } + + + +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(main_menu, "(ibs@vibb@v@v)", &command_id, &b_present, &title, &items, &item_cnt, + &b_help_info, &b_updated, &icon_id, &icon_list); + + telephony_sat_complete_get_main_menu_info(sat, invocation, result, command_id, b_present, title, + items, item_cnt, b_help_info, b_updated, icon_id, icon_list); +#else + g_variant_get(main_menu, "(ibs@vibb)", &command_id, &b_present, &title, &items, &item_cnt, + &b_help_info, &b_updated); + + telephony_sat_complete_get_main_menu_info(sat, invocation, result, command_id, b_present, title, + items, item_cnt, b_help_info, b_updated); +#endif + g_free(title); + + return TRUE; +} + +static gboolean on_sat_send_display_status(TelephonySAT *sat, GDBusMethodInvocation *invocation, + gint arg_command_id, gboolean arg_display_status, + gpointer user_data) +{ + TcorePlugin *plg = NULL; + char *cp_name; + struct custom_data *ctx = user_data; + gboolean result = FALSE; + gint out_param = 1; + + if (!check_access_control (invocation, AC_SAT, "x")) + return TRUE; + + cp_name = GET_CP_NAME(invocation); + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + out_param = 0; + telephony_sat_complete_send_ui_display_status(sat, invocation, out_param); + return TRUE; + } + + result = sat_manager_handle_ui_display_status(ctx, plg, arg_command_id, arg_display_status); + if(!result){ + dbg("fail to send exec result"); + } + + out_param = (result ? 1 : 0); + telephony_sat_complete_send_ui_display_status(sat, invocation, out_param); + return TRUE; +} + +static gboolean on_sat_send_user_confirm(TelephonySAT *sat, GDBusMethodInvocation *invocation, + gint arg_command_id, gint arg_command_type, gint arg_user_confirm_type, + GVariant *arg_additional_data, gpointer user_data) +{ + TcorePlugin *plg = NULL; + char *cp_name; + struct custom_data *ctx = user_data; + + gboolean result = FALSE; + gint out_param = 1; + GVariant *confirm_data = NULL; + + if (!check_access_control (invocation, AC_SAT, "x")) + return TRUE; + + cp_name = GET_CP_NAME(invocation); + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + out_param = 0; + telephony_sat_complete_send_user_confirm(sat, invocation, out_param); + return TRUE; + } + + confirm_data = g_variant_new("(iiv)", arg_command_id, arg_user_confirm_type, arg_additional_data); + + result = sat_manager_handle_user_confirm(ctx, plg, confirm_data); + if(!result){ + dbg("fail to send user confirm"); + } + + out_param = (result ? 1 : 0); + telephony_sat_complete_send_user_confirm(sat, invocation, out_param); + + return TRUE; +} + +static gboolean on_sat_send_app_exec_result(TelephonySAT *sat, GDBusMethodInvocation *invocation, + gint arg_command_id, gint arg_command_type, GVariant *arg_exec_result, + gpointer user_data) +{ + TcorePlugin *plg = NULL; + char *cp_name; + struct custom_data *ctx = user_data; + + gboolean result = FALSE; + gint out_param = 1; + + if (!check_access_control (invocation, AC_SAT, "x")) + return TRUE; + + cp_name = GET_CP_NAME(invocation); + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + out_param = 0; + telephony_sat_complete_send_app_exec_result(sat, invocation, out_param); + return TRUE; + } + + dbg("processing app exec result"); + result = sat_manager_handle_app_exec_result(ctx, plg, arg_command_id, arg_command_type, arg_exec_result); + if(!result){ + dbg("fail to send exec result"); + } + + out_param = (result ? 1 : 0); + telephony_sat_complete_send_app_exec_result(sat, invocation, out_param); + return TRUE; +} + +static gboolean on_sat_select_menu(TelephonySAT *sat, GDBusMethodInvocation *invocation, + guchar arg_item_identifier, gboolean arg_help_request, + gpointer user_data) +{ + TReturn rv; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + struct treq_sat_envelop_cmd_data envelop_data; + + if (!check_access_control (invocation, AC_SAT, "x")) + return TRUE; + + ur = MAKE_UR(ctx, sat, invocation); + memset(&envelop_data, 0, sizeof(struct treq_sat_envelop_cmd_data)); + envelop_data.sub_cmd = ENVELOP_MENU_SELECTION; + envelop_data.envelop_data.menu_select.device_identitie.src = DEVICE_ID_KEYPAD; + envelop_data.envelop_data.menu_select.device_identitie.dest = DEVICE_ID_SIM; + envelop_data.envelop_data.menu_select.item_identifier.item_identifier = arg_item_identifier; + envelop_data.envelop_data.menu_select.help_request = arg_help_request; + + tcore_user_request_set_data(ur, sizeof(struct treq_sat_envelop_cmd_data), &envelop_data); + tcore_user_request_set_command(ur, TREQ_SAT_REQ_ENVELOPE); + rv = tcore_communicator_dispatch_request(ctx->comm, ur); + if(rv != TCORE_RETURN_SUCCESS){ + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", rv); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sat_download_event(TelephonySAT *sat, GDBusMethodInvocation *invocation, + gint arg_event_download_type, gint arg_src_device,gint arg_dest_device, + GVariant *arg_download_data, gpointer user_data) +{ + gboolean b_event = FALSE; + TReturn rv; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + + struct treq_sat_envelop_cmd_data envelop_data; + + if (!check_access_control (invocation, AC_SAT, "x")) + return TRUE; + + ur = MAKE_UR(ctx, sat, invocation); + memset(&envelop_data, 0, sizeof(struct treq_sat_envelop_cmd_data)); + envelop_data.sub_cmd = ENVELOP_EVENT_DOWNLOAD; + envelop_data.envelop_data.event_download.event = arg_event_download_type; + b_event = sat_manager_handle_event_download_envelop(arg_event_download_type, arg_src_device, arg_dest_device, + &envelop_data.envelop_data.event_download, arg_download_data); + + if(!b_event){ + telephony_sat_complete_download_event(sat, invocation, -1, ENVELOPE_FAILED); + tcore_user_request_unref(ur); + return TRUE; + } + + tcore_user_request_set_data(ur, sizeof(struct treq_sat_envelop_cmd_data), &envelop_data); + tcore_user_request_set_command(ur, TREQ_SAT_REQ_ENVELOPE); + rv = tcore_communicator_dispatch_request(ctx->comm, ur); + if(rv != TCORE_RETURN_SUCCESS){ + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", rv); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +gboolean dbus_plugin_setup_sat_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonySAT *sat; + + sat = telephony_sat_skeleton_new(); + telephony_object_skeleton_set_sat(object, sat); + g_object_unref(sat); + + dbg("sat = %p", sat); + + g_signal_connect (sat, + "handle-get-main-menu-info", + G_CALLBACK (on_sat_get_main_menu_info), + ctx); + + g_signal_connect (sat, + "handle-send-ui-display-status", + G_CALLBACK (on_sat_send_display_status), + ctx); + + g_signal_connect (sat, + "handle-send-user-confirm", + G_CALLBACK (on_sat_send_user_confirm), + ctx); + + g_signal_connect (sat, + "handle-send-app-exec-result", + G_CALLBACK (on_sat_send_app_exec_result), + ctx); + + g_signal_connect (sat, + "handle-select-menu", + G_CALLBACK (on_sat_select_menu), + ctx); + + g_signal_connect (sat, + "handle-download-event", + G_CALLBACK (on_sat_download_event), + ctx); + + return TRUE; +} + +gboolean dbus_plugin_sat_response(struct custom_data *ctx, UserRequest *ur, + struct dbus_request_info *dbus_info, enum tcore_response_command command, + unsigned int data_len, const void *data) +{ + const struct tresp_sat_envelop_data *envelop_rsp = NULL; + + dbg("sat response command = [0x%x], data_len = %d", command, data_len); + + switch (command) { + case TRESP_SAT_REQ_ENVELOPE: { + envelop_rsp = (struct tresp_sat_envelop_data *)data; + + dbg("envelop sub_cmd(%d) result(%d) rsp(%d)", envelop_rsp->sub_cmd, envelop_rsp->result, envelop_rsp->envelop_resp); + + if(envelop_rsp->sub_cmd == ENVELOP_MENU_SELECTION){ + telephony_sat_complete_select_menu(dbus_info->interface_object, dbus_info->invocation, + envelop_rsp->result, envelop_rsp->envelop_resp); + } + else if(envelop_rsp->sub_cmd == ENVELOP_EVENT_DOWNLOAD){ + telephony_sat_complete_download_event(dbus_info->interface_object, dbus_info->invocation, + envelop_rsp->result, envelop_rsp->envelop_resp); + } + } break; + + case TRESP_SAT_REQ_TERMINALRESPONSE: + dbg("receive TRESP_SAT_REQ_TERMINALRESPONSE"); + break; + + default: + dbg("not handled command[%d]", command); + break; + } + return TRUE; +} + +gboolean dbus_plugin_sat_notification(struct custom_data *ctx, CoreObject *source, + TelephonyObjectSkeleton *object, enum tcore_notification_command command, + unsigned int data_len, const void *data) +{ + TelephonySAT *sat; + const char *cp_name; + enum dbus_tapi_sim_slot_id slot_id; + + if (!object || !ctx) { + dbg("NULL data is detected!!"); + return FALSE; + } + cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source)); + + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, cp_name); + + slot_id = get_sim_slot_id_by_cp_name((char *)cp_name); + dbg("slot_id: [%d]", slot_id); + + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + + //session end notification + switch (command) { + case TNOTI_SAT_SESSION_END: { + + dbg("notified sat session end evt"); + sat_manager_init_queue(ctx, cp_name); + + //sat_ui_support_terminate_sat_ui(); + telephony_sat_emit_end_proactive_session(sat, SAT_PROATV_CMD_TYPE_END_PROACTIVE_SESSION); + return TRUE; + } + break; + + //call control notification + case TNOTI_SAT_CALL_CTRL_RESULT: { + struct tnoti_sat_call_control_result_ind *cc_result_noti = NULL; + gint call_ctrl_result = 0, bc_repeat_indicator = 0, ton = 0x0F, npi=0X0F; + gchar *text = NULL, *call_num = NULL, *ss_string = NULL, *sub_addr = NULL, *ccp1 = NULL, *ccp2 = NULL; + + cc_result_noti = (struct tnoti_sat_call_control_result_ind *)data; + if (cc_result_noti == NULL) { + err("Indication data is NULL"); + return FALSE; + } + dbg("sat call control result notification"); + + call_ctrl_result = cc_result_noti->cc_result; + bc_repeat_indicator = cc_result_noti->bc_repeat_type.bc_indi_repeat_type; + + if(cc_result_noti->address.dialing_number_len > 0){ + ton = cc_result_noti->address.ton; + npi = cc_result_noti->address.npi; + if(ton == TON_INTERNATIONAL) + call_num = g_strdup_printf("+%s", cc_result_noti->address.dialing_number); + else + call_num = g_strdup(cc_result_noti->address.dialing_number); + ss_string = g_strdup(""); + } + else if(cc_result_noti->ss_string.string_len > 0){ + ton = cc_result_noti->ss_string.ton; + npi = cc_result_noti->ss_string.npi; + call_num = g_strdup(""); + ss_string = g_strdup(cc_result_noti->ss_string.ss_string); + } + + if(cc_result_noti->alpha_id.alpha_data_len > 0){ + text = g_strdup(cc_result_noti->alpha_id.alpha_data); + } + else{ + text = g_strdup(""); + } + + if(cc_result_noti->sub_address.subaddress_len > 0){ + sub_addr = g_strdup(cc_result_noti->sub_address.subaddress); + } + else{ + sub_addr = g_strdup(""); + } + + if(cc_result_noti->ccp1.data_len > 0){ + ccp1 = g_strdup(cc_result_noti->ccp1.data); + } + else{ + ccp1 = g_strdup(""); + } + + + if(cc_result_noti->ccp2.data_len > 0){ + ccp2 = g_strdup(cc_result_noti->ccp2.data); + } + else{ + ccp2 = g_strdup(""); + } + + telephony_sat_emit_call_control_result(sat, call_ctrl_result, text, ton, npi, call_num, + ss_string, sub_addr, ccp1, ccp2, bc_repeat_indicator); + + g_free(text); g_free(call_num); g_free(ss_string); g_free(sub_addr); g_free(ccp1); g_free(ccp2); + return TRUE; + } + break; + + case TNOTI_SAT_MO_SM_CTRL_RESULT: { + struct tnoti_sat_mo_sm_control_result_ind *mo_sm_result_noti = NULL; + gint call_ctrl_result = 0; + gint rp_dst_ton = 0x0F, rp_dst_npi = 0X0F, tp_dst_ton = 0x0F, tp_dst_npi = 0X0F; + gchar *text = NULL, *rp_dst_call_num = NULL, *tp_dst_call_num = NULL; + + mo_sm_result_noti = (struct tnoti_sat_mo_sm_control_result_ind *)data; + if (mo_sm_result_noti == NULL) { + err("Indication data is NULL"); + return FALSE; + } + dbg("sat mo sm control result notification"); + + call_ctrl_result = mo_sm_result_noti->cc_result; + + if(mo_sm_result_noti->rp_dst_address.dialing_number_len > 0){ + rp_dst_ton = mo_sm_result_noti->rp_dst_address.ton; + rp_dst_npi = mo_sm_result_noti->rp_dst_address.npi; + if(rp_dst_ton == TON_INTERNATIONAL) + rp_dst_call_num = g_strdup_printf("+%s", mo_sm_result_noti->rp_dst_address.dialing_number); + else + rp_dst_call_num = g_strdup(mo_sm_result_noti->rp_dst_address.dialing_number); + } else { + rp_dst_call_num = g_strdup(""); + } + + if(mo_sm_result_noti->tp_dst_address.dialing_number_len > 0){ + tp_dst_ton = mo_sm_result_noti->tp_dst_address.ton; + tp_dst_npi = mo_sm_result_noti->tp_dst_address.npi; + if(tp_dst_ton == TON_INTERNATIONAL) + tp_dst_call_num = g_strdup_printf("+%s", mo_sm_result_noti->tp_dst_address.dialing_number); + else + tp_dst_call_num = g_strdup(mo_sm_result_noti->tp_dst_address.dialing_number); + } else { + tp_dst_call_num = g_strdup(""); + } + + if(mo_sm_result_noti->alpha_id.alpha_data_len > 0){ + text = g_strdup(mo_sm_result_noti->alpha_id.alpha_data); + } + else{ + text = g_strdup(""); + } + + telephony_sat_emit_mo_sm_control_result(sat, call_ctrl_result, text, + rp_dst_ton, rp_dst_npi, rp_dst_call_num, tp_dst_ton, tp_dst_npi, tp_dst_call_num); + + g_free(text); g_free(rp_dst_call_num); g_free(tp_dst_call_num); + return TRUE; + } + break; + + //Proactive Command Notification + case TNOTI_SAT_PROACTIVE_CMD: { + struct tnoti_sat_proactive_ind *p_ind; + TcorePlugin *plg; + plg = tcore_object_ref_plugin(source); + if (plg == NULL) { + dbg("there is no valid plugin at this point"); + return FALSE; + } + + if (cp_name == NULL) { + dbg("CP name is NULL"); + return FALSE; + } + + p_ind = (struct tnoti_sat_proactive_ind *)data; + if (p_ind == NULL) { + dbg("Indication data is NULL"); + return FALSE; + } + dbg("notified sat proactive command(%d)", p_ind->cmd_type); + + switch (p_ind->cmd_type) { + case SAT_PROATV_CMD_SETUP_MENU:{ + GVariant *menu_info = NULL; + gchar *title; + gint command_id, menu_cnt; + gboolean b_present, b_helpinfo, b_updated; + GVariant *items; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariant *icon_list = NULL; +#endif + menu_info = sat_manager_caching_setup_menu_info(ctx, cp_name, + (struct tel_sat_setup_menu_tlv*)&p_ind->proactive_ind_data.setup_menu); + + dbg("menu_info type_format(%s)", g_variant_get_type_string(menu_info)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(menu_info, "(ibs@vibb@v@v)", &command_id, &b_present, &title, &items, + &menu_cnt, &b_helpinfo, &b_updated, &icon_id, &icon_list); +#else + g_variant_get(menu_info, "(ibs@vibb)", &command_id, &b_present, &title, &items, + &menu_cnt, &b_helpinfo, &b_updated); +#endif + if(!menu_cnt){ + dbg("no main menu data"); + /* No need to cache anything so make store NULL in cached_sat_main_menu */ + _sat_set_main_menu(ctx, cp_name, NULL); + g_variant_unref(menu_info); + } else { + _sat_set_main_menu(ctx, cp_name, menu_info); + } + if(b_updated) { +#if defined(TIZEN_SUPPORT_SAT_ICON) + telephony_sat_emit_setup_menu(sat, command_id, b_present, title, items, menu_cnt, + b_helpinfo, b_updated, icon_id, icon_list); +#else + telephony_sat_emit_setup_menu(sat, command_id, b_present, title, items, menu_cnt, + b_helpinfo, b_updated); +#endif + } + g_free(title); + } break; + + case SAT_PROATV_CMD_DISPLAY_TEXT:{ + GVariant *display_text = NULL; + + gint command_id, text_len, duration; + gboolean high_priority, user_rsp_required, immediately_rsp; + gchar* text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; +#endif + int ret; + + display_text = sat_manager_display_text_noti(ctx, cp_name, (struct tel_sat_display_text_tlv*) &p_ind->proactive_ind_data.display_text, p_ind->decode_err_code); + + if(!display_text){ + dbg("no display text data"); + return TRUE; + } + + dbg("display text type_format(%s)", g_variant_get_type_string(display_text)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(display_text, "(isiibbb@v)", &command_id, &text, &text_len, &duration, + &high_priority, &user_rsp_required, &immediately_rsp, &icon_id); +#else + g_variant_get(display_text, "(isiibbb)", &command_id, &text, &text_len, &duration, + &high_priority, &user_rsp_required, &immediately_rsp); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_DISPLAY_TEXT, display_text, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + +#if defined(TIZEN_SUPPORT_SAT_ICON) + telephony_sat_emit_display_text(sat, command_id, text, text_len, duration, + high_priority, user_rsp_required, immediately_rsp, icon_id); +#else + telephony_sat_emit_display_text(sat, command_id, text, text_len, duration, + high_priority, user_rsp_required, immediately_rsp); +#endif + g_free(text); + } break; + + case SAT_PROATV_CMD_SELECT_ITEM:{ + GVariant *select_menu = NULL; + + gboolean help_info ; + gchar *selected_text = NULL; + gint command_id, default_item_id, menu_cnt, text_len =0; + GVariant *menu_items; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id, *icon_list; +#endif + int ret; + + select_menu = sat_manager_select_item_noti(ctx, cp_name, (struct tel_sat_select_item_tlv*) &p_ind->proactive_ind_data.select_item); + + if(!select_menu){ + dbg("no select menu data"); + return TRUE; + } + + dbg("select menu type_format(%s)", g_variant_get_type_string(select_menu)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(select_menu, "(ibsiii@v@v@v)", &command_id, &help_info, &selected_text, + &text_len, &default_item_id, &menu_cnt, &menu_items, &icon_id, &icon_list); +#else + g_variant_get(select_menu, "(ibsiii@v)", &command_id, &help_info, &selected_text, + &text_len, &default_item_id, &menu_cnt, &menu_items); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_SELECT_ITEM, select_menu, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + +#if defined(TIZEN_SUPPORT_SAT_ICON) + telephony_sat_emit_select_item (sat, command_id, help_info, selected_text, text_len, + default_item_id, menu_cnt, menu_items, icon_id, icon_list); +#else + telephony_sat_emit_select_item (sat, command_id, help_info, selected_text, text_len, + default_item_id, menu_cnt, menu_items); +#endif + g_free(selected_text); + } break; + + case SAT_PROATV_CMD_GET_INKEY:{ + GVariant *get_inkey = NULL; + gint command_id, key_type, input_character_mode; + gint text_len, duration; + gboolean b_numeric, b_help_info; + gchar *text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + int ret; + + get_inkey = sat_manager_get_inkey_noti(ctx, cp_name, (struct tel_sat_get_inkey_tlv*) &p_ind->proactive_ind_data.get_inkey, p_ind->decode_err_code); + + if(!get_inkey){ + dbg("no get inkey data"); + return TRUE; + } + + dbg("get inkey type_format(%s)", g_variant_get_type_string(get_inkey)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(get_inkey, "(iiibbsii@v)", &command_id, &key_type, &input_character_mode, + &b_numeric,&b_help_info, &text, &text_len, &duration, &icon_id); +#else + g_variant_get(get_inkey, "(iiibbsii)", &command_id, &key_type, &input_character_mode, + &b_numeric,&b_help_info, &text, &text_len, &duration); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_GET_INKEY, get_inkey, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + +#if defined(TIZEN_SUPPORT_SAT_ICON) + telephony_sat_emit_get_inkey(sat, command_id, key_type, input_character_mode, + b_numeric, b_help_info, text, text_len, duration, icon_id); +#else + telephony_sat_emit_get_inkey(sat, command_id, key_type, input_character_mode, + b_numeric, b_help_info, text, text_len, duration); +#endif + g_free(text); + } break; + + case SAT_PROATV_CMD_GET_INPUT:{ + GVariant *get_input = NULL; + gint command_id, input_character_mode; + gint text_len, def_text_len, rsp_len_min, rsp_len_max; + gboolean b_numeric, b_help_info, b_echo_input; + gchar *text = NULL, *def_text = NULL; + int ret; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + get_input = sat_manager_get_input_noti(ctx, cp_name, (struct tel_sat_get_input_tlv*) &p_ind->proactive_ind_data.get_input, p_ind->decode_err_code); + + if(!get_input){ + dbg("no get input data"); + return TRUE; + } + + dbg("get input type_format(%s)", g_variant_get_type_string(get_input)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(get_input, "(iibbbsiiisi@v)", &command_id, &input_character_mode, &b_numeric, &b_help_info, &b_echo_input, + &text, &text_len, &rsp_len_max, &rsp_len_min, &def_text, &def_text_len, &icon_id); +#else + g_variant_get(get_input, "(iibbbsiiisi)", &command_id, &input_character_mode, &b_numeric, &b_help_info, &b_echo_input, + &text, &text_len, &rsp_len_max, &rsp_len_min, &def_text, &def_text_len); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_GET_INPUT, get_input, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + +#if defined(TIZEN_SUPPORT_SAT_ICON) + telephony_sat_emit_get_input(sat, command_id, input_character_mode, b_numeric, b_help_info, + b_echo_input, text, text_len, rsp_len_max, rsp_len_min, def_text, def_text_len, icon_id); +#else + telephony_sat_emit_get_input(sat, command_id, input_character_mode, b_numeric, b_help_info, + b_echo_input, text, text_len, rsp_len_max, rsp_len_min, def_text, def_text_len); +#endif + g_free(text); + g_free(def_text); + } break; + + case SAT_PROATV_CMD_PLAY_TONE:{ + GVariant *play_tone = NULL; + gint command_id, tone_type, duration; + gint text_len; + gchar* text = NULL; + int ret; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + play_tone = sat_manager_play_tone_noti(ctx, cp_name, (struct tel_sat_play_tone_tlv*) &p_ind->proactive_ind_data.play_tone); + + if(!play_tone){ + dbg("no play tone data"); + return TRUE; + } + + dbg("play tone type_format(%s)", g_variant_get_type_string(play_tone)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(play_tone, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &tone_type, &duration); +#else + g_variant_get(play_tone, "(isiii)", &command_id, &text, &text_len, &tone_type, &duration); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_PLAY_TONE, play_tone, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + +#if defined(TIZEN_SUPPORT_SAT_ICON) + telephony_sat_emit_play_tone(sat, command_id, text, text_len, icon_id, tone_type, duration); +#else + telephony_sat_emit_play_tone(sat, command_id, text, text_len, tone_type, duration); +#endif + g_free(text); + } break; + + case SAT_PROATV_CMD_SEND_SMS:{ + GVariant *send_sms = NULL; + + gint command_id, ton, npi, tpdu_type; + gboolean b_packing_required; + gint text_len, number_len, tpdu_data_len; + gchar* text = NULL, *dialling_number = NULL; + GVariant *tpdu_data; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + send_sms = sat_manager_send_sms_noti(ctx, cp_name, (struct tel_sat_send_sms_tlv*) &p_ind->proactive_ind_data.send_sms); + + if(!send_sms){ + dbg("no send sms data"); + return TRUE; + } + + dbg("send sms type_format(%s)", g_variant_get_type_string(send_sms)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(send_sms, "(isi@vbiisii@vi)", &command_id, &text, &text_len, &icon_id, &b_packing_required, &ton, &npi, + &dialling_number, &number_len, &tpdu_type, &tpdu_data, &tpdu_data_len); +#else + g_variant_get(send_sms, "(isibiisii@vi)", &command_id, &text, &text_len, &b_packing_required, &ton, &npi, + &dialling_number, &number_len, &tpdu_type, &tpdu_data, &tpdu_data_len); +#endif + dbg("check display text : text(%s) text len(%d)", text, text_len); + if(text_len > 1 && (g_strcmp0(text,"") != 0) ){ + GVariant *ui_info = NULL; + gboolean user_confirm = FALSE; + int ret; + dbg("text should be displayed by ui"); + dbg("send sms is pending!!!"); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + ui_info = g_variant_new("(isibv)", command_id, text, text_len, user_confirm, icon_id); +#else + ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_SEND_SMS, ui_info, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + g_free(text); + g_free(dialling_number); + return TRUE; + } +#if !defined(TIZEN_PLATFORM_USE_QCOM_QMI) + telephony_sat_emit_send_sms(sat, command_id, text, text_len, b_packing_required, + ton, npi, dialling_number, number_len, tpdu_type, tpdu_data, tpdu_data_len); +#endif + g_free(text); + g_free(dialling_number); + } break; + + case SAT_PROATV_CMD_SEND_SS:{ + GVariant *send_ss = NULL; + + gint command_id, ton, npi; + gint text_len, ss_str_len; + gchar* text = NULL, *ss_string = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + send_ss = sat_manager_send_ss_noti(ctx, cp_name, (struct tel_sat_send_ss_tlv*) &p_ind->proactive_ind_data.send_ss); + + if(!send_ss){ + dbg("no send ss data"); + return TRUE; + } + + dbg("send ss type_format(%s)", g_variant_get_type_string(send_ss)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(send_ss, "(isi@viiis)", &command_id, &text, &text_len, &icon_id, + &ton, &npi, &ss_str_len, &ss_string); +#else + g_variant_get(send_ss, "(isiiiis)", &command_id, &text, &text_len, + &ton, &npi, &ss_str_len, &ss_string); +#endif + dbg("check display text : text(%s) text len(%d)", text, text_len); + if(text_len > 1 && (g_strcmp0(text,"") != 0) ){ + GVariant *ui_info = NULL; + gboolean user_confirm = FALSE; + int ret; + dbg("text should be displayed by ui"); + dbg("send ss is pending!!!"); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + ui_info = g_variant_new("(isibv)", command_id, text, text_len, user_confirm, icon_id); +#else + ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + g_free(text); + g_free(ss_string); + return TRUE; + } +#if !defined(TIZEN_PLATFORM_USE_QCOM_QMI) + telephony_sat_emit_send_ss(sat, command_id, text, text_len, ton, npi, ss_string); + //tizen ciss + sat_ui_support_launch_ciss_application(SAT_PROATV_CMD_SEND_SS, send_ss, slot_id); +#endif + g_free(text); + g_free(ss_string); + } break; + + case SAT_PROATV_CMD_SEND_USSD:{ + GVariant *send_ussd = NULL; + + gint command_id; + gint text_len, ussd_str_len; + guchar dcs; + gchar* text = NULL, *ussd_string = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + send_ussd = sat_manager_send_ussd_noti(ctx, cp_name, (struct tel_sat_send_ussd_tlv*) &p_ind->proactive_ind_data.send_ussd); + + if(!send_ussd){ + dbg("no send ussd data"); + return TRUE; + } + + dbg("send ussd type_format(%s)", g_variant_get_type_string(send_ussd)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(send_ussd, "(isi@vyis)", &command_id, &text, &text_len, &icon_id, &dcs, &ussd_str_len, &ussd_string); +#else + g_variant_get(send_ussd, "(isiyis)", &command_id, &text, &text_len, &dcs, &ussd_str_len, &ussd_string); +#endif + dbg("check display text : text(%s) text len(%d)", text, text_len); + if(text_len > 1 && (g_strcmp0(text,"") != 0) ){ + GVariant *ui_info = NULL; + gboolean user_confirm = FALSE; + int ret; + dbg("text should be displayed by ui"); + dbg("send ussd is pending!!!"); +#if defined(TIZEN_SUPPORT_SAT_ICON) + ui_info = g_variant_new("(isibv)", command_id, text, text_len, user_confirm, icon_id); +#else + ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + g_free(text); + g_free(ussd_string); + return TRUE; + } +#if !defined(TIZEN_PLATFORM_USE_QCOM_QMI) + telephony_sat_emit_setup_ussd(sat, command_id, text, text_len, dcs, ussd_string); + //tizen ciss ui + sat_ui_support_launch_ciss_application(SAT_PROATV_CMD_SEND_USSD, send_ussd, slot_id); +#endif + g_free(text); + g_free(ussd_string); + } break; + + case SAT_PROATV_CMD_SETUP_CALL:{ + GVariant *setup_call = NULL; + + gint command_id, call_type, confirmed_text_len, text_len, duration; + gchar *confirmed_text, *text = NULL, *call_number = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + setup_call = sat_manager_setup_call_noti(ctx, cp_name, (struct tel_sat_setup_call_tlv*) &p_ind->proactive_ind_data.setup_call); + + if(!setup_call){ + dbg("no setup call data"); + return TRUE; + } + + dbg("setup call type_format(%s)", g_variant_get_type_string(setup_call)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(setup_call, "(isisi@visi)", &command_id, &confirmed_text, &confirmed_text_len, &text, &text_len, &icon_id, &call_type, &call_number, &duration); +#else + g_variant_get(setup_call, "(isisiisi)", &command_id, &confirmed_text, &confirmed_text_len, &text, &text_len, &call_type, &call_number, &duration); +#endif + dbg("check display text : text(%s) text len(%d)", confirmed_text, confirmed_text_len); + if(confirmed_text_len > 1 && (g_strcmp0(confirmed_text,"") != 0) ){ + GVariant *ui_info = NULL; + gboolean user_confirm = TRUE; + int ret; + dbg("text should be displayed by ui"); + dbg("setup call is pending!!!"); +#if defined(TIZEN_SUPPORT_SAT_ICON) + ui_info = g_variant_new("(isibv)", command_id, confirmed_text, confirmed_text_len, user_confirm, icon_id); +#else + ui_info = g_variant_new("(isib)", command_id, confirmed_text, confirmed_text_len, user_confirm); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + g_free(text); + g_free(call_number); + return TRUE; + } +#if defined(TIZEN_SUPPORT_SAT_ICON) + telephony_sat_emit_setup_call(sat, command_id, confirmed_text, confirmed_text_len,text, text_len, icon_id, call_type, call_number, duration); +#else + telephony_sat_emit_setup_call(sat, command_id, confirmed_text, confirmed_text_len,text, text_len, call_type, call_number, duration); +#endif + g_free(text); + g_free(call_number); + + //tizen call ui in no alpha id case + sat_ui_support_launch_call_application(SAT_PROATV_CMD_SETUP_CALL, setup_call, slot_id); + + }break; + + case SAT_PROATV_CMD_SETUP_EVENT_LIST:{ + GVariant *event_list = NULL; + + gint event_cnt; + GVariant *evt_list; + + event_list = sat_manager_setup_event_list_noti(ctx, cp_name, (struct tel_sat_setup_event_list_tlv*) &p_ind->proactive_ind_data.setup_event_list); + + if(!event_list){ + dbg("no setup event list data"); + return TRUE; + } + + dbg("setup event list type_format(%s)", g_variant_get_type_string(event_list)); + g_variant_get(event_list, "(i@v)", &event_cnt, &evt_list); + + telephony_sat_emit_setup_event_list(sat, event_cnt, evt_list); + + //bip proactive command is only handled by BIP Manager + { + GDBusConnection *conn = NULL; + const gchar *g_path = NULL; + + conn = g_dbus_object_manager_server_get_connection(ctx->manager); + g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); + + /* TODO: SAT Event Downloader should execute event_list as well. */ + sat_ui_support_exec_evtdw(conn, g_path, SAT_PROATV_CMD_SETUP_EVENT_LIST, event_list); + sat_ui_support_exec_bip(conn, g_path, SAT_PROATV_CMD_SETUP_EVENT_LIST, event_list); + } + } break; + + case SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT:{ + GVariant *setup_idle_mode = NULL; + int ret; + + gint command_id, text_len; + gchar* text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + setup_idle_mode = sat_manager_setup_idle_mode_text_noti(ctx, cp_name, (struct tel_sat_setup_idle_mode_text_tlv*) &p_ind->proactive_ind_data.setup_idle_mode_text, p_ind->decode_err_code); + + if(!setup_idle_mode){ + dbg("no setup idle mode text data"); + return TRUE; + } + + dbg("setup idle mode text type_format(%s)", g_variant_get_type_string(setup_idle_mode)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(setup_idle_mode, "(isi@v)", &command_id, &text, &text_len, &icon_id); +#else + g_variant_get(setup_idle_mode, "(isi)", &command_id, &text, &text_len); +#endif + + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT, setup_idle_mode, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } +#if defined(TIZEN_SUPPORT_SAT_ICON) + telephony_sat_emit_setup_idle_mode_text(sat, command_id, text, text_len, icon_id); +#else + telephony_sat_emit_setup_idle_mode_text(sat, command_id, text, text_len); +#endif + g_free(text); + } break; + + case SAT_PROATV_CMD_OPEN_CHANNEL:{ + GVariant *open_channel = NULL; + + gint command_id, bearer_type, protocol_type, dest_addr_type; + gboolean immediate_link, auto_reconnection, bg_mode; + gint text_len, buffer_size, port_number; + gchar *text = NULL, *dest_address; + GVariant *bearer_param; + GVariant *bearer_detail; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + open_channel = sat_manager_open_channel_noti(ctx, cp_name, (struct tel_sat_open_channel_tlv*) &p_ind->proactive_ind_data.open_channel); + + if(!open_channel){ + dbg("no open channel data"); + return TRUE; + } + + dbg("open channel type_format(%s)", g_variant_get_type_string(open_channel)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(open_channel,"(isi@vbbbi@viiiis@v)", &command_id, &text, &text_len, &icon_id, &immediate_link, &auto_reconnection, &bg_mode, + &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); +#else + g_variant_get(open_channel,"(isibbbi@viiiis@v)", &command_id, &text, &text_len, &immediate_link, &auto_reconnection, &bg_mode, + &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); +#endif + dbg("check display text : text(%s) text len(%d)", text, text_len); + if(text_len > 1 && (g_strcmp0(text,"") != 0) ){ + GVariant *ui_info = NULL; + gboolean user_confirm = TRUE; + int ret; + dbg("text should be displayed by ui"); + dbg("open channel text is displayed!!!"); +#if defined(TIZEN_SUPPORT_SAT_ICON) + ui_info = g_variant_new("(isibv)", command_id, text, text_len, user_confirm, icon_id); +#else + ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_NONE, ui_info, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + g_free(text); + g_free(dest_address); + return TRUE; + } + g_free(text); + g_free(dest_address); + + /*telephony_sat_emit_open_channel(sat, command_id, text, text_len, immediate_link, auto_reconnection, bg_mode, + bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail);*/ +#if !defined(TIZEN_PLATFORM_USE_QCOM_QMI) + //bip proactive command is only handled by BIP Manager + { + GDBusConnection *conn = NULL; + const gchar *g_path = NULL; + + conn = g_dbus_object_manager_server_get_connection(ctx->manager); + g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); + + sat_ui_support_exec_bip(conn, g_path, SAT_PROATV_CMD_OPEN_CHANNEL, open_channel); + } +#endif + } break; + + case SAT_PROATV_CMD_CLOSE_CHANNEL:{ + GVariant *close_channel = NULL; + + gint command_id, channel_id, text_len; + gchar *text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + close_channel = sat_manager_close_channel_noti(ctx, cp_name, (struct tel_sat_close_channel_tlv*) &p_ind->proactive_ind_data.close_channel); + + if(!close_channel){ + dbg("no close channel data"); + return TRUE; + } + + //TODO check the data for sat-ui + + dbg("close channel type_format(%s)", g_variant_get_type_string(close_channel)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(close_channel, "(isi@vi)", &command_id, &text, &text_len, &icon_id, &channel_id); +#else + g_variant_get(close_channel, "(isii)", &command_id, &text, &text_len, &channel_id); +#endif + + /*telephony_sat_emit_close_channel(sat, command_id, text, text_len, channel_id);*/ + + //bip proactive command is only handled by BIP Manager + { + GDBusConnection *conn = NULL; + const gchar *g_path = NULL; + + conn = g_dbus_object_manager_server_get_connection(ctx->manager); + g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); + + sat_ui_support_exec_bip(conn, g_path, SAT_PROATV_CMD_CLOSE_CHANNEL, close_channel); + } + + g_free(text); + } break; + + case SAT_PROATV_CMD_RECEIVE_DATA:{ + GVariant *receive_data = NULL; + + gint command_id, text_len, channel_id, channel_data_len = 0; + gchar *text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + receive_data = sat_manager_receive_data_noti(ctx, cp_name, (struct tel_sat_receive_channel_tlv*) &p_ind->proactive_ind_data.receive_data); + + if(!receive_data){ + dbg("no receive data data"); + return TRUE; + } + + //TODO check the data for sat-ui + + dbg("receive data type_format(%s)", g_variant_get_type_string(receive_data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(receive_data, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &channel_id, &channel_data_len); +#else + g_variant_get(receive_data, "(isiii)", &command_id, &text, &text_len, &channel_id, &channel_data_len); +#endif + /*telephony_sat_emit_receive_data(sat, command_id, text, text_len, channel_id, channel_data_len);*/ + + //bip proactive command is only handled by BIP Manager + { + GDBusConnection *conn = NULL; + const gchar *g_path = NULL; + + conn = g_dbus_object_manager_server_get_connection(ctx->manager); + g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); + + sat_ui_support_exec_bip(conn, g_path, SAT_PROATV_CMD_RECEIVE_DATA, receive_data); + } + g_free(text); + } break; + + case SAT_PROATV_CMD_SEND_DATA:{ + GVariant *send_data = NULL; + + gint command_id, channel_id, text_len, channel_data_len; + gboolean send_data_immediately; + gchar *text = NULL; + GVariant *channel_data; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + send_data = sat_manager_send_data_noti(ctx, cp_name, (struct tel_sat_send_channel_tlv*) &p_ind->proactive_ind_data.send_data); + + if(!send_data){ + dbg("no send data data"); + return TRUE; + } + + //TODO check the data for sat-ui + + dbg("send data type_format(%s)", g_variant_get_type_string(send_data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(send_data, "(isi@vib@vi)", &command_id, &text, &text_len, &icon_id, &channel_id, &send_data_immediately, &channel_data, &channel_data_len); +#else + g_variant_get(send_data, "(isiib@vi)", &command_id, &text, &text_len, &channel_id, &send_data_immediately, &channel_data, &channel_data_len); +#endif + /*telephony_sat_emit_send_data(sat, command_id, text, text_len, channel_id, send_data_immediately, channel_data, channel_data_len);*/ + + //bip proactive command is only handled by BIP Manager + { + GDBusConnection *conn = NULL; + const gchar *g_path = NULL; + + conn = g_dbus_object_manager_server_get_connection(ctx->manager); + g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); + + sat_ui_support_exec_bip(conn, g_path, SAT_PROATV_CMD_SEND_DATA, send_data); + } + g_free(text); + } break; + + case SAT_PROATV_CMD_GET_CHANNEL_STATUS:{ + GVariant *channel_status = NULL; + + gint command_id; + + channel_status = sat_manager_get_channel_status_noti(ctx, cp_name, (struct tel_sat_get_channel_status_tlv*) &p_ind->proactive_ind_data.get_channel_status); + + if(!channel_status){ + dbg("no get channel status data"); + return TRUE; + } + + //TODO check the data for sat-ui + + dbg("get channel status type_format(%s)", g_variant_get_type_string(channel_status)); + g_variant_get(channel_status, "(i)", &command_id); + + /*telephony_sat_emit_get_channel_status(sat, command_id);*/ + + //bip proactive command is only handled by BIP Manager + { + GDBusConnection *conn = NULL; + const gchar *g_path = NULL; + + conn = g_dbus_object_manager_server_get_connection(ctx->manager); + g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); + + sat_ui_support_exec_bip(conn, g_path, SAT_PROATV_CMD_GET_CHANNEL_STATUS, channel_status); + } + } break; + + case SAT_PROATV_CMD_REFRESH:{ + GVariant *refresh = NULL; + gint command_id = 0; + gint refresh_type =0; + GVariant *file_list = NULL; + int ret; + + refresh = sat_manager_refresh_noti(ctx, cp_name, (struct tel_sat_refresh_tlv*) &p_ind->proactive_ind_data.refresh); + + if(!refresh){ + dbg("no refresh data"); + return TRUE; + } + + dbg("refresh type_format(%s)", g_variant_get_type_string(refresh)); + g_variant_get(refresh, "(ii@v)", &command_id, &refresh_type, &file_list); + + telephony_sat_emit_refresh(sat, command_id, refresh_type, file_list); + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_REFRESH, refresh, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + }break; + + case SAT_PROATV_CMD_MORE_TIME:{ + sat_manager_more_time_noti(ctx, cp_name, (struct tel_sat_more_time_tlv*) &p_ind->proactive_ind_data.more_time); + telephony_sat_emit_more_time(sat); + }break; + + case SAT_PROATV_CMD_SEND_DTMF:{ + GVariant *send_dtmf = NULL; + gint command_id = 0; + gint text_len = 0, dtmf_str_len = 0; + gchar *text = NULL; + gchar *dtmf_str = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; +#endif + send_dtmf = sat_manager_send_dtmf_noti(ctx, cp_name, (struct tel_sat_send_dtmf_tlv*) &p_ind->proactive_ind_data.send_dtmf); + if(!send_dtmf){ + dbg("no send_dtmf data"); + return TRUE; + } + + dbg("send_dtmf type_format(%s)", g_variant_get_type_string(send_dtmf)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(send_dtmf, "(isi@vis)", &command_id, &text, &text_len, &icon_id, &dtmf_str_len, &dtmf_str); +#else + g_variant_get(send_dtmf, "(isiis)", &command_id, &text, &text_len, &dtmf_str_len, &dtmf_str); +#endif + if(text_len > 1 && (g_strcmp0(text,"") != 0) ){ + GVariant *ui_info = NULL; + gboolean user_confirm = FALSE; + int ret; + dbg("text should be displayed by ui"); + dbg("send dtmf is displayed!!!"); +#if defined(TIZEN_SUPPORT_SAT_ICON) + ui_info = g_variant_new("(isibv)", command_id, text, text_len, user_confirm, icon_id); +#else + ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_SEND_DTMF, ui_info, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + g_free(text); + g_free(dtmf_str); + return TRUE; + } +#if !defined(TIZEN_PLATFORM_USE_QCOM_QMI) + telephony_sat_emit_send_dtmf(sat, command_id, text, text_len, dtmf_str, dtmf_str_len); +#endif + g_free(text); + g_free(dtmf_str); + }break; + + case SAT_PROATV_CMD_LAUNCH_BROWSER:{ + GVariant *launch_browser = NULL; + gint command_id = 0; + gint browser_launch_type = 0, browser_id = 0; + gint url_len = 0, text_len = 0, gateway_proxy_len =0; + gchar *url = NULL; + gchar *text = NULL; + gchar *gateway_proxy = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; +#endif + launch_browser = sat_manager_launch_browser_noti(ctx, cp_name, (struct tel_sat_launch_browser_tlv*) &p_ind->proactive_ind_data.launch_browser); + if(!launch_browser){ + dbg("no launch_browser data"); + return TRUE; + } + + dbg("launch_browser type_format(%s)", g_variant_get_type_string(launch_browser)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(launch_browser, "(iiisisisi@v)", &command_id, &browser_launch_type, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len, &icon_id); +#else + g_variant_get(launch_browser, "(iiisisisi)", &command_id, &browser_launch_type, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len); +#endif + //Popup is mendatory option in browser case + { + GVariant *ui_info = NULL; + gboolean user_confirm = TRUE; + int ret; + dbg("text should be displayed by ui"); + dbg("launch browser is displayed!!!"); +#if defined(TIZEN_SUPPORT_SAT_ICON) + ui_info = g_variant_new("(isibv)", command_id, text, text_len, user_confirm, icon_id); +#else + ui_info = g_variant_new("(isib)", command_id, text, text_len, user_confirm); +#endif + ret = sat_ui_support_launch_sat_ui(SAT_PROATV_CMD_LAUNCH_BROWSER, ui_info, slot_id); + if(!ret) { + int rv; + dbg("fail to launch sat-ui, remove the queued data!!\n"); + if(!sat_manager_handle_sat_ui_launch_fail(ctx, cp_name, p_ind)) + dbg("Fail to send terminal response\n"); + rv = sat_manager_remove_cmd_by_id(ctx, command_id); + if(!rv) + dbg("fail to dequeue data\n"); + } + g_free(url); + g_free(text); + g_free(gateway_proxy); + return TRUE; + } + }break; + + case SAT_PROATV_CMD_PROVIDE_LOCAL_INFO:{ + GVariant *provide_info = NULL; + gint info_type = 0; + + provide_info = sat_manager_provide_local_info_noti(ctx, cp_name, (struct tel_sat_provide_local_info_tlv*) &p_ind->proactive_ind_data.provide_local_info); + if(!provide_info){ + dbg("no provide_info data"); + return TRUE; + } + + dbg("provide_info type_format(%s)", g_variant_get_type_string(provide_info)); + g_variant_get(provide_info, "(i)", &info_type); + + telephony_sat_emit_provide_local_info(sat, info_type); + }break; + + case SAT_PROATV_CMD_LANGUAGE_NOTIFICATION:{ + GVariant *language_noti = NULL; + gint command_id = 0; + gint language = 0; + gboolean b_specified = FALSE; + + language_noti = sat_manager_language_notification_noti(ctx, cp_name, (struct tel_sat_language_notification_tlv*) &p_ind->proactive_ind_data.language_notification); + if(!language_noti){ + dbg("no language_noti data"); + return TRUE; + } + + dbg("language_noti type_format(%s)", g_variant_get_type_string(language_noti)); + g_variant_get(language_noti, "(iib)", &command_id, &language, &b_specified); + + sat_manager_update_language(ctx, cp_name, language_noti); + + telephony_sat_emit_language_notification(sat, command_id, language, b_specified); + }break; + + default:{ + gboolean rv = FALSE; + rv = sat_manager_processing_unsupport_proactive_command(ctx, cp_name, (struct tel_sat_unsupproted_command_tlv*) &p_ind->proactive_ind_data.unsupport_cmd); + dbg("not handled ind->cmd_type[0x%x] send error tr result(%d)", p_ind->cmd_type, rv); + }break; + } + } break; + default: + err("Unhandled Notification: [0x%x]", command); + break; + } + + return TRUE; +} + diff --git a/src/sat_manager.c b/src/sat_manager.c new file mode 100755 index 0000000..f82a13f --- /dev/null +++ b/src/sat_manager.c @@ -0,0 +1,6437 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "generated-code.h" +#include "common.h" +#include "sat_manager.h" +#include "sat_ui_support/sat_ui_support.h" + +#define SAT_DEF_CMD_Q_MAX 10 +#define SAT_DEF_CMD_Q_MIN 0 +#define SAT_TIME_OUT 30000 +#define TIZEN_SAT_DELAY_TO_CLEAN_MSG 15000 +#define SAT_USC2_INPUT_LEN_MAX 70 +#define SAT_EVENT_DOWNLOAD_MAX 9 + +#define LANGUAGE_XML_PATH "/opt/usr/apps/org.tizen.setting/data/langlist.xml" + +#define SAT_CMD_Q_CHECK(index) \ + if (index < SAT_DEF_CMD_Q_MIN || index > SAT_DEF_CMD_Q_MAX-1) { warn("invalid index!!"); return FALSE; } + +static gboolean _sat_manager_handle_open_channel_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data); + +static struct sat_manager_queue_data *sat_queue[SAT_DEF_CMD_Q_MAX] = {NULL, }; +gboolean g_evt_list[SAT_EVENT_DOWNLOAD_MAX] = {0}; + +static unsigned char _convert_decimal_to_bcd(int dec) +{ + int tmp1, tmp0; + unsigned char tmp3; + + tmp1 = dec/10; + tmp0 = dec - tmp1*10; + tmp3 = tmp0 << 4; + tmp3 += tmp1; + + dbg("input decimal(%d), bcd(%d%d), endian(%x)", dec, tmp1, tmp0, tmp3); + return tmp3; +} + +static const gchar* _convert_sim_lang_to_string(enum tel_sim_language_type lang) +{ + dbg("convert lang(%d)", lang); + switch(lang){ + case SIM_LANG_GERMAN: + return "de_DE.UTF-8"; + case SIM_LANG_ENGLISH: + return "en_GB.UTF-8"; + case SIM_LANG_ITALIAN: + return "it_IT.UTF-8"; + case SIM_LANG_FRENCH: + return "fr_FR.UTF-8"; + case SIM_LANG_SPANISH: + return "es_ES.UTF-8"; + case SIM_LANG_DUTCH: + return "nl_NL.UTF-8"; + case SIM_LANG_SWEDISH: + return "sv_SE.UTF-8"; + case SIM_LANG_DANISH: + return "da_DK.UTF-8"; + case SIM_LANG_PORTUGUESE: + return "pt_PT.UTF-8"; + case SIM_LANG_FINNISH: + return "fi_FI.UTF-8"; + case SIM_LANG_NORWEGIAN: + return "nb_NO.UTF-8"; + case SIM_LANG_GREEK: + return "el_GR.UTF-8"; + case SIM_LANG_TURKISH: + return "tr_TR.UTF-8"; + case SIM_LANG_HUNGARIAN: + return "hu_HU.UTF-8"; + case SIM_LANG_POLISH: + return "pl_PL.UTF-8"; + case SIM_LANG_KOREAN: + return "ko_KR.UTF-8"; + case SIM_LANG_CHINESE: + return "zh_CH.UTF-8"; + case SIM_LANG_RUSSIAN: + return "ru_RU.UTF-8"; + case SIM_LANG_JAPANESE: + return "ja_JP.UTF-8"; + default: + return NULL; + }//end of switch + + return NULL; +} + +static enum tel_sim_language_type _convert_string_to_sim_lang(const gchar* lang_str) +{ + dbg("convert lang(%s)", lang_str); + + if (g_str_equal(lang_str, "de_DE.UTF-8") == TRUE) { + return SIM_LANG_GERMAN; + } + else if (g_str_equal(lang_str, "en_GB.UTF-8") == TRUE) { + return SIM_LANG_ENGLISH; + } + else if (g_str_equal(lang_str, "it_IT.UTF-8") == TRUE) { + return SIM_LANG_ITALIAN; + } + else if (g_str_equal(lang_str, "fr_FR.UTF-8") == TRUE) { + return SIM_LANG_FRENCH; + } + else if (g_str_equal(lang_str, "es_ES.UTF-8") == TRUE) { + return SIM_LANG_SPANISH; + } + else if (g_str_equal(lang_str, "nl_NL.UTF-8") == TRUE) { + return SIM_LANG_DUTCH; + } + else if (g_str_equal(lang_str, "sv_SE.UTF-8") == TRUE) { + return SIM_LANG_SWEDISH; + } + else if (g_str_equal(lang_str, "da_DK.UTF-8") == TRUE) { + return SIM_LANG_DANISH; + } + else if (g_str_equal(lang_str, "pt_PT.UTF-8") == TRUE) { + return SIM_LANG_PORTUGUESE; + } + else if (g_str_equal(lang_str, "fi_FI.UTF-8") == TRUE) { + return SIM_LANG_FINNISH; + } + else if (g_str_equal(lang_str, "nb_NO.UTF-8") == TRUE) { + return SIM_LANG_NORWEGIAN; + } + else if (g_str_equal(lang_str, "el_GR.UTF-8") == TRUE) { + return SIM_LANG_GREEK; + } + else if (g_str_equal(lang_str, "tr_TR.UTF-8") == TRUE) { + return SIM_LANG_TURKISH; + } + else if (g_str_equal(lang_str, "hu_HU.UTF-8") == TRUE) { + return SIM_LANG_HUNGARIAN; + } + else if (g_str_equal(lang_str, "pl_PL.UTF-8") == TRUE) { + return SIM_LANG_POLISH; + } + else if (g_str_equal(lang_str, "ko_KR.UTF-8") == TRUE) { + return SIM_LANG_KOREAN; + } + else if (g_str_equal(lang_str, "zh_CH.UTF-8") == TRUE) { + return SIM_LANG_CHINESE; + } + else if (g_str_equal(lang_str, "ru_RU.UTF-8") == TRUE) { + return SIM_LANG_RUSSIAN; + } + else if (g_str_equal(lang_str, "ja_JP.UTF-8") == TRUE) { + return SIM_LANG_JAPANESE; + } + + dbg("there is no matched language"); + return SIM_LANG_UNSPECIFIED; +} + +static unsigned char _convert_hex_char_to_int(char c) +{ + if (c >= '0' && c <= '9') + return (c - '0'); + else if (c >= 'A' && c <= 'F') + return (c - 'A' + 10); + else if (c >= 'a' && c <= 'f') + return (c - 'a' + 10); + else { + dbg("invalid charater!!"); + return -1; + } +} + +static char* _convert_hex_string_to_bytes(char *s) +{ + char *ret; + int i; + int sz; + + if (s == NULL) + return NULL; + + sz = strlen(s); + ret = calloc(1, (sz / 2) + 1); + + dbg("Convert String to Binary!!"); + + for (i = 0; i < sz; i += 2) { + ret[i / 2] = (char) ((_convert_hex_char_to_int(s[i]) << 4) | _convert_hex_char_to_int(s[i + 1])); + } + + return ret; +} + +static unsigned int _get_time_in_ms(struct tel_sat_duration *dr) +{ + switch (dr->time_unit) { + case TIME_UNIT_MINUTES: + return (unsigned int)dr->time_interval * 60000; + break; + + case TIME_UNIT_SECONDS: + return (unsigned int)dr->time_interval * 1000; + break; + + case TIME_UNIT_TENTHS_OF_SECONDS: + return (unsigned int)dr->time_interval * 100; + break; + + case TIME_UNIT_RESERVED: + default: + return 0; // set default + break; + } + + return 0; +} + +static int _get_queue_empty_index(void) +{ + int cnt = 0; + int i; + int local_index = -1; + + for(i =0; icmd_id; + + SAT_CMD_Q_CHECK(local_index); + + if (sat_queue[local_index]) { + dbg("[SAT] sat_queue[%d] is not null [%p].\n", sat_queue[local_index]); + return FALSE; + } + + item = g_new0(struct sat_manager_queue_data, 1); + + if(!item) { + dbg("[SAT] FAILED TO ALLOC QUEUE ITEM!\n"); + return FALSE; + } + + memcpy((void*)item, (void*)cmd_obj, sizeof(struct sat_manager_queue_data)); + sat_queue[local_index] = item; + dbg("push data to queue at index[%d], [%p].\n",local_index, item); + return TRUE; +} + +static gboolean _pop_nth_data(struct custom_data *ctx, struct sat_manager_queue_data *cmd_obj, int command_id) +{ + struct sat_manager_queue_data *item; + int local_index = command_id; + + SAT_CMD_Q_CHECK(local_index); + + if(!sat_queue[local_index]) { + dbg("[SAT] sat_queue[%d] is null !!\n", local_index); + return FALSE; + } + + item = sat_queue[local_index]; + + memcpy((void*)cmd_obj, (void*)item, sizeof(struct sat_manager_queue_data)); + dbg("pop data from queue at index[%d],[%p].\n",local_index, item); + sat_queue[local_index] = NULL; + g_free(item); + return TRUE; +} + +static gboolean _peek_nth_data(struct custom_data *ctx, struct sat_manager_queue_data *cmd_obj, int command_id) +{ + struct sat_manager_queue_data *item = NULL; + + int local_index = command_id; + + SAT_CMD_Q_CHECK(local_index); + + if(!sat_queue[local_index]) { + dbg("[SAT] sat_queue[%d] is null !!\n", local_index); + return FALSE; + } + + item = sat_queue[local_index]; + memcpy((void*)cmd_obj, (void*)item, sizeof(struct sat_manager_queue_data)); + dbg("peek data from queue at index[%d],[%p].\n",local_index, item); + return TRUE; +} + +static gboolean _sat_manager_check_language_set(const char* lan) +{ + xmlNode *cur_node = NULL; + xmlNodePtr cur; + void *xml_doc = NULL,*xml_root_node = NULL; + char *id = NULL; + gboolean ret = FALSE; + + dbus_plugin_util_load_xml(LANGUAGE_XML_PATH, "langlist", &xml_doc, &xml_root_node); + if (!xml_root_node) { + err("[LANGUAGE LIST] Load error - Root node is NULL."); + goto EXIT; + } + + cur = xml_root_node; + /* Compare language */ + for(cur_node = cur; cur_node; cur_node = cur_node->next) { + if (cur_node->type == XML_ELEMENT_NODE) { + id = (char *)xmlGetProp(cur_node, (const xmlChar *)"id"); + if (id && g_str_has_prefix(lan, id)) { + dbg("Supported: id[%s], lan[%s]", id, lan); + ret = TRUE; + goto EXIT; + } + } + } + warn("Not supported language[%s]", lan); +EXIT: + dbus_plugin_util_unload_xml(&xml_doc, &xml_root_node); + return ret; +} + +void sat_manager_init_queue(struct custom_data *ctx, const char *cp_name) +{ + int i; + + dbg("Entered into queue"); + for(i=0;icp_name)) { + dbg("item[%d]: cmd_type[%d]", i, item->cmd_type); +#if defined(TIZEN_PLATFORM_USE_QCOM_QMI) + switch(item->cmd_type) { + case SAT_PROATV_CMD_SEND_SMS: + case SAT_PROATV_CMD_SEND_SS: + case SAT_PROATV_CMD_SEND_USSD: + case SAT_PROATV_CMD_SEND_DTMF: { + dbg("[SAT] set noti flag"); + item->noti_required = TRUE; + return; + } break; + default: + break; + } +#endif + g_free(item->cp_name); + g_free(item); + sat_queue[i] = NULL; + } + } +} + +static gboolean sat_manager_enqueue_cmd(struct custom_data *ctx, struct sat_manager_queue_data *cmd_obj) +{ + int id; + + id = _get_queue_empty_index(); + if(id < 0) { + dbg("Fail to get empty index.\n"); + return FALSE; + } + cmd_obj->cmd_id = id; + return _push_data(ctx, cmd_obj); +} + +static gboolean sat_manager_dequeue_cmd_by_id(struct custom_data *ctx, struct sat_manager_queue_data *cmd_obj, int cmd_id) +{ + return _pop_nth_data(ctx, cmd_obj, cmd_id); +} + +static gboolean sat_manager_queue_peek_data_by_id(struct custom_data *ctx, struct sat_manager_queue_data *cmd_obj, int command_id) +{ + return _peek_nth_data(ctx, cmd_obj, command_id); +} + +static gboolean sat_manager_check_availiable_event_list(struct tel_sat_setup_event_list_tlv *event_list_tlv) +{ + gboolean rv = TRUE; + int local_index = 0; + + for(local_index = 0; local_index < event_list_tlv->event_list.event_list_cnt; local_index++){ + if(event_list_tlv->event_list.evt_list[local_index] == EVENT_USER_ACTIVITY){ + dbg("do user activity"); + } + else if(event_list_tlv->event_list.evt_list[local_index] == EVENT_IDLE_SCREEN_AVAILABLE){ + dbg("do idle screen"); + } + else if(event_list_tlv->event_list.evt_list[local_index] == EVENT_LANGUAGE_SELECTION){ + dbg("do language selection"); + } + else if(event_list_tlv->event_list.evt_list[local_index] == EVENT_BROWSER_TERMINATION){ + dbg("do browser termination"); + } + else if(event_list_tlv->event_list.evt_list[local_index] == EVENT_DATA_AVAILABLE){ + dbg("do data available (bip)"); + } + else if(event_list_tlv->event_list.evt_list[local_index] == EVENT_CHANNEL_STATUS){ + dbg("do channel status (bip)"); + } + else{ + dbg("unmanaged event (%d)", event_list_tlv->event_list.evt_list[local_index]); + rv = FALSE; + } + } + + return rv; +} + +#if defined(TIZEN_PLATFORM_USE_QCOM_QMI) +static TReturn sat_manager_send_user_confirmation(Communicator *comm, TcorePlugin *target_plg, struct treq_sat_user_confirmation_data *conf_data) +{ + TReturn rv = TCORE_RETURN_SUCCESS; + UserRequest *ur = NULL; + + ur = tcore_user_request_new(comm, tcore_server_get_cp_name_by_plugin(target_plg)); + if (!ur) { + dbg("ur is NULL"); + return TCORE_RETURN_FAILURE; + } + + tcore_user_request_set_command(ur, TREQ_SAT_REQ_USERCONFIRMATION); + tcore_user_request_set_data(ur, sizeof(struct treq_sat_user_confirmation_data), (void *)conf_data); + rv = tcore_communicator_dispatch_request(comm, ur); + if (rv != TCORE_RETURN_SUCCESS) { + dbg("fail to send terminal response",rv); + tcore_user_request_unref(ur); + rv = TCORE_RETURN_FAILURE; + } + + return rv; +} +#endif + +static TReturn sat_manager_send_terminal_response(Communicator *comm, TcorePlugin *target_plg, struct treq_sat_terminal_rsp_data *tr) +{ + TReturn rv = TCORE_RETURN_SUCCESS; + UserRequest *ur = NULL; + + ur = tcore_user_request_new(comm, tcore_server_get_cp_name_by_plugin(target_plg)); + if (!ur) { + dbg("ur is NULL"); + return TCORE_RETURN_FAILURE; + } + + tcore_user_request_set_command(ur, TREQ_SAT_REQ_TERMINALRESPONSE); + tcore_user_request_set_data(ur, sizeof(struct treq_sat_terminal_rsp_data), (void *)tr); + rv = tcore_communicator_dispatch_request(comm, ur); + if (rv != TCORE_RETURN_SUCCESS) { + dbg("fail to send terminal response",rv); + tcore_user_request_unref(ur); + rv = TCORE_RETURN_FAILURE; + } + + return rv; +} + +gboolean sat_manager_remove_cmd_by_id(struct custom_data *ctx, int cmd_id) +{ + struct sat_manager_queue_data *item; + int local_index = cmd_id; + + if(!sat_queue[local_index]) { + dbg("[SAT] sat_queue[%d] is already null !!\n", local_index); + return FALSE; + } + item = sat_queue[local_index]; + + dbg("remove data from queue at index[%d],[%p].\n",local_index, item); + sat_queue[local_index] = NULL; + g_free(item->cp_name); + g_free(item); + return TRUE; +} + +GVariant* sat_manager_caching_setup_menu_info(struct custom_data *ctx, const char *cp_name, struct tel_sat_setup_menu_tlv* setup_menu_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *setup_menu_info = NULL; + struct sat_manager_queue_data q_data; + + gushort title_len = 0; + gint command_id = 0, menu_cnt = 0; + gboolean menu_present = FALSE, help_info = FALSE, updated = FALSE; + gchar main_title[SAT_ALPHA_ID_LEN_MAX]; + GVariantBuilder v_builder; + GVariant *menu_items = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + int local_index = 0; + GVariant *icon_id = NULL; + GVariant *icon_list = NULL; + GVariant *icon_list_info = NULL; + GVariantBuilder v_builder_icon; + GVariantBuilder v_builder_icon_list_data; +#endif + /* To check menu update */ + GSList *list = NULL; + struct cached_data *object; + struct treq_sat_terminal_rsp_data tr; + + dbg("interpreting setup menu notification"); + memset(&main_title, 0 , SAT_ALPHA_ID_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + /* check menu info is already updated */ + for (list = ctx->cached_data; list; list = list->next) { + object = (struct cached_data *) list->data; + if (object == NULL) + continue; + + if (g_strcmp0(object->cp_name, cp_name) == 0) { + if(object->cached_sat_main_menu) { + dbg("main menu info is updated"); + updated = TRUE; + } + } + } + + //check the validation of content + if(!setup_menu_tlv->menu_item_cnt || !setup_menu_tlv->menu_item[0].text_len){ + //support GCF case 27.22.4.8.1 - 1.1 setup menu + + dbg("no menu item updated menu(%d)", updated); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = setup_menu_tlv->command_detail.cmd_num; + tr.cmd_type = setup_menu_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.setup_menu.command_detail, + &setup_menu_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.setup_menu.device_id.src = setup_menu_tlv->device_id.dest; + tr.terminal_rsp_data.setup_menu.device_id.dest = setup_menu_tlv->device_id.src; + + if(updated){ + tr.terminal_rsp_data.setup_menu.result_type = RESULT_SUCCESS; + }else{ + tr.terminal_rsp_data.setup_menu.result_type = RESULT_BEYOND_ME_CAPABILITIES; + } + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + //return NULL; + } + + + help_info = setup_menu_tlv->command_detail.cmd_qualifier.setup_menu.help_info; + menu_present = setup_menu_tlv->command_detail.cmd_qualifier.setup_menu.select_preference; + menu_cnt = setup_menu_tlv->menu_item_cnt; + + //get title + if(setup_menu_tlv->alpha_id.alpha_data_len) + tcore_util_convert_string_to_utf8((unsigned char*)&main_title, (unsigned short*)&title_len, + setup_menu_tlv->alpha_id.dcs.a_format, + (unsigned char*)&setup_menu_tlv->alpha_id.alpha_data, + (unsigned short)setup_menu_tlv->alpha_id.alpha_data_len); + dbg("sat main menu title(%s)",main_title); + + g_variant_builder_init(&v_builder, G_VARIANT_TYPE ("a(si)")); + + //get menu items + if(!setup_menu_tlv->next_act_ind_list.cnt){ + int local_index = 0; + + dbg("setup_menu_tlv->next_act_ind_list.cnt == 0"); + + for(local_index = 0; local_index < menu_cnt; local_index++){ + gushort item_len; + gchar item_str[SAT_ITEM_TEXT_LEN_MAX + 1]; + + memset(&item_str, 0 , SAT_ITEM_TEXT_LEN_MAX + 1); + tcore_util_convert_string_to_utf8((unsigned char*)&item_str, (unsigned short *)&item_len, + setup_menu_tlv->menu_item[local_index].dcs.a_format, + (unsigned char*)&setup_menu_tlv->menu_item[local_index].text, + (unsigned short)setup_menu_tlv->menu_item[local_index].text_len); + + dbg( "index(%d) item_id(%d) item_string(%s)", local_index, setup_menu_tlv->menu_item[local_index].item_id, item_str); + + //g_variant_builder_add(v_builder, "(sy)", &item_str, setup_menu_tlv->menu_item[index].item_id); + g_variant_builder_add(&v_builder, "(si)", item_str, (gint32)(setup_menu_tlv->menu_item[local_index].item_id)); + } + } + else{ + int local_index = 0; + + dbg("setup_menu_tlv->next_act_ind_list.cnt != 0"); + + for(local_index = 0; local_index < menu_cnt; local_index++){ + gushort item_len; + gchar item_str[SAT_ITEM_TEXT_LEN_MAX + 1]; + + memset(&item_str, '\0' , SAT_ITEM_TEXT_LEN_MAX + 1); + tcore_util_convert_string_to_utf8((unsigned char*)&item_str, (unsigned short *)&item_len, + setup_menu_tlv->menu_item[local_index].dcs.a_format, + (unsigned char*)&setup_menu_tlv->menu_item[local_index].text, + (unsigned short)setup_menu_tlv->menu_item[local_index].text_len); + + dbg( "index(%d) item_id(%d) item_string(%s)", local_index, setup_menu_tlv->menu_item[local_index].item_id, item_str); + + //g_variant_builder_add(v_builder, "(sy)", g_strdup(item_str), setup_menu_tlv->menu_item[local_index].item_id); + g_variant_builder_add(&v_builder, "(si)", item_str, (gint32)(setup_menu_tlv->menu_item[local_index].item_id)); + } + } + + menu_items = g_variant_builder_end(&v_builder); + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_SETUP_MENU; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.setupMenuInd), setup_menu_tlv, sizeof(struct tel_sat_setup_menu_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(setup_menu_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", setup_menu_tlv->icon_id.is_exist, setup_menu_tlv->icon_id.icon_qualifer, (gint32) setup_menu_tlv->icon_id.icon_identifier, (gint32) setup_menu_tlv->icon_id.icon_info.width, + (gint32) setup_menu_tlv->icon_id.icon_info.height, setup_menu_tlv->icon_id.icon_info.ics, setup_menu_tlv->icon_id.icon_info.icon_data_len, setup_menu_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + /* Icon list data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiv)")); + if(setup_menu_tlv->icon_list.is_exist) { + g_variant_builder_init(&v_builder_icon_list_data, G_VARIANT_TYPE ("a(iiiiis)")); + for(local_index= 0; local_index< (int)setup_menu_tlv->icon_list.icon_cnt; local_index++){ + g_variant_builder_add(&v_builder_icon_list_data, "(iiiiis)", (gint32) setup_menu_tlv->icon_list.icon_id_list[local_index], (gint32) setup_menu_tlv->icon_list.icon_info[local_index].width, + (gint32) setup_menu_tlv->icon_list.icon_info[local_index].height, setup_menu_tlv->icon_list.icon_info[local_index].ics, setup_menu_tlv->icon_list.icon_info[local_index].icon_data_len, setup_menu_tlv->icon_list.icon_info[local_index].icon_file); + } + icon_list_info = g_variant_builder_end(&v_builder_icon_list_data); + + g_variant_builder_add(&v_builder_icon, "(biiv)", setup_menu_tlv->icon_list.is_exist, setup_menu_tlv->icon_list.icon_qualifer, (gint32) setup_menu_tlv->icon_list.icon_cnt, icon_list_info); + } + icon_list = g_variant_builder_end(&v_builder_icon); + + setup_menu_info = g_variant_new("(ibsvibbvv)", command_id, menu_present, main_title, menu_items, + menu_cnt, help_info, updated, icon_id, icon_list); +#else + setup_menu_info = g_variant_new("(ibsvibb)", command_id, menu_present, main_title, menu_items, + menu_cnt, help_info, updated); +#endif + return setup_menu_info; +} + +GVariant* sat_manager_display_text_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_display_text_tlv* display_text_tlv, int decode_error) +{ + TcorePlugin *plg = NULL; + GVariant *display_text = NULL; + struct sat_manager_queue_data q_data; + + gushort text_len = 0; + gint command_id = 0, duration= 0, tmp_duration = 0; + gboolean immediately_rsp = FALSE, high_priority = FALSE, user_rsp_required = FALSE; + gchar text[SAT_TEXT_STRING_LEN_MAX+1]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting display text notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX+1); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + if(!display_text_tlv->text.string_length || + (display_text_tlv->text.string_length > 0 && decode_error != TCORE_SAT_SUCCESS)){ + struct treq_sat_terminal_rsp_data tr; + + dbg("displat text - invalid parameter of TLVs is found!!"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = display_text_tlv->command_detail.cmd_num; + tr.cmd_type = display_text_tlv->command_detail.cmd_type; + + memcpy((void*) &tr.terminal_rsp_data.display_text.command_detail, + &display_text_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr.terminal_rsp_data.display_text.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.display_text.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.display_text.result_type = RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + + return NULL; + } + + //user resp required & time_duration + if(display_text_tlv->command_detail.cmd_qualifier.display_text.text_clear_type == TEXT_WAIT_FOR_USER_TO_CLEAR_MSG){ + user_rsp_required = TRUE; + duration = SAT_TIME_OUT; + } + else{ + /* Set by default if duration is not provided. */ + duration = TIZEN_SAT_DELAY_TO_CLEAN_MSG; + } + + //immediate response requested + if (display_text_tlv->immediate_response_requested) + immediately_rsp = TRUE; + + //high priority + if (display_text_tlv->command_detail.cmd_qualifier.display_text.text_priority == TEXT_PRIORITY_HIGH) + high_priority = TRUE; + + //get text + tcore_util_convert_string_to_utf8((unsigned char*) &text, (unsigned short *) &text_len, + display_text_tlv->text.dcs.a_format, + (unsigned char*) &display_text_tlv->text.string, + (unsigned short) display_text_tlv->text.string_length); + dbg("sat display text(%s)",text); + + //duration + if(display_text_tlv->duration.time_interval){ + tmp_duration = _get_time_in_ms(&display_text_tlv->duration); + } + + /* duration is required only when clear message after a delay + * 27.22.4.1.7.4.2 DISPLAY TEXT ( Variable Timeout ) + */ + if(tmp_duration > 0) { + duration = tmp_duration; + } + + if(immediately_rsp && user_rsp_required) + duration = 0; + + dbg("user rsp required(%d), immediately rsp(%d) duration (%d), priority(%d)", + user_rsp_required, immediately_rsp, duration, high_priority); + +/* ETSI TS 102 223 6.4.1 DISPLAY TEXT + If help information is requested by the user, this command may be used to display help information on the screen. The + help information should be sent as high priority text and with the option that it should be cleared after a short delay.*/ + +/* if (ctx->help_requested == TRUE) { + ad->bIsPriorityHigh = TRUE; + ad->duration = 7000; + ctx->help_requested = FALSE; + }*/ + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_DISPLAY_TEXT; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.displayTextInd), display_text_tlv, sizeof(struct tel_sat_display_text_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(display_text_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", display_text_tlv->icon_id.is_exist, display_text_tlv->icon_id.icon_qualifer, (gint32) display_text_tlv->icon_id.icon_identifier, (gint32) display_text_tlv->icon_id.icon_info.width, + (gint32) display_text_tlv->icon_id.icon_info.height, display_text_tlv->icon_id.icon_info.ics, display_text_tlv->icon_id.icon_info.icon_data_len, display_text_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + display_text = g_variant_new("(isiibbbv)", command_id, text, text_len, duration, + high_priority, user_rsp_required, immediately_rsp, icon_id); +#else + display_text = g_variant_new("(isiibbb)", command_id, text, text_len, duration, + high_priority, user_rsp_required, immediately_rsp); +#endif + + return display_text; +} + +GVariant* sat_manager_select_item_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_select_item_tlv* select_item_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *select_item = NULL; + struct sat_manager_queue_data q_data; + + gushort text_len = 0; + gint command_id = 0, default_item_id = 0, menu_cnt = 0; + gboolean help_info = FALSE; + gchar text[SAT_TEXT_STRING_LEN_MAX+1]; + GVariantBuilder v_builder; + GVariant *menu_items = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + int local_index = 0; + GVariant *icon_id = NULL; + GVariant *icon_list = NULL; + GVariant *icon_list_info = NULL; + GVariantBuilder v_builder_icon; + GVariantBuilder v_builder_icon_list; +#else + int local_index = 0; +#endif + dbg("interpreting select item notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX+1); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + if(!select_item_tlv->menu_item_cnt || !select_item_tlv->menu_item[0].text_len){ + struct treq_sat_terminal_rsp_data tr; + + dbg("select item - mandatory field does not exist"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = select_item_tlv->command_detail.cmd_num; + tr.cmd_type = select_item_tlv->command_detail.cmd_type; + + memcpy((void*) &tr.terminal_rsp_data.select_item.command_detail, + &select_item_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr.terminal_rsp_data.select_item.device_id.src = select_item_tlv->device_id.dest; + tr.terminal_rsp_data.select_item.device_id.dest = select_item_tlv->device_id.src; + tr.terminal_rsp_data.select_item.result_type = RESULT_BEYOND_ME_CAPABILITIES; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + + return NULL; + } + + // help info + help_info = select_item_tlv->command_detail.cmd_qualifier.select_item.help_info; + + if(!select_item_tlv->alpha_id.is_exist){ + dbg("set the item dcs value to ALPHABET_FORMAT_8BIT_DATA"); + select_item_tlv->alpha_id.dcs.a_format = ALPHABET_FORMAT_8BIT_DATA; + } + + // select item text + if(select_item_tlv->alpha_id.is_exist && select_item_tlv->alpha_id.alpha_data_len > 0) + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + select_item_tlv->alpha_id.dcs.a_format, + (unsigned char*)&select_item_tlv->alpha_id.alpha_data, + (unsigned short)select_item_tlv->alpha_id.alpha_data_len); + dbg("select item text(%s)",text); + + //default item id + default_item_id = select_item_tlv->item_identifier.item_identifier; + dbg( "default item id(%d)", default_item_id); + + //item count + menu_cnt = select_item_tlv->menu_item_cnt; + dbg( "menu item count(%d)", menu_cnt); + + //items + g_variant_builder_init(&v_builder, G_VARIANT_TYPE ("a(iis)")); + for(local_index= 0; local_index< menu_cnt; local_index++){ + gushort item_len; + gchar item_str[SAT_ITEM_TEXT_LEN_MAX + 1]; + + memset(&item_str, 0 , SAT_ITEM_TEXT_LEN_MAX + 1); + + tcore_util_convert_string_to_utf8((unsigned char*) &item_str, (unsigned short *) &item_len, + select_item_tlv->menu_item[local_index].dcs.a_format, + (unsigned char*) &select_item_tlv->menu_item[local_index].text, + (unsigned short) select_item_tlv->menu_item[local_index].text_len); + + dbg( "index(%d) item_id(%d) item_len(%d) item_string(%s)", local_index, select_item_tlv->menu_item[local_index].item_id, item_len, item_str); + g_variant_builder_add(&v_builder, "(iis)", (gint32)(select_item_tlv->menu_item[local_index].item_id), item_len, item_str); + } + menu_items = g_variant_builder_end(&v_builder); + + // generate command id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_SELECT_ITEM; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.selectItemInd), select_item_tlv, sizeof(struct tel_sat_select_item_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(select_item_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", select_item_tlv->icon_id.is_exist, select_item_tlv->icon_id.icon_qualifer, (gint32) select_item_tlv->icon_id.icon_identifier, (gint32) select_item_tlv->icon_id.icon_info.width, + (gint32) select_item_tlv->icon_id.icon_info.height, select_item_tlv->icon_id.icon_info.ics, select_item_tlv->icon_id.icon_info.icon_data_len, select_item_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + /* Icon list data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiv)")); + if(select_item_tlv->icon_list.is_exist) { + g_variant_builder_init(&v_builder_icon_list, G_VARIANT_TYPE ("a(iiiiis)")); + for(local_index= 0; local_index< (int)select_item_tlv->icon_list.icon_cnt; local_index++){ + g_variant_builder_add(&v_builder_icon_list, "(iiiiis)", (gint32) select_item_tlv->icon_list.icon_id_list[local_index], (gint32) select_item_tlv->icon_list.icon_info[local_index].width, + (gint32) select_item_tlv->icon_list.icon_info[local_index].height, select_item_tlv->icon_list.icon_info[local_index].ics, select_item_tlv->icon_list.icon_info[local_index].icon_data_len, select_item_tlv->icon_list.icon_info[local_index].icon_file); + } + icon_list_info = g_variant_builder_end(&v_builder_icon_list); + + g_variant_builder_add(&v_builder_icon, "(biiv)", select_item_tlv->icon_list.is_exist, select_item_tlv->icon_list.icon_qualifer, (gint32) select_item_tlv->icon_list.icon_cnt, icon_list_info); + + } + icon_list = g_variant_builder_end(&v_builder_icon); + + select_item = g_variant_new("(ibsiiivvv)", command_id, help_info, text, text_len, + default_item_id, menu_cnt, menu_items, icon_id, icon_list); +#else + select_item = g_variant_new("(ibsiiiv)", command_id, help_info, text, text_len, + default_item_id, menu_cnt, menu_items); +#endif + return select_item; +} + +GVariant* sat_manager_get_inkey_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_get_inkey_tlv* get_inkey_tlv, int decode_error) +{ + TcorePlugin *plg = NULL; + GVariant *get_inkey = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0, key_type = 0, input_character_mode = 0; + gushort text_len = 0; + gint duration = 0, tmp_duration = 0; + gboolean b_numeric = FALSE, b_help_info = FALSE; + gchar text[SAT_TEXT_STRING_LEN_MAX+1]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting get inkey notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX+1); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + if(!get_inkey_tlv->text.string_length || + (get_inkey_tlv->text.string_length > 0 && decode_error != TCORE_SAT_SUCCESS)){ + struct treq_sat_terminal_rsp_data tr; + + dbg("get inkey - invalid parameter of TLVs is found!!"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = get_inkey_tlv->command_detail.cmd_num; + tr.cmd_type = get_inkey_tlv->command_detail.cmd_type; + + memcpy((void*) &tr.terminal_rsp_data.get_inkey.command_detail, + &get_inkey_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr.terminal_rsp_data.get_inkey.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.get_inkey.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.get_inkey.result_type = RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + + return NULL; + } + + //key type + key_type = get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.inkey_type; + + //time duration + duration = SAT_TIME_OUT; + tmp_duration = _get_time_in_ms(&get_inkey_tlv->duration); + if (tmp_duration > 0) + duration = tmp_duration; + + //input mode + input_character_mode = get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.alphabet_type; + + //numeric + b_numeric = !get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.alphabet_set; + + //help info + b_help_info = get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.help_info; + + //text & text len + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + get_inkey_tlv->text.dcs.a_format , + (unsigned char*)&get_inkey_tlv->text.string, + (unsigned short)get_inkey_tlv->text.string_length); + + dbg("get inkey text(%s)",text); + + if (get_inkey_tlv->command_detail.cmd_qualifier.get_inkey.immediate_rsp_required) { + dbg("get_inkey immediate_rsp_require is TRUE"); + //Send TR if UI display success + } + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_GET_INKEY; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.getInkeyInd), get_inkey_tlv, sizeof(struct tel_sat_get_inkey_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(get_inkey_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", get_inkey_tlv->icon_id.is_exist, get_inkey_tlv->icon_id.icon_qualifer, (gint32) get_inkey_tlv->icon_id.icon_identifier, (gint32) get_inkey_tlv->icon_id.icon_info.width, + (gint32) get_inkey_tlv->icon_id.icon_info.height, get_inkey_tlv->icon_id.icon_info.ics, get_inkey_tlv->icon_id.icon_info.icon_data_len, get_inkey_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + get_inkey = g_variant_new("(iiibbsiiv)", command_id, key_type, input_character_mode, b_numeric, + b_help_info, text, text_len, duration, icon_id); +#else + get_inkey = g_variant_new("(iiibbsii)", command_id, key_type, input_character_mode, b_numeric, + b_help_info, text, text_len, duration); +#endif + return get_inkey; +} + +GVariant* sat_manager_get_input_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_get_input_tlv* get_input_tlv, int decode_error) +{ + TcorePlugin *plg = NULL; + GVariant *get_input = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0, input_character_mode = 0; + gushort text_len = 0, def_text_len = 0; + gint rsp_len_min = 0, rsp_len_max = 0; + gboolean b_numeric = FALSE, b_help_info = FALSE, b_echo_input = FALSE; + gchar text[SAT_TEXT_STRING_LEN_MAX+1]; + gchar def_text[SAT_TEXT_STRING_LEN_MAX+1]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting get input notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX+1); + memset(&def_text, 0 , SAT_TEXT_STRING_LEN_MAX+1); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + +#if GCF //disable the text length prb for GCF + if( + (get_input_tlv->text.string_length > 0 && decode_error != TCORE_SAT_SUCCESS) || + (!get_input_tlv->rsp_len.max) || (get_input_tlv->rsp_len.min > get_input_tlv->rsp_len.max)){ +#else + if(!get_input_tlv->text.string_length || + (get_input_tlv->text.string_length > 0 && decode_error != TCORE_SAT_SUCCESS) || + (!get_input_tlv->rsp_len.max) || (get_input_tlv->rsp_len.min > get_input_tlv->rsp_len.max)){ +#endif + struct treq_sat_terminal_rsp_data tr; + + dbg("get input - invalid parameter of TLVs is found!!"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = get_input_tlv->command_detail.cmd_num; + tr.cmd_type = get_input_tlv->command_detail.cmd_type; + + memcpy((void*) &tr.terminal_rsp_data.get_input.command_detail, + &get_input_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr.terminal_rsp_data.get_input.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.get_input.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.get_input.result_type = RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + + return NULL; + } + + dbg( "[SAT] is SMS7 packing required [%d]",get_input_tlv->command_detail.cmd_qualifier.get_input.user_input_unpacked_format); + + //input mode + input_character_mode = get_input_tlv->command_detail.cmd_qualifier.get_input.alphabet_type; + + //numeric + b_numeric = !get_input_tlv->command_detail.cmd_qualifier.get_input.alphabet_set; + + //help info + b_help_info = get_input_tlv->command_detail.cmd_qualifier.get_input.help_info; + + //echo input + b_echo_input = get_input_tlv->command_detail.cmd_qualifier.get_input.me_echo_user_input; + dbg("numeric (%d), help info(%d), echo input(%d)", b_numeric, b_help_info, b_echo_input); + + //text & text len + if(get_input_tlv->text.string_length){ + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + get_input_tlv->text.dcs.a_format , + (unsigned char*)&get_input_tlv->text.string, + (unsigned short)get_input_tlv->text.string_length); + dbg("get input text(%s)",text); + } + + //response length min & max + rsp_len_min = get_input_tlv->rsp_len.min; + rsp_len_max = get_input_tlv->rsp_len.max; + + /* 27.22.4.3.4 Expected Seq.4.2 */ + if(input_character_mode == INPUT_ALPHABET_TYPE_UCS2 && rsp_len_max > SAT_USC2_INPUT_LEN_MAX) + rsp_len_max = SAT_USC2_INPUT_LEN_MAX; + + //default text & default text len + if(get_input_tlv->default_text.string_length){ + int temp_len = get_input_tlv->default_text.string_length; + if(temp_len > rsp_len_max) { + dbg("get input def_text_len(%d) is larger than rsp_len_max(%d)", temp_len, rsp_len_max); + get_input_tlv->default_text.string_length = rsp_len_max; + } + tcore_util_convert_string_to_utf8((unsigned char*)&def_text,(unsigned short *)&def_text_len, + get_input_tlv->default_text.dcs.a_format , + (unsigned char*)&get_input_tlv->default_text.string, + (unsigned short)get_input_tlv->default_text.string_length); + dbg("get input default text(%s)",def_text); + } + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_GET_INPUT; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.getInputInd), get_input_tlv, sizeof(struct tel_sat_get_input_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(get_input_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", get_input_tlv->icon_id.is_exist, get_input_tlv->icon_id.icon_qualifer, (gint32) get_input_tlv->icon_id.icon_identifier, (gint32) get_input_tlv->icon_id.icon_info.width, + (gint32) get_input_tlv->icon_id.icon_info.height, get_input_tlv->icon_id.icon_info.ics, get_input_tlv->icon_id.icon_info.icon_data_len, get_input_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + get_input = g_variant_new("(iibbbsiiisiv)", command_id, input_character_mode, b_numeric, b_help_info, + b_echo_input, text, text_len, rsp_len_max, rsp_len_min, def_text, def_text_len, icon_id); +#else + get_input = g_variant_new("(iibbbsiiisi)", command_id, input_character_mode, b_numeric, b_help_info, + b_echo_input, text, text_len, rsp_len_max, rsp_len_min, def_text, def_text_len); +#endif + return get_input; +} + +GVariant* sat_manager_play_tone_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_play_tone_tlv* play_tone_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *play_tone = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0, tone_type = 0, duration = 0, tmp_duration = 0; + gushort text_len = 0; + gchar text[SAT_TEXT_STRING_LEN_MAX+1]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting play tone notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX+1); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + //text and text len + if( play_tone_tlv->alpha_id.is_exist && play_tone_tlv->alpha_id.alpha_data_len){ + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + play_tone_tlv->alpha_id.dcs.a_format, + (unsigned char*)&play_tone_tlv->alpha_id.alpha_data, + (unsigned short)play_tone_tlv->alpha_id.alpha_data_len); + dbg("play tone ui display text (%s)",text); + } + + //tone type + tone_type = play_tone_tlv->tone.tone_type; + + //time duration + duration = SAT_TIME_OUT; + tmp_duration = _get_time_in_ms(&play_tone_tlv->duration); + if (tmp_duration > 0) + duration = tmp_duration; + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_PLAY_TONE; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.play_tone), play_tone_tlv, sizeof(struct tel_sat_play_tone_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(play_tone_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", play_tone_tlv->icon_id.is_exist, play_tone_tlv->icon_id.icon_qualifer, (gint32) play_tone_tlv->icon_id.icon_identifier, (gint32) play_tone_tlv->icon_id.icon_info.width, + (gint32) play_tone_tlv->icon_id.icon_info.height, play_tone_tlv->icon_id.icon_info.ics, play_tone_tlv->icon_id.icon_info.icon_data_len, play_tone_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + play_tone = g_variant_new("(isivii)", command_id, text, text_len, icon_id, tone_type, duration); +#else + play_tone = g_variant_new("(isiii)", command_id, text, text_len, tone_type, duration); +#endif + return play_tone; +} + +GVariant* sat_manager_send_sms_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_send_sms_tlv* send_sms_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *send_sms = NULL; + struct sat_manager_queue_data q_data; + + int local_index = 0; + gint command_id = 0, ton = 0, npi = 0, tpdu_type = 0; + gboolean b_packing_required = FALSE; + gushort text_len = 0, number_len = 0, tpdu_data_len= 0; + gchar text[SAT_TEXT_STRING_LEN_MAX], dialling_number[SAT_DIALING_NUMBER_LEN_MAX]; + GVariantBuilder builder; + GVariant *tpdu_data = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting send sms notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&dialling_number, 0 , SAT_DIALING_NUMBER_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + //text and text len + if( send_sms_tlv->alpha_id.is_exist && send_sms_tlv->alpha_id.alpha_data_len){ + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + send_sms_tlv->alpha_id.dcs.a_format, + (unsigned char*)&send_sms_tlv->alpha_id.alpha_data, + (unsigned short)send_sms_tlv->alpha_id.alpha_data_len); + dbg("send sms ui display text (%s)",text); + } + else{ + memcpy(text,"",1); + text_len = 0; + } + + //packing required + b_packing_required = send_sms_tlv->command_detail.cmd_qualifier.send_sms.packing_by_me_required; + + //address : ton, npi, dialling number, number len + ton = send_sms_tlv->address.ton; + npi = send_sms_tlv->address.npi; + number_len = send_sms_tlv->address.dialing_number_len; + memcpy(dialling_number, send_sms_tlv->address.dialing_number, SAT_DIALING_NUMBER_LEN_MAX); + + //tpdu data : type, data, data len + tpdu_type = send_sms_tlv->sms_tpdu.tpdu_type; + tpdu_data_len = send_sms_tlv->sms_tpdu.data_len; + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay")); + for (local_index= 0; local_index < tpdu_data_len; local_index++) { + g_variant_builder_add(&builder, "y", send_sms_tlv->sms_tpdu.data[local_index]); + } + tpdu_data = g_variant_builder_end(&builder); + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_SEND_SMS; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.sendSMSInd), send_sms_tlv, sizeof(struct tel_sat_send_sms_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(send_sms_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", send_sms_tlv->icon_id.is_exist, send_sms_tlv->icon_id.icon_qualifer, (gint32) send_sms_tlv->icon_id.icon_identifier, (gint32) send_sms_tlv->icon_id.icon_info.width, + (gint32) send_sms_tlv->icon_id.icon_info.height, send_sms_tlv->icon_id.icon_info.ics, send_sms_tlv->icon_id.icon_info.icon_data_len, send_sms_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + send_sms = g_variant_new("(isivbiisiivi)", command_id, text, text_len, icon_id, b_packing_required, + ton, npi, dialling_number, number_len, tpdu_type, tpdu_data, tpdu_data_len); +#else + send_sms = g_variant_new("(isibiisiivi)", command_id, text, text_len, b_packing_required, + ton, npi, dialling_number, number_len, tpdu_type, tpdu_data, tpdu_data_len); +#endif + return send_sms; +} + +GVariant* sat_manager_send_ss_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_send_ss_tlv* send_ss_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *send_ss = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0, ton = 0, npi = 0; + gushort text_len = 0; + gint ss_str_len = 0; + gchar text[SAT_TEXT_STRING_LEN_MAX], ss_string[SAT_SS_STRING_LEN_MAX]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting send ss notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&ss_string, 0 , SAT_SS_STRING_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + if(!send_ss_tlv->alpha_id.is_exist && + (send_ss_tlv->icon_id.is_exist && send_ss_tlv->icon_id.icon_qualifer != ICON_QUALI_SELF_EXPLANATORY)){ + struct treq_sat_terminal_rsp_data tr; + dbg("no alpha id and no self explanatory"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = send_ss_tlv->command_detail.cmd_num; + tr.cmd_type = send_ss_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.send_ss.command_detail, &send_ss_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.send_ss.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.send_ss.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.send_ss.result_type = RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + return NULL; + } + + //text and text len + if( send_ss_tlv->alpha_id.is_exist && send_ss_tlv->alpha_id.alpha_data_len){ + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + send_ss_tlv->alpha_id.dcs.a_format, + (unsigned char*)&send_ss_tlv->alpha_id.alpha_data, + (unsigned short)send_ss_tlv->alpha_id.alpha_data_len); + dbg("send ss ui display text (%s)",text); + } + + //ss string: ton, npi, ss string len, ss string + ton = send_ss_tlv->ss_string.ton; + npi = send_ss_tlv->ss_string.npi; + ss_str_len = send_ss_tlv->ss_string.string_len; + memcpy(ss_string, send_ss_tlv->ss_string.ss_string, SAT_SS_STRING_LEN_MAX); + + if(!ss_str_len || (ss_str_len > SAT_SS_STRING_LEN_MAX) ){ + struct treq_sat_terminal_rsp_data tr; + dbg("no ss string"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = send_ss_tlv->command_detail.cmd_num; + tr.cmd_type = send_ss_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.send_ss.command_detail, &send_ss_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.send_ss.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.send_ss.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.send_ss.result_type = RESULT_BEYOND_ME_CAPABILITIES; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + return NULL; + } + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_SEND_SS; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.send_ss), send_ss_tlv, sizeof(struct tel_sat_send_ss_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(send_ss_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", send_ss_tlv->icon_id.is_exist, send_ss_tlv->icon_id.icon_qualifer, (gint32) send_ss_tlv->icon_id.icon_identifier, (gint32) send_ss_tlv->icon_id.icon_info.width, + (gint32) send_ss_tlv->icon_id.icon_info.height, send_ss_tlv->icon_id.icon_info.ics, send_ss_tlv->icon_id.icon_info.icon_data_len, send_ss_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + send_ss = g_variant_new("(isiviiis)", command_id, text, text_len, icon_id, ton, npi, ss_str_len, ss_string); +#else + send_ss = g_variant_new("(isiiiis)", command_id, text, text_len, ton, npi, ss_str_len, ss_string); +#endif + return send_ss; +} + +GVariant* sat_manager_send_ussd_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_send_ussd_tlv* send_ussd_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *send_ussd = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0; + guchar dcs = 0; + gushort text_len = 0, ussd_str_len = 0; + gchar text[SAT_TEXT_STRING_LEN_MAX], ussd_string[SAT_USSD_STRING_LEN_MAX]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting send ussd notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&ussd_string, 0 , SAT_USSD_STRING_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + if(!send_ussd_tlv->alpha_id.is_exist && + (send_ussd_tlv->icon_id.is_exist && send_ussd_tlv->icon_id.icon_qualifer != ICON_QUALI_SELF_EXPLANATORY)){ + struct treq_sat_terminal_rsp_data tr; + dbg("no alpha id and no self explanatory"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = send_ussd_tlv->command_detail.cmd_num; + tr.cmd_type = send_ussd_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.send_ussd.command_detail, &send_ussd_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.send_ussd.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.send_ussd.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.send_ussd.result_type = RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + return NULL; + } + + //text and text len + if( send_ussd_tlv->alpha_id.is_exist && send_ussd_tlv->alpha_id.alpha_data_len){ + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + send_ussd_tlv->alpha_id.dcs.a_format, + (unsigned char*)&send_ussd_tlv->alpha_id.alpha_data, + (unsigned short)send_ussd_tlv->alpha_id.alpha_data_len); + dbg("send ussd ui display text (%s)",text); + } + + //ussd string + dcs = send_ussd_tlv->ussd_string.dsc.raw_dcs; + tcore_util_convert_string_to_utf8((unsigned char*)&ussd_string,(unsigned short *)&ussd_str_len, + send_ussd_tlv->ussd_string.dsc.a_format, + (unsigned char*)&send_ussd_tlv->ussd_string.ussd_string, + (unsigned short)send_ussd_tlv->ussd_string.string_len); + + + if(!ussd_str_len || (ussd_str_len > SAT_USSD_STRING_LEN_MAX) ){ + struct treq_sat_terminal_rsp_data tr; + dbg("no ss string"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = send_ussd_tlv->command_detail.cmd_num; + tr.cmd_type = send_ussd_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.send_ussd.command_detail, &send_ussd_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.send_ussd.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.send_ussd.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.send_ussd.result_type = RESULT_BEYOND_ME_CAPABILITIES; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + return NULL; + } + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_SEND_USSD; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.send_ussd), send_ussd_tlv, sizeof(struct tel_sat_send_ussd_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(send_ussd_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", send_ussd_tlv->icon_id.is_exist, send_ussd_tlv->icon_id.icon_qualifer, (gint32) send_ussd_tlv->icon_id.icon_identifier, (gint32) send_ussd_tlv->icon_id.icon_info.width, + (gint32) send_ussd_tlv->icon_id.icon_info.height, send_ussd_tlv->icon_id.icon_info.ics, send_ussd_tlv->icon_id.icon_info.icon_data_len, send_ussd_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + send_ussd = g_variant_new("(isivyis)", command_id, text, text_len, icon_id, dcs, ussd_str_len, ussd_string); +#else + send_ussd = g_variant_new("(isiyis)", command_id, text, text_len, dcs, ussd_str_len, ussd_string); +#endif + return send_ussd; +} + +GVariant* sat_manager_setup_call_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_setup_call_tlv* setup_call_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *setup_call = NULL; + struct sat_manager_queue_data q_data; + struct treq_sat_terminal_rsp_data tr; + + gushort text_len = 0, confirm_text_len = 0; + gint command_id = 0, call_type = 0, duration = 0; + gchar confirm_text[SAT_TEXT_STRING_LEN_MAX], text[SAT_TEXT_STRING_LEN_MAX], call_number[SAT_DIALING_NUMBER_LEN_MAX]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting setup call notification"); + memset(&confirm_text, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&call_number, 0 , SAT_DIALING_NUMBER_LEN_MAX); + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + if(setup_call_tlv->duration.time_interval > 0) + { + dbg("[SAT] redial is not supported.\n"); + tr.terminal_rsp_data.setup_call.result_type = RESULT_BEYOND_ME_CAPABILITIES; + goto SEND_TR; + } + + //check for subaddress field + if(setup_call_tlv->subaddress.subaddress_len > 0) + { + dbg("[SAT] Sub address is not supported > 0)"); + tr.terminal_rsp_data.setup_call.result_type = RESULT_BEYOND_ME_CAPABILITIES; + goto SEND_TR; + return NULL; + } + + if(setup_call_tlv->command_detail.cmd_qualifier.setup_call.setup_call == SETUP_CALL_IF_ANOTHER_CALL_NOT_BUSY || + setup_call_tlv->command_detail.cmd_qualifier.setup_call.setup_call == SETUP_CALL_IF_ANOTHER_CALL_NOT_BUSY_WITH_REDIAL) + { + GSList *co_list = NULL; + CoreObject *co_call = NULL; + int total_call_cnt = 0; + + co_list = tcore_plugin_get_core_objects_bytype(plg, CORE_OBJECT_TYPE_CALL); + if ( !co_list ) { + dbg("[ error ] co_list : 0"); + tr.terminal_rsp_data.setup_call.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + goto SEND_TR; + } + + co_call = (CoreObject *)co_list->data; + g_slist_free(co_list); + total_call_cnt = tcore_call_object_total_length(co_call); + if (total_call_cnt){ + dbg("[SAT] Another call in progress hence rejecting. total_call_cnt: %d", total_call_cnt); + tr.terminal_rsp_data.setup_call.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr.terminal_rsp_data.setup_call.me_problem_type = ME_PROBLEM_ME_BUSY_ON_CALL; + goto SEND_TR; + } + } + + //call type + call_type = setup_call_tlv->command_detail.cmd_qualifier.setup_call.setup_call; + + //call display data + if(setup_call_tlv->call_setup_alpha_id.alpha_data_len != 0){ + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + setup_call_tlv->call_setup_alpha_id.dcs.a_format, + (unsigned char*)&setup_call_tlv->call_setup_alpha_id.alpha_data, + (unsigned short)setup_call_tlv->call_setup_alpha_id.alpha_data_len); + } + dbg("setup call display text (%s)",text); + + if(setup_call_tlv->user_confirm_alpha_id.alpha_data_len != 0){ + tcore_util_convert_string_to_utf8((unsigned char*)&confirm_text,(unsigned short *)&confirm_text_len, + setup_call_tlv->user_confirm_alpha_id.dcs.a_format, + (unsigned char*)&setup_call_tlv->user_confirm_alpha_id.alpha_data, + (unsigned short)setup_call_tlv->user_confirm_alpha_id.alpha_data_len); + } + + //call number + if(setup_call_tlv->address.ton == TON_INTERNATIONAL){ + call_number[0] = '+'; + memcpy(&call_number[1],setup_call_tlv->address.dialing_number, setup_call_tlv->address.dialing_number_len); + } + else{ + memcpy(call_number,setup_call_tlv->address.dialing_number, setup_call_tlv->address.dialing_number_len); + } + dbg("setup call call number: origin(%s), final(%s)",setup_call_tlv->address.dialing_number, call_number); + + //duration + if(setup_call_tlv->duration.time_interval > 0) + duration = _get_time_in_ms(&setup_call_tlv->duration); + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_SETUP_CALL; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.setup_call), setup_call_tlv, sizeof(struct tel_sat_setup_call_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(setup_call_tlv->call_setup_icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", setup_call_tlv->call_setup_icon_id.is_exist, setup_call_tlv->call_setup_icon_id.icon_qualifer, (gint32) setup_call_tlv->call_setup_icon_id.icon_identifier, (gint32) setup_call_tlv->call_setup_icon_id.icon_info.width, + (gint32) setup_call_tlv->call_setup_icon_id.icon_info.height, setup_call_tlv->call_setup_icon_id.icon_info.ics, setup_call_tlv->call_setup_icon_id.icon_info.icon_data_len, setup_call_tlv->call_setup_icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + setup_call = g_variant_new("(isisivisi)", command_id, confirm_text, confirm_text_len, text, text_len, icon_id, call_type, call_number, duration); +#else + setup_call = g_variant_new("(isisiisi)", command_id, confirm_text, confirm_text_len, text, text_len, call_type, call_number, duration); +#endif + return setup_call; + +SEND_TR: + tr.cmd_number = setup_call_tlv->command_detail.cmd_num; + tr.cmd_type = setup_call_tlv->command_detail.cmd_type; + memcpy((void*)&tr.terminal_rsp_data.setup_call.command_detail, &setup_call_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.setup_call.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.setup_call.device_id.dest = setup_call_tlv->device_id.src; + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + return NULL; +} + +GVariant* sat_manager_setup_event_list_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_setup_event_list_tlv *event_list_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *event_list = NULL; + + int local_index = 0; + gboolean rv = FALSE; + gint event_cnt = 0; + GVariantBuilder builder; + GVariant *evt_list = NULL; + struct treq_sat_terminal_rsp_data *tr = NULL; + + dbg("interpreting event list notification"); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + //event cnt + event_cnt = event_list_tlv->event_list.event_list_cnt; + dbg("event cnt(%d)", event_cnt); + // reset evnet list + memset(g_evt_list, 0, SAT_EVENT_DOWNLOAD_MAX); + + //get event + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ai")); + for (local_index = 0; local_index < event_cnt; local_index++) { + g_variant_builder_add(&builder, "i", event_list_tlv->event_list.evt_list[local_index]); + if(event_list_tlv->event_list.evt_list[local_index] >= SAT_EVENT_DOWNLOAD_MAX) + continue; + g_evt_list[event_list_tlv->event_list.evt_list[local_index]] = TRUE; + } + evt_list = g_variant_builder_end(&builder); + + event_list = g_variant_new("(iv)", event_cnt, evt_list); + + //send TR - does not need from application's response + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = event_list_tlv->command_detail.cmd_num; + tr->cmd_type = event_list_tlv->command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.setup_event_list.command_detail, &event_list_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.setup_event_list.device_id.src = event_list_tlv->device_id.dest; + tr->terminal_rsp_data.setup_event_list.device_id.dest = event_list_tlv->device_id.src; + tr->terminal_rsp_data.setup_event_list.result_type = RESULT_SUCCESS; + tr->terminal_rsp_data.setup_event_list.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + + rv = sat_manager_check_availiable_event_list(event_list_tlv); + dbg("rv of sat_manager_check_availiable_event_list()=[%d]", rv); + + sat_manager_send_terminal_response(ctx->comm, plg, tr); + g_free(tr); + + return event_list; +} + +GVariant* sat_manager_setup_idle_mode_text_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_setup_idle_mode_text_tlv *idle_mode_tlv, int decode_error) +{ + TcorePlugin *plg = NULL; + GVariant *idle_mode = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0; + gushort text_len = 0; + gchar text[SAT_TEXT_STRING_LEN_MAX+1]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting setup idle mode text notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX+1); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + + if(!idle_mode_tlv->text.string_length && decode_error != TCORE_SAT_SUCCESS){ + struct treq_sat_terminal_rsp_data tr; + + dbg("setup idle mode text - invalid parameter of TLVs is found!!"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = idle_mode_tlv->command_detail.cmd_num; + tr.cmd_type = idle_mode_tlv->command_detail.cmd_type; + + memcpy((void*) &tr.terminal_rsp_data.setup_idle_mode_text.command_detail, + &idle_mode_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr.terminal_rsp_data.setup_idle_mode_text.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.setup_idle_mode_text.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.setup_idle_mode_text.result_type = RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + + return NULL; + } + + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + idle_mode_tlv->text.dcs.a_format, + (unsigned char*)&idle_mode_tlv->text.string, + (unsigned short)idle_mode_tlv->text.string_length); + + dbg("setup idle mode text display text (%s)",text); + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.idle_mode), idle_mode_tlv, sizeof(struct tel_sat_setup_idle_mode_text_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(idle_mode_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", idle_mode_tlv->icon_id.is_exist, idle_mode_tlv->icon_id.icon_qualifer, (gint32) idle_mode_tlv->icon_id.icon_identifier, (gint32) idle_mode_tlv->icon_id.icon_info.width, + (gint32) idle_mode_tlv->icon_id.icon_info.height, idle_mode_tlv->icon_id.icon_info.ics, idle_mode_tlv->icon_id.icon_info.icon_data_len, idle_mode_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + idle_mode = g_variant_new("(isiv)", command_id, text, text_len, icon_id); +#else + idle_mode = g_variant_new("(isi)", command_id, text, text_len); +#endif + return idle_mode; +} + +GVariant* sat_manager_open_channel_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_open_channel_tlv *open_channel_tlv) +{ + TcorePlugin *plg = NULL; + CoreObject *co_call = NULL; + CoreObject *co_network = NULL; + + GSList* call_active_list = NULL; + enum telephony_network_access_technology result = 0; + + GVariant *open_channel = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0, bearer_type = 0, protocol_type = 0, dest_addr_type = 0; + gboolean immediate_link = FALSE, auto_reconnection = FALSE, bg_mode = FALSE; + gushort text_len = 0; + gint buffer_size = 0, port_number = 0; + gchar text[SAT_ALPHA_ID_LEN_MAX], dest_address[SAT_OTHER_ADDR_LEN_MAX]; + GVariant *bearer_param = NULL; + GVariant *bearer_detail = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting open channel notification"); + memset(&text, 0 , SAT_ALPHA_ID_LEN_MAX); + memset(&dest_address, 0 , SAT_OTHER_ADDR_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + co_call = tcore_plugin_ref_core_object(plg, CORE_OBJECT_TYPE_CALL); + co_network = tcore_plugin_ref_core_object(plg, CORE_OBJECT_TYPE_NETWORK); + if(!co_call || !co_network){ + struct treq_sat_terminal_rsp_data tr; + dbg("call or network co_obj does not exist"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = open_channel_tlv->command_detail.cmd_num; + tr.cmd_type = open_channel_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.open_channel.command_detail, &open_channel_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.open_channel.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.open_channel.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.open_channel.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr.terminal_rsp_data.open_channel.me_problem_type = ME_PROBLEM_NO_SERVICE; + + memcpy((void*)&tr.terminal_rsp_data.open_channel.bearer_desc, &open_channel_tlv->bearer_desc, sizeof(struct tel_sat_bearer_description)); + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + + return NULL; + } + + call_active_list = tcore_call_object_find_by_status(co_call, TCORE_CALL_STATUS_ACTIVE); + tcore_network_get_access_technology(co_network,&result); + if(result < NETWORK_ACT_UMTS && call_active_list){ + struct treq_sat_terminal_rsp_data tr; + dbg("call is busy in not 3G state atc(%d)", result); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = open_channel_tlv->command_detail.cmd_num; + tr.cmd_type = open_channel_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.open_channel.command_detail, &open_channel_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.open_channel.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.open_channel.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.open_channel.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr.terminal_rsp_data.open_channel.me_problem_type = ME_PROBLEM_ME_BUSY_ON_CALL; + + memcpy((void*)&tr.terminal_rsp_data.open_channel.bearer_desc, &open_channel_tlv->bearer_desc, sizeof(struct tel_sat_bearer_description)); + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + g_slist_free(call_active_list); + return NULL; + } + + + //immediate link + immediate_link = open_channel_tlv->command_detail.cmd_qualifier.open_channel.immediate_link; + + //auto reconnection + auto_reconnection = open_channel_tlv->command_detail.cmd_qualifier.open_channel.automatic_reconnection; + + //back ground mode + bg_mode = open_channel_tlv->command_detail.cmd_qualifier.open_channel.background_mode; + + //open channel text + if(open_channel_tlv->alpha_id.is_exist && open_channel_tlv->alpha_id.alpha_data_len > 0) + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + open_channel_tlv->alpha_id.dcs.a_format, + (unsigned char*)&open_channel_tlv->alpha_id.alpha_data, + (unsigned short)open_channel_tlv->alpha_id.alpha_data_len); + dbg("open channel text(%s)",text); + + //buffer size + buffer_size = open_channel_tlv->buffer_size.size[0]; + buffer_size = buffer_size << 8; + buffer_size += open_channel_tlv->buffer_size.size[1]; + //memcpy(&buffer_size, open_channel_tlv->buffer_size.size, sizeof(unsigned char)*2); + dbg("buffer size(%d)", buffer_size); + + //interface transport level + protocol_type = open_channel_tlv->interface_transport_level.protocol_type; + port_number = open_channel_tlv->interface_transport_level.port_number; + + //data destination address + dest_addr_type = open_channel_tlv->data_destination_address.address_type; + memcpy(dest_address, open_channel_tlv->data_destination_address.address, + open_channel_tlv->data_destination_address.address_len); + dbg("destination IP address (%s)", dest_address); + + //bearer type + bearer_type = open_channel_tlv->bearer_desc.bearer_type; + + //bearer param & bearer detail + switch(bearer_type){ + case BEARER_CSD:{ + //bearer param + gint data_rate = 0, service_type = 0, conn_element_type = 0; + + //bearer detail + gint ton = 0, npi = 0, time_duration1 = 0, time_duration2 = 0, other_addr_type = 0; + gushort login_len = 0, pwd_len = 0; + gchar dialling_number[SAT_DIALING_NUMBER_LEN_MAX], sub_addr[SAT_SUB_ADDR_LEN_MAX]; + gchar other_address[SAT_OTHER_ADDR_LEN_MAX]; + gchar login[SAT_TEXT_STRING_LEN_MAX], pwd[SAT_TEXT_STRING_LEN_MAX]; + + memset(&dialling_number, 0 , SAT_DIALING_NUMBER_LEN_MAX); + memset(&sub_addr, 0 , SAT_SUB_ADDR_LEN_MAX); + memset(&other_address, 0 , SAT_OTHER_ADDR_LEN_MAX); + memset(&login, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&pwd, 0 , SAT_TEXT_STRING_LEN_MAX); + + //bearer parameter + data_rate = open_channel_tlv->bearer_desc.bearer_parameter.cs_bearer_param.data_rate; + service_type = open_channel_tlv->bearer_desc.bearer_parameter.cs_bearer_param.service_type; + conn_element_type = open_channel_tlv->bearer_desc.bearer_parameter.cs_bearer_param.connection_element_type; + + bearer_param = g_variant_new("(iii)", data_rate, service_type, conn_element_type); + + //bearer detail + ton = open_channel_tlv->bearer_detail.cs_bearer.address.ton; + npi = open_channel_tlv->bearer_detail.cs_bearer.address.npi; + memcpy(dialling_number, open_channel_tlv->bearer_detail.cs_bearer.address.dialing_number, open_channel_tlv->bearer_detail.cs_bearer.address.dialing_number_len); + + memcpy(sub_addr, open_channel_tlv->bearer_detail.cs_bearer.subaddress.subaddress, open_channel_tlv->bearer_detail.cs_bearer.subaddress.subaddress_len); + + time_duration1 = _get_time_in_ms(&open_channel_tlv->bearer_detail.cs_bearer.duration1); + time_duration2 = _get_time_in_ms(&open_channel_tlv->bearer_detail.cs_bearer.duration2); + + other_addr_type = open_channel_tlv->bearer_detail.cs_bearer.other_address.address_type; + memcpy(other_address, open_channel_tlv->bearer_detail.cs_bearer.other_address.address, open_channel_tlv->bearer_detail.cs_bearer.other_address.address_len); + + tcore_util_convert_string_to_utf8((unsigned char*) &login, (unsigned short *) &login_len, + open_channel_tlv->bearer_detail.cs_bearer.text_user_login.dcs.a_format, + (unsigned char*) &open_channel_tlv->bearer_detail.cs_bearer.text_user_login.string, + (unsigned short) open_channel_tlv->bearer_detail.cs_bearer.text_user_login.string_length); + + tcore_util_convert_string_to_utf8((unsigned char*) &pwd, (unsigned short *) &pwd_len, + open_channel_tlv->bearer_detail.cs_bearer.text_user_pwd.dcs.a_format, + (unsigned char*) &open_channel_tlv->bearer_detail.cs_bearer.text_user_pwd.string, + (unsigned short) open_channel_tlv->bearer_detail.cs_bearer.text_user_pwd.string_length); + + bearer_detail= g_variant_new("(iissiiisss)", ton, npi, dialling_number, sub_addr, time_duration1, time_duration2, + other_addr_type, other_address, login, pwd); + } break; + case BEARER_GPRS:{ + //bearer param + gint precedence_class = 0, delay_class = 0, reliability_class = 0; + gint peak_class = 0, mean_class = 0, pdp_type = 0; + + //bearer detail + gint other_addr_type = 0; + gushort login_len = 0, pwd_len = 0; + gchar network_access_name[SAT_NET_ACC_NAM_LEN_MAX]; + gchar other_address[SAT_OTHER_ADDR_LEN_MAX]; + gchar login[SAT_TEXT_STRING_LEN_MAX], pwd[SAT_TEXT_STRING_LEN_MAX]; + + memset(&network_access_name, 0 , SAT_NET_ACC_NAM_LEN_MAX); + memset(&other_address, 0 , SAT_OTHER_ADDR_LEN_MAX); + memset(&login, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&pwd, 0 , SAT_TEXT_STRING_LEN_MAX); + + //bearer parameter + precedence_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.precedence_class; + delay_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.delay_class; + reliability_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.reliability_class; + peak_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.peak_throughput_class; + mean_class = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.mean_throughput_class; + pdp_type = open_channel_tlv->bearer_desc.bearer_parameter.ps_bearer_param.pdp_type; + + bearer_param = g_variant_new("(iiiiii)", precedence_class, delay_class, reliability_class, peak_class, mean_class, pdp_type); + + memcpy(network_access_name, open_channel_tlv->bearer_detail.ps_bearer.network_access_name.network_access_name, + open_channel_tlv->bearer_detail.ps_bearer.network_access_name.length); + other_addr_type = open_channel_tlv->bearer_detail.ps_bearer.other_address.address_type; + memcpy(other_address, open_channel_tlv->bearer_detail.ps_bearer.other_address.address, open_channel_tlv->bearer_detail.ps_bearer.other_address.address_len); + + tcore_util_convert_string_to_utf8((unsigned char*) &login, (unsigned short *) &login_len, + open_channel_tlv->bearer_detail.ps_bearer.text_user_login.dcs.a_format, + (unsigned char*) &open_channel_tlv->bearer_detail.ps_bearer.text_user_login.string, + (unsigned short) open_channel_tlv->bearer_detail.ps_bearer.text_user_login.string_length); + + tcore_util_convert_string_to_utf8((unsigned char*) &pwd, (unsigned short *) &pwd_len, + open_channel_tlv->bearer_detail.ps_bearer.text_user_pwd.dcs.a_format, + (unsigned char*) &open_channel_tlv->bearer_detail.ps_bearer.text_user_pwd.string, + (unsigned short) open_channel_tlv->bearer_detail.ps_bearer.text_user_pwd.string_length); + + bearer_detail= g_variant_new("(sisss)", network_access_name, other_addr_type, other_address, login, pwd); + + } break; + case BEARER_DEFAULT_BEARER_FROM_TRANSPORT_LAYER:{ + //bearer param + + //bearer detail + gint other_addr_type = 0; + gushort login_len = 0, pwd_len = 0; + gchar other_address[SAT_OTHER_ADDR_LEN_MAX]; + gchar login[SAT_TEXT_STRING_LEN_MAX], pwd[SAT_TEXT_STRING_LEN_MAX]; + + memset(&other_address, 0 , SAT_OTHER_ADDR_LEN_MAX); + memset(&login, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&pwd, 0 , SAT_TEXT_STRING_LEN_MAX); + + //bearer parameter + bearer_param = g_variant_new("()"); + + other_addr_type = open_channel_tlv->bearer_detail.default_bearer.other_address.address_type; + memcpy(other_address, open_channel_tlv->bearer_detail.default_bearer.other_address.address, open_channel_tlv->bearer_detail.default_bearer.other_address.address_len); + + tcore_util_convert_string_to_utf8((unsigned char*) &login, (unsigned short *) &login_len, + open_channel_tlv->bearer_detail.default_bearer.text_user_login.dcs.a_format, + (unsigned char*) &open_channel_tlv->bearer_detail.default_bearer.text_user_login.string, + (unsigned short) open_channel_tlv->bearer_detail.default_bearer.text_user_login.string_length); + + tcore_util_convert_string_to_utf8((unsigned char*) &pwd, (unsigned short *) &pwd_len, + open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.dcs.a_format, + (unsigned char*) &open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.string, + (unsigned short) open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.string_length); + + bearer_detail= g_variant_new("(isss)", other_addr_type, other_address, login, pwd); + + } break; + case BEARER_LOCAL_LINK_TECHNOLOGY_INDEPENDENT:{ + //bearer param + + //bearer detail + gushort pwd_len = 0; + gint remote_address_type =0, time_duration1 = 0, time_duration2 = 0; + gchar remote_address[SAT_REMOTE_ENTITY_ADDR_LEN_MAX]; + gchar pwd[SAT_TEXT_STRING_LEN_MAX]; + + memset(&remote_address, 0 , SAT_REMOTE_ENTITY_ADDR_LEN_MAX); + memset(&pwd, 0 , SAT_TEXT_STRING_LEN_MAX); + + //bearer parameter + bearer_param = g_variant_new("()"); + + time_duration1 = _get_time_in_ms(&open_channel_tlv->bearer_detail.local_bearer.duration1); + time_duration2 = _get_time_in_ms(&open_channel_tlv->bearer_detail.local_bearer.duration2); + + tcore_util_convert_string_to_utf8((unsigned char*) &pwd, (unsigned short *) &pwd_len, + open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.dcs.a_format, + (unsigned char*) &open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.string, + (unsigned short) open_channel_tlv->bearer_detail.default_bearer.text_user_pwd.string_length); + + remote_address_type = open_channel_tlv->bearer_detail.local_bearer.remote_entity_address.coding_type; + memcpy(remote_address, open_channel_tlv->bearer_detail.local_bearer.remote_entity_address.remote_entity_address, open_channel_tlv->bearer_detail.local_bearer.remote_entity_address.length); + + bearer_detail= g_variant_new("(iisis)", time_duration1, time_duration2, pwd, remote_address_type, remote_address); + + } break; + default: + dbg("invalid bearer data"); + return NULL; + }//end of switch + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_OPEN_CHANNEL; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.open_channel), open_channel_tlv, sizeof(struct tel_sat_open_channel_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_STK_HIDE_ALPHA_ID) + dbg("orange request - do not show the popup"); + _sat_manager_handle_open_channel_confirm(ctx, plg, command_id, USER_CONFIRM_YES, NULL); + return open_channel; +#endif + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(open_channel_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", open_channel_tlv->icon_id.is_exist, open_channel_tlv->icon_id.icon_qualifer, (gint32) open_channel_tlv->icon_id.icon_identifier, (gint32) open_channel_tlv->icon_id.icon_info.width, + (gint32) open_channel_tlv->icon_id.icon_info.height, open_channel_tlv->icon_id.icon_info.ics, open_channel_tlv->icon_id.icon_info.icon_data_len, open_channel_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + //execute bip + //sat_ui_support_exec_bip(); + + open_channel = g_variant_new("(isivbbbiviiiisv)", command_id, text, text_len, icon_id, immediate_link, auto_reconnection, bg_mode, + bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail); +#else + open_channel = g_variant_new("(isibbbiviiiisv)", command_id, text, text_len, immediate_link, auto_reconnection, bg_mode, + bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail); +#endif + return open_channel; +} + +GVariant* sat_manager_close_channel_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_close_channel_tlv *close_channel_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *close_channel = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0, channel_id = 0; + gushort text_len = 0; + gchar text[SAT_ALPHA_ID_LEN_MAX]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting close channel notification"); + memset(&text, 0 , SAT_ALPHA_ID_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + //channel id + channel_id = close_channel_tlv->device_id.dest; + + //close channel text + if(close_channel_tlv->alpha_id.is_exist && close_channel_tlv->alpha_id.alpha_data_len > 0) + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + close_channel_tlv->alpha_id.dcs.a_format, + (unsigned char*)&close_channel_tlv->alpha_id.alpha_data, + (unsigned short)close_channel_tlv->alpha_id.alpha_data_len); + dbg("close channel text(%s)",text); + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_CLOSE_CHANNEL; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.close_channel), close_channel_tlv, sizeof(struct tel_sat_close_channel_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(close_channel_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", close_channel_tlv->icon_id.is_exist, close_channel_tlv->icon_id.icon_qualifer, (gint32) close_channel_tlv->icon_id.icon_identifier, (gint32) close_channel_tlv->icon_id.icon_info.width, + (gint32) close_channel_tlv->icon_id.icon_info.height, close_channel_tlv->icon_id.icon_info.ics, close_channel_tlv->icon_id.icon_info.icon_data_len, close_channel_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + close_channel = g_variant_new("(isivi)", command_id, text, text_len, icon_id, channel_id); +#else + close_channel = g_variant_new("(isii)", command_id, text, text_len, channel_id); +#endif + return close_channel; +} + +GVariant* sat_manager_receive_data_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_receive_channel_tlv *receive_data_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *receive_data = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0, channel_id = 0; + gushort text_len = 0; + gint channel_data_len = 0; + gchar text[SAT_ALPHA_ID_LEN_MAX]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting receive data notification"); + memset(&text, 0 , SAT_ALPHA_ID_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + //channel id + channel_id = receive_data_tlv->device_id.dest; + + //receive data text + if(receive_data_tlv->alpha_id.is_exist && receive_data_tlv->alpha_id.alpha_data_len > 0) + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + receive_data_tlv->alpha_id.dcs.a_format, + (unsigned char*)&receive_data_tlv->alpha_id.alpha_data, + (unsigned short)receive_data_tlv->alpha_id.alpha_data_len); + dbg("receive data text(%s)",text); + + channel_data_len = receive_data_tlv->channel_data_len.data_len; + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_RECEIVE_DATA; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.receive_data), receive_data_tlv, sizeof(struct tel_sat_receive_channel_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(receive_data_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", receive_data_tlv->icon_id.is_exist, receive_data_tlv->icon_id.icon_qualifer, (gint32) receive_data_tlv->icon_id.icon_identifier, (gint32) receive_data_tlv->icon_id.icon_info.width, + (gint32) receive_data_tlv->icon_id.icon_info.height, receive_data_tlv->icon_id.icon_info.ics, receive_data_tlv->icon_id.icon_info.icon_data_len, receive_data_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + receive_data = g_variant_new("(isivii)", command_id, text, text_len, icon_id, channel_id, channel_data_len); +#else + receive_data = g_variant_new("(isiii)", command_id, text, text_len, channel_id, channel_data_len); +#endif + return receive_data; +} + +GVariant* sat_manager_send_data_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_send_channel_tlv *send_data_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *send_data = NULL; + struct sat_manager_queue_data q_data; + + int local_index = 0; + gint command_id = 0, channel_id = 0, data_len = 0; + gboolean send_data_immediately = FALSE; + gushort text_len = 0; + gchar text[SAT_ALPHA_ID_LEN_MAX]; + GVariantBuilder builder; + GVariant *channel_data = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting send data notification"); + memset(&text, 0 , SAT_ALPHA_ID_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + //send data immediately + send_data_immediately = send_data_tlv->command_detail.cmd_qualifier.send_data.send_data_immediately; + + //channel id + channel_id = send_data_tlv->device_id.dest; + + //send data text + if(send_data_tlv->alpha_id.is_exist && send_data_tlv->alpha_id.alpha_data_len > 0) + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + send_data_tlv->alpha_id.dcs.a_format, + (unsigned char*)&send_data_tlv->alpha_id.alpha_data, + (unsigned short)send_data_tlv->alpha_id.alpha_data_len); + dbg("send data text(%s)",text); + + //channel data, data len + data_len = send_data_tlv->channel_data.data_string_len; + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay")); + for (local_index = 0; local_index < data_len; local_index++) { + //dbg("send data index(%d) data(0x%x)",index, send_data_tlv->channel_data.data_string[index]); + g_variant_builder_add(&builder, "y", send_data_tlv->channel_data.data_string[local_index]); + } + channel_data = g_variant_builder_end(&builder); + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_SEND_DATA; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.send_data), send_data_tlv, sizeof(struct tel_sat_send_channel_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(send_data_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", send_data_tlv->icon_id.is_exist, send_data_tlv->icon_id.icon_qualifer, (gint32) send_data_tlv->icon_id.icon_identifier, (gint32) send_data_tlv->icon_id.icon_info.width, + (gint32) send_data_tlv->icon_id.icon_info.height, send_data_tlv->icon_id.icon_info.ics, send_data_tlv->icon_id.icon_info.icon_data_len, send_data_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + send_data = g_variant_new("(isivibvi)", command_id, text, text_len, icon_id, channel_id, send_data_immediately, channel_data, data_len); +#else + send_data = g_variant_new("(isiibvi)", command_id, text, text_len, channel_id, send_data_immediately, channel_data, data_len); +#endif + return send_data; +} + +GVariant* sat_manager_get_channel_status_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_get_channel_status_tlv *get_channel_status_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *get_channel_status = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0; + + dbg("interpreting get channel status notification"); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_GET_CHANNEL_STATUS; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.get_channel_status), get_channel_status_tlv, sizeof(struct tel_sat_get_channel_status_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + + get_channel_status = g_variant_new("(i)", command_id); + + return get_channel_status; +} + +GVariant* sat_manager_refresh_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_refresh_tlv *refresh_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *refresh = NULL; +#if !defined(TIZEN_SUPPORT_STK_HIDE_ALPHA_ID) + struct sat_manager_queue_data q_data; +#endif + + gint command_id = 0; + gint refresh_type =0; + GVariantBuilder builder; + GVariant *file_list = NULL; + int local_index = 0; + + dbg("interpreting refresh notification"); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + refresh_type = refresh_tlv->command_detail.cmd_qualifier.refresh.refresh; + + if(refresh_type != SIM_REFRESH_CMD_FCN) { + dbg("reset event list."); + memset(g_evt_list, 0, SAT_EVENT_DOWNLOAD_MAX); + } + + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ai")); + for (local_index = 0; local_index < refresh_tlv->file_list.file_count; local_index++) { + g_variant_builder_add(&builder, "i", refresh_tlv->file_list.file_id[local_index]); + } + file_list = g_variant_builder_end(&builder); + + //enqueue data and generate cmd_id +#if !defined(TIZEN_SUPPORT_STK_HIDE_ALPHA_ID) + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_REFRESH; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.refresh), refresh_tlv, sizeof(struct tel_sat_refresh_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; +#endif + + refresh = g_variant_new("(iiv)", command_id, refresh_type, file_list); + + return refresh; +} + +void sat_manager_more_time_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_more_time_tlv *more_time_tlv) +{ + TcorePlugin *plg = NULL; + struct treq_sat_terminal_rsp_data *tr = NULL; + + dbg("interpreting more time notification"); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return; + } + + //send TR - does not need from application's response + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return; + + tr->cmd_number = more_time_tlv->command_detail.cmd_num; + tr->cmd_type = more_time_tlv->command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.more_time.command_detail, &more_time_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.more_time.device_id.src = more_time_tlv->device_id.dest; + tr->terminal_rsp_data.more_time.device_id.dest = more_time_tlv->device_id.src; + tr->terminal_rsp_data.more_time.result_type = RESULT_SUCCESS; + tr->terminal_rsp_data.more_time.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + + sat_manager_send_terminal_response(ctx->comm, plg, tr); + g_free(tr); + + return; +} + +GVariant* sat_manager_send_dtmf_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_send_dtmf_tlv *send_dtmf_tlv) +{ + TcorePlugin *plg = NULL; + CoreObject *co_call = NULL; + GSList* call_active_list = NULL; + + GVariant *send_dtmf = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0; + gushort text_len =0; + gint dtmf_str_len =0; + gchar text[SAT_TEXT_STRING_LEN_MAX], dtmf_str[SAT_DTMF_STRING_LEN_MAX]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting send dtmf notification"); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&dtmf_str, 0 , SAT_DTMF_STRING_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + co_call = tcore_plugin_ref_core_object(plg, CORE_OBJECT_TYPE_CALL); + if(!co_call){ + struct treq_sat_terminal_rsp_data tr; + dbg("call object does not exist"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = send_dtmf_tlv->command_detail.cmd_num; + tr.cmd_type = send_dtmf_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.send_dtmf.command_detail, &send_dtmf_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.send_dtmf.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.send_dtmf.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.send_dtmf.result_type = RESULT_BEYOND_ME_CAPABILITIES; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + return NULL; + } + + call_active_list = tcore_call_object_find_by_status(co_call, TCORE_CALL_STATUS_ACTIVE); + if(!call_active_list){ + struct treq_sat_terminal_rsp_data tr; + dbg("no active call"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = send_dtmf_tlv->command_detail.cmd_num; + tr.cmd_type = send_dtmf_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.send_dtmf.command_detail, &send_dtmf_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.send_dtmf.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.send_dtmf.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.send_dtmf.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr.terminal_rsp_data.send_dtmf.me_problem_type = ME_PROBLEM_NOT_IN_SPEECH_CALL; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + return NULL; + } + g_slist_free(call_active_list); + + //text and text len + if( send_dtmf_tlv->alpha_id.is_exist && send_dtmf_tlv->alpha_id.alpha_data_len){ + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + send_dtmf_tlv->alpha_id.dcs.a_format, + (unsigned char*)&send_dtmf_tlv->alpha_id.alpha_data, + (unsigned short)send_dtmf_tlv->alpha_id.alpha_data_len); + dbg("send dtmf ui display text (%s)",text); + } + + //dtmf string len, dtmf string + dtmf_str_len = send_dtmf_tlv->dtmf_string.dtmf_length; + memcpy(dtmf_str, send_dtmf_tlv->dtmf_string.dtmf_string, SAT_DTMF_STRING_LEN_MAX); + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_SEND_DTMF; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.send_dtmf), send_dtmf_tlv, sizeof(struct tel_sat_send_dtmf_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(send_dtmf_tlv->icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", send_dtmf_tlv->icon_id.is_exist, send_dtmf_tlv->icon_id.icon_qualifer, (gint32) send_dtmf_tlv->icon_id.icon_identifier, (gint32) send_dtmf_tlv->icon_id.icon_info.width, + (gint32) send_dtmf_tlv->icon_id.icon_info.height, send_dtmf_tlv->icon_id.icon_info.ics, send_dtmf_tlv->icon_id.icon_info.icon_data_len, send_dtmf_tlv->icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + send_dtmf = g_variant_new("(isivis)", command_id, text, text_len, icon_id, dtmf_str_len, dtmf_str); +#else + send_dtmf = g_variant_new("(isiis)", command_id, text, text_len, dtmf_str_len, dtmf_str); +#endif + return send_dtmf; +} + +GVariant* sat_manager_launch_browser_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_launch_browser_tlv *launch_browser_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *launch_browser = NULL; + struct sat_manager_queue_data q_data; + +#if GCF_SAT_BROWSER_WITH_SINGLE_SESSION + gboolean b_app_running = FALSE; +#endif + gint command_id = 0; + gint browser_launch_type = 0, browser_id = 0; + gint url_len =0; + gushort text_len =0, gateway_proxy_len =0; + gchar url[SAT_URL_LEN_MAX], text[SAT_TEXT_STRING_LEN_MAX], gateway_proxy[SAT_TEXT_STRING_LEN_MAX]; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariantBuilder v_builder_icon; +#endif + dbg("interpreting launch browser notification"); + memset(&url, 0 , SAT_URL_LEN_MAX); + memset(&text, 0 , SAT_TEXT_STRING_LEN_MAX); + memset(&gateway_proxy, 0 , SAT_TEXT_STRING_LEN_MAX); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + if(!launch_browser_tlv->user_confirm_alpha_id.is_exist && + (launch_browser_tlv->user_confirm_icon_id.is_exist && launch_browser_tlv->user_confirm_icon_id.icon_qualifer != ICON_QUALI_SELF_EXPLANATORY)){ + struct treq_sat_terminal_rsp_data tr; + dbg("no alpha id and no self explanatory"); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = launch_browser_tlv->command_detail.cmd_num; + tr.cmd_type = launch_browser_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.launch_browser.command_detail, &launch_browser_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.launch_browser.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.launch_browser.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.launch_browser.result_type = RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + return NULL; + } + +#if GCF_SAT_BROWSER_WITH_SINGLE_SESSION + b_app_running = sat_ui_check_app_is_running("org.tizen.browser"); +#endif + //browser launch type + browser_launch_type = launch_browser_tlv->command_detail.cmd_qualifier.launch_browser.launch_browser; + + /* ORA PLM P131004-00081:Launch browser while session already opened. + * Tizen-SAT looks at command qualifier only when ME in GCF mode. + * + * 2013.12.10 : Now, GCF certificate permits device option that "Terminal supports + * browser with multiple sessions/taps" so we don't need GCF feature anymore and + * therefore disabled here. + */ +#if GCF_SAT_BROWSER_WITH_SINGLE_SESSION + if(browser_launch_type == LAUNCH_BROWSER_IF_NOT_ALREADY_LAUNCHED && b_app_running){ + struct treq_sat_terminal_rsp_data tr; + dbg("browser is already running type(%d)", browser_launch_type); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = launch_browser_tlv->command_detail.cmd_num; + tr.cmd_type = launch_browser_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.launch_browser.command_detail, &launch_browser_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.launch_browser.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.launch_browser.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.launch_browser.result_type = RESULT_LAUNCH_BROWSER_GENERIC_ERROR_CODE; + tr.terminal_rsp_data.launch_browser.browser_problem_type = BROWSER_PROBLEM_BROWSER_UNAVAILABLE; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + + return NULL; + } + else if( (browser_launch_type == LAUNCH_BROWSER_USE_EXISTING_BROWSER || browser_launch_type == LAUNCH_BROWSER_CLOSE_AND_LAUNCH_NEW_BROWSER) && !b_app_running){ + struct treq_sat_terminal_rsp_data tr; + dbg("browser is not running type(%d)", browser_launch_type); + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = launch_browser_tlv->command_detail.cmd_num; + tr.cmd_type = launch_browser_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.launch_browser.command_detail, &launch_browser_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.launch_browser.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.launch_browser.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.launch_browser.result_type = RESULT_LAUNCH_BROWSER_GENERIC_ERROR_CODE; + tr.terminal_rsp_data.launch_browser.browser_problem_type = BROWSER_PROBLEM_BROWSER_UNAVAILABLE; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + + return NULL; + } +#endif + + //browser id + browser_id = launch_browser_tlv->browser_id; + + //url and url len + if( launch_browser_tlv->url.url_length){ + url_len = launch_browser_tlv->url.url_length; + memcpy(url, launch_browser_tlv->url.url, launch_browser_tlv->url.url_length); + dbg("launch browser url (%s)",url); + } + + //gateway_proxy_text + if(launch_browser_tlv->gateway_proxy_text.is_digit_only) { + memcpy(gateway_proxy, launch_browser_tlv->gateway_proxy_text.string, launch_browser_tlv->gateway_proxy_text.string_length); + dbg("launch browser gateway_proxy digit type string (%s)",gateway_proxy); + } else { + if( launch_browser_tlv->gateway_proxy_text.string_length){ + tcore_util_convert_string_to_utf8((unsigned char*)&gateway_proxy,(unsigned short *)&gateway_proxy_len, + launch_browser_tlv->gateway_proxy_text.dcs.a_format, + (unsigned char*)&launch_browser_tlv->gateway_proxy_text.string, + (unsigned short)launch_browser_tlv->gateway_proxy_text.string_length); + dbg("launch browser gateway_proxy_text (%s)",gateway_proxy); + } + } + + //user confirm text and user confirm text len + if( launch_browser_tlv->user_confirm_alpha_id.is_exist && launch_browser_tlv->user_confirm_alpha_id.alpha_data_len){ + tcore_util_convert_string_to_utf8((unsigned char*)&text,(unsigned short *)&text_len, + launch_browser_tlv->user_confirm_alpha_id.dcs.a_format, + (unsigned char*)&launch_browser_tlv->user_confirm_alpha_id.alpha_data, + (unsigned short)launch_browser_tlv->user_confirm_alpha_id.alpha_data_len); + dbg("launch browser user confirm text (%s)",text); + } + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_LAUNCH_BROWSER; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.launch_browser), launch_browser_tlv, sizeof(struct tel_sat_launch_browser_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + /* Icon data extraction */ + g_variant_builder_init(&v_builder_icon, G_VARIANT_TYPE ("a(biiiiiis)")); + if(launch_browser_tlv->user_confirm_icon_id.is_exist) { + g_variant_builder_add(&v_builder_icon, "(biiiiiis)", launch_browser_tlv->user_confirm_icon_id.is_exist, launch_browser_tlv->user_confirm_icon_id.icon_qualifer, (gint32) launch_browser_tlv->user_confirm_icon_id.icon_identifier, (gint32) launch_browser_tlv->user_confirm_icon_id.icon_info.width, + (gint32) launch_browser_tlv->user_confirm_icon_id.icon_info.height, launch_browser_tlv->user_confirm_icon_id.icon_info.ics, launch_browser_tlv->user_confirm_icon_id.icon_info.icon_data_len, launch_browser_tlv->user_confirm_icon_id.icon_info.icon_file); + } + icon_id = g_variant_builder_end(&v_builder_icon); + + launch_browser = g_variant_new("(iiisisisiv)", + command_id, browser_launch_type, browser_id, url, url_len, gateway_proxy, gateway_proxy_len, text, text_len, icon_id); +#else + launch_browser = g_variant_new("(iiisisisi)", + command_id, browser_launch_type, browser_id, url, url_len, gateway_proxy, gateway_proxy_len, text, text_len); +#endif + return launch_browser; +} + +GVariant* sat_manager_provide_local_info_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_provide_local_info_tlv *provide_local_info_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *provide_info = NULL; + + gint info_type =0; + struct treq_sat_terminal_rsp_data *tr = NULL; + + dbg("interpreting provide local info notification"); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + provide_info = g_variant_new("(i)", info_type); + + //send TR - does not need from application's response + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return NULL; + + tr->cmd_number = provide_local_info_tlv->command_detail.cmd_num; + tr->cmd_type = provide_local_info_tlv->command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.provide_local_info.command_detail, &provide_local_info_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.provide_local_info.device_id.src = provide_local_info_tlv->device_id.dest; + tr->terminal_rsp_data.provide_local_info.device_id.dest = provide_local_info_tlv->device_id.src; + tr->terminal_rsp_data.provide_local_info.other_info = TRUE; + + info_type = provide_local_info_tlv->command_detail.cmd_qualifier.provide_local_info.provide_local_info; + + switch(info_type){ + case LOCAL_INFO_DATE_TIME_AND_TIMEZONE:{ + int err = 0; int gmt = 0, n_flg = 0; + struct timezone c_tz; + struct timeval c_time; + + time_t time_val; + struct tm time_info; + + time(&time_val); + + tzset(); + err = gettimeofday(&c_time, &c_tz); + localtime_r(&time_val, &time_info); + + //set the time information + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.year = + _convert_decimal_to_bcd(time_info.tm_year+1900-2000); + + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.month = + _convert_decimal_to_bcd(time_info.tm_mon+1); + + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.day = + _convert_decimal_to_bcd(time_info.tm_mday); + + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.hour = + _convert_decimal_to_bcd(time_info.tm_hour); + + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.minute = + _convert_decimal_to_bcd(time_info.tm_min); + + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.second = + _convert_decimal_to_bcd(time_info.tm_sec); + + gmt = c_tz.tz_minuteswest/60; + if(gmt < 0){ + gmt = gmt * -1; + n_flg = 1; + } + + if(err != 0){ + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.timeZone = 0xFF; + } + else{ + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.timeZone = + _convert_decimal_to_bcd(gmt); + + if(n_flg == 1){ + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.timeZone += 0x80; + } + + if(time_info.tm_isdst > 0){ + tr->terminal_rsp_data.provide_local_info.other.date_time_and_timezone.timeZone += 0x40; + } + } + + tr->terminal_rsp_data.provide_local_info.result_type = RESULT_SUCCESS; + tr->terminal_rsp_data.provide_local_info.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + } break; + case LOCAL_INFO_LANGUAGE:{ + Server *s = NULL; + static Storage *strg; + gchar *lang_str = NULL; + enum tel_sim_language_type lang_type = SIM_LANG_UNSPECIFIED; + + tr->terminal_rsp_data.provide_local_info.result_type = RESULT_SUCCESS; + tr->terminal_rsp_data.provide_local_info.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + + s = ctx->server; + strg = tcore_server_find_storage(s, "vconf"); + lang_str = tcore_storage_get_string(strg, STORAGE_KEY_LANGUAGE_SET); + if(lang_str) + lang_type = _convert_string_to_sim_lang(lang_str); + + tr->terminal_rsp_data.provide_local_info.other.language = lang_type; + } break; + default :{ + tr->terminal_rsp_data.provide_local_info.other_info = FALSE; + tr->terminal_rsp_data.provide_local_info.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.provide_local_info.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + } break; + } + + sat_manager_send_terminal_response(ctx->comm, plg, tr); + g_free(tr); + + return provide_info; +} + +GVariant* sat_manager_language_notification_noti(struct custom_data *ctx, const char *cp_name, struct tel_sat_language_notification_tlv *language_notification_tlv) +{ + TcorePlugin *plg = NULL; + GVariant *language_noti = NULL; + struct sat_manager_queue_data q_data; + + gint command_id = 0; + gint language =0; + gboolean b_specified = FALSE; + + dbg("interpreting langauge notification"); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return NULL; + } + + if (language_notification_tlv->command_detail.cmd_qualifier.language_notification.specific_language == TRUE){ + b_specified = TRUE; + language = language_notification_tlv->language; + } else { + b_specified = FALSE; + language =SIM_LANG_UNSPECIFIED; + } + + //enqueue data and generate cmd_id + memset(&q_data, 0x00, sizeof(struct sat_manager_queue_data)); + q_data.cmd_type = SAT_PROATV_CMD_LANGUAGE_NOTIFICATION; + q_data.cp_name = g_strdup(cp_name); + memcpy((void*)&(q_data.cmd_data.language_notification), language_notification_tlv, sizeof(struct tel_sat_language_notification_tlv)); + if(FALSE == sat_manager_enqueue_cmd(ctx, &q_data)){ + g_free(q_data.cp_name); + } + command_id = q_data.cmd_id; + + language_noti = g_variant_new("(iib)", command_id, language, b_specified); + + return language_noti; +} + +gboolean sat_manager_processing_unsupport_proactive_command(struct custom_data *ctx, const char *cp_name, struct tel_sat_unsupproted_command_tlv *unsupport_tlv) +{ + TcorePlugin *plg = NULL; + struct treq_sat_terminal_rsp_data tr; + + dbg("[SAT] unsupport proactive command (%d)", unsupport_tlv->command_detail.cmd_type); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return FALSE; + } + + memset(&tr, 0x00, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = unsupport_tlv->command_detail.cmd_num; + tr.cmd_type = unsupport_tlv->command_detail.cmd_type; + + memcpy((void*)&tr.terminal_rsp_data.unsupport_cmd.command_detail, &unsupport_tlv->command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.unsupport_cmd.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.unsupport_cmd.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.unsupport_cmd.result_type = RESULT_BEYOND_ME_CAPABILITIES; + + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + + return TRUE; +} + +gboolean sat_manager_handle_sat_ui_launch_fail(struct custom_data *ctx, const char *cp_name, struct tnoti_sat_proactive_ind *p_ind) +{ + TReturn rv = TCORE_RETURN_FAILURE; + TcorePlugin *plg = NULL; + struct treq_sat_terminal_rsp_data tr; + + dbg("[SAT] proactive command (%d)", p_ind->cmd_type); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return FALSE; + } + + memset(&tr, 0x00, sizeof(struct treq_sat_terminal_rsp_data)); + tr.cmd_number = p_ind->cmd_number; + tr.cmd_type = p_ind->cmd_type; + + switch (p_ind->cmd_type) { + case SAT_PROATV_CMD_DISPLAY_TEXT: { + memcpy((void*)&tr.terminal_rsp_data.display_text.command_detail, &p_ind->proactive_ind_data.display_text.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.display_text.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.display_text.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.display_text.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_SELECT_ITEM: { + memcpy((void*)&tr.terminal_rsp_data.select_item.command_detail, &p_ind->proactive_ind_data.select_item.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.select_item.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.select_item.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.select_item.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_GET_INKEY: { + memcpy((void*)&tr.terminal_rsp_data.get_inkey.command_detail, &p_ind->proactive_ind_data.get_inkey.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.get_inkey.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.get_inkey.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.get_inkey.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_GET_INPUT: { + memcpy((void*)&tr.terminal_rsp_data.get_input.command_detail, &p_ind->proactive_ind_data.get_input.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.get_input.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.get_input.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.get_input.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_PLAY_TONE: { + memcpy((void*)&tr.terminal_rsp_data.play_tone.command_detail, &p_ind->proactive_ind_data.play_tone.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.play_tone.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.play_tone.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.play_tone.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_SEND_SMS: { + memcpy((void*)&tr.terminal_rsp_data.send_sms.command_detail, &p_ind->proactive_ind_data.send_sms.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.send_sms.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.send_sms.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.send_sms.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_SEND_SS: { + memcpy((void*)&tr.terminal_rsp_data.send_ss.command_detail, &p_ind->proactive_ind_data.send_ss.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.send_ss.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.send_ss.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.send_ss.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_SEND_USSD: { + memcpy((void*)&tr.terminal_rsp_data.send_ussd.command_detail, &p_ind->proactive_ind_data.send_ussd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.send_ussd.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.send_ussd.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.send_ussd.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_SETUP_CALL: { + memcpy((void*)&tr.terminal_rsp_data.setup_call.command_detail, &p_ind->proactive_ind_data.setup_call.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.setup_call.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.setup_call.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.setup_call.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: { + memcpy((void*)&tr.terminal_rsp_data.setup_idle_mode_text.command_detail, &p_ind->proactive_ind_data.setup_idle_mode_text.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.setup_idle_mode_text.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.setup_idle_mode_text.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.setup_idle_mode_text.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_OPEN_CHANNEL: { + memcpy((void*)&tr.terminal_rsp_data.open_channel.command_detail, &p_ind->proactive_ind_data.open_channel.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.open_channel.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.open_channel.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.open_channel.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + case SAT_PROATV_CMD_LAUNCH_BROWSER: { + memcpy((void*)&tr.terminal_rsp_data.launch_browser.command_detail, &p_ind->proactive_ind_data.launch_browser.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.launch_browser.device_id.src = DEVICE_ID_ME; + tr.terminal_rsp_data.launch_browser.device_id.dest = DEVICE_ID_SIM; + tr.terminal_rsp_data.launch_browser.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } break; + default: + dbg("unsupported command."); + break; + } + + rv = sat_manager_send_terminal_response(ctx->comm, plg, &tr); + if(rv != TCORE_RETURN_SUCCESS) + return FALSE; + + return TRUE; +} + +static gboolean _sat_manager_handle_setup_menu_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] setup menu result data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(i)", &resp); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.setupMenuInd.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.setupMenuInd.command_detail.cmd_type; + + memcpy((void*)&tr->terminal_rsp_data.setup_menu.command_detail, + &q_data.cmd_data.setupMenuInd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.setup_menu.device_id.src = q_data.cmd_data.setupMenuInd.device_id.dest; + tr->terminal_rsp_data.setup_menu.device_id.dest = q_data.cmd_data.setupMenuInd.device_id.src; + + dbg("[SAT] resp(%d)", resp); + + switch(resp){ + case RESULT_SUCCESS: + tr->terminal_rsp_data.setup_menu.result_type = RESULT_SUCCESS; + + if(q_data.cmd_data.setupMenuInd.text_attribute.b_txt_attr || q_data.cmd_data.setupMenuInd.text_attribute_list.list_cnt > 0) + tr->terminal_rsp_data.setup_menu.result_type = RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION; + + if(q_data.cmd_data.setupMenuInd.icon_id.is_exist) + tr->terminal_rsp_data.setup_menu.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + tr->terminal_rsp_data.setup_menu.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.setup_menu.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.setup_menu.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + default: + //check the default case + tr->terminal_rsp_data.setup_menu.result_type = resp; + tr->terminal_rsp_data.setup_menu.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + dbg("[SAT] wrong result from app exec resp(%d)", resp); + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + + return result; +} + +static gboolean _sat_manager_handle_display_text_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, me_problem; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] display text result data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(ii)",&resp, &me_problem); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.displayTextInd.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.displayTextInd.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.display_text.command_detail, &q_data.cmd_data.displayTextInd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.display_text.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.display_text.device_id.dest = DEVICE_ID_SIM; + + switch (resp) { + case RESULT_SUCCESS: + tr->terminal_rsp_data.display_text.result_type = RESULT_SUCCESS; + + if(q_data.cmd_data.displayTextInd.text_attribute.b_txt_attr) + tr->terminal_rsp_data.display_text.result_type = RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION; + + if (q_data.cmd_data.displayTextInd.icon_id.is_exist) + tr->terminal_rsp_data.display_text.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + tr->terminal_rsp_data.display_text.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.display_text.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.display_text.me_problem_type = me_problem; + break; + + default: + tr->terminal_rsp_data.display_text.result_type = resp; + tr->terminal_rsp_data.display_text.me_problem_type = me_problem; + dbg("[SAT] wrong result from app exec resp(%d) me_problem(%d)", resp, me_problem); + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + + return result; +} + +static gboolean _sat_manager_handle_play_tone_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] display text result data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(i)",&resp); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.play_tone.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.play_tone.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.play_tone.command_detail, &q_data.cmd_data.play_tone.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.play_tone.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.play_tone.device_id.dest = DEVICE_ID_SIM; + + switch (resp) { + case RESULT_SUCCESS: + tr->terminal_rsp_data.play_tone.result_type = RESULT_SUCCESS; + + if(q_data.cmd_data.play_tone.text_attribute.b_txt_attr) + tr->terminal_rsp_data.play_tone.result_type = RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION; + + if (q_data.cmd_data.play_tone.icon_id.is_exist) + tr->terminal_rsp_data.play_tone.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + tr->terminal_rsp_data.play_tone.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.play_tone.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.play_tone.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER: + tr->terminal_rsp_data.play_tone.result_type = RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; + tr->terminal_rsp_data.play_tone.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + default: + tr->terminal_rsp_data.play_tone.result_type = resp; + tr->terminal_rsp_data.play_tone.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + dbg("[SAT] wrong result from app exec resp(%d)", resp); + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + return result; +} + +static gboolean _sat_manager_handle_send_sms_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] send sms data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(i)",&resp); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.sendSMSInd.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.sendSMSInd.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_sms.command_detail, &q_data.cmd_data.sendSMSInd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.send_sms.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_sms.device_id.dest = q_data.cmd_data.sendSMSInd.device_id.src; + + switch (resp) { + case RESULT_SUCCESS: + tr->terminal_rsp_data.send_sms.result_type = RESULT_SUCCESS; + if (q_data.cmd_data.sendSMSInd.icon_id.is_exist) + tr->terminal_rsp_data.send_sms.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + break; + + case RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM: + tr->terminal_rsp_data.send_sms.result_type = RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM; + tr->terminal_rsp_data.send_sms.cc_problem_type = CC_PROBLEM_ACTION_NOT_ALLOWED; + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.send_sms.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.send_sms.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_BEYOND_ME_CAPABILITIES: + tr->terminal_rsp_data.send_sms.result_type = RESULT_BEYOND_ME_CAPABILITIES; + tr->terminal_rsp_data.send_sms.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME: + tr->terminal_rsp_data.send_sms.result_type = RESULT_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME; + tr->terminal_rsp_data.send_sms.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME: + tr->terminal_rsp_data.send_sms.result_type = RESULT_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME; + tr->terminal_rsp_data.send_sms.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_ERROR_REQUIRED_VALUES_ARE_MISSING: + tr->terminal_rsp_data.send_sms.result_type = RESULT_ERROR_REQUIRED_VALUES_ARE_MISSING; + tr->terminal_rsp_data.send_sms.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_SMS_RP_ERROR: + tr->terminal_rsp_data.send_sms.result_type = RESULT_SMS_RP_ERROR; + tr->terminal_rsp_data.send_sms.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.send_sms.result_type = RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.send_sms.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + default: + tr->terminal_rsp_data.send_sms.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.send_sms.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + +/* if( q_data.cmd_data.sendSMSInd.alpha_id.alpha_data_len && q_data.cmd_data.sendSMSInd.alpha_id.is_exist) + sat_ui_support_terminate_sat_ui();*/ + + return result; +} + +static gboolean _sat_manager_handle_send_ss_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, me_problem, ss_cause, call_ctrl_problem, ss_str_len; + GVariant *ss_str = NULL; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + //call ctrl action, result data object, text + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] send ss data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(iii@vii)", &resp, &me_problem, &ss_cause, &ss_str, &ss_str_len, &call_ctrl_problem); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.send_ss.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.send_ss.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_ss.command_detail, &q_data.cmd_data.send_ss.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.send_ss.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_ss.device_id.dest = q_data.cmd_data.send_ss.device_id.src; + + switch (resp) { + case RESULT_SUCCESS: + tr->terminal_rsp_data.send_ss.result_type = RESULT_SUCCESS; + if (q_data.cmd_data.send_ss.icon_id.is_exist) + tr->terminal_rsp_data.send_ss.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + if(ss_str_len > 0 && ss_str){ + int local_index = 0; + guchar data; + GVariantIter *iter = NULL; + GVariant *intermediate = NULL; + char *tmp = NULL; + + intermediate = g_variant_get_variant(ss_str); + dbg("ss string format(%s)", g_variant_get_type_string(intermediate)); + + g_variant_get(intermediate, "ay", &iter); + while( g_variant_iter_loop (iter, "y", &data)){ + dbg("index(%d) data(%c)", local_index, data); + tr->terminal_rsp_data.send_ss.text.string[local_index] = data; + local_index++; + } + g_variant_iter_free(iter); + g_variant_unref(intermediate); + + tr->terminal_rsp_data.send_ss.text.string_length = local_index; + tmp = _convert_hex_string_to_bytes(tr->terminal_rsp_data.send_ss.text.string); + memset(tr->terminal_rsp_data.send_ss.text.string, 0x00, + sizeof(tr->terminal_rsp_data.send_ss.text.string)); + if(tmp) { + memcpy(tr->terminal_rsp_data.send_ss.text.string, tmp, + tr->terminal_rsp_data.send_ss.text.string_length); + g_free(tmp); + } + else { + err("memcpy failed"); + } + dbg("SS string len:%d", tr->terminal_rsp_data.send_ss.text.string_length); + } + break; + + case RESULT_SS_RETURN_ERROR: + tr->terminal_rsp_data.send_ss.result_type = RESULT_SS_RETURN_ERROR; + if (ss_cause == SATK_SS_PROBLEM_FACILITY_NOT_SUPPORTED) { + tr->terminal_rsp_data.send_ss.ss_problem = SATK_SS_PROBLEM_FACILITY_NOT_SUPPORTED; + } else { + tr->terminal_rsp_data.send_ss.ss_problem = SATK_SS_PROBLEM_NO_SPECIFIC_CAUSE; + } + break; + + case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.send_ss.result_type = RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.send_ss.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + default: + tr->terminal_rsp_data.send_ss.result_type = RESULT_SS_RETURN_ERROR; + tr->terminal_rsp_data.send_ss.ss_problem = SATK_SS_PROBLEM_NO_SPECIFIC_CAUSE; + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + g_free(tr); + +#if defined(TIZEN_PLATFORM_USE_QCOM_QMI) + if( q_data.cmd_data.send_ss.alpha_id.alpha_data_len && q_data.cmd_data.send_ss.alpha_id.is_exist ) { + char *path; + const gchar *cp_name; + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + + dbg("AlphaID is present, terminate SAT-UI."); + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + goto Exit; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + goto Exit; + } + + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + telephony_sat_emit_end_proactive_session(sat, SAT_PROATV_CMD_TYPE_END_PROACTIVE_SESSION); + } +Exit: +#endif + return result; +} + +static gboolean _sat_manager_handle_send_ussd_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, me_problem, ss_cause, ussd_str_len; + GVariant *ussd_str = NULL; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + //call ctrl action, result data object, text, result2, text2 + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] send ss data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(iii@vi)", &resp, &me_problem, &ss_cause, &ussd_str, &ussd_str_len); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.send_ussd.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.send_ussd.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_ussd.command_detail, &q_data.cmd_data.send_ussd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.send_ussd.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_ussd.device_id.dest = q_data.cmd_data.send_ussd.device_id.src; + + switch (resp) { + case RESULT_SUCCESS: + tr->terminal_rsp_data.send_ussd.result_type = RESULT_SUCCESS; + if (q_data.cmd_data.send_ussd.icon_id.is_exist) + tr->terminal_rsp_data.send_ussd.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + if(ussd_str_len > 0 && ussd_str){ + int local_index = 0, i = 0; + guchar data; + GVariantIter *iter = NULL; + GVariant *intermediate = NULL; + enum alphabet_format alpha_format; + + intermediate = g_variant_get_variant(ussd_str); + dbg("ussd string format(%s)", g_variant_get_type_string(intermediate)); + + g_variant_get(intermediate, "ay", &iter); + while( g_variant_iter_loop (iter, "y", &data)){ + dbg("local_index(%d) data(%c)", local_index, data); + tr->terminal_rsp_data.send_ussd.text.string[local_index] = data; + local_index++; + } + + if(local_index >=1 ) + tr->terminal_rsp_data.send_ussd.text.string_length = local_index-1; + tr->terminal_rsp_data.send_ussd.text.dcs.raw_dcs = q_data.cmd_data.send_ussd.ussd_string.dsc.raw_dcs; + /*bits 2 & 3 indicate the character set being used */ + switch (tr->terminal_rsp_data.send_ussd.text.dcs.raw_dcs & 0x0C) { + case 0x00: + case 0x0C: + alpha_format = ALPHABET_FORMAT_SMS_DEFAULT; + break; + + case 0x04: + alpha_format = ALPHABET_FORMAT_8BIT_DATA; + break; + + case 0X08: + alpha_format = ALPHABET_FORMAT_UCS2; + break; + + default: + alpha_format = ALPHABET_FORMAT_RESERVED; + break; + } + dbg("string :[%s] len:[%d] dcs:[%d] alpha_format:[%d]", tr->terminal_rsp_data.send_ussd.text.string, tr->terminal_rsp_data.send_ussd.text.string_length, + tr->terminal_rsp_data.send_ussd.text.dcs.raw_dcs, alpha_format); + g_variant_iter_free(iter); + g_variant_unref(intermediate); + switch(alpha_format){ + case ALPHABET_FORMAT_SMS_DEFAULT: + /* As per the test spec TS 151.010-04 raw dcs for SMS default is 0 */ + tr->terminal_rsp_data.send_ussd.text.dcs.raw_dcs = ALPHABET_FORMAT_SMS_DEFAULT; + if (tr->terminal_rsp_data.send_ussd.text.string_length > 0){ + int tmp_len; + char tmp_str[SAT_TEXT_STRING_LEN_MAX + 1]; + char *packed_data; + + dbg("UTF 8 to GSM SMS default"); + tcore_util_convert_utf8_to_gsm((unsigned char*)tmp_str, &tmp_len, + (unsigned char*)tr->terminal_rsp_data.send_ussd.text.string, + tr->terminal_rsp_data.send_ussd.text.string_length); + packed_data = (char*) tcore_util_pack_gsm7bit((const unsigned char *)tmp_str, tmp_len); + memset(tr->terminal_rsp_data.send_ussd.text.string, 0x00, + sizeof(tr->terminal_rsp_data.send_ussd.text.string)); + if(packed_data){ + memcpy((void*)tr->terminal_rsp_data.send_ussd.text.string, packed_data, strlen(packed_data)); + tr->terminal_rsp_data.send_ussd.text.string_length = strlen(packed_data); + g_free(packed_data); + } + } + dbg("final ussd len:%d", tr->terminal_rsp_data.send_ussd.text.string_length); + for(i = 0; i< tr->terminal_rsp_data.send_ussd.text.string_length; i++) + dbg("string :%c \n", tr->terminal_rsp_data.send_ussd.text.string[i]); + break; + case ALPHABET_FORMAT_8BIT_DATA: { + gint output_data_len = 0; + gchar output_data[SAT_USSD_STRING_LEN_MAX]; + dbg("UTF 8 to GSM 8 BIT DATA"); + tcore_util_convert_utf8_to_gsm((unsigned char*)output_data,&output_data_len, + (unsigned char*)tr->terminal_rsp_data.send_ussd.text.string, + tr->terminal_rsp_data.send_ussd.text.string_length); + memset(tr->terminal_rsp_data.send_ussd.text.string, 0x00, + sizeof(tr->terminal_rsp_data.send_ussd.text.string)); + if(output_data_len > 0){ + memcpy((void*)tr->terminal_rsp_data.send_ussd.text.string, output_data, output_data_len); + tr->terminal_rsp_data.send_ussd.text.string_length = output_data_len; + } + dbg("final ussd len:%d", tr->terminal_rsp_data.send_ussd.text.string_length); + for(i = 0; i< tr->terminal_rsp_data.send_ussd.text.string_length; i++) + dbg("string :%c \n", tr->terminal_rsp_data.send_ussd.text.string[i]); + } + break; + case ALPHABET_FORMAT_UCS2: { + char *tmp = NULL; + int str_len = 0; + dbg("UCS2 DATA"); + tcore_util_convert_utf8_to_ucs2(&tmp, + &str_len, (unsigned char*)tr->terminal_rsp_data.send_ussd.text.string, + tr->terminal_rsp_data.send_ussd.text.string_length); + memset(tr->terminal_rsp_data.send_ussd.text.string, 0x00, + sizeof(tr->terminal_rsp_data.send_ussd.text.string)); + memcpy(tr->terminal_rsp_data.send_ussd.text.string, tmp, str_len); + tr->terminal_rsp_data.send_ussd.text.string_length = str_len; + dbg("final ussd len:%d", tr->terminal_rsp_data.send_ussd.text.string_length); + for(i = 0; i< tr->terminal_rsp_data.send_ussd.text.string_length; i++) + dbg("string :%c \n", tr->terminal_rsp_data.send_ussd.text.string[i]); + g_free(tmp); + } + break; + default: + break; + } + } + break; + + case RESULT_SS_RETURN_ERROR: + case RESULT_USSD_RETURN_ERROR: + tr->terminal_rsp_data.send_ussd.result_type = RESULT_USSD_RETURN_ERROR; + if(ss_cause == SATK_USSD_PROBLEM_UNKNOWN_ALPHABET) + tr->terminal_rsp_data.send_ussd.ussd_problem = ss_cause; + + break; + + case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.send_ussd.result_type = RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.send_ussd.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.send_ussd.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.send_ussd.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + default: + tr->terminal_rsp_data.send_ussd.result_type = RESULT_USSD_RETURN_ERROR; + tr->terminal_rsp_data.send_ussd.ussd_problem = SATK_USSD_PROBLEM_NO_SPECIFIC_CAUSE; + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + g_free(tr); + +#if defined(TIZEN_PLATFORM_USE_QCOM_QMI) + if( q_data.cmd_data.send_ussd.alpha_id.alpha_data_len && q_data.cmd_data.send_ussd.alpha_id.is_exist ) { + char *path; + const gchar *cp_name; + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + + dbg("AlphaID is present, terminate SAT-UI."); + //emit session end signal + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + goto Exit; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + goto Exit; + } + + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + telephony_sat_emit_end_proactive_session(sat, SAT_PROATV_CMD_TYPE_END_PROACTIVE_SESSION); + } + +Exit: +#endif + return result; +} + +static gboolean _sat_manager_handle_setup_call_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, me_problem, cc_problem, call_cause; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] setup call data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(iiii)",&resp, &me_problem, &cc_problem, &call_cause); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.setup_call.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.setup_call.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.setup_call.command_detail, &q_data.cmd_data.setup_call.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.setup_call.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.setup_call.device_id.dest = q_data.cmd_data.setup_call.device_id.src; + + switch (resp) { + case RESULT_SUCCESS: + tr->terminal_rsp_data.setup_call.result_type = RESULT_SUCCESS; + if (q_data.cmd_data.setup_call.call_setup_icon_id.is_exist || q_data.cmd_data.setup_call.user_confirm_icon_id.is_exist) + tr->terminal_rsp_data.setup_call.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + tr->terminal_rsp_data.setup_call.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + tr->terminal_rsp_data.setup_call.cc_problem_type = CC_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.setup_call.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.setup_call.me_problem_type = me_problem; + break; + + case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND:{ + tr->terminal_rsp_data.setup_call.result_type = RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND; + switch(call_cause){ + case CALL_ERROR_BUSY: + tr->terminal_rsp_data.setup_call.network_problem_type = NETWORK_PROBLEM_USER_BUSY; + break; + default : + tr->terminal_rsp_data.setup_call.network_problem_type = NETWORK_PROBLEM_NO_SPECIFIC_CAUSE; + break; + } + }break; + + case RESULT_USER_CLEAR_DOWN_CALL_BEFORE_CONN: + tr->terminal_rsp_data.setup_call.result_type = RESULT_USER_CLEAR_DOWN_CALL_BEFORE_CONN; + tr->terminal_rsp_data.setup_call.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + tr->terminal_rsp_data.setup_call.cc_problem_type = CC_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_BEYOND_ME_CAPABILITIES: + tr->terminal_rsp_data.setup_call.result_type = RESULT_BEYOND_ME_CAPABILITIES; + tr->terminal_rsp_data.setup_call.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + tr->terminal_rsp_data.setup_call.cc_problem_type = CC_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM: + tr->terminal_rsp_data.setup_call.result_type = RESULT_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM; + tr->terminal_rsp_data.setup_call.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + tr->terminal_rsp_data.setup_call.cc_problem_type = cc_problem; + break; + + + default: + break; + } + + //TODO Other infomation set - not supported + tr->terminal_rsp_data.setup_call.other_info = FALSE; + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + return result; +} + +static gboolean _sat_manager_handle_setup_idle_mode_text_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp; + struct treq_sat_terminal_rsp_data tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] send ss data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(i)",&resp); + + tr.cmd_number = q_data.cmd_data.idle_mode.command_detail.cmd_num; + tr.cmd_type = q_data.cmd_data.idle_mode.command_detail.cmd_type; + memcpy((void*)&tr.terminal_rsp_data.setup_idle_mode_text.command_detail, &q_data.cmd_data.idle_mode.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.setup_idle_mode_text.device_id.src = q_data.cmd_data.idle_mode.device_id.dest; + tr.terminal_rsp_data.setup_idle_mode_text.device_id.dest = q_data.cmd_data.idle_mode.device_id.src; + + switch (resp) { + case RESULT_SUCCESS: + tr.terminal_rsp_data.setup_idle_mode_text.result_type = RESULT_SUCCESS; + if (q_data.cmd_data.idle_mode.icon_id.is_exist) + tr.terminal_rsp_data.setup_idle_mode_text.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + break; + default: + tr.terminal_rsp_data.setup_idle_mode_text.result_type = resp; + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, &tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + return result; +} + +static gboolean sat_manager_handle_open_channel_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, me_problem, bip_problem; + gint bearer_type, channel_id, channel_status, channel_status_info, buffer_size; + gboolean other_info; + GVariant *desc_tmp, *bearer_desc; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] open channel data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(iiiiiiiibv)",&resp, &me_problem, &bip_problem, + &bearer_type, &channel_id, &channel_status, &channel_status_info, &buffer_size, + &other_info, &desc_tmp); + + bearer_desc = g_variant_get_variant(desc_tmp); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.open_channel.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.open_channel.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.open_channel.command_detail, &q_data.cmd_data.open_channel.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.open_channel.device_id.src = q_data.cmd_data.open_channel.device_id.dest; + tr->terminal_rsp_data.open_channel.device_id.dest = q_data.cmd_data.open_channel.device_id.src; + + tr->terminal_rsp_data.open_channel.result_type = resp; + switch (resp) { + case RESULT_SUCCESS: + case RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: + case RESULT_SUCCESS_WITH_MISSING_INFO: + //channel status + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.open_channel.me_problem_type = me_problem; + break; + + case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: + tr->terminal_rsp_data.open_channel.bip_problem_type = bip_problem; + break; + + default: + break; + } + + tr->terminal_rsp_data.open_channel.channel_status.channel_id = channel_id; + tr->terminal_rsp_data.open_channel.channel_status.status = channel_status; + tr->terminal_rsp_data.open_channel.channel_status.status_info = channel_status_info; + + dbg("check channel id(%d) channel status(%d) channel info(%d)", channel_id, channel_status, channel_status_info); + + //memcpy(tr->terminal_rsp_data.open_channel.buffer_size.size, &buffer_size, sizeof(unsigned char)*2); + tr->terminal_rsp_data.open_channel.buffer_size.size[0] = buffer_size >> 8; + tr->terminal_rsp_data.open_channel.buffer_size.size[1] = buffer_size & 0xFF; + dbg("check buffer size[0](0x%x) size[1](0x%x)", tr->terminal_rsp_data.open_channel.buffer_size.size[0], tr->terminal_rsp_data.open_channel.buffer_size.size[1]); + + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_type = bearer_type; + switch(bearer_type){ + case BEARER_CSD:{ + gint data_rate, service_type, conn_element_type; + + dbg("bearer_desc cs bearer type_format(%s)", g_variant_get_type_string(bearer_desc)); + g_variant_get(bearer_desc, "(iii)",&data_rate, &service_type, &conn_element_type); + dbg("check cs bearer data_rade(%d), service_type(%d), conn_element_type(%d)", data_rate, service_type, conn_element_type); + + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.cs_bearer_param.data_rate = data_rate; + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.cs_bearer_param.service_type = service_type; + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.cs_bearer_param.connection_element_type = conn_element_type; + }break; + case BEARER_GPRS:{ + gint precedence_class, delay_class, reliability_class; + gint peak_class, mean_class, pdp_type; + + dbg("bearer_desc ps bearer type_format(%s)", g_variant_get_type_string(bearer_desc)); + g_variant_get(bearer_desc, "(iiiiii)",&precedence_class, &delay_class, &reliability_class, + &peak_class, &mean_class, &pdp_type); + dbg("check ps bearer precedence class(%d), delay class(%d), reliability class(%d) peak class(%d) mean class(%d) pdp_type(%d)", + precedence_class, delay_class, reliability_class, peak_class, mean_class, pdp_type); + + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.precedence_class = precedence_class; + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.delay_class = delay_class; + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.reliability_class = reliability_class; + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.peak_throughput_class = peak_class; + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.mean_throughput_class = mean_class; + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.ps_bearer_param.pdp_type = pdp_type; + }break; + case BEARER_LOCAL_LINK_TECHNOLOGY_INDEPENDENT:{ + gint service_type; + gchar *service_record = NULL; + + dbg("bearer_desc link local type_format(%s)", g_variant_get_type_string(bearer_desc)); + g_variant_get(bearer_desc, "(is)",&service_type, &service_record); + dbg("check link local service_type(%d), service_record(%d)", service_type, service_record); + + tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.local_link_bearer_param.service_type = service_type; + + if(service_record) { + memcpy(tr->terminal_rsp_data.open_channel.bearer_desc.bearer_parameter.local_link_bearer_param.service_record, service_record, strlen(service_record)); + g_free(service_record); + } + + }break; + default: + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + return result; +} + +static gboolean sat_manager_handle_close_channel_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, me_problem, bip_problem; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] close channel data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(iii)",&resp, &me_problem, &bip_problem); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.close_channel.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.close_channel.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.close_channel.command_detail, &q_data.cmd_data.close_channel.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.close_channel.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.close_channel.device_id.dest = q_data.cmd_data.close_channel.device_id.src; + + tr->terminal_rsp_data.close_channel.result_type = resp; + switch (resp) { + case RESULT_SUCCESS: + case RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: + case RESULT_SUCCESS_WITH_MISSING_INFO: + //channel status + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.close_channel.me_problem_type = me_problem; + break; + + case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: + tr->terminal_rsp_data.close_channel.bip_problem_type = bip_problem; + break; + + default: + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + return result; +} + +static gboolean sat_manager_handle_receive_data_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, me_problem, bip_problem; + gint data_str_len, data_len; + gboolean other_info; + GVariant *received_data; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] receive data data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(iiiiibv)",&resp, &me_problem, &bip_problem, &data_str_len, &data_len, &other_info, &received_data); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.receive_data.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.receive_data.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.receive_data.command_detail, &q_data.cmd_data.receive_data.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.receive_data.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.receive_data.device_id.dest = q_data.cmd_data.receive_data.device_id.src; + + tr->terminal_rsp_data.receive_data.result_type = resp; + switch (resp) { + case RESULT_SUCCESS: + case RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: + case RESULT_SUCCESS_WITH_MISSING_INFO: + //channel status + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.receive_data.me_problem_type = me_problem; + break; + + case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: + tr->terminal_rsp_data.receive_data.bip_problem_type = bip_problem; + break; + + default: + break; + } + + tr->terminal_rsp_data.receive_data.channel_data_len.data_len = data_len; + tr->terminal_rsp_data.receive_data.channel_data.data_string_len = data_str_len; + + if(received_data){ + int local_index = 0; + guchar data; + GVariantIter *iter = NULL; + + dbg("additional data exist type_format(%s)", g_variant_get_type_string(received_data)); + + g_variant_get(received_data, "ay", &iter); + while( g_variant_iter_loop (iter, "y", &data)){ + //dbg("index(%d) data(%d)", index, data); + tr->terminal_rsp_data.receive_data.channel_data.data_string[local_index] = data; + local_index++; + } + g_variant_iter_free(iter); + + dbg("the last index data(%d), data_total_len(%d)", local_index, data_str_len); + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + return result; +} + +static gboolean sat_manager_handle_send_data_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, me_problem, bip_problem; + gint data_len; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] send data data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(iiii)",&resp, &me_problem, &bip_problem, &data_len); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.send_data.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.send_data.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_data.command_detail, &q_data.cmd_data.send_data.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.send_data.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_data.device_id.dest = q_data.cmd_data.send_data.device_id.src; + + tr->terminal_rsp_data.send_data.result_type = resp; + switch (resp) { + case RESULT_SUCCESS: + case RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: + case RESULT_SUCCESS_WITH_MISSING_INFO: + //channel status + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.send_data.me_problem_type = me_problem; + break; + + case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: + tr->terminal_rsp_data.send_data.bip_problem_type = bip_problem; + break; + + default: + break; + } + + tr->terminal_rsp_data.send_data.channel_data_len.data_len = data_len; + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + return result; +} + +static gboolean sat_manager_handle_get_channel_status_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, me_problem, bip_problem; + gint channel_id, channel_status, channel_status_info; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] get channel status data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(iiiiii)",&resp, &me_problem, &bip_problem, + &channel_id, &channel_status, &channel_status_info); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.get_channel_status.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.get_channel_status.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.get_channel_status.command_detail, &q_data.cmd_data.get_channel_status.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.get_channel_status.device_id.src = q_data.cmd_data.get_channel_status.device_id.dest; + tr->terminal_rsp_data.get_channel_status.device_id.dest = q_data.cmd_data.get_channel_status.device_id.src; + + tr->terminal_rsp_data.get_channel_status.result_type = resp; + switch (resp) { + case RESULT_SUCCESS: + case RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED: + case RESULT_SUCCESS_WITH_MISSING_INFO: + //channel status + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + case RESULT_NETWORK_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.get_channel_status.me_problem_type = me_problem; + break; + + case RESULT_BEARER_INDEPENDENT_PROTOCOL_ERROR: + tr->terminal_rsp_data.get_channel_status.bip_problem_type = bip_problem; + break; + + default: + break; + } + + tr->terminal_rsp_data.get_channel_status.channel_status.channel_id = channel_id; + tr->terminal_rsp_data.get_channel_status.channel_status.status = channel_status; + tr->terminal_rsp_data.get_channel_status.channel_status.status_info = channel_status_info; + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + return result; +} + +static gboolean sat_manager_handle_send_dtmf_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + g_free(tr); + return result; + } + + if(!exec_result){ + dbg("[SAT] get channel status data is null"); + g_free(tr); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + g_free(tr); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(i)",&resp); + + tr->cmd_number = q_data.cmd_data.send_dtmf.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.send_dtmf.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_dtmf.command_detail, &q_data.cmd_data.send_dtmf.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.send_dtmf.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_dtmf.device_id.dest = q_data.cmd_data.send_dtmf.device_id.src; + + tr->terminal_rsp_data.send_dtmf.result_type = resp; + switch (resp) { + case RESULT_SUCCESS: + if (q_data.cmd_data.send_dtmf.icon_id.is_exist) + tr->terminal_rsp_data.send_dtmf.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + break; + + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.send_dtmf.me_problem_type = ME_PROBLEM_NOT_IN_SPEECH_CALL; + break; + + default: + tr->terminal_rsp_data.send_dtmf.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.send_dtmf.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + return result; +} + +static gboolean sat_manager_handle_launch_browser_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, GVariant *exec_result) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint resp, browser_problem; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(!exec_result){ + dbg("[SAT] get channel status data is null"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "(ii)",&resp,&browser_problem); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.launch_browser.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.launch_browser.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.launch_browser.command_detail, &q_data.cmd_data.launch_browser.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.launch_browser.device_id.src = q_data.cmd_data.launch_browser.device_id.dest; + tr->terminal_rsp_data.launch_browser.device_id.dest = q_data.cmd_data.launch_browser.device_id.src; + + tr->terminal_rsp_data.launch_browser.result_type = resp; + switch (resp) { + case RESULT_SUCCESS: + if (q_data.cmd_data.launch_browser.user_confirm_icon_id.is_exist) + tr->terminal_rsp_data.launch_browser.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + tr->terminal_rsp_data.launch_browser.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + tr->terminal_rsp_data.launch_browser.browser_problem_type = BROWSER_PROBLEM_NO_SPECIFIC_CAUSE; + break; + case RESULT_ME_UNABLE_TO_PROCESS_COMMAND: + tr->terminal_rsp_data.launch_browser.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + tr->terminal_rsp_data.launch_browser.browser_problem_type = BROWSER_PROBLEM_NO_SPECIFIC_CAUSE; + break; + + case RESULT_LAUNCH_BROWSER_GENERIC_ERROR_CODE: + tr->terminal_rsp_data.launch_browser.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + tr->terminal_rsp_data.launch_browser.browser_problem_type = browser_problem; + break; + default: + tr->terminal_rsp_data.launch_browser.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + tr->terminal_rsp_data.launch_browser.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + tr->terminal_rsp_data.launch_browser.browser_problem_type = BROWSER_PROBLEM_NO_SPECIFIC_CAUSE; + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + return result; +} + +gboolean sat_manager_handle_app_exec_result(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint command_type, GVariant *exec_result) +{ + gboolean result = FALSE; + GVariant *resp = NULL; + dbg("[SAT] app exec result command id(%d) command type(%d)", command_id, command_type); + + dbg("exec_result type_format(%s)", g_variant_get_type_string(exec_result)); + g_variant_get(exec_result, "v", &resp); + + switch (command_type) { + case SAT_PROATV_CMD_SETUP_MENU: + result = _sat_manager_handle_setup_menu_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_DISPLAY_TEXT: + result = _sat_manager_handle_display_text_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_PLAY_TONE: + result = _sat_manager_handle_play_tone_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_SEND_SMS: + result = _sat_manager_handle_send_sms_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_SEND_SS: + result = _sat_manager_handle_send_ss_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_SEND_USSD: + result = _sat_manager_handle_send_ussd_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_SETUP_CALL: + result = _sat_manager_handle_setup_call_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: + result = _sat_manager_handle_setup_idle_mode_text_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_OPEN_CHANNEL: + result = sat_manager_handle_open_channel_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_CLOSE_CHANNEL: + result = sat_manager_handle_close_channel_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_RECEIVE_DATA: + result = sat_manager_handle_receive_data_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_SEND_DATA: + result = sat_manager_handle_send_data_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_GET_CHANNEL_STATUS: + result = sat_manager_handle_get_channel_status_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_SEND_DTMF: + result = sat_manager_handle_send_dtmf_result(ctx, plg, command_id, resp); + break; + + case SAT_PROATV_CMD_LAUNCH_BROWSER: + result = sat_manager_handle_launch_browser_result(ctx, plg, command_id, resp); + break; + + default: + dbg("[SAT] invalid command type(%d)", command_type); + break; + } + + return result; +} + +static gboolean _sat_manager_handle_menu_select_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint item_id=0; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + if(addtional_data){ + int local_index = 0; + guchar data; + GVariantIter *iter = NULL; + GVariant *inner_gv = NULL; + + inner_gv = g_variant_get_variant(addtional_data); + dbg("additional data exist type_format(%s)", g_variant_get_type_string(inner_gv)); + + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop (iter, "y", &data)){ + dbg("index(%d) data(%d)", local_index, data); + item_id = data; + local_index++; + } + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + } + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.selectItemInd.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.selectItemInd.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.select_item.command_detail, &q_data.cmd_data.selectItemInd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.select_item.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.select_item.device_id.dest = DEVICE_ID_SIM; + + switch (confirm_type) { + case USER_CONFIRM_YES: + tr->terminal_rsp_data.select_item.item_identifier.item_identifier = item_id; + tr->terminal_rsp_data.select_item.other_info = FALSE; + tr->terminal_rsp_data.select_item.result_type = RESULT_SUCCESS; + tr->terminal_rsp_data.select_item.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + + if(q_data.cmd_data.selectItemInd.text_attribute.b_txt_attr || q_data.cmd_data.selectItemInd.text_attribute_list.list_cnt > 0) + tr->terminal_rsp_data.select_item.result_type = RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION; + + if (q_data.cmd_data.selectItemInd.icon_id.is_exist) + tr->terminal_rsp_data.select_item.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + break; + + case USER_CONFIRM_HELP_INFO: + tr->terminal_rsp_data.select_item.item_identifier.item_identifier = item_id; + tr->terminal_rsp_data.select_item.other_info = FALSE; + tr->terminal_rsp_data.select_item.result_type = RESULT_HELP_INFO_REQUIRED_BY_USER; + tr->terminal_rsp_data.select_item.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + //TODO ctx->help_requested = TRUE; + break; + + case USER_CONFIRM_END: + tr->terminal_rsp_data.select_item.result_type = RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; + break; + + case USER_CONFIRM_NO_OR_CANCEL: + tr->terminal_rsp_data.select_item.result_type = RESULT_BACKWARD_MOVE_BY_USER; + break; + + case USER_CONFIRM_TIMEOUT: + tr->terminal_rsp_data.select_item.result_type = RESULT_NO_RESPONSE_FROM_USER; + break; + + default: + dbg("not handled value[%d] here", confirm_type); + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + + return result; +} + +static gboolean _sat_manager_handle_display_text_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.displayTextInd.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.displayTextInd.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.display_text.command_detail, &q_data.cmd_data.displayTextInd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.display_text.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.display_text.device_id.dest = DEVICE_ID_SIM; + + switch (confirm_type){ + case USER_CONFIRM_YES: { + tr->terminal_rsp_data.display_text.result_type = RESULT_SUCCESS; + tr->terminal_rsp_data.display_text.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + + if(q_data.cmd_data.displayTextInd.text_attribute.b_txt_attr) + tr->terminal_rsp_data.display_text.result_type = RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION; + + if (q_data.cmd_data.displayTextInd.icon_id.is_exist) + tr->terminal_rsp_data.display_text.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + } break; + + case USER_CONFIRM_NO_OR_CANCEL: + tr->terminal_rsp_data.display_text.result_type = RESULT_BACKWARD_MOVE_BY_USER; + break; + + case USER_CONFIRM_TIMEOUT: + tr->terminal_rsp_data.display_text.result_type = RESULT_SUCCESS; + + if (q_data.cmd_data.displayTextInd.command_detail.cmd_qualifier.display_text.text_clear_type == TEXT_WAIT_FOR_USER_TO_CLEAR_MSG ) + tr->terminal_rsp_data.display_text.result_type = RESULT_NO_RESPONSE_FROM_USER; + + break; + + case USER_CONFIRM_END: + tr->terminal_rsp_data.display_text.result_type = RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; + break; + + case USER_CONFIRM_HELP_INFO: + default: + dbg("not handled value[%d] here", confirm_type); + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + + return result; +} + +static gboolean _sat_manager_handle_get_inkey_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint inkey_data_len = 0; + gchar inkey_data[SAT_TEXT_STRING_LEN_MAX]; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + memset(inkey_data, 0, SAT_TEXT_STRING_LEN_MAX); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + if(addtional_data){ + int local_index = 0; + guchar data; + GVariantIter *iter = NULL; + GVariant *inner_gv = NULL; + + inner_gv = g_variant_get_variant(addtional_data); + dbg("additional data exist type_format(%s)", g_variant_get_type_string(inner_gv)); + + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop (iter, "y", &data)){ + dbg("index(%d) data(%d)", local_index, data); + inkey_data[local_index] = data; + local_index++; + } + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + inkey_data_len = local_index; + } + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.getInkeyInd.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.getInkeyInd.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.get_inkey.command_detail, &q_data.cmd_data.getInkeyInd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.get_inkey.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.get_inkey.device_id.dest = DEVICE_ID_SIM; + + switch (confirm_type){ + case USER_CONFIRM_YES: + tr->terminal_rsp_data.get_inkey.result_type = RESULT_SUCCESS; + + if(q_data.cmd_data.getInkeyInd.text_attribute.b_txt_attr) + tr->terminal_rsp_data.get_inkey.result_type = RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION; + + if (q_data.cmd_data.getInkeyInd.icon_id.is_exist) + tr->terminal_rsp_data.get_inkey.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + if (q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.inkey_type == INKEY_TYPE_YES_NO_REQUESTED) { + tr->terminal_rsp_data.get_inkey.text.dcs.m_class = MSG_CLASS_RESERVED; + tr->terminal_rsp_data.get_inkey.text.dcs.a_format = ALPHABET_FORMAT_8BIT_DATA; + tr->terminal_rsp_data.get_inkey.text.string_length = 1; + tr->terminal_rsp_data.get_inkey.text.string[0] = 0x01; + } + else if(inkey_data_len > 0) + { + tr->terminal_rsp_data.get_inkey.text.string_length = inkey_data_len; + + if (!q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.alphabet_set){ + tr->terminal_rsp_data.get_inkey.text.is_digit_only = TRUE; + tr->terminal_rsp_data.get_inkey.text.dcs.a_format = ALPHABET_FORMAT_8BIT_DATA; + tr->terminal_rsp_data.get_inkey.text.dcs.m_class = MSG_CLASS_RESERVED; + + memcpy((void*)tr->terminal_rsp_data.get_inkey.text.string, inkey_data, inkey_data_len); + } + else + { + tr->terminal_rsp_data.get_inkey.text.dcs.m_class = MSG_CLASS_RESERVED; + + if(q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.alphabet_type == INPUT_ALPHABET_TYPE_SMS_DEFAULT ) + { + int tmp_len; + char tmp_str[SAT_TEXT_STRING_LEN_MAX + 1], *packed_data; + + dbg("sat gsm7 encoding"); + tcore_util_convert_utf8_to_gsm((unsigned char*) tmp_str, &tmp_len, (unsigned char*)inkey_data, inkey_data_len); + packed_data = (char*) tcore_util_pack_gsm7bit((const unsigned char *)tmp_str, tmp_len); + + if(packed_data){ + tr->terminal_rsp_data.get_inkey.text.dcs.a_format = ALPHABET_FORMAT_8BIT_DATA; + tr->terminal_rsp_data.get_inkey.text.string_length = strlen(packed_data); + memcpy((void*) tr->terminal_rsp_data.get_inkey.text.string, packed_data, strlen(packed_data)); + + g_free(packed_data); + } + } + else if(q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.alphabet_type == INPUT_ALPHABET_TYPE_UCS2 ) + { + char *tmp = NULL; + dbg("UCS2 DATA"); + + tr->terminal_rsp_data.get_inkey.text.dcs.a_format = ALPHABET_FORMAT_UCS2; + tcore_util_convert_utf8_to_ucs2(&tmp, + &tr->terminal_rsp_data.get_inkey.text.string_length, (unsigned char*)inkey_data, inkey_data_len); + + memcpy(tr->terminal_rsp_data.get_inkey.text.string, tmp, tr->terminal_rsp_data.get_inkey.text.string_length); + g_free(tmp); + } + else + { + tr->terminal_rsp_data.get_inkey.text.dcs.a_format = ALPHABET_FORMAT_RESERVED; + dbg("[SAT] invalid DCS[%d]",tr->terminal_rsp_data.get_inkey.text.dcs.a_format); + } + } + } + break; + + case USER_CONFIRM_HELP_INFO: + tr->terminal_rsp_data.get_inkey.result_type = RESULT_HELP_INFO_REQUIRED_BY_USER; + //TODO ctx->help_requested = TRUE; + break; + + case USER_CONFIRM_NO_OR_CANCEL: + tr->terminal_rsp_data.get_inkey.result_type = RESULT_BACKWARD_MOVE_BY_USER; + + if (q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_inkey.inkey_type == INKEY_TYPE_YES_NO_REQUESTED) { + tr->terminal_rsp_data.get_inkey.result_type = RESULT_SUCCESS; + tr->terminal_rsp_data.get_inkey.text.dcs.m_class = MSG_CLASS_RESERVED; + tr->terminal_rsp_data.get_inkey.text.dcs.a_format = ALPHABET_FORMAT_8BIT_DATA; + tr->terminal_rsp_data.get_inkey.text.string_length = 1; + tr->terminal_rsp_data.get_inkey.text.string[0] = 0x00; + } + break; + + case USER_CONFIRM_TIMEOUT: + tr->terminal_rsp_data.get_inkey.result_type = RESULT_NO_RESPONSE_FROM_USER; + break; + + case USER_CONFIRM_END: + tr->terminal_rsp_data.get_inkey.result_type = RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; + break; + + default: + dbg("not handled value[%d] here", confirm_type); + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + + return result; +} + +static gboolean _sat_manager_handle_get_input_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint input_data_len = 0; + gchar input_data[SAT_TEXT_STRING_LEN_MAX]; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + memset(input_data, 0, SAT_TEXT_STRING_LEN_MAX); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + if(addtional_data){ + int local_index = 0; + guchar data; + GVariantIter *iter = NULL; + GVariant *inner_gv = NULL; + + inner_gv = g_variant_get_variant(addtional_data); + dbg("additional data exist type_format(%s)", g_variant_get_type_string(inner_gv)); + + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop (iter, "y", &data)){ + dbg("index(%d) data(%d)", local_index, data); + input_data[local_index] = data; + local_index++; + } + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + input_data_len = local_index; + } + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + tr->cmd_number = q_data.cmd_data.getInputInd.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.getInputInd.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.get_input.command_detail, &q_data.cmd_data.getInputInd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.get_input.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.get_input.device_id.dest = DEVICE_ID_SIM; + + switch (confirm_type){ + case USER_CONFIRM_YES: + tr->terminal_rsp_data.get_input.result_type = RESULT_SUCCESS; + tr->terminal_rsp_data.get_input.text.dcs.m_class = MSG_CLASS_RESERVED; + + if(!q_data.cmd_data.getInputInd.command_detail.cmd_qualifier.get_input.alphabet_set){ + tr->terminal_rsp_data.get_input.text.is_digit_only = TRUE; + } + + if(q_data.cmd_data.getInputInd.text_attribute.b_txt_attr) + tr->terminal_rsp_data.get_input.result_type = RESULT_SUCCESS_WITH_PARTIAL_COMPREHENSION; + + if (q_data.cmd_data.getInputInd.icon_id.is_exist) + tr->terminal_rsp_data.get_input.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + if(!q_data.cmd_data.getInputInd.command_detail.cmd_qualifier.get_input.user_input_unpacked_format){ + dbg("[SAT] packing to SMS7 default"); + + tr->terminal_rsp_data.get_input.text.string_length = 0; + tr->terminal_rsp_data.get_input.text.dcs.a_format = ALPHABET_FORMAT_SMS_DEFAULT; + + if (input_data_len > 0){ + int tmp_len; + char tmp_str[SAT_TEXT_STRING_LEN_MAX + 1], *packed_data; + + dbg("sat gsm7 encoding"); + tcore_util_convert_utf8_to_gsm((unsigned char*)tmp_str, &tmp_len, (unsigned char*)input_data, input_data_len); + packed_data = (char*) tcore_util_pack_gsm7bit((const unsigned char *)tmp_str, tmp_len); + + if(packed_data){ + memcpy((void*)tr->terminal_rsp_data.get_input.text.string, packed_data, strlen(packed_data)); + tr->terminal_rsp_data.get_input.text.string_length = strlen(packed_data); + + g_free(packed_data); + } + } + + } + else + { + dbg("[SAT] packing not required"); + + if(q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_input.alphabet_type == INPUT_ALPHABET_TYPE_SMS_DEFAULT){ + + tr->terminal_rsp_data.get_input.text.dcs.a_format = ALPHABET_FORMAT_8BIT_DATA; + tcore_util_convert_utf8_to_gsm((unsigned char*)tr->terminal_rsp_data.get_input.text.string, + &tr->terminal_rsp_data.get_input.text.string_length, (unsigned char*)input_data, input_data_len); + + } + else if(q_data.cmd_data.getInkeyInd.command_detail.cmd_qualifier.get_input.alphabet_type == INPUT_ALPHABET_TYPE_UCS2 ){ + char *tmp = NULL; + + tr->terminal_rsp_data.get_input.text.dcs.a_format = ALPHABET_FORMAT_UCS2; + tcore_util_convert_utf8_to_ucs2(&tmp, &tr->terminal_rsp_data.get_input.text.string_length, (unsigned char*)input_data, input_data_len); + + memcpy(tr->terminal_rsp_data.get_input.text.string, tmp, tr->terminal_rsp_data.get_input.text.string_length); + g_free(tmp); + } + else{ + tr->terminal_rsp_data.get_input.text.dcs.a_format = ALPHABET_FORMAT_RESERVED; + dbg("[SAT] invalid DCS[%d]",tr->terminal_rsp_data.get_input.text.dcs.a_format); + } + } break; + + case USER_CONFIRM_HELP_INFO: + tr->terminal_rsp_data.get_input.result_type = RESULT_HELP_INFO_REQUIRED_BY_USER; + //TODO ctx->help_requested = TRUE; + break; + + case USER_CONFIRM_NO_OR_CANCEL: + tr->terminal_rsp_data.get_input.result_type = RESULT_BACKWARD_MOVE_BY_USER; + break; + + case USER_CONFIRM_TIMEOUT: + tr->terminal_rsp_data.get_input.result_type = RESULT_NO_RESPONSE_FROM_USER; + break; + + case USER_CONFIRM_END: + tr->terminal_rsp_data.get_input.result_type = RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; + break; + default: + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + + g_free(tr); + + return result; +} + +static gboolean _sat_manager_handle_setup_call_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + gint input_data_len = 0; + gchar input_data[SAT_TEXT_STRING_LEN_MAX]; + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + memset(input_data, 0, SAT_TEXT_STRING_LEN_MAX); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + if (addtional_data) { + int local_index = 0; + guchar data; + GVariantIter *iter = NULL; + GVariant *inner_gv = NULL; + + inner_gv = g_variant_get_variant(addtional_data); + dbg("additional data exist type_format(%s)", g_variant_get_type_string(inner_gv)); + + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop (iter, "y", &data)){ + dbg("index(%d) data(%d)", local_index, data); + input_data[local_index] = data; + local_index++; + } + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + input_data_len = local_index; + dbg("input_data_len=[%d]", input_data_len); + } + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.setup_call.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.setup_call.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.setup_call.command_detail, &q_data.cmd_data.setup_call.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.setup_call.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.setup_call.device_id.dest = q_data.cmd_data.setup_call.device_id.src; + + switch(confirm_type){ + case USER_CONFIRM_YES:{ + char *path; + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + + const gchar *cp_name; + GVariant *setup_call = NULL; + + gint command_id, call_type, confirmed_text_len, text_len, duration; + gchar *confirmed_text = NULL, *text = NULL, *call_number = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + enum dbus_tapi_sim_slot_id slot_id; + gboolean call_app_rv; + + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + goto Exit; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + goto Exit; + } + + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + + setup_call = sat_manager_setup_call_noti(ctx, cp_name, &q_data.cmd_data.setup_call); + + dbg("setup call type_format(%s)", g_variant_get_type_string(setup_call)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(setup_call, "(isisi@visi)", &command_id, &confirmed_text, &confirmed_text_len, &text, &text_len, &icon_id, &call_type, &call_number, &duration); + + telephony_sat_emit_setup_call(sat, command_id, confirmed_text, confirmed_text_len, text, text_len, icon_id, call_type, + call_number, duration); +#else + g_variant_get(setup_call, "(isisiisi)", &command_id, &confirmed_text, &confirmed_text_len, &text, &text_len, &call_type, &call_number, &duration); + + telephony_sat_emit_setup_call(sat, command_id, confirmed_text, confirmed_text_len, text, text_len, call_type, + call_number, duration); +#endif + g_free(confirmed_text); + g_free(text); + g_free(call_number); + + slot_id = get_sim_slot_id_by_cp_name((char *)tcore_server_get_cp_name_by_plugin(plg)); + dbg("slot_id: [%d]", slot_id); + + call_app_rv = sat_ui_support_launch_call_application(q_data.cmd_data.setup_call.command_detail.cmd_type, setup_call, slot_id); + free (tr); + + return call_app_rv; + } + + case USER_CONFIRM_NO_OR_CANCEL:{ + tr->terminal_rsp_data.setup_call.result_type = RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; + }break; + + case USER_CONFIRM_END:{ + tr->terminal_rsp_data.setup_call.result_type = RESULT_USER_DID_NOT_ACCEPT_CALL_SETUP_REQ; + }break; + + case USER_CONFIRM_HELP_INFO: + default: + tr->terminal_rsp_data.setup_call.result_type = RESULT_NO_RESPONSE_FROM_USER; + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } +Exit: + free (tr); + return result; +} + +static gboolean _sat_manager_handle_send_dtmf_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.send_dtmf.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.send_dtmf.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_dtmf.command_detail, &q_data.cmd_data.send_dtmf.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.send_dtmf.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_dtmf.device_id.dest = q_data.cmd_data.send_dtmf.device_id.src; + + dbg("confirm_type[%d]", confirm_type); + + switch(confirm_type){ + case USER_CONFIRM_NO_OR_CANCEL: + case USER_CONFIRM_END: + tr->terminal_rsp_data.send_dtmf.result_type = RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; + tr->terminal_rsp_data.send_dtmf.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + break; + default: + tr->terminal_rsp_data.send_dtmf.result_type = RESULT_NO_RESPONSE_FROM_USER; + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + g_free(tr); + + return result; +} + +static gboolean _sat_manager_handle_launch_browser_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.launch_browser.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.launch_browser.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.launch_browser.command_detail, &q_data.cmd_data.launch_browser.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.launch_browser.device_id.src = q_data.cmd_data.launch_browser.device_id.dest; + tr->terminal_rsp_data.launch_browser.device_id.dest = q_data.cmd_data.launch_browser.device_id.src; + + dbg("confirm_type[%d]", confirm_type); + + switch(confirm_type){ + case USER_CONFIRM_YES:{ + char *path; + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + + const gchar *cp_name; + GVariant *launch_browser = NULL; + + gint command_id = 0; + gint browser_launch_type = 0, browser_id = 0; + gint url_len = 0, text_len = 0, gateway_proxy_len =0; + gchar *url = NULL; + gchar *text = NULL; + gchar *gateway_proxy = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; +#endif + enum dbus_tapi_sim_slot_id slot_id; + + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + goto Exit; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + goto Exit; + } + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + + launch_browser = sat_manager_launch_browser_noti(ctx, cp_name, &q_data.cmd_data.launch_browser); + + dbg("launch_browser type_format(%s)", g_variant_get_type_string(launch_browser)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(launch_browser, "(iiisisisi@v)", &command_id, &browser_launch_type, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len, &icon_id); + + telephony_sat_emit_launch_browser(sat, command_id, browser_launch_type, browser_id, url, url_len, gateway_proxy, gateway_proxy_len, text, text_len, icon_id); +#else + g_variant_get(launch_browser, "(iiisisisi)", &command_id, &browser_launch_type, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len); + + telephony_sat_emit_launch_browser(sat, command_id, browser_launch_type, browser_id, url, url_len, gateway_proxy, gateway_proxy_len, text, text_len); +#endif + g_free(url); + g_free(text); + g_free(gateway_proxy); + + slot_id = get_sim_slot_id_by_cp_name((char*)tcore_server_get_cp_name_by_plugin(plg)); + dbg("slot_id: [%d]", slot_id); + + sat_ui_support_launch_browser_application(q_data.cmd_data.launch_browser.command_detail.cmd_type, launch_browser, slot_id); + + g_free(tr); + return TRUE; + }break; + + case USER_CONFIRM_NO_OR_CANCEL: + tr->terminal_rsp_data.launch_browser.result_type = RESULT_BACKWARD_MOVE_BY_USER; + break; + case USER_CONFIRM_END: + tr->terminal_rsp_data.launch_browser.result_type = RESULT_PROACTIVE_SESSION_TERMINATED_BY_USER; + break; + + default: + tr->terminal_rsp_data.launch_browser.result_type = RESULT_NO_RESPONSE_FROM_USER; + break; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } +Exit: + g_free(tr); + return result; +} +#if !defined(TIZEN_PLATFORM_USE_QCOM_QMI) +static gboolean _sat_manager_handle_open_channel_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data.cmd_data.open_channel.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.open_channel.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.open_channel.command_detail, &q_data.cmd_data.open_channel.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.open_channel.device_id.src = q_data.cmd_data.send_dtmf.device_id.dest; + tr->terminal_rsp_data.open_channel.device_id.dest = q_data.cmd_data.send_dtmf.device_id.src; + + dbg("confirm_type[%d]", confirm_type); + + switch(confirm_type){ + case USER_CONFIRM_YES:{ + char *path; + TelephonyObjectSkeleton *object; + + const gchar *cp_name; + + GVariant *open_channel = NULL; + + gint command_id, bearer_type, protocol_type, dest_addr_type; + gboolean immediate_link, auto_reconnection, bg_mode; + gint text_len, buffer_size, port_number; + gchar *text = NULL, *dest_address = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + GVariant *bearer_param; + GVariant *bearer_detail; + + //emit send_dtmf signal + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + goto Exit; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + goto Exit; + } + + open_channel = sat_manager_open_channel_noti(ctx, cp_name, &q_data.cmd_data.open_channel); + + dbg("open channel type_format(%s)", g_variant_get_type_string(open_channel)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(open_channel,"(isi@vbbbi@viiiis@v)", &command_id, &text, &text_len, &icon_id, &immediate_link, &auto_reconnection, &bg_mode, + &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); +#else + g_variant_get(open_channel,"(isibbbi@viiiis@v)", &command_id, &text, &text_len, &immediate_link, &auto_reconnection, &bg_mode, + &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); +#endif + /*telephony_sat_emit_open_channel(sat, command_id, text, text_len, immediate_link, auto_reconnection, bg_mode, + bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail);*/ + + g_free(text); + g_free(dest_address); + //BIP Manager + { + GDBusConnection *conn = NULL; + const gchar *g_path = NULL; + + conn = g_dbus_object_manager_server_get_connection(ctx->manager); + g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); + + sat_ui_support_exec_bip(conn, g_path, SAT_PROATV_CMD_OPEN_CHANNEL, open_channel); + } + + g_free(tr); + + return TRUE; + }break; + + case USER_CONFIRM_NO_OR_CANCEL: + case USER_CONFIRM_END: + tr->terminal_rsp_data.open_channel.result_type = RESULT_USER_DID_NOT_ACCEPT_CALL_SETUP_REQ; + break; + default: + tr->terminal_rsp_data.open_channel.result_type = RESULT_NO_RESPONSE_FROM_USER; + break; + } + + memcpy((void*)&tr->terminal_rsp_data.open_channel.bearer_desc, &q_data.cmd_data.open_channel.bearer_desc, sizeof(struct tel_sat_bearer_description)); + memcpy((void*)&tr->terminal_rsp_data.open_channel.buffer_size, &q_data.cmd_data.open_channel.buffer_size, sizeof(struct tel_sat_buffer_size)); + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } +Exit: + g_free(tr); + return result; +} +#else +static gboolean _sat_manager_handle_open_channel_confirm(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gint confirm_type, GVariant *addtional_data) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + struct treq_sat_user_confirmation_data *conf_data; + struct sat_manager_queue_data q_data; + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + conf_data = (struct treq_sat_user_confirmation_data *)calloc(1, sizeof(struct treq_sat_user_confirmation_data)); + if (!conf_data) + return result; + + dbg("confirm_type[%d]", confirm_type); + + switch(confirm_type){ + case USER_CONFIRM_YES: + case USER_CONFIRM_NO_OR_CANCEL: + case USER_CONFIRM_END: + conf_data->user_conf = confirm_type; + break; + default: + dbg("Not handled confirm type!"); + break; + } + result = TRUE; + rv = sat_manager_send_user_confirmation(ctx->comm, plg, conf_data); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send user confirmation message"); + result = FALSE; + } + g_free(conf_data); + return result; +} +#endif +gboolean sat_manager_handle_user_confirm(struct custom_data *ctx, TcorePlugin *plg, GVariant *user_confirm_data) +{ + gboolean rv = FALSE; + gboolean result = FALSE; + struct sat_manager_queue_data q_data; + + gint command_id, command_type, confirm_type; + GVariant *additional_data = NULL; + + dbg("user_confirm_data type_format(%s)", g_variant_get_type_string(user_confirm_data)); + g_variant_get(user_confirm_data, "(iiv)", &command_id, &confirm_type, &additional_data); + + dbg("[SAT] user confirm data command id(%d), confirm_type(%d)", command_id, confirm_type); + + rv = sat_manager_queue_peek_data_by_id(ctx, &q_data, command_id); + if(!rv){ + dbg("[SAT] no commands in queue"); + return result; + } + + command_type = (gint)q_data.cmd_type; + dbg("[SAT] command type(%d)", command_type); + + switch(command_type){ + case SAT_PROATV_CMD_SELECT_ITEM: + result = _sat_manager_handle_menu_select_confirm(ctx, plg, command_id, confirm_type, additional_data); + break; + case SAT_PROATV_CMD_DISPLAY_TEXT: + result = _sat_manager_handle_display_text_confirm(ctx, plg, command_id, confirm_type, additional_data); + break; + case SAT_PROATV_CMD_GET_INKEY: + result = _sat_manager_handle_get_inkey_confirm(ctx, plg, command_id, confirm_type, additional_data); + break; + case SAT_PROATV_CMD_GET_INPUT: + result = _sat_manager_handle_get_input_confirm(ctx, plg, command_id, confirm_type, additional_data); + break; + case SAT_PROATV_CMD_SETUP_CALL: + result = _sat_manager_handle_setup_call_confirm(ctx, plg, command_id, confirm_type, additional_data); + break; + case SAT_PROATV_CMD_SEND_DTMF: + result = _sat_manager_handle_send_dtmf_confirm(ctx, plg, command_id, confirm_type, additional_data); + break; + case SAT_PROATV_CMD_LAUNCH_BROWSER: + result = _sat_manager_handle_launch_browser_confirm(ctx, plg, command_id, confirm_type, additional_data); + break; + case SAT_PROATV_CMD_OPEN_CHANNEL: + result = _sat_manager_handle_open_channel_confirm(ctx, plg, command_id, confirm_type, additional_data); + break; + default: + dbg("[SAT] cannot handle user confirm command(0x%x)", command_type); + break; + } + + return result; +} + +static gboolean _sat_manager_handle_play_tone_ui_display_status(struct custom_data *ctx, TcorePlugin *plg,struct sat_manager_queue_data *q_data, gboolean display_status) +{ + char *path; + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + + const gchar *cp_name; + GVariant *play_tone = NULL; + + + gint command_id, tone_type, duration; + gint text_len; + gchar* text; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + if(!display_status){ + struct treq_sat_terminal_rsp_data *tr = NULL; + dbg("[SAT] fail to show ui display for play tone"); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return FALSE; + + tr->cmd_number = q_data->cmd_data.play_tone.command_detail.cmd_num; + tr->cmd_type = q_data->cmd_data.play_tone.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.play_tone.command_detail, &q_data->cmd_data.play_tone.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.play_tone.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.play_tone.device_id.dest = q_data->cmd_data.play_tone.device_id.src; + tr->terminal_rsp_data.play_tone.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + + sat_manager_send_terminal_response(ctx->comm, plg, tr); + free (tr); + + return TRUE; + } + + //emit play tone signal + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + return FALSE; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + return FALSE; + } + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + + play_tone = sat_manager_play_tone_noti(ctx, cp_name, &q_data->cmd_data.play_tone); + + dbg("play tone type_format(%s)", g_variant_get_type_string(play_tone)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(play_tone, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &tone_type, &duration); + + telephony_sat_emit_play_tone(sat, command_id, text, text_len, icon_id, tone_type, duration); +#else + g_variant_get(play_tone, "(isiii)", &command_id, &text, &text_len, &tone_type, &duration); + + telephony_sat_emit_play_tone(sat, command_id, text, text_len, tone_type, duration); +#endif + g_free(text); + + return TRUE; +} + +static gboolean _sat_manager_handle_setup_idle_mode_text_ui_display_status(struct custom_data *ctx, TcorePlugin *plg,struct sat_manager_queue_data *q_data, gboolean display_status) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + + struct treq_sat_terminal_rsp_data *tr; + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return result; + + tr->cmd_number = q_data->cmd_data.idle_mode.command_detail.cmd_num; + tr->cmd_type = q_data->cmd_data.idle_mode.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.setup_idle_mode_text.command_detail, &q_data->cmd_data.idle_mode.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.setup_idle_mode_text.device_id.src = q_data->cmd_data.idle_mode.device_id.dest; + tr->terminal_rsp_data.setup_idle_mode_text.device_id.dest = q_data->cmd_data.idle_mode.device_id.src; + + tr->terminal_rsp_data.setup_idle_mode_text.result_type = RESULT_SUCCESS; + if (q_data->cmd_data.idle_mode.icon_id.is_exist) + tr->terminal_rsp_data.setup_idle_mode_text.result_type = RESULT_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED; + + //fail to display text + if(!display_status){ + dbg("[SAT] fail to show ui display for setup_idle_mode_text"); + tr->terminal_rsp_data.setup_idle_mode_text.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + result = FALSE; + } + g_free(tr); + + return result; +} + +static gboolean _sat_manager_handle_refresh_ui_display_status(struct custom_data *ctx, TcorePlugin *plg,struct sat_manager_queue_data *q_data, gboolean display_status) +{ + struct treq_sat_terminal_rsp_data tr; + + memset(&tr, 0, sizeof(struct treq_sat_terminal_rsp_data)); + + tr.cmd_number = q_data->cmd_data.refresh.command_detail.cmd_num; + tr.cmd_type = q_data->cmd_data.refresh.command_detail.cmd_type; + memcpy((void*)&tr.terminal_rsp_data.refresh.command_detail, &q_data->cmd_data.refresh.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr.terminal_rsp_data.refresh.device_id.src = q_data->cmd_data.refresh.device_id.dest; + tr.terminal_rsp_data.refresh.device_id.dest = q_data->cmd_data.refresh.device_id.src; + + if(!display_status){ + dbg("fail to show ui for refresh"); + tr.terminal_rsp_data.refresh.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + } + else{ + dbg("success to show ui for refresh"); + tr.terminal_rsp_data.refresh.result_type = RESULT_SUCCESS; + tr.terminal_rsp_data.refresh.me_problem_type = ME_PROBLEM_NO_SPECIFIC_CAUSE; + } + + dbg("send refresh tr"); + sat_manager_send_terminal_response(ctx->comm, plg, &tr); + return TRUE; +} + + +#if !defined(TIZEN_PLATFORM_USE_QCOM_QMI) +static gboolean _sat_manager_handle_send_sms_ui_display_status(struct custom_data *ctx, TcorePlugin *plg,struct sat_manager_queue_data *q_data, gboolean display_status) +{ + char *path; + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + + const char *cp_name; + GVariant *send_sms = NULL; + + gint command_id, ton, npi, tpdu_type; + gboolean b_packing_required; + gint text_len, number_len, tpdu_data_len; + gchar* text, *dialling_number; + GVariant *tpdu_data; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + + if(!display_status){ + struct treq_sat_terminal_rsp_data *tr = NULL; + dbg("[SAT] fail to show ui display for send sms"); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return FALSE; + + tr->cmd_number = q_data->cmd_data.sendSMSInd.command_detail.cmd_num; + tr->cmd_type = q_data->cmd_data.sendSMSInd.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_sms.command_detail, &q_data->cmd_data.sendSMSInd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.send_sms.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_sms.device_id.dest = q_data->cmd_data.sendSMSInd.device_id.src; + tr->terminal_rsp_data.send_sms.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + + sat_manager_send_terminal_response(ctx->comm, plg, tr); + free (tr); + + return TRUE; + } + + //emit send sms signal + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + return FALSE; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + return FALSE; + } + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + + send_sms = sat_manager_send_sms_noti(ctx, cp_name, &q_data->cmd_data.sendSMSInd); + + dbg("send sms type_format(%s)", g_variant_get_type_string(send_sms)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(send_sms, "(isi@vbiisii@vi)", &command_id, &text, &text_len, &icon_id, &b_packing_required, &ton, &npi, + &dialling_number, &number_len, &tpdu_type, &tpdu_data, &tpdu_data_len); +#else + g_variant_get(send_sms, "(isibiisii@vi)", &command_id, &text, &text_len, &b_packing_required, &ton, &npi, + &dialling_number, &number_len, &tpdu_type, &tpdu_data, &tpdu_data_len); +#endif + telephony_sat_emit_send_sms(sat, command_id, text, text_len, b_packing_required, + ton, npi, dialling_number, number_len, tpdu_type, tpdu_data, tpdu_data_len); + + g_free(text); + g_free(dialling_number); + return TRUE; +} + +static gboolean _sat_manager_handle_send_ss_ui_display_status(struct custom_data *ctx, TcorePlugin *plg,struct sat_manager_queue_data *q_data, gboolean display_status) +{ + char *path; + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + + const gchar *cp_name; + GVariant *send_ss = NULL; + + gint command_id, ton, npi; + gint text_len, ss_str_len; + gchar* text = NULL, *ss_string = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + enum dbus_tapi_sim_slot_id slot_id; + + if(!display_status){ + struct treq_sat_terminal_rsp_data *tr = NULL; + dbg("[SAT] fail to show ui display for send ss"); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return FALSE; + + tr->cmd_number = q_data->cmd_data.send_ss.command_detail.cmd_num; + tr->cmd_type = q_data->cmd_data.send_ss.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_ss.command_detail, &q_data->cmd_data.send_ss.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.send_ss.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_ss.device_id.dest = q_data->cmd_data.send_ss.device_id.src; + tr->terminal_rsp_data.send_ss.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + + sat_manager_send_terminal_response(ctx->comm, plg, tr); + free (tr); + + return TRUE; + } + + //emit send ss signal + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + return FALSE; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + return FALSE; + } + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + + send_ss = sat_manager_send_ss_noti(ctx, cp_name, &q_data->cmd_data.send_ss); + + dbg("send ss type_format(%s)", g_variant_get_type_string(send_ss)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(send_ss, "(isi@viiis)", &command_id, &text, &text_len, &icon_id, + &ton, &npi, &ss_str_len, &ss_string); +#else + g_variant_get(send_ss, "(isiiiis)", &command_id, &text, &text_len, + &ton, &npi, &ss_str_len, &ss_string); +#endif + telephony_sat_emit_send_ss(sat, command_id, text, text_len, ton, npi, ss_string); + g_free(text); + g_free(ss_string); + + slot_id = get_sim_slot_id_by_cp_name((char *)tcore_server_get_cp_name_by_plugin(plg)); + dbg("slot_id: [%d]", slot_id); + sat_ui_support_launch_ciss_application(SAT_PROATV_CMD_SEND_SS, send_ss, slot_id); + + return TRUE; +} + +static gboolean _sat_manager_handle_send_ussd_ui_display_status(struct custom_data *ctx, TcorePlugin *plg,struct sat_manager_queue_data *q_data, gboolean display_status) +{ + char *path; + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + + const gchar *cp_name; + GVariant *send_ussd = NULL; + + gint command_id; + guchar dcs; + gint text_len, ussd_str_len; + gchar* text = NULL, *ussd_string = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + enum dbus_tapi_sim_slot_id slot_id; + + if(!display_status){ + struct treq_sat_terminal_rsp_data *tr = NULL; + dbg("[SAT] fail to show ui display for send ussd"); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return FALSE; + + tr->cmd_number = q_data->cmd_data.send_ussd.command_detail.cmd_num; + tr->cmd_type = q_data->cmd_data.send_ussd.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_ussd.command_detail, &q_data->cmd_data.send_ussd.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.send_ussd.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_ussd.device_id.dest = q_data->cmd_data.send_ussd.device_id.src; + tr->terminal_rsp_data.send_ussd.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + + sat_manager_send_terminal_response(ctx->comm, plg, tr); + g_free(tr); + + return TRUE; + } + + //emit send ussd signal + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + return FALSE; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + return FALSE; + } + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + + send_ussd = sat_manager_send_ussd_noti(ctx, cp_name, &q_data->cmd_data.send_ussd); + + dbg("send ussd type_format(%s)", g_variant_get_type_string(send_ussd)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(send_ussd, "(isi@vyis)", &command_id, &text, &text_len, &icon_id, &dcs, &ussd_str_len, &ussd_string); +#else + g_variant_get(send_ussd, "(isiyis)", &command_id, &text, &text_len, &dcs, &ussd_str_len, &ussd_string); +#endif + telephony_sat_emit_setup_ussd(sat, command_id, text, text_len, dcs, ussd_string); + g_free(text); + g_free(ussd_string); + + slot_id = get_sim_slot_id_by_cp_name((char *)tcore_server_get_cp_name_by_plugin(plg)); + dbg("slot_id: [%d]", slot_id); + sat_ui_support_launch_ciss_application(SAT_PROATV_CMD_SEND_USSD, send_ussd,slot_id); + + return TRUE; +} + +static gboolean _sat_manager_handle_send_dtmf_ui_display_status(struct custom_data *ctx, TcorePlugin *plg,struct sat_manager_queue_data *q_data, gboolean display_status) +{ + char *path; + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + + const gchar *cp_name; + + GVariant *send_dtmf = NULL; + gint command_id = 0; + gint text_len = 0, dtmf_str_len = 0; + gchar *text = NULL; + gchar *dtmf_str = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; +#endif + if(!display_status){ + struct treq_sat_terminal_rsp_data *tr = NULL; + dbg("[SAT] fail to show ui display for send_dtmf"); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return FALSE; + + tr->cmd_number = q_data->cmd_data.send_dtmf.command_detail.cmd_num; + tr->cmd_type = q_data->cmd_data.send_dtmf.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.send_dtmf.command_detail, &q_data->cmd_data.send_dtmf.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.send_dtmf.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.send_dtmf.device_id.dest = q_data->cmd_data.send_dtmf.device_id.src; + tr->terminal_rsp_data.send_dtmf.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + + sat_manager_send_terminal_response(ctx->comm, plg, tr); + g_free(tr); + + return TRUE; + } + + //emit send_dtmf signal + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + return FALSE; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + return FALSE; + } + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + + send_dtmf = sat_manager_send_dtmf_noti(ctx, cp_name, &q_data->cmd_data.send_dtmf); + + dbg("send_dtmf type_format(%s)", g_variant_get_type_string(send_dtmf)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(send_dtmf, "(isi@vis)", &command_id, &text, &text_len, &icon_id, &dtmf_str_len, &dtmf_str); +#else + g_variant_get(send_dtmf, "(isiis)", &command_id, &text, &text_len, &dtmf_str_len, &dtmf_str); +#endif + telephony_sat_emit_send_dtmf(sat, command_id, text, text_len, dtmf_str, dtmf_str_len); + g_free(text); + g_free(dtmf_str); + + return TRUE; +} + +static gboolean _sat_manager_handle_open_channel_ui_display_status(struct custom_data *ctx, TcorePlugin *plg,struct sat_manager_queue_data *q_data, gboolean display_status) +{ + char *path; + TelephonyObjectSkeleton *object; + + const gchar *cp_name; + + GVariant *open_channel = NULL; + + gint command_id, bearer_type, protocol_type, dest_addr_type; + gboolean immediate_link, auto_reconnection, bg_mode; + gint text_len, buffer_size, port_number; + gchar *text, *dest_address; + GVariant *bearer_param; + GVariant *bearer_detail; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + + if(!display_status){ + struct treq_sat_terminal_rsp_data *tr = NULL; + dbg("[SAT] fail to show ui display for open channel"); + + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return FALSE; + + tr->cmd_number = q_data->cmd_data.open_channel.command_detail.cmd_num; + tr->cmd_type = q_data->cmd_data.open_channel.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.open_channel.command_detail, &q_data->cmd_data.open_channel.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + + tr->terminal_rsp_data.open_channel.device_id.src = q_data->cmd_data.send_dtmf.device_id.dest; + tr->terminal_rsp_data.open_channel.device_id.dest = q_data->cmd_data.send_dtmf.device_id.src; + tr->terminal_rsp_data.open_channel.result_type = RESULT_ME_UNABLE_TO_PROCESS_COMMAND; + + sat_manager_send_terminal_response(ctx->comm, plg, tr); + g_free(tr); + + return TRUE; + } + + //emit send_dtmf signal + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + return FALSE; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + return FALSE; + } + + open_channel = sat_manager_open_channel_noti(ctx, cp_name, &q_data->cmd_data.open_channel); + + dbg("open channel type_format(%s)", g_variant_get_type_string(open_channel)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(open_channel,"(isi@vbbbi@viiiis@v)", &command_id, &text, &text_len, &icon_id, &immediate_link, &auto_reconnection, &bg_mode, + &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); +#else + g_variant_get(open_channel,"(isibbbi@viiiis@v)", &command_id, &text, &text_len, &immediate_link, &auto_reconnection, &bg_mode, + &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); +#endif + /*telephony_sat_emit_open_channel(sat, command_id, text, text_len, immediate_link, auto_reconnection, bg_mode, + bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail);*/ + g_free(text); + g_free(dest_address); + + //BIP Manager + { + GDBusConnection *conn = NULL; + const gchar *g_path = NULL; + + conn = g_dbus_object_manager_server_get_connection(ctx->manager); + g_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object)); + + sat_ui_support_exec_bip(conn, g_path, SAT_PROATV_CMD_OPEN_CHANNEL, open_channel); + } + + return TRUE; +} + +gboolean sat_manager_handle_ui_display_status(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gboolean display_status) +{ + gboolean result = FALSE; + struct sat_manager_queue_data q_data; + + dbg("[SAT] ui display status : command id(%d) display status(%d)", command_id, display_status); + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command peek data from queue is failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + switch(q_data.cmd_type){ + case SAT_PROATV_CMD_PLAY_TONE: + result = _sat_manager_handle_play_tone_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_SEND_SMS: + result = _sat_manager_handle_send_sms_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_SEND_SS: + result = _sat_manager_handle_send_ss_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_SEND_USSD: + result = _sat_manager_handle_send_ussd_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: + result = _sat_manager_handle_setup_idle_mode_text_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_REFRESH: + result = _sat_manager_handle_refresh_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_SEND_DTMF: + result = _sat_manager_handle_send_dtmf_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_OPEN_CHANNEL: + result = _sat_manager_handle_open_channel_ui_display_status(ctx, plg, &q_data, display_status); + break; + default: + dbg("[SAT] cannot handle ui display status command(0x%x)", q_data.cmd_type); + break; + } + + return result; +} +#else +static gboolean _sat_manager_handle_open_channel_ui_display_status(struct custom_data *ctx, TcorePlugin *plg,struct sat_manager_queue_data *q_data, gboolean display_status) +{ + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + struct treq_sat_user_confirmation_data *conf_data; + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + conf_data = (struct treq_sat_user_confirmation_data *)calloc(1, sizeof(struct treq_sat_user_confirmation_data)); + if (!conf_data) + return result; + + dbg("display_status[%d]", display_status); + + if(display_status) + conf_data->user_conf = USER_CONFIRM_YES; + else + conf_data->user_conf = USER_CONFIRM_NO_OR_CANCEL; + + result = TRUE; + rv = sat_manager_send_user_confirmation(ctx->comm, plg, conf_data); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send user confirmation message"); + result = FALSE; + } + g_free(conf_data); + return result; +} + +gboolean sat_manager_handle_ui_display_status(struct custom_data *ctx, TcorePlugin *plg, gint command_id, gboolean display_status) +{ + gboolean result = FALSE; + struct sat_manager_queue_data q_data; + + dbg("[SAT] ui display status : command id(%d) display status(%d)", command_id, display_status); + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command peek data from queue is failed. didn't find in command Q!!"); + return result; + } + + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + switch(q_data.cmd_type){ + case SAT_PROATV_CMD_PLAY_TONE: + result = _sat_manager_handle_play_tone_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: + result = _sat_manager_handle_setup_idle_mode_text_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_REFRESH: + result = _sat_manager_handle_refresh_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_OPEN_CHANNEL: + result = _sat_manager_handle_open_channel_ui_display_status(ctx, plg, &q_data, display_status); + break; + case SAT_PROATV_CMD_SEND_SMS: + case SAT_PROATV_CMD_SEND_SS: + case SAT_PROATV_CMD_SEND_USSD: + case SAT_PROATV_CMD_SEND_DTMF: + dbg("[SAT] command(0x%x) will be handled by CP", q_data.cmd_type); + result = TRUE; + if(q_data.noti_required) { + TelephonySAT *sat; + TelephonyObjectSkeleton *object; + const gchar *cp_name; + gchar *path = NULL; + + dbg("Noti flag is set, send session end evt."); + //emit session end + + cp_name = tcore_server_get_cp_name_by_plugin(plg); + if (cp_name == NULL) { + err("CP name is NULL"); + return FALSE; + } + + dbg("CP Name: [%s]", cp_name); + path = g_strdup_printf("%s/%s", MY_DBUS_PATH, cp_name); + + /* Look-up Hash table for Object */ + object = g_hash_table_lookup(ctx->objects, path); + dbg("Path: [%s] Interface object: [%p]", path, object); + g_free(path); + if (object == NULL) { + err("Object is NOT defined!!!"); + return FALSE; + } + + sat = telephony_object_peek_sat(TELEPHONY_OBJECT(object)); + telephony_sat_emit_end_proactive_session(sat, SAT_PROATV_CMD_TYPE_END_PROACTIVE_SESSION); + } + break; + default: + dbg("[SAT] cannot handle ui display status command(0x%x)", q_data.cmd_type); + break; + } + return result; +} + +#endif +gboolean sat_manager_handle_event_download_envelop(int event_type, int src_dev, int dest_dev, struct tel_sat_envelop_event_download_tlv *evt_download, GVariant *download_data) +{ + gboolean rv = FALSE; + GVariant *data = NULL; + + dbg("download data type_format(%s)", g_variant_get_type_string(download_data)); + g_variant_get(download_data, "v", &data); + + + if(g_evt_list[event_type] == TRUE){ + dbg("event (%d) shoud be passed to sim", event_type); + rv = TRUE; + } + + if(!rv){ + dbg("(%d) event does not requested by sim", event_type); + return FALSE; + } + + switch(event_type) + { + case EVENT_USER_ACTIVITY: + dbg("data type_format(%s)", g_variant_get_type_string(data)); + evt_download->device_identitie.src = src_dev; + evt_download->device_identitie.dest = dest_dev; + break; + case EVENT_IDLE_SCREEN_AVAILABLE: + dbg("data type_format(%s)", g_variant_get_type_string(data)); + g_variant_get(data, "(b)", &evt_download->idle_screen); + evt_download->device_identitie.src = DEVICE_ID_DISPLAY; + evt_download->device_identitie.dest = dest_dev; + dbg("idle screen available (%d)", evt_download->idle_screen); + break; + case EVENT_LANGUAGE_SELECTION: + dbg("data type_format(%s)", g_variant_get_type_string(data)); + g_variant_get(data, "(i)", &evt_download->language); + evt_download->device_identitie.src = src_dev; + evt_download->device_identitie.dest = dest_dev; + dbg("selected language (%d)", evt_download->language); + break; + case EVENT_BROWSER_TERMINATION:{ + dbg("data type_format(%s)", g_variant_get_type_string(data)); + g_variant_get(data, "(i)", &evt_download->browser_termination); + evt_download->device_identitie.src = src_dev; + evt_download->device_identitie.dest = dest_dev; + dbg("browser termination cause(%d)", evt_download->browser_termination); + } break; + case EVENT_DATA_AVAILABLE:{ + gint channel_id, channel_status, channel_info, channel_data_len; + + dbg("data type_format(%s)", g_variant_get_type_string(data)); + g_variant_get(data, "(iiii)", &channel_id, &channel_status, &channel_info, &channel_data_len); + evt_download->device_identitie.src = src_dev; + evt_download->device_identitie.dest = dest_dev; + evt_download->channel_status.channel_id = channel_id; + evt_download->channel_status.status = channel_status; + evt_download->channel_status.status_info = channel_info; + evt_download->channel_data_len.data_len = channel_data_len; + dbg("data available channel id (%d)", evt_download->channel_status.channel_id); + } break; + case EVENT_CHANNEL_STATUS:{ + gint channel_id, channel_status, channel_info; + + dbg("data type_format(%s)", g_variant_get_type_string(data)); + g_variant_get(data, "(iii)", &channel_id, &channel_status, &channel_info); + evt_download->device_identitie.src = src_dev; + evt_download->device_identitie.dest = dest_dev; + evt_download->channel_status.channel_id = channel_id; + evt_download->channel_status.status = channel_status; + evt_download->channel_status.status_info = channel_info; + + } break; + default : + dbg("not support download event (%d)", event_type); + break; + } + + return TRUE; +} + +gboolean sat_manager_update_language(struct custom_data *ctx, const char *cp_name, GVariant *language_noti) +{ + Server *s = NULL; + TcorePlugin *plg = NULL; + static Storage *strg; + + TReturn rv = TCORE_RETURN_FAILURE; + gboolean result = FALSE; + const gchar *lang_str = NULL; + gint command_id, language; + gboolean b_specified; + + struct treq_sat_terminal_rsp_data *tr; + struct sat_manager_queue_data q_data; + + s = ctx->server; + strg = tcore_server_find_storage(s, "vconf"); + + plg = tcore_server_find_plugin(ctx->server, cp_name); + if (!plg){ + dbg("there is no valid plugin at this point"); + return result; + } + + memset(&q_data, 0, sizeof(struct sat_manager_queue_data)); + + dbg("language_noti type_format(%s)", g_variant_get_type_string(language_noti)); + g_variant_get(language_noti, "(iib)", &command_id, &language, &b_specified); + + if (sat_manager_dequeue_cmd_by_id(ctx, &q_data, command_id) == FALSE) { + dbg("[SAT] command dequeue failed. didn't find in command Q!!"); + return result; + } + + if(q_data.cmd_type != SAT_PROATV_CMD_LANGUAGE_NOTIFICATION){ + dbg("[SAT] Language Noti dequeue failed. didn't find in command Q!!"); + return result; + } + + if (b_specified) { + lang_str = _convert_sim_lang_to_string((enum tel_sim_language_type)language); + if(!lang_str){ + dbg("language is not exist"); + } + dbg("converted lang (%s)", lang_str); + + if(_sat_manager_check_language_set(lang_str)) { + dbg("supprted language, set vconf."); + result = tcore_storage_set_string(strg,STORAGE_KEY_LANGUAGE_SET, (const char*)lang_str); + if(!result){ + dbg("fail to update language"); + } + } + } + + /* TR should be sent with success result + * regardless of language is specified or not. + */ + tr = (struct treq_sat_terminal_rsp_data *)calloc(1, sizeof(struct treq_sat_terminal_rsp_data)); + if (!tr) + return FALSE; + + tr->cmd_number = q_data.cmd_data.language_notification.command_detail.cmd_num; + tr->cmd_type = q_data.cmd_data.language_notification.command_detail.cmd_type; + memcpy((void*)&tr->terminal_rsp_data.language_notification.command_detail, &q_data.cmd_data.language_notification.command_detail, sizeof(struct tel_sat_cmd_detail_info)); + tr->terminal_rsp_data.language_notification.device_id.src = DEVICE_ID_ME; + tr->terminal_rsp_data.language_notification.device_id.dest = DEVICE_ID_SIM; + tr->terminal_rsp_data.language_notification.result_type = RESULT_SUCCESS; + + result = TRUE; + rv = sat_manager_send_terminal_response(ctx->comm, plg, tr); + if(rv != TCORE_RETURN_SUCCESS){ + dbg("fail to send terminal response"); + g_free(tr); + result = FALSE; + return result; + } + + g_free(tr); + return result; +} diff --git a/src/sat_manager.h b/src/sat_manager.h new file mode 100644 index 0000000..7fb1d36 --- /dev/null +++ b/src/sat_manager.h @@ -0,0 +1,106 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 SAT_MANAGER_H_ +#define SAT_MANAGER_H_ + +#include +#include +#include "common.h" + + +typedef union { + struct tel_sat_display_text_tlv displayTextInd; /**< Parsed proactive command info from TLV to Telephony data type - display text */ + struct tel_sat_get_inkey_tlv getInkeyInd; /**< Parsed proactive command info from TLV to Telephony data type - getInkey */ + struct tel_sat_get_input_tlv getInputInd; /**< Parsed proactive command info from TLV to Telephony data type - getInput */ + struct tel_sat_play_tone_tlv play_tone; + struct tel_sat_setup_menu_tlv setupMenuInd; /**< Parsed proactive command info from TLV to Telephony data type - setup menu */ + struct tel_sat_select_item_tlv selectItemInd; /**< Parsed proactive command info from TLV to Telephony data type - select item */ + struct tel_sat_send_sms_tlv sendSMSInd; + struct tel_sat_send_ss_tlv send_ss; + struct tel_sat_send_ussd_tlv send_ussd; + struct tel_sat_setup_call_tlv setup_call; + struct tel_sat_refresh_tlv refresh; + struct tel_sat_provide_local_info_tlv provide_local_info; + struct tel_sat_setup_idle_mode_text_tlv idle_mode; + struct tel_sat_send_dtmf_tlv send_dtmf; + struct tel_sat_language_notification_tlv language_notification; + struct tel_sat_launch_browser_tlv launch_browser; + struct tel_sat_open_channel_tlv open_channel; + struct tel_sat_close_channel_tlv close_channel; + struct tel_sat_receive_channel_tlv receive_data; + struct tel_sat_send_channel_tlv send_data; + struct tel_sat_get_channel_status_tlv get_channel_status; + struct tel_sat_unsupproted_command_tlv unsupport_cmd; +} sat_manager_proactive_data; + +/** + * This structure defines the Command Queue Info. + */ +struct sat_manager_queue_data { + enum tel_sat_proactive_cmd_type cmd_type; /** + * + * 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. + */ + +/** + * @open + * @ingroup TelephonyAPI + * @addtogroup TAPI_CALL CALL + * @{ + * + * @file TelCall.h + + @brief This file serves as a "C" header file defines structures for Tapi Call Services. \n + It contains a sample set of constants, enums, structs that would be required by applications. + */ + +#ifndef _TEL_CALL_H_ +#define _TEL_CALL_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TAPI_CALLING_NAME_SIZE_MAX 80 /**< The maximum length of the string for calling party name. */ +#define TAPI_CALL_UUS_DATA_LEN_MAX 131 /**< The Maximum length of the user to user singnalling data string. */ +#define TAPI_CALL_DISPLAY_RECORD_MAX 32 /**< The maximum length of the string for display record in CDMA */ +#define MAX_TAPI_CALL_COUNT 6 /**< Maximum number of call can be possible at a time */ +#define MAX_TAPI_CONF_CALL_COUNT 5 /**< Maximum number of Call can be possible in a conference call at a time */ +#define INVALID_CALL_HANDLE 0 /**< TS_UINT is used for call handle */ + +/* Call */ +#define TAPI_CALL_DIALDIGIT_LEN_MAX 82 /**< Maximum Dialling Digit Length */ +#define TAPI_CALL_SUBADDRESS_LEN_MAX 40 /**< Maximum Call Subaddress Length */ +#define TAPI_CALL_NUMBER_LEN_MAX 7 /**< Dialling Num length */ +#define TAPI_CONTEXT_CALL_SIZE_MAX 6 /**< Maximum Call context */ +#define TAPI_CALL_DIAL_NUMBER_LEN_MAX 82 + +#define TAPI_INVALID_CONTEXTHANDLE (HTapiContext)-1 +#define TAPI_CLIENT_SIZE_MAX 30 +#define TAPI_CALL_CUSTOM_SERVICE_DATA_MAX 128 + +/** + * @enum TelCallCause_t + * This structure defines the values for Call Cause. + */ +typedef enum { + TAPI_CAUSE_SUCCESS, /**< Success */ + TAPI_CAUSE_ACCESSDISCARD, /**< Access discarded */ + TAPI_CAUSE_BARR_BYOPERATOR, /**< Barred by operator */ + TAPI_CAUSE_BEARERMODE_NOTIMPL, /**< Bearer mode not implemented */ + TAPI_CAUSE_BEARERMODE_RESTRICTED, /**< Bearer mode restricted */ + TAPI_CAUSE_BEARERMODE_UNAUTH, /**< Bearer mode un authorized */ + TAPI_CAUSE_BEARERMODE_UNAVAIL, /**< Bearer mode not available */ + TAPI_CAUSE_BUSY, /**< (Network/Server) busy */ + TAPI_CAUSE_CALLMETER_EXPIRED, /**< Call meter expired */ + TAPI_CAUSE_CALLNO_ERROR, /**< Call number error */ + TAPI_CAUSE_CKTUNAVAIL, /**< Circuit channel unavailable */ //10 + TAPI_CAUSE_CONGESTION, /**< Congestion happened */ + TAPI_CAUSE_NO_CIRCUIT_AVAIL, /**< Circuit not available */ + TAPI_CAUSE_DESTIN_INCOMPAT, /**< Destination incompatibility */ + TAPI_CAUSE_DTMF_NOSPEECH, /**< No speech in DTMF */ + TAPI_CAUSE_DTMF_REJECTED, /**< DTMF rejected */ + TAPI_CAUSE_FACILITY_NOTIMPL, /**< Facility not implemented */ + TAPI_CAUSE_FACILITY_NOTSUBSCRIBED, /**< Facility not subscribed */ + TAPI_CAUSE_INCOMINGCUGCALLS_BARRED, /**< Incoming CUG Calls barred */ + TAPI_CAUSE_INVALNUM, /**< Invalid number */ + TAPI_CAUSE_MPTY_ERROR, /**< Multiparty error */ //20 + TAPI_CAUSE_NOANSWER, /**< No answer */ + TAPI_CAUSE_NONCUGMEMBER, /**< Non CUG member */ + TAPI_CAUSE_NUMBERCHANGED, /**< Number changed */ + TAPI_CAUSE_NUMBER_ERROR, /**< Number error */ + TAPI_CAUSE_NWFAILURE, /**< Network failure */ + TAPI_CAUSE_OPERATIONUNAVAIL, /**< Operation not available */ + TAPI_CAUSE_OUTOFORDER, /**< Out of order */ + TAPI_CAUSE_PROTOCOL_ERROR, /**< Protocol error */ + TAPI_CAUSE_QOSUNAVAIL, /**< QOS unavailable */ + TAPI_CAUSE_REJECT, /**< Rejected */ //30 + TAPI_CAUSE_REJ_FAIL, /**< Rejection failed */ + TAPI_CAUSE_REJ_SRVC_NOT_AVL, /**< Rejection service not available */ + TAPI_CAUSE_REMOTE_CKTUNAVAIL, /**< Remote Circuit channel unavailable */ + TAPI_CAUSE_RESOURCEUNAVAIL, /**< Resource not available */ + TAPI_CAUSE_SERVICEID_ERROR, /**< Service id error */ + TAPI_CAUSE_SERVICE_NOTIMPL, /**< Service not implemented */ + TAPI_CAUSE_SERVICE_UNAVAIL, /**< Service not available */ + TAPI_CAUSE_MODIFY_SAME_BEARER, /**< Modify same bearer */ + TAPI_CAUSE_MODIFY_NOT_PERMITTED, /**< Modification not permitted */ + TAPI_CAUSE_HOLD_FAIL, /**< Call hold fail */ //40 + TAPI_CAUSE_TEMPFAILURE, /**< Temporary failure */ + TAPI_CAUSE_WRONGNUM, /**< Wrong number */ + TAPI_CAUSE_NORMAL_UNSPECIFIED, /**< Normal but unspecified */ + TAPI_CAUSE_SSERRINVALIDTIVALUE, /**< SS invalid Transaction ID Value */ + TAPI_CAUSE_SSERRINVALIDTI, /**< SS Invalid transaction ID */ + TAPI_CAUSE_SSINCOMPATIBLESTATE, /**< SS incompatible state */ + TAPI_CAUSE_SSERRSYNTAXERROR, /**< SS syntax error */ + TAPI_CAUSE_SSPROTOCOLERROR, /**< Protocol error */ + TAPI_CAUSE_SSNEGATIVEPASSWORDCHECK, /**< Negative password check */ + TAPI_CAUSE_SSSENTASPHASE1, /**< SS sent as phase1 message */ //50 + TAPI_CAUSE_SSERROR, /**< Supplementary service error */ + TAPI_CAUSE_SS_USSD_BUSY, /**< Second USSD request will be rejected when already USSD transaction is ongoing. */ + TAPI_CAUSE_IDLE, /**< Idle */ + TAPI_CAUSE_NETWORK_SPECIFIC, /**< Network specific error */ + TAPI_CAUSE_FADE, /**< voice call was dropped e.g. because of a loss of signal */ + TAPI_CAUSE_UNKNOWN, /**< unknown no details available */ + TAPI_CAUSE_INCOM_CALL, /**< terminated by incoming call */ + TAPI_CAUSE_ALERT_STOP, /**< terminated by alert stop */ + TAPI_CAUSE_INTERCEPT, /**< voice call was dropped by interception */ + TAPI_CAUSE_REORDER, /**< voice call was dropped by reordering */ //60 + TAPI_CAUSE_CLIENT_END, /**< client ended the call */ + TAPI_CAUSE_ACCESS_CLASS_BLOCKED, /**< access class blocked */ + TAPI_CAUSE_MEMCAPEXCEEDED, /**< Memory capacity exceeded */ + TAPI_CAUSE_TYPENOTSUPPORTED, /**< Type not supported */ + TAPI_CAUSE_REPLACENOTSUPPORTED, /**< Replace not supported */ + TAPI_CAUSE_PROTOCOLID_ERROR, /**< Protocol id error */ + TAPI_CAUSE_CLASSNOTSUPPORTED, /**< Class not supported */ + TAPI_CAUSE_DATACODING_ERROR, /**< Data coding error */ + TAPI_CAUSE_INVAL_MSG, /**< Invalid message */ + TAPI_CAUSE_CALL_BARRED, /**< Call barred */ //70 + TAPI_CAUSE_SIM_CALL_CONTROL_CHANGED_TO_SS, /**< Sim call control changed to SS */ + TAPI_CAUSE_SIM_CALL_CONTROL_CHANGED_TO_CALL, /**< SIM Call control changed to call */ + TAPI_CAUSE_SIM_ERROR, /**< SIM error */ + TAPI_CAUSE_SIM_CALL_CONTROL_MODIFIED, /**< SIM call control modified */ + TAPI_CAUSE_RANDOM_ACCESS_FAILURE, /**< Random access error */ + TAPI_CAUSE_LOWER_LAYER_FAILURE, /**< Lower layer error */ + TAPI_CAUSE_ACCESS_REJECTED, /**< Access rejected */ + TAPI_CAUSE_RESET_NOT_ALLOWED, /**< Reset not allowed */ + TAPI_CAUSE_EMERGENCY_CALL_NOT_ALLOWED, /**< Emergency call not allowed */ + TAPI_CAUSE_ACCESS_NOT_ALLOWED, /**< Access not allowed */ //80 + TAPI_CAUSE_RADIO_LINK_FAILURE, /**< Radio link failure */ + TAPI_CAUSE_INVALID_IDENTITY, /**< Invalid identity */ + TAPI_CAUSE_UNKNOWN_IDENTITY, /**< Unknown identity */ + TAPI_CAUSE_UNACCEPTABLE_IDENTITY, /**< Un acceptable identity */ + TAPI_CAUSE_NO_SERVICE_HERE, /**< No service here */ + TAPI_CAUSE_SERVICE_NOT_ALLOWED, /**< Service not allowed */ + TAPI_CAUSE_SERVICE_NOT_AVAIL, /**< Service not available */ + TAPI_CAUSE_SERVICE_NOT_WORKING, /**< Service not working */ + TAPI_CAUSE_CANNOT_IDENTIFY_CALL, /**< Cannot identify the call */ + TAPI_CAUSE_DEACTIVATION, /**< Deactivation */ //90 + TAPI_CAUSE_FATAL_ERROR, /**< Fatal error */ + TAPI_CAUSE_SEND_DTMF_SUCCESS, /**< Sending DTMF Success */ + TAPI_CAUSE_SEND_DTMF_FAIL, /**< Sending DTMF Failed */ + TAPI_CAUSE_TIMER_EXPIRED, /**< Call Timer Expired */ +} TelCallCause_t; + +/** + * @enum TelTapiEndCause_t + * When a call is ended, this end cause is given with the CALL END notification to the application. This end cause can be originated + * from different elements in the communication path or different modules in the same element. + */ +typedef enum { + TAPI_CALL_END_NO_CAUSE = 0x00, /**< No Cause */ + + TAPI_CC_CAUSE_UNASSIGNED_NUMBER, /**< Unassigned Number */ + TAPI_CC_CAUSE_NO_ROUTE_TO_DEST, /**< No Route to Destination */ + TAPI_CC_CAUSE_CHANNEL_UNACCEPTABLE, /**< Channel Unacceptable */ + TAPI_CC_CAUSE_OPERATOR_DETERMINED_BARRING, /**< Operator Determined Barring */ + TAPI_CC_CAUSE_NORMAL_CALL_CLEARING, /**< Normal Call Clearing */ + + TAPI_CC_CAUSE_USER_BUSY, /**< User Busy */ + TAPI_CC_CAUSE_NO_USER_RESPONDING, /**< No user Responding */ + TAPI_CC_CAUSE_USER_ALERTING_NO_ANSWER, /**< User Alerting no Answer */ + TAPI_CC_CAUSE_CALL_REJECTED, /**< Call Rejected */ + TAPI_CC_CAUSE_NUMBER_CHANGED, /**< Number Changed */ + + TAPI_CC_CAUSE_NON_SELECTED_USER_CLEARING, /**< Non Selected User Clearing */ + TAPI_CC_CAUSE_DESTINATION_OUT_OF_ORDER, /**< Destination out of Order */ + TAPI_CC_CAUSE_INVALID_NUMBER_FORMAT, /**< Invalid Number Format */ + TAPI_CC_CAUSE_FACILITY_REJECTED, /**< Facility Rejected */ + TAPI_CC_CAUSE_RESPONSE_TO_STATUS_ENQUIRY, /**< Response to Status Enquiry */ + + TAPI_CC_CAUSE_NORMAL_UNSPECIFIED, /**< Normal Unspecified */ + TAPI_CC_CAUSE_NO_CIRCUIT_CHANNEL_AVAILABLE, /**< No Circuit Channel Available */ + TAPI_CC_CAUSE_NETWORK_OUT_OF_ORDER, /**< Network out of Order */ + TAPI_CC_CAUSE_TEMPORARY_FAILURE, /**< Temporary Failure */ + TAPI_CC_CAUSE_SWITCHING_EQUIPMENT_CONGESTION, /**< Switching Equipment Congestion */ + + TAPI_CC_CAUSE_ACCESS_INFORMATION_DISCARDED, /**< Access Information Discarded */ + TAPI_CC_CAUSE_REQUESTED_CIRCUIT_CHANNEL_NOT_AVAILABLE, /**< Requested Circuit channel not available */ + TAPI_CC_CAUSE_RESOURCES_UNAVAILABLE_UNSPECIFIED, /**< Resources unavailable unspecified */ + TAPI_CC_CAUSE_QUALITY_OF_SERVICE_UNAVAILABLE, /**< Quality of service unavailable */ + TAPI_CC_CAUSE_REQUESTED_FACILITY_NOT_SUBSCRIBED, /**< Requested facility not subscribed */ + + TAPI_CC_CAUSE_INCOMING_CALL_BARRED_WITHIN_CUG, /**< incomming call barred within CUG */ + TAPI_CC_CAUSE_BEARER_CAPABILITY_NOT_AUTHORISED, /**< Bearer Capability not Authorised */ + TAPI_CC_CAUSE_BEARER_CAPABILITY_NOT_PRESENTLY_AVAILABLE,/**< Bearer capability not presently Available */ + TAPI_CC_CAUSE_SERVICE_OR_OPTION_NOT_AVAILABLE, /**< Service or Option not available */ + TAPI_CC_CAUSE_BEARER_SERVICE_NOT_IMPLEMENTED, /**< Service not implemented */ + + TAPI_CC_CAUSE_ACM_GEQ_ACMMAX, /**< ACM GEQ ACMAX */ + TAPI_CC_CAUSE_REQUESTED_FACILITY_NOT_IMPLEMENTED, /**< Requested facility not implemented */ + TAPI_CC_CAUSE_ONLY_RESTRICTED_DIGITAL_INFO_BC_AVAILABLE,/**< Resticted digital info BC not available */ + TAPI_CC_CAUSE_SERVICE_OR_OPTION_NOT_IMPLEMENTED, /**< Service or Option not Implemented */ + TAPI_CC_CAUSE_INVALID_TRANSACTION_ID_VALUE, /**< Transaction ID value */ + + TAPI_CC_CAUSE_USER_NOT_MEMBER_OF_CUG, /**< Not member of CUG */ + TAPI_CC_CAUSE_INCOMPATIBLE_DESTINATION, /**< Incompatible Destination */ + TAPI_CC_CAUSE_INVALID_TRANSIT_NETWORK_SELECTION, /**< Transit Network selection */ + TAPI_CC_CAUSE_SEMANTICALLY_INCORRECT_MESSAGE, /**< Semantically Incorrect message */ + TAPI_CC_CAUSE_INVALID_MANDATORY_INFORMATION, /**< Invalid Mandatory Message */ + + TAPI_CC_CAUSE_MESSAGE_TYPE_NON_EXISTENT, /**< Message Type Non Existent */ + TAPI_CC_CAUSE_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROT_STATE, /**< Message type not compatible with Prot state */ + TAPI_CC_CAUSE_IE_NON_EXISTENT_OR_NOT_IMPLEMENTED, /**< IE non exitent or not implemented */ + TAPI_CC_CAUSE_CONDITIONAL_IE_ERROR, /**< Conditional IE error */ + TAPI_CC_CAUSE_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE, /**< Not Compatible with protocol state */ + + TAPI_CC_CAUSE_RECOVERY_ON_TIMER_EXPIRY, /**< Recovery on timer expiry */ + TAPI_CC_CAUSE_PROTOCOL_ERROR_UNSPECIFIED, /**< Protocol error unspecified */ + TAPI_CC_CAUSE_INTERWORKING_UNSPECIFIED, /**< Interworking unspecified */ + + TAPI_CC_CAUSE_END = 128, + + /* Reject causes*/ + TAPI_REJECT_CAUSE_IMSI_UNKNOWN_IN_HLR, /**< IMSI unknown in HLR */ + TAPI_REJECT_CAUSE_ILLEGAL_MS, /**< Illegal MS */ + TAPI_REJECT_CAUSE_IMSI_UNKNOWN_IN_VLR, /**< IMSI unknown in VLR */ + TAPI_REJECT_CAUSE_IMEI_NOT_ACCEPTED, /**< IMEI not accepted */ + TAPI_REJECT_CAUSE_ILLEGAL_ME, /**< Illegal ME */ + + TAPI_REJECT_CAUSE_GPRS_SERVICES_NOT_ALLOWED, /**< GPRS service not allowed */ + TAPI_REJECT_CAUSE_GPRS_SERVICES_AND_NON_GPRS_SERVICES_NOT_ALLOWED, /**< GPRS services and Non-GPRS services not allowed */ + TAPI_REJECT_CAUSE_MS_IDENTITY_CANNOT_BE_DERIVED_BY_THE_NETWORK, /**< MS device cannot be derived by the network */ + TAPI_REJECT_CAUSE_IMPLICITLY_DETACHED, /**< Implicitly detached */ + TAPI_REJECT_CAUSE_PLMN_NOT_ALLOWED, /**< PLMN not allowed */ + + TAPI_REJECT_CAUSE_LA_NOT_ALLOWED, /**< LA not allowed */ + TAPI_REJECT_CAUSE_NATIONAL_ROAMING_NOT_ALLOWED, /**< National roaming not allowed */ + TAPI_REJECT_CAUSE_GPRS_SERVICES_NOT_ALLOWED_IN_THIS_PLMN, /**< GPRS services not allowed in this PLMN */ + TAPI_REJECT_CAUSE_NO_SUITABLE_CELLS_IN_LA, /**< No suitable cells in the LA */ + TAPI_REJECT_CAUSE_MSC_TEMPORARILY_NOT_REACHABLE, /**< MSC temporarily not reachable */ + + TAPI_REJECT_CAUSE_NETWORK_FAILURE, /**< Network unavailable */ + TAPI_REJECT_CAUSE_MAC_FAILURE, /**< MAC failure */ + TAPI_REJECT_CAUSE_SYNCH_FAILURE, /**< SYNCh failure */ + TAPI_REJECT_CAUSE_CONGESTTION, /**< Congestion */ + TAPI_REJECT_CAUSE_GSM_AUTH_UNACCEPTED, /**< GSM Auth unaccepted */ + + TAPI_REJECT_CAUSE_SERVICE_OPTION_NOT_SUPPORTED, /**< Service option not supported */ + TAPI_REJECT_CAUSE_REQ_SERV_OPT_NOT_SUBSCRIBED, /**< REQ_SERV option not suscribed */ + TAPI_REJECT_CAUSE_SERVICE_OPT__OUT_OF_ORDER, /**< Service OPT out of order */ + TAPI_REJECT_CAUSE_CALL_CANNOT_BE_IDENTIFIED, /**< Call cannot be identified */ + TAPI_REJECT_CAUSE_NO_PDP_CONTEXT_ACTIVATED, /**< No PDP context Activated */ + + TAPI_REJECT_CAUSE_RETRY_UPON_ENTRY_INTO_A_NEW_CELL_MIN_VALUE, /**< Retry upon entry into a new call min value */ + TAPI_REJECT_CAUSE_RETRY_UPON_ENTRY_INTO_A_NEW_CELL_MAX_VALUE, /**< Retry upon entry into a new call max value */ + TAPI_REJECT_CAUSE_SEMANTICALLY_INCORRECT_MSG, /**< Semantically incorret message */ + TAPI_REJECT_CAUSE_INVALID_MANDATORY_INFO, /**< Invalid mandatory information */ + TAPI_REJECT_CAUSE_MESSAGE_TYPE_NON_EXISTANT, /**< Message type non-existant */ + + TAPI_REJECT_CAUSE_MESSAGE_TYPE_NOT_COMP_PRT_ST, /**< Message type not COMP PRT ST */ + TAPI_REJECT_CAUSE_IE_NON_EXISTANT, /**< IE not existant */ + TAPI_REJECT_CAUSE_MSG_NOT_COMPATIBLE_PROTOCOL_STATE, /**< MSG not compatible protocol state */ + + /* Connection Management establishment rejection cause */ + TAPI_REJECT_CAUSE_REJ_UNSPECIFIED, /**< rej unspecified */ + + /* AS reject causes */ + TAPI_REJECT_CAUSE_AS_REJ_RR_REL_IND, /**< RR release indication */ + TAPI_REJECT_CAUSE_AS_REJ_RR_RANDOM_ACCESS_FAILURE, /**< Random Access Failure */ + TAPI_REJECT_CAUSE_AS_REJ_RRC_REL_IND, /**< RRC release indication */ + TAPI_REJECT_CAUSE_AS_REJ_RRC_CLOSE_SESSION_IND, /**< RRC close session indication */ + TAPI_REJECT_CAUSE_AS_REJ_RRC_OPEN_SESSION_FAILURE, /**< RRC open session failure */ + TAPI_REJECT_CAUSE_AS_REJ_LOW_LEVEL_FAIL, /**< Low level failure */ + TAPI_REJECT_CAUSE_AS_REJ_LOW_LEVEL_FAIL_REDIAL_NOT_ALLOWED, /**< Low level failure redial not alowed */ + TAPI_REJECT_CAUSE_AS_REJ_LOW_LEVEL_IMMED_RETRY, /**< low level immediate retry */ + + /* MM reject causes */ + TAPI_REJECT_CAUSE_MM_REJ_INVALID_SIM, /**< invalid Sim */ + TAPI_REJECT_CAUSE_MM_REJ_NO_SERVICE, /**< No service */ + TAPI_REJECT_CAUSE_MM_REJ_TIMER_T3230_EXP, /**< Timer T3230 expire */ + TAPI_REJECT_CAUSE_MM_REJ_NO_CELL_AVAILABLE, /**< No call available */ + TAPI_REJECT_CAUSE_MM_REJ_WRONG_STATE, /**< wrong state */ + TAPI_REJECT_CAUSE_MM_REJ_ACCESS_CLASS_BLOCKED, /**< Access class blocked */ + + /* Definitions for release ind causes between MM and CNM*/ + TAPI_REJECT_CAUSE_ABORT_MSG_RECEIVED, /**< Abort Message received */ + TAPI_REJECT_CAUSE_OTHER_CAUSE, /**< Other cause */ + + /* CNM reject causes */ + TAPI_REJECT_CAUSE_CNM_REJ_TIMER_T303_EXP, /**< Timer T303 expiry */ + TAPI_REJECT_CAUSE_CNM_REJ_NO_RESOURCES, /**< Rejected due to unavailibilty of resources */ + TAPI_REJECT_CAUSE_CNM_MM_REL_PENDING, /**< MM release pending */ + TAPI_REJECT_CAUSE_CNM_INVALID_USER_DATA, /**< Invalid user data */ + TAPI_CALL_END_CAUSE_MAX = 255, /**< Maximum End Cause limit for gsm/wcdma */ + + /* CDMA CALL END CAUSE */ + TAPI_CDMA_END_CAUSE_REL_BY_USER = 0x1001, /**< Call Released by User */ + TAPI_CDMA_END_CAUSE_REL_BY_NET, /**< Call Released by Network */ + TAPI_CDMA_END_CAUSE_REL_NET_BUSY, /**< Call Released because of Network busy */ + TAPI_CDMA_END_CAUSE_NO_SVC, /**< Call Released because of No Service area */ + TAPI_CDMA_END_CAUSE_FADING, /**< Call Released because of Fading */ + TAPI_CDMA_END_CAUSE_RELEASE_BY_REORDER, /**< Call Released because of reorder */ + TAPI_CDMA_END_CAUSE_RELEASE_BY_INTERCEPT, /**< Call Released because of intercept */ + TAPI_CDMA_END_CAUSE_SILENT_ZONE_RETRY, /**< Call Released because of silent zone retry */ + TAPI_CDMA_END_CAUSE_OTA_CALL_FAIL, /**< Call Released because of OTA cal failure */ + TAPI_CDMA_END_CAUSE_PHONE_OFFLINE, /**< Call Released because of phone offline */ + TAPI_CDMA_END_CAUSE_PHONE_IS_CDMA_LOCKED, /**< Call Released because of CDMA locked */ + TAPI_CDMA_END_CAUSE_FLASH_IS_IN_PROGRESS_ERR, /**< Call Released because of flash-is-in-progress error */ + TAPI_CDMA_END_CAUSE_E911_MODE_ERR, /**< Call Released because of e911 mode */ + TAPI_CDMA_END_CAUSE_OTHERS, /**< Call Released by Others */ + TAPI_CDMA_END_CAUSE_MAX /**< Maximum End Cause limit for cdma */ +} TelTapiEndCause_t; + +/** + * @enum TelConferenceCallState_t + * This enum defines the call conference states + */ +typedef enum { + TAPI_CALL_CONFERENCE_IDLE, /**< idle */ + TAPI_CALL_CONFERENCE_ACTIVE /**< active */ +} TelConferenceCallState_t; + +/** + * @enum TelCallStates_t + * Applications can use these sates or can have their own states. + */ +typedef enum { + TAPI_CALL_STATE_IDLE, /**< Call is in idle state - i.e. no call */ + TAPI_CALL_STATE_ACTIVE, /**< Call is in connected and conversation state */ + TAPI_CALL_STATE_HELD, /**< Call is in held state */ + TAPI_CALL_STATE_DIALING, /**< Call is in dialing state */ + TAPI_CALL_STATE_ALERT, /**< Call is in alerting state */ + TAPI_CALL_STATE_INCOMING, /**< Call is in incoming state */ + TAPI_CALL_STATE_WAITING, /**< Call is in answered state, and waiting for connected indication event */ + TAPI_CALL_STATE_MAX +} TelCallStates_t; + +/** + * IN GSM ONLY: call identification number. + */ +typedef enum { + TAPI_CALL_ACTIVE_LINE1, /**< Line 1 */ + TAPI_CALL_ACTIVE_LINE2 /**< Line 2 */ +} TelCallActiveLine_t; + +typedef enum { + TAPI_CALL_UUS_NONE, /**< No User to User information */ + TAPI_CALL_UUS_1, /**< User to User information 1 */ +} TelCallUusType_t; + +/** + * The Incoming call indication could have be one of the following SS info messages in it. + */ +typedef enum { + /* Number details are present in the "char number" of call info struct. if number is not present + then "no cli cause" member in mt_ss_info is set accordingly. */ + TAPI_CALL_MT_CLI_PRESENT = 0x31, + + /* Calling Name Info presnet, TelCallingNameInfo_t of call info struct contains this info. */ + TAPI_CALL_MT_CNA_PRESENT = 0x32, + + /* Undefined ss indication. Ignore mt_ss_info */ + TAPI_CALL_MT_SS_UNDEFINED = 0x00, + +} TelCallMtSSInfo_t; + +/** + * @enum TelCallAnswerType_t + * Answer type used as in parameter in the answer call API. + */ +typedef enum { + TAPI_CALL_ANSWER_ACCEPT = 0, /**< Used to answer an incoming call when there are no current active calls. */ + TAPI_CALL_ANSWER_REJECT, /**< Used to reject the incoming call */ + TAPI_CALL_ANSWER_REPLACE, /**< Release current active call and accept the */ + TAPI_CALL_ANSWER_HOLD_AND_ACCEPT, /**< Hold the current active call, and accept the wating call */ +} TelCallAnswerType_t; + +/** + * @enum TelCallEndType_t + * End type used as in parameter in the end call API. + */ +typedef enum { + TAPI_CALL_END = 0, + TAPI_CALL_END_ALL, + TAPI_CALL_END_ACTIVE_ALL, + TAPI_CALL_END_HOLD_ALL, +} TelCallEndType_t; + + + + +/** + * @enum TelCallType_t + * Applications needs to use this call type while using the setup call API. Like the requested call is a voice call or video call. + */ +typedef enum { + TAPI_CALL_TYPE_VOICE, /**< Voice call type. */// in ipcv4, 0x0100 + TAPI_CALL_TYPE_DATA, /**< Data call type - (for modem, fax, packet, etc. calls). */// in ipcv4, 0x0200 + TAPI_CALL_TYPE_E911 /**< Emergency call type. */// in ipcv4, 0x0700 +} TelCallType_t; + +/** + * @enum TelCallAlertingPattern_t + * This enumeration defines the different alerting patterns available. + */ +typedef enum { + TAPI_CALL_ALERTING_PATTERN_1 = 0x00, /**< Pattern 1 */ + TAPI_CALL_ALERTING_PATTERN_2 = 0x01, /**< Pattern 2 */ + TAPI_CALL_ALERTING_PATTERN_3 = 0x02, /**< Pattern 3 */ + TAPI_CALL_ALERTING_PATTERN_4 = 0x03, /**< Pattern 4 */ + TAPI_CALL_ALERTING_PATTERN_5 = 0x04, /**< Pattern 5 */ + TAPI_CALL_ALERTING_PATTERN_6 = 0x05, /**< Pattern 6 */ + TAPI_CALL_ALERTING_PATTERN_7 = 0x06, /**< Pattern 7 */ + TAPI_CALL_ALERTING_PATTERN_8 = 0x07, /**< Pattern 8 */ + TAPI_CALL_NO_ALERTING_PATTERN = 0x08 /**< No Alerting Pattern */ +} TelCallAlertingPattern_t; + +/** + * @enum TelCallActiveState_t + * State of the current call. + */ +typedef enum { + TAPI_CALL_CONNECT_IDLE, /**< Call is in Idle state. */ + TAPI_CALL_CONNECT_ACTIVE, /**< Call is in Active state.*/ + TAPI_CALL_CONNECT_HELD /**< Call is in Held state. */ +} TelCallActiveState_t; + +/** + * @enum TelCallCugOptions_t + * This enumeration defines the closed user group options + */ +typedef enum { + TAPI_CALL_CUG_NO_INFO = 0x00, /**< No information */ + TAPI_CALL_CUG_SUPRESS_OA, /**< suppress OA */ + TAPI_CALL_CUG_SUPRESS_PRF_CUG, /**< suppress preferential CUG */ + TAPI_CALL_CUG_SUPRESS_OA_AND_CUG /**< suppress OA and preferential CUG */ +} TelCallCugOptions_t; + +/** + * @enum TelCallUusProtocolType_t + * This enumeration defines the tapi call uus protocol types + */ +typedef enum { + TAPI_CALL_UUS_PROTO_SPECIFIC = 0, /**< The user information is structured according to user needs. */ + TAPI_CALL_UUS_PROTO_OSI_HIGHER_LAYER = 1, /**< OSI high layer protocols */ + TAPI_CALL_UUS_PROTO_IA5_CHARS = 4, /**< user information consists of IA5 characters */ + TAPI_CALL_UUS_PROTO_V120 = 7, /**< rate adaptation */ + TAPI_CALL_UUS_PROTO_Q931 = 8 /**< user-network call control messages */ +} TelCallUusProtocolType_t; + +/** + * @enum TelCallNameMode_t + * This enumeration defines the call name mode + */ +typedef enum { + TAPI_CALL_NAME_AVAIL = 0, /**< This identifier refers to the presentation of the calling party's name identity to the called party. */ + TAPI_CALL_NAME_RESTRICTED = 1, /**< This identifier refers to the restriction of presentation of the name identity of the calling party to the called party. */ + TAPI_CALL_NAME_UNAVAIL = 2, /**< This identifier refers to the unavailability of the calling party's name identity to be offered to the called party. */ + TAPI_CALL_NAME_AVAIL_RESTRICTED = 3 /**< This identifier refers to the calling party's name identity to be offered to the called party with which presentation restriction is overridden. */ +} TelCallNameMode_t; + +/** + * @enum TelCallNocliCause_t + * This enumeration defines the value for "No Cli cause". + */ +typedef enum { + TAPI_CALL_NO_CLI_CAUSE_NONE = -1, /**< None */ + TAPI_CALL_NO_CLI_CAUSE_UNAVAILABLE = 0x00, /**< Unavailable */ + TAPI_CALL_NO_CLI_CAUSE_REJECTBY_USER = 0x01, /**< Rejected by User */ + TAPI_CALL_NO_CLI_CAUSE_INTERACTION_OTHERSERVICES = 0x02, /**< Other services */ + TAPI_CALL_NO_CLI_CAUSE_COINLINE_PAYPHONE = 0x03, /**< Coin line phone */ +} TelCallNocliCause_t; + +/** + * @enum TelCallCliMode_t + * This enumeration defines the value for "Cli mode". + */ +typedef enum { + TAPI_CALL_PRES_AVAIL, /** */ + TelCallNocliCause_t CliCause; /**< No of CLI cause */ + int fwded; /**< True or false. If Incoming call is a forwarded call, then true else false. */ + TelCallActiveLine_t ActiveLine; /**< Current Active Line */ +} TelCallIncomingCallInfo_t; + +/** + *SS Info message. + */ +typedef struct { + TelCallMtSSInfo_t type; /* Type of the SS Info presnet. */ + TelCallCliMode_t CliMode; /** */ + TelCallNocliCause_t no_cli_cause; +} TelCallMtSsInfo_t; // not used + +typedef struct { + int isMobileOriginated; /* Is this call Mobile Originated? */ + TelCallNameMode_t nameMode; /* Calling Party Name availability mode */ + char callNumber[TAPI_CALL_DIALDIGIT_LEN_MAX + 1]; /* A character array of the destination address. This follows the dial callNumber format. */ + unsigned int startTime; /* Time when a call is started */ + unsigned int endTime; /* Time when a call is ended */ + TelCallType_t callType; /* Type of a call */ + TelCallStates_t callState; /* State of a call */ + TelCallActiveState_t activeState; /* Status of a call */ + TelConferenceCallState_t conferenceState; /* State of a conference call */ + TelCallingNameInfo_t callingNameInfo; /* Calling name information of a call */ + TelCallActiveLine_t current_line; /* Line information of a call */ + TelCallCause_t cause; /* End type of a call when a call is ended */ + TelTapiEndCause_t endCause; /* EndCause */ +} TelTapiCallInfo_t; + +/** + * This structure contains the connected number information. + */ +typedef struct { + TelCallCliMode_t CliMode; /** */ + TelCallNocliCause_t no_cli_cause; /**< Cause when no CLI number. */ + unsigned char dcs; /**< DCS */ + unsigned char number_type; /**< Number type */ + TelCallNameMode_t name_mode; /**< Display mode of the name. */ + char number[TAPI_CALL_DIALDIGIT_LEN_MAX + 1]; /**< Caller number, null terminated ASCII */ + char sub_address[TAPI_CALL_SUBADDRESS_LEN_MAX + 1]; /**< Called sub-address, null terminated ASCII */ +} TelCallConnectedNumberInfo_t; + +/** + * This structure contains the voice privacy indication(CDMA only). + */ +typedef struct { + TelCallPrivacyMode_t privacy_mode; /**< Voice Privacy Mode */ +} TelCallVoicePrivacyNoti_t; + +typedef struct { + TelCallAlertSignalType_t signal_type; + TelCallAlertPitchType_t pitch_type; + union { + TelCallToneSignal_t sig_tone_type; + TelCallIsdnAlertSignal_t sig_isdn_alert_type; + TelCallIs54bAlertSignal_t sig_is54b_alert_type; + } signal; +} TelCallSignalInfoNoti_t; + +/** + * This structure contains information about a call time and call count. + */ +typedef struct { + unsigned short req_type_mask; /**< call time request type */ + unsigned long TotalCallCnt; /**< Total Call Count */ + unsigned long OutgoingCallCnt; /**< Outgoing Call Count */ + unsigned long IncomingCallCnt; /**< Incoming Call Count */ + unsigned long TotalCallTime; /**< Overall Call Time(Outgoing + Incoming, in second) */ + unsigned long OutgoingCallTime; /**< Overall Outgoing Call Time(in second) */ + unsigned long IncomingCallTime; /**< Overall Incoming Call Time(in second) */ + unsigned long LastCallTime; /**< Last Call Time(in second) */ +} TelCallTimeInfo_t; + +/** + * This structure contains information about display record in CDMA. + */ +typedef struct { + unsigned char Record[TAPI_CALL_DISPLAY_RECORD_MAX + 1]; /**< display record */ +} TelCallDisplayRecordInfo_t; + +// New Struct for New API +typedef enum { + TAPI_SOUND_MUTE =0x00, /** + * + * 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. + */ + +/** + * @ingroup TelephonyAPI + * @addtogroup COMMON_TAPI COMMON + * @{ + * + * @file TelDefines.h + * @brief This file provides #defines required for Telephony server and TAPI Client Library + */ + +#ifndef _TEL_DEFINES_H_ +#define _TEL_DEFINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Machine independence */ +typedef long TS_INT32; +typedef unsigned long TS_UINT32; + +typedef int TS_INT; +typedef unsigned int TS_UINT; +typedef double TS_DOUBLE; + +typedef int TS_BOOL; + +/* Programming concept */ +typedef unsigned char TS_BYTE; +typedef unsigned short TS_WORD; +typedef unsigned long TS_DWORD; +typedef unsigned char TS_UINT8; +typedef char TS_INT8; +typedef unsigned short TS_UINT16; +typedef unsigned long TS_ULONG; +typedef unsigned long long TS_UINT64; +typedef unsigned short TS_USHORT; + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifndef DEPRECATED +#define DEPRECATED __attribute__((deprecated)) +#endif + +typedef int HObj; + +#ifdef __cplusplus +} +#endif + +#endif /* _TEL_DEFINES_H_ */ + +/** + * @} + */ diff --git a/src/sat_ui_support/TelErr.h b/src/sat_ui_support/TelErr.h new file mode 100644 index 0000000..2567817 --- /dev/null +++ b/src/sat_ui_support/TelErr.h @@ -0,0 +1,186 @@ +/* + * tel-plugin-dbus_tapi + * + * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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. + */ + +/** + * @open + * @ingroup TelephonyAPI + * @addtogroup COMMON_TAPI COMMON + * @{ + * These error codes are used by Applications. + */ + + +#ifndef _TEL_ERR_H_ +#define _TEL_ERR_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/************************************************************ +** Errors defined in "+CME ERROR" , +** - see 3GPP TS 27.007 +** - ranges are 0x00 ~ 0x7FFF +************************************************************/ +/** + Error codes sent by the modem in response to the above operations. +*/ +typedef enum +{ + /* GENERAL ERRORS */ + TAPI_OP_GEN_ERR_PHONE_FAILURE = 0, /* 0 */ + TAPI_OP_GEN_ERR_NO_CONNECTION_TO_PHONE, /* 1 */ + TAPI_OP_GEN_ERR_PHONE_ADAPTOR_LINK_RESERVED, /* 2 */ + TAPI_OP_GEN_ERR_OPER_NOT_ALLOWED, /* 3 */ + TAPI_OP_GEN_ERR_OPER_NOT_SUPPORTED, /* 4 */ + TAPI_OP_GEN_ERR_PH_SIM_PIN_REQU, /* 5 */ + TAPI_OP_GEN_ERR_PH_FSIM_PIN_REQU, /* 6 */ + TAPI_OP_GEN_ERR_PH_FSIM_PUK_REQU, /* 7 */ + TAPI_OP_GEN_ERR_SIM_NOT_INSERTED =10, /* 10 */ + TAPI_OP_GEN_ERR_SIM_PIN_REQU, /* 11 */ + TAPI_OP_GEN_ERR_SIM_PUK_REQU, /* 12 */ + TAPI_OP_GEN_ERR_SIM_FAILURE, /* 13 */ + TAPI_OP_GEN_ERR_SIM_BUSY, /* 14 */ + TAPI_OP_GEN_ERR_SIM_WRONG, /* 15 */ + TAPI_OP_GEN_ERR_INCORRECT_PW, /* 16 */ + TAPI_OP_GEN_ERR_SIM_PIN2_REQU, /* 17 */ + TAPI_OP_GEN_ERR_SIM_PUK2_REQU, /* 18 */ + TAPI_OP_GEN_ERR_MEM_FULL = 20, /* 20 */ + TAPI_OP_GEN_ERR_INVALID_INDEX, /* 21 */ + TAPI_OP_GEN_ERR_NOT_FOUND, /* 22 */ + TAPI_OP_GEN_ERR_MEM_FAILURE, /* 23 */ + TAPI_OP_GEN_ERR_TEXT_STR_TOO_LONG, /* 24 */ + TAPI_OP_GEN_ERR_INVALID_CHARACTERS_IN_TEXT_STR, /* 25 */ + TAPI_OP_GEN_ERR_DIAL_STR_TOO_LONG, /* 26 */ + TAPI_OP_GEN_ERR_INVALID_CHARACTERS_IN_DIAL_STR, /* 27 */ + TAPI_OP_GEN_ERR_NO_NET_SVC = 30, /* 30 */ + TAPI_OP_GEN_ERR_NET_TIMEOUT, /* 31 */ + TAPI_OP_GEN_ERR_NET_NOT_ALLOWED_EMERGENCY_CALLS_ONLY, /* 32 */ + TAPI_OP_GEN_ERR_NET_PERS_PIN_REQU = 40, /* 40 */ + TAPI_OP_GEN_ERR_NET_PERS_PUK_REQU, /* 41 */ + TAPI_OP_GEN_ERR_NET_SUBSET_PERS_PIN_REQU, /* 42 */ + TAPI_OP_GEN_ERR_NET_SUBSET_PERS_PUK_REQU, /* 43 */ + TAPI_OP_GEN_ERR_SVC_PROVIDER_PERS_PIN_REQU, /* 44 */ + TAPI_OP_GEN_ERR_SVC_PROVIDER_PERS_PUK_REQU, /* 45 */ + TAPI_OP_GEN_ERR_CORPORATE_PERS_PIN_REQU, /* 46 */ + TAPI_OP_GEN_ERR_CORPORATE_PERS_PUK_REQU, /* 47 */ + TAPI_OP_GEN_ERR_HIDDEN_KEY_REQU, /* 48 */ + TAPI_OP_GEN_ERR_UNKNOWN = 100, /* 100 */ + + /* Errors related to a failure to perform an Attach */ + TAPI_OP_GEN_ERR_ILLEGAL_MS = 103, /* 103 */ + TAPI_OP_GEN_ERR_ILLEGAL_ME = 106, /* 106 */ + TAPI_OP_GEN_ERR_GPRS_SVC_NOT_ALLOWED, /* 107 */ + TAPI_OP_GEN_ERR_PLMN_NOT_ALLOWED = 111, /* 111 */ + TAPI_OP_GEN_ERR_LOCATION_AREA_NOT_ALLOWED, /* 112 */ + TAPI_OP_GEN_ERR_ROAMING_NOT_ALLOWED_IN_THIS_LOCATION_AREA,/* 113 */ + + /* Errors related to a failure to Activate a Context */ + TAPI_OP_GEN_ERR_SVC_OPT_NOT_SUPPORTED = 132, /* 132 */ + TAPI_OP_GEN_ERR_REQ_SVC_OPT_NOT_SUBSCRIBED, /* 133 */ + TAPI_OP_GEN_ERR_SVC_OPT_TEMPORARILY_OUT_OF_ORDER, /* 134 */ + TAPI_OP_GEN_ERR_UNSPECIFIED_GPRS_ERR = 148, /* 148 */ + TAPI_OP_GEN_ERR_PDP_AUTHENTICATION_FAILURE, /* 149 */ + TAPI_OP_GEN_ERR_INVALID_MOBILE_CLASS, /* 150 */ + + /* VBS / VGCS and eMLPP -related errors */ + TAPI_OP_GEN_ERR_VBS_VGCS_NOT_SUPPORTED_BY_THE_NET = 151, /* 151 */ + TAPI_OP_GEN_ERR_NO_SVC_SUBSCRIPTION_ON_SIM, /* 152 */ + TAPI_OP_GEN_ERR_NO_SUBSCRIPTION_FOR_GROUP_ID, /* 153 */ + TAPI_OP_GEN_ERR_GROUP_ID_NOT_ACTIVATED_ON_SIM, /* 154 */ + TAPI_OP_GEN_ERR_NO_MATCHING_NOTI = 155, /* 155 */ + TAPI_OP_GEN_ERR_VBS_VGCS_CALL_ALREADY_PRESENT, /* 156 */ + TAPI_OP_GEN_ERR_CONGESTION, /* 157 */ + TAPI_OP_GEN_ERR_NET_FAILURE, /* 158 */ + TAPI_OP_GEN_ERR_UPLINK_BUSY, /* 159 */ + TAPI_OP_GEN_ERR_NO_ACCESS_RIGHTS_FOR_SIM_FILE = 160, /* 160 */ + TAPI_OP_GEN_ERR_NO_SUBSCRIPTION_FOR_PRIORITY, /* 161 */ + TAPI_OP_GEN_ERR_OPER_NOT_APPLICABLE_OR_NOT_POSSIBLE, /* 162 */ + + + TAPI_OP_GEN_ERR_NONE = 0x8000, /* 0x8000 : No Errors */ + + /* General Common Errors : 0x8000 - 0x80FF */ + TAPI_OP_GEN_ERR_INVALID_IPC, /* 0x8001 : Invalid IPC_GSM Parameter or Format */ + TAPI_OP_GEN_ERR_PHONE_OFFLINE, /* 0x8002 : */ + TAPI_OP_GEN_ERR_CMD_NOT_ALLOWED, /* 0x8003 : */ + TAPI_OP_GEN_ERR_PHONE_IS_INUSE, /* 0x8004 : */ + TAPI_OP_GEN_ERR_INVALID_STATE = 0x8005, /* 0x8005 : */ + + TAPI_OP_GEN_ERR_NO_BUFFER, /* 0x8006 : No internal free buffers */ + TAPI_OP_GEN_ERR_OPER_REJ, /* 0x8007 : Operation Rejected */ + TAPI_OP_GEN_ERR_INSUFFICIENT_RESOURCE, /* 0x8008 : insufficient resource */ + TAPI_OP_GEN_ERR_NET_NOT_RESPOND, /* 0x8009 : Network not responding */ + TAPI_OP_GEN_ERR_SIM_PIN_ENABLE_REQ = 0x800A, /* 0x800A : SIM Pin Enable Required */ + TAPI_OP_GEN_ERR_SIM_PERM_BLOCKED, /* 0x800B : SIM Permanent Blocked */ + TAPI_OP_GEN_ERR_SIM_PHONEBOOK_RESTRICTED, /*0x800C: SIM Phonebook Restricted*/ + TAPI_OP_GEM_ERR_FIXED_DIALING_NUMBER_ONLY, /*0x800D: Restricted By FDN Mode */ + + /* Reserved : 0x800E ~ 0x80FF */ + TAPI_OP_GEN_ERR_800E_RESERVED_START = 0x800E, /* 0x800E */ + + TAPI_OP_GEN_ERR_80FF_RESERVED_END = 0x80ff, /* 0x80FF */ + + /* the other errors */ + TAPI_OP_GEN_ERR_OTHERS = 0xFFFE, /* 0xFFFE */ + + TAPI_OP_GEN_ERR_MAX = 0xFFFF + +}tapi_phone_err_t; + +typedef enum { + TAPI_PDP_FAILURE_CAUSE_NORMAL = 0x00, // 0x00 : Normal Process ( no problem ) + TAPI_PDP_FAILURE_CAUSE_REL_BY_USER = 0x01, // Call Released by User + TAPI_PDP_FAILURE_CAUSE_REGULAR_DEACTIVATION = 0x02, // Regular de-activation + TAPI_PDP_FAILURE_CAUSE_LLC_SNDCP = 0x03, // LLC SNDCP failure + TAPI_PDP_FAILURE_CAUSE_INSUFFICIENT_RESOURCE = 0x04, // Insufficient resources + TAPI_PDP_FAILURE_CAUSE_UNKNOWN_APN = 0x05, // Missing or unknown APN + TAPI_PDP_FAILURE_CAUSE_UNKNOWN_PDP_ADDRESS = 0x06, // Unknown PDP address or type + TAPI_PDP_FAILURE_CAUSE_USER_AUTH_FAILED = 0x07, // Unknown PDP address or type + TAPI_PDP_FAILURE_CAUSE_ACT_REJ_GGSN = 0x08, // Unknown PDP address or type + TAPI_PDP_FAILURE_CAUSE_ACT_REJ_UNSPECIFIED = 0x09, // Unknown PDP address or type + TAPI_PDP_FAILURE_CAUSE_SVC_OPTION_NOT_SUPPORTED = 0x0A, // Service option not supported + TAPI_PDP_FAILURE_CAUSE_SVC_NOT_SUBSCRIBED = 0x0B, // Requested service option not subscribed + TAPI_PDP_FAILURE_CAUSE_SVC_OPT_OUT_ORDER = 0x0C, // Service out of order + TAPI_PDP_FAILURE_CAUSE_NSAPI_USED = 0x0D, // NSAPI already used + TAPI_PDP_FAILURE_CAUSE_QOS_NOT_ACCEPTED = 0x0E, // QoS not accepted + TAPI_PDP_FAILURE_CAUSE_NETWORK_FAILURE = 0x0F, // Network Failure + TAPI_PDP_FAILURE_CAUSE_REACT_REQUIRED = 0x10, // Reactivation Required + TAPI_PDP_FAILURE_CAUSE_FEATURE_NOT_SUPPORTED = 0x11, // Feature not supported + TAPI_PDP_FAILURE_CAUSE_TFT_FILTER_ERROR = 0x12, // TFT or filter error + TAPI_PDP_FAILURE_CAUSE_UNKOWN_PDP_CONTEXT = 0x13, // Unknown PDP context + TAPI_PDP_FAILURE_CAUSE_INVALID_MSG = 0x14, // Invalid MSG + TAPI_PDP_FAILURE_CAUSE_PROTOCOL_ERROR = 0x15, // Protocol error + TAPI_PDP_FAILURE_CAUSE_MOBILE_FAILURE_ERROR = 0x16, // Mobile failure error + TAPI_PDP_FAILURE_CAUSE_TIMEOUT_ERROR = 0x17, // Timeout error + TAPI_PDP_FAILURE_CAUSE_UNKNOWN_ERROR = 0x18, // Unknown error + TAPI_PDP_FAILURE_CAUSE_MAX , +} tapi_pdp_err_t; + +#ifdef __cplusplus +} +#endif + +#endif // _TEL_ERR_H_ + +/** +* @} +*/ diff --git a/src/sat_ui_support/TelSat.h b/src/sat_ui_support/TelSat.h new file mode 100644 index 0000000..8fbf727 --- /dev/null +++ b/src/sat_ui_support/TelSat.h @@ -0,0 +1,719 @@ +/* + * tel-plugin-dbus_tapi + * + * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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. + */ + +/** +* @open +* @ingroup TelephonyAPI +* @addtogroup SAT_TAPI SAT +* @{ +* +* @file TelSat.h + + @brief This file serves as a "C" header file defines structures for Telephony SAT Services. \n + It contains a sample set of constants, enums, structs that would be required by applications. + + + */ + +#ifndef _TEL_SAT_H_ +#define _TEL_SAT_H_ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define TAPI_SAT_DEF_TITLE_LEN_MAX 50 /**< max length for Menu Title */ +#define TAPI_SAT_DEF_ITEM_STR_LEN_MAX 50 /**< max length for Menu Item */ +#define TAPI_SAT_DEF_TEXT_STRING_LEN_MAX 500 /**< max length for Text String */ +#define TAPI_SAT_DEF_BIT_MASK_CONTACT 0x01 /**< Bit Mask for Contact */ +#define TAPI_SAT_DEF_BIT_MASK_MSG 0x02 /**< Bit Mask for Msg */ +#define TAPI_SAT_DEF_BIT_MASK_OTHER 0x04 /**< Bit Mask for Psh */ +#define TAPI_SAT_REFRESH_FILE_LIST 20 /**< Refresh File List*/ +#define TAPI_SAT_DEF_SS_LEN_MAX 250 +#define TAPI_SAT_DEF_USSD_LEN_MAX 250 + +// Telephony UI USER CONFIRM TYPE +/** + * @enum TelSatUiUserConfirmType_t + * This enumeration defines the UI User Confirm Type. + */ +typedef enum +{ + TAPI_SAT_USER_CONFIRM_YES, /** + * + * 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. + */ + +/** +* @open +* @ingroup TelephonyAPI +* @addtogroup SAT_TAPI SAT +* @{ +* +* @file TelSatEnvelope.h + + @brief This file serves as a "C" header file defines structures for Tapi Sat envelope command Services. \n + It contains a sample set of constants, enums, structs that would be required by applications. + */ + +#ifndef _TEL_SAT_ENVELOPE_H_ +#define _TEL_SAT_ENVELOPE_H_ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @enum TelSatCallType_t + * This enum indicates the SAT call type + */ +typedef enum +{ + TAPI_SAT_CALL_TYPE_MO_VOICE = 0X00, /**< call type - mo voice */ + TAPI_SAT_CALL_TYPE_MO_SMS, /**< call type - mo sms */ + TAPI_SAT_CALL_TYPE_SS, /**< call type - ss */ + TAPI_SAT_CALL_TYPE_USSD, /**< call type - ussd */ + TAPI_SAT_PDP_CNTXT_ACT, /**< call type - pdp context action */ + TAPI_SAT_CALL_TYPE_MAX /**< call type - max */ +}TelSatCallType_t; + +/** + * @enum TelSatCallCtrlResultType_t + * This enum indicates the result of call control by SIM. + */ +typedef enum +{ + TAPI_SAT_CALL_CTRL_R_ALLOWED_NO_MOD = 0, /**< call control result type - ALLOWED WITH NO MOD */ + TAPI_SAT_CALL_CTRL_R_NOT_ALLOWED = 1, /**< call control result type - NOT ALLOWED */ + TAPI_SAT_CALL_CTRL_R_ALLOWED_WITH_MOD = 2, /**< call control result type - ALLOWED WITH MOD */ + TAPI_SAT_CALL_CTRL_R_RESERVED = 0xFF /**< call control result type - RESERVED */ + +} TelSatCallCtrlResultType_t; + +/** + * @enum TelSatEnvelopeResp_t + * This enum indicates the general result of sending an envelope command to USIM. + */ +typedef enum +{ + TAPI_SAT_ENVELOPE_SUCCESS, /**< envelope result - success */ + TAPI_SAT_ENVELOPE_SIM_BUSY, /**< envelope result - USIM busy */ + TAPI_SAT_ENVELOPE_FAILED /**< envelope result - failed */ + +}TelSatEnvelopeResp_t; + +// 8. MENU SELECTION +/** + * This structure contains the data objects for MENU SELECTION envelope. + */ +typedef struct +{ + unsigned char itemIdentifier; /**< menu selection item identifier */ + int bIsHelpRequested; /**< flag to check whether help information required or not */ +} TelSatMenuSelectionReqInfo_t; + +// 9.1 CALL CONTROL BY SIM +/** + * This struct contains the data objects for Call Control result data sent by USIM. + */ +typedef struct +{ + TelSatAddressInfo_t address; /**< call number */ + TelSatSubAddressInfo_t subAddress; /**< call number sub address */ + TelSatBcRepeatIndicatorType_t bcRepeatIndicator; /**< bc repeat indicator */ + TelSatCapaConfigParamInfo_t ccp1; /**< capability configuration parameter1 */ + TelSatCapaConfigParamInfo_t ccp2; /**< capability configuration parameter2 */ +}TelSatVoiceCallCtrlIndInfo_t; + +/** + * This struct contains SAT ss control result data sent by USIM. + */ +typedef struct +{ + TelSatSsStringInfo_t ssString; /**< ss number */ + TelSatSubAddressInfo_t subAddress; /**< ss sub address */ + TelSatBcRepeatIndicatorType_t bcRepeatIndicator; /**< bc repeat indicator */ + TelSatCapaConfigParamInfo_t ccp1; /**< capability configuration parameter1 */ + TelSatCapaConfigParamInfo_t ccp2; /**< capability configuration parameter2 */ +}TelSatSsCtrlIndInfo_t; + +/** + * This struct contains SAT mo SMS control configuration data + */ +typedef struct +{ + TelSatAddressInfo_t rpDestAddress; /**< sms control rp destination address */ + TelSatAddressInfo_t tpDestAddress; /**< sms control tp destination address */ +} TelSatMoSmsCtrlIndInfo_t; + +/** + * This struct contains SAT call control configuration data + */ +typedef struct +{ + TelSatCallType_t callType; /**< call type */ + TelSatCallCtrlResultType_t callCtrlResult; /**< call control result */ + TelSatAlphaIdentifierInfo_t alphaIdentifier;/**< alpha identifier */ + unsigned char callId; /**< call id */ + TelSatCallType_t oldCallType; /**< old call type */ + union + { + TelSatVoiceCallCtrlIndInfo_t voiceCallData; /**< voice call control data */ + TelSatSsCtrlIndInfo_t ssData; /**< ss control data */ + TelSatMoSmsCtrlIndInfo_t smsData; + }u; /**< Union */ +} TelSatCallCtrlIndInfo_t; + +// 9.2 MO SHORT MESSAGE CONTROL BY SIM RESULT +/** + * This struct contains SAT mo ss control request data + */ + typedef struct +{ + TelSatCallCtrlResultType_t callCtrlResult; /**< call control result */ + TelSatAlphaIdentifierInfo_t alphaIdentifier; /**< alpha identifier */ + TelSatMoSmsCtrlIndInfo_t smsData; /**< sms control data */ +}TelSatMoSMCtrlResult_t; + +// 11.5 EVENT DOWNLOAD - USER ACTIVITY EVENT +/** + * This struct contains SAT user activity event request data + */ +typedef struct +{ + TelSatEventListInfo_t eventList; /**< event List */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info */ + +} TelSatUserActivityEventReqInfo_t; + +// 11.6 EVENT DOWNLOAD - IDLE SCREEN AVAILABLE EVENT +/** + * This structure contains the data objects for IDLE SCREEN AVAILABLE event download. + */ +typedef struct +{ + TelSatEventDownloadType_t eventData; /**< event type */ +} TelSatIdleScreenAvailableEventReqInfo_t; + +// 11.8 EVENT DOWNLOAD - LANGUAGE SELECTION EVENT +/** + * This structure contains the data objects for LANGUAGE SELECTION event download. + */ +typedef struct +{ + TelSatLanguageType_t language; /**< selected language info */ +} TelSatLanguageSelectionEventReqInfo_t; + +// 11.9 EVENT DOWNLOAD - BROWSER TERMINATION EVENT +/** + * This structure contains the data objects for BROWSER TERMINATION event download. + */ +typedef struct +{ + TelSatBrowserTerminationCauseType_t browserTerminationCause; /**< browser Termination Cause */ +} TelSatBrowserTerminationEventReqInfo_t; + +// 11.10 EVENT DOWNLOAD - DATA AVAILABLE EVENT +/** + * This struct contains SAT data available event request data + */ +typedef struct +{ + TelSatEventListInfo_t eventList; /**< event List */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info */ + TelSatChannelStatusInfo_t channelStatus; /**< channel status */ + TelSatChannelDataLengthInfo_t channelDataLen; /**< channel data length */ + +} TelSatDataAvailableEventReqInfo_t; + +// 11.11 EVENT DOWNLOAD - CHANNEL STATUS EVENT +/** + * This struct contains SAT channel status even request data + */ +typedef struct +{ + TelSatEventListInfo_t eventList; /**< event list */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info */ + TelSatChannelStatusInfo_t channelStatus; /**< channel Status */ +} TelSatChannelStatusEventReqInfo_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _TEL_SAT_ENVELOPE_H_ */ + +/** + * @} + */ diff --git a/src/sat_ui_support/TelSatObj.h b/src/sat_ui_support/TelSatObj.h new file mode 100644 index 0000000..6648cfc --- /dev/null +++ b/src/sat_ui_support/TelSatObj.h @@ -0,0 +1,1399 @@ +/* + * tel-plugin-dbus_tapi + * + * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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. + */ + +/** + * @open + * @ingroup TelephonyAPI + * @addtogroup SAT_TAPI SAT + * @{ + * + * @file TelSatObj.h + + @brief This file serves as a "C" header file defines structures for Telephony SAT Services. \n + It contains a sample set of constants, enums, structs that would be required by applications. + */ + +#ifndef _TEL_SAT_OBJ_H_ +#define _TEL_SAT_OBJ_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define EXTENDED_ASCII 1 + +#define TAPI_SAT_DIALLING_NUMBER_LEN_MAX 200 /**< max length of dialing number */ +#define TAPI_SAT_ALPHA_ID_LEN_MAX 255 /**< max length of alpha identifier */ +#define TAPI_SAT_TEXT_STRING_LEN_MAX 500 /**< max length of text string -when the string data is in 7Bit packed format, this length is not enough to support the maximum size so should increase the value to a value > 275 */ +#define TAPI_SAT_SUB_ADDR_LEN_MAX 30 /**< max length of sub address */ +#define TAPI_SAT_CCP_DATA_LEN_MAX 30 /**< max length of ccp data */ +#define TAPI_SAT_ITEM_TEXT_LEN_MAX 255 /**< max length of item text */ +#define TAPI_SAT_SMS_TPDU_SMS_DATA_LEN_MAX 175 /**< max length of sms tpdu data */ +#define TAPI_SAT_SS_STRING_LEN_MAX 160 /**< max length of ss string */ +#define TAPI_SAT_USSD_STRING_LEN_MAX 255 /**< max length of ussd string */ +#define TAPI_SAT_FILE_ID_LIST_MAX_COUNT 255 /**< max count of file id list */ +#define TAPI_SAT_ITEMS_NEXT_ACTION_INDI_LIST_MAX_COUNT 50 /**< max count of items next action indication list */ +#define TAPI_SAT_EVENT_LIST_MAX_COUNT 17 /**< max count of sat event list */ +#define TAPI_SAT_IMG_INSTANT_RAW_DATA_LEN_MAX 256 /**< max length of image instant raw */ +#define TAPI_SAT_CLUT_DATA_LEN_MAX 256 /**< max length of clut data */ +#define TAPI_SAT_IMG_DATA_FILE_PATH_LEN_MAX 50 /**< max length of image data file name (Icon, CLUT) */ +#define TAPI_SAT_ICON_LIST_MAX_COUNT 50 /**< max count of icon list */ +#define TAPI_SAT_DTMF_STRING_LEN_MAX 30 /**< max length of dtmf string */ +#define TAPI_SAT_DATE_TIME_AND_TIME_ZONE_LEN 7 /**< max length of date time and time zone */ +#define TAPI_SAT_URL_LEN_MAX 129 /**< max length of url */ +#define TAPI_SAT_BEARER_LIST_MAX_COUNT 50 /**< max count of bearer list */ +#define TAPI_SAT_PROVISIONING_FILE_PATH_LEN_MAX 50 /**< max length of provisioning file path */ +#define TAPI_SAT_BEARER_PARAMS_LEN_MAX 10 /**< max length of bearer parameters */ +#define TAPI_SAT_CHANNEL_DATA_STRING_LEN_MAX 255 /**< max length of channel data string */ +#define TAPI_SAT_CHANNEL_STATUS_LEN 2 /**< max length of channel status */ +#define TAPI_SAT_CHANNEL_ID_LEN 3 /**< max length of channel id */ +#define TAPI_SAT_OTHER_ADDR_LEN_MAX 30 /**< max length of other address */ +#define TAPI_SAT_PORT_NUMBER_LEN 2 /**< max length of port number */ +#define TAPI_SAT_NET_ACC_NAM_LEN_MAX 30 /**< max length of net acc name */ +#define TAPI_SAT_AID_LEN_MAX 128 /**< max length of aid */ +#define TAPI_SAT_REMOTE_ENTITY_ADDR_LEN_MAX 50 /**< max length of remote entity address */ +#define TAPI_SAT_ITEM_TEXT_ATTRIBUTES_LIST_MAX_COUNT 50 /**< max count of item text attributes list */ +#define TAPI_SAT_MCC_CODE_LEN 3 /**< max length of mcc */ +#define TAPI_SAT_MNC_CODE_LEN 3 /**< max length of mnc */ +#define TAPI_SAT_LAC_CODE_LEN 2 /**< max length of lac */ +#define TAPI_SAT_CELL_ID_LEN 2 /**< max length of cell id */ + +/** + * @enum TelSatAlphabetFormatType_t + * This enum lists the Alphabet Format. + */ +typedef enum { + TAPI_SAT_ALPHABET_FORMAT_SMS_DEFAULT = 0x00, /**< ALPHABET FROMAT SMS DEFAULT */ + TAPI_SAT_ALPHABET_FORMAT_8BIT_DATA = 0x01, /**< ALPHABET FROMAT 8BIT DATA */ + TAPI_SAT_ALPHABET_FORMAT_UCS2 = 0x02, /**< ALPHABET FROMAT UCS2 */ + TAPI_SAT_ALPHABET_FORMAT_RESERVED = 0x03 /**< ALPHABET FROMAT RESERVED */ +} TelSatAlphabetFormatType_t; + +/** + * @enum TelSatMsgClassType_t + * This enum lists the message class. + */ +typedef enum { + TAPI_SAT_MSG_CLASS_NONE = 0x00, /**< none */ + TAPI_SAT_MSG_CLASS_0 = 0x01, /**< class 0 */ + TAPI_SAT_MSG_CLASS_1, /**< class 1 Default meaning:ME-specific */ + TAPI_SAT_MSG_CLASS_2, /**< class 2 SIM specific message */ + TAPI_SAT_MSG_CLASS_3, /**< class 3 Default meaning: TE specific */ + TAPI_SAT_MSG_CLASS_RESERVED = 0xFF /**< class reserved */ +} TelSatMsgClassType_t; + +/** + * @enum TelSatCommandType_t + * This enum lists the type of command and the next action indicator. + */ +typedef enum { + TAPI_SAT_CMD_TYPE_NONE = 0x00, /**< command type - None */ + + TAPI_SAT_CMD_TYPE_REFRESH = 0x01, /**< command type - refresh */ + TAPI_SAT_CMD_TYPE_MORE_TIME = 0x02, /**< command type - more time */ + TAPI_SAT_CMD_TYPE_SETUP_EVENT_LIST = 0x05, /**< command type - setup event list */ + TAPI_SAT_CMD_TYPE_SETUP_CALL = 0x10, /**< command type - setup call */ + TAPI_SAT_CMD_TYPE_SEND_SS = 0x11, /**< command type - send ss */ + TAPI_SAT_CMD_TYPE_SEND_USSD = 0x12, /**< command type - send ussd */ + TAPI_SAT_CMD_TYPE_SEND_SMS = 0x13, /**< command type - send sms */ + TAPI_SAT_CMD_TYPE_SEND_DTMF = 0x14, /**< command type - send dtmf */ + TAPI_SAT_CMD_TYPE_LAUNCH_BROWSER = 0x15, /**< command type - launch browser */ + TAPI_SAT_CMD_TYPE_PLAY_TONE = 0x20, /**< command type - play tone */ + TAPI_SAT_CMD_TYPE_DISPLAY_TEXT = 0x21, /**< command type - display text */ + TAPI_SAT_CMD_TYPE_GET_INKEY = 0x22, /**< command type - get inkey */ + TAPI_SAT_CMD_TYPE_GET_INPUT = 0x23, /**< command type - get input */ + TAPI_SAT_CMD_TYPE_SELECT_ITEM = 0x24, /**< command type - select item */ + TAPI_SAT_CMD_TYPE_SETUP_MENU = 0x25, /**< command type - setup menu */ + TAPI_SAT_CMD_TYPE_PROVIDE_LOCAL_INFO = 0x26, /**< command type - provide local info */ + TAPI_SAT_CMD_TYPE_SETUP_IDLE_MODE_TEXT = 0x28, /**< command type - setup idle mode text */ + TAPI_SAT_CMD_TYPE_LANGUAGE_NOTIFICATION = 0x35, /**< command type - language notification */ + TAPI_SAT_CMD_TYPE_OPEN_CHANNEL = 0x40, /**< command type - open channel -class e */ + TAPI_SAT_CMD_TYPE_CLOSE_CHANNEL = 0x41, /**< command type - close channel - class e */ + TAPI_SAT_CMD_TYPE_RECEIVE_DATA = 0x42, /**< command type - receive data -class e */ + TAPI_SAT_CMD_TYPE_SEND_DATA = 0x43, /**< command type - send data */ + TAPI_SAT_CMD_TYPE_GET_CHANNEL_STATUS = 0x44, /**< command type - get channel status -class e */ + TAPI_SAT_CMD_TYPE_END_OF_APP_EXEC = 0xFD, /**< inform to End the execution of a Proactive Command*/ + TAPI_SAT_CMD_TYPE_END_PROACTIVE_SESSION = 0xFE, /**< inform end proactive session */ + TAPI_SAT_CMD_TYPE_RESERVED = 0xFF /**< command type - reserved */ +} TelSatCommandType_t; + +/** + * @enum TelSatCmdQualiRefresh_t + * This enum lists the Command qualifier values for Refresh command. + */ +typedef enum { + TAPI_SAT_REFRESH_SIM_INIT_AND_FULL_FCN = 0x00, /**< command qualifier for REFRESH SIM INIT AND FULL FILE CHANGE_NOTIFICATION */ + TAPI_SAT_REFRESH_FCN = 0x01, /**< command qualifier for REFRESH FILE CHANGE NOTIFICATION */ + TAPI_SAT_REFRESH_SIM_INIT_AND_FCN = 0x02, /**< command qualifier for REFRESH SIM INIT AND FILE CHANGE NOTIFICATION */ + TAPI_SAT_REFRESH_SIM_INIT = 0x03, /**< command qualifier for REFRESH SIM INIT */ + TAPI_SAT_REFRESH_SIM_RESET = 0x04, /**< command qualifier for REFRESH SIM RESET */ + TAPI_SAT_REFRESH_3G_APPLICATION_RESET = 0x05, /**< command qualifier for REFRESH 3G APPLICATION RESET */ + TAPI_SAT_REFRESH_3G_SESSION_RESET = 0x06, /**< command qualifier for REFRESH 3G SESSION RESET */ + TAPI_SAT_REFRESH_RESERVED = 0xFF /**< command qualifier for REFRESH RESERVED */ +} TelSatCmdQualiRefresh_t; + +/** + * @enum TelSatCmdQualiSetupCall_t + * This enum lists the Command qualifier values for setup call command. + */ +typedef enum { + TAPI_SAT_SETUP_CALL_IF_ANOTHER_CALL_NOT_BUSY = 0x00, /**< command qualifier for SETUP CALL IF ANOTHER CALL NOT BUSY */ + TAPI_SAT_SETUP_CALL_IF_ANOTHER_CALL_NOT_BUSY_WITH_REDIAL = 0x01, /**< command qualifier for SETUP CALL IF ANOTHER CALL NOT BUSY WITH REDIAL */ + TAPI_SAT_SETUP_CALL_PUT_ALL_OTHER_CALLS_ON_HOLD = 0x02, /**< command qualifier for SETUP CALL PUTTING ALL OTHER CALLS ON HOLD */ + TAPI_SAT_SETUP_CALL_PUT_ALL_OTHER_CALLS_ON_HOLD_WITH_REDIAL = 0x03, /**< command qualifier for SETUP CALL PUTTING ALL OTHER CALLS ON HOLD WITH REDIAL */ + TAPI_SAT_SETUP_CALL_DISCONN_ALL_OTHER_CALLS = 0x04, /**< command qualifier for SETUP CALL DISCONNECTING ALL OTHER CALLS */ + TAPI_SAT_SETUP_CALL_DISCONN_ALL_OTHER_CALLS_WITH_REDIAL = 0x05, /**< command qualifier for SETUP CALL DISCONNECTING ALL OTHER CALLS WITH REDIAL */ + TAPI_SAT_SETUP_CALL_RESERVED = 0xFF /**< command qualifier for SETUP CALL RESERVED */ +} TelSatCmdQualiSetupCall_t; + +/** + * @enum TelSatDisplayTextPriorityType_t + * This is associated with the command qualifier for display text. + */ +typedef enum { + TAPI_SAT_MSG_PRIORITY_NORMAL = 0, /**< MSG PRIORITY NORMAL */ + TAPI_SAT_MSG_PRIORITY_HIGH = 1 /**< MSG PRIORITY HIGH */ +} TelSatDisplayTextPriorityType_t; + +/** + * @enum TelSatDisplayTextMsgClearType_t + * This is associated with the command qualifier for display text. + */ +typedef enum { + TAPI_SAT_AUTO_CLEAR_MSG_AFTER_A_DELAY = 0, /**< message clear type - AUTO CLEAR MSG AFTER A DELAY */ + TAPI_SAT_WAIT_FOR_USER_TO_CLEAR_MSG = 1 /**< message clear type - WAIT FOR USER TO CLEAR MSG */ +} TelSatDisplayTextMsgClearType_t; + +/** + * @enum TelSatInkeyType_t + * This is associated with the command qualifier for get inkey. + */ +typedef enum { + TAPI_SAT_INKEY_TYPE_CHARACTER_SET_ENABLED = 0, /**< command qualifier for INKEY TYPE CHARACTER SET ENABLED */ + TAPI_SAT_INKEY_TYPE_YES_NO_REQUESTED = 1 /**< command qualifier for INKEY TYPE YES NO REQUESTED */ +} TelSatInkeyType_t; + +/** + * @enum TelSatUseInputAlphabetType_t + * This is associated with the command qualifier for get input. + */ +typedef enum { + TAPI_SAT_USER_INPUT_ALPHABET_TYPE_SMS_DEFAULT = 1, /**< command qualifier for ALPHABET TYPE SMS DEFAULT */ + TAPI_SAT_USER_INPUT_ALPHABET_TYPE_UCS2 = 2 /**< command qualifier for ALPHABET TYPE UCS2 */ +} TelSatUseInputAlphabetType_t; + +/** + * @enum TelSatDisplayVibrateAlertType_t + * This is associated with the command qualifier for play tone command. + */ +typedef enum { + TAPI_SAT_VIBRATE_ALERT_OPTIONAL = 0, /**< VIBRATE ALERT UPTO THE TERMINAL */ + TAPI_SAT_VIBRATE_ALERT_REQUIRED = 1 /**< VIBRATE, IF AVAILABLE, WITH TONE. */ +} TelSatDisplayVibrateAlertType_t; + +/** + * @enum TelSatPresentationType_t + * This is associated with the command qualifier for select item command. + */ +typedef enum { + TAPI_SAT_PRESENTATION_TYPE_NOT_SPECIFIED = 0x00, /**< command qualifier for PRESENTATION TYPE NOT SPECIFIED */ + TAPI_SAT_PRESENTATION_TYPE_DATA_VALUE = 0x01, /**< command qualifier for PRESENTATION TYPE DATA VALUE */ + TAPI_SAT_PRESENTATION_TYPE_NAVIGATION_OPTION = 0x02 /**< command qualifier for PRESENTATION TYPE NAVIGATION OPTION */ +} TelSatPresentationType_t; + +/** + * @enum TelSatSelectionPreferenceType_t + * This is associated with the command qualifier for select item command. + */ +typedef enum { + TAPI_SAT_SELECTION_PREFERENCE_NONE_REQUESTED = 0, /**< command qualifier for SELECTION PREFERENCE NONE REQUESTED */ + TAPI_SAT_SELECTION_PREFERENCE_USING_SOFT_KEY = 1 /**< command qualifier for SELECTION PREFERENCE USING SOFT KEY */ +} TelSatSelectionPreferenceType_t; + +/** + * @enum TelSatCmdQualiProvideLocalInfo_t + * This enum defines the Command qualifier values for provide local info command. + */ +typedef enum { + TAPI_SAT_PROVIDE_DATE_TIME_AND_TIME_ZONE = 0x03, /**< command qualifier for PROVIDE DATE TIME AND TIME ZONE */ + TAPI_SAT_PROVIDE_LANGUAGE_SETTING = 0x04, /**< command qualifier for PROVIDE LANGUAGE SETTING */ + TAPI_SAT_PROVIDE_IMEISV = 0x08, TAPI_SAT_PROVIDE_RESERVED = 0xFF /**< reserved */ +} TelSatCmdQualiProvideLocalInfo_t; + +/** + * @enum TelSatCmdQualiLaunchBrowser_t + * This enum defines the Command qualifier values for launch browser command. + */ +typedef enum { + TAPI_SAT_LAUNCH_BROWSER = 0, /**< command qualifier for LAUNCH BROWSER */ + TAPI_SAT_NOT_USED = 1, /**< command qualifier for NOT USED */ + TAPI_SAT_USE_EXISTING_BROWSER = 2, /**< command qualifier for USE EXISTING BROWSER if secure session, do not use it. */ + TAPI_SAT_CLOSE_AND_LAUNCH_NEW_BROWSER = 3, /**< command qualifier for CLOSE AND LAUNCH NEW BROWSER */ + TAPI_SAT_NOT_USED2 = 4, /**< command qualifier for NOT USED2 */ + TAPI_SAT_LB_RESERVED = 0xFF /**< reserved */ +} TelSatCmdQualiLaunchBrowser_t; + +/** + * @enum TelSatDeviceIdentitiesTagType_t + * This enum lists the device identity tag value IDs. + */ +typedef enum { + TAPI_SAT_DEVICE_ID_KEYPAD = 0x01, /**< DEVICE ID KEYPAD */ + TAPI_SAT_DEVICE_ID_DISPLAY = 0x02, /**< DEVICE ID DISPLAY */ + TAPI_SAT_DEVICE_ID_EARPIECE = 0x03, /**< DEVICE ID EARPIECE */ + + TAPI_SAT_DEVICE_ID_SIM = 0x81, /**< DEVICE ID SIM */ + TAPI_SAT_DEVICE_ID_ME = 0x82, /**< DEVICE ID ME */ + TAPI_SAT_DEVICE_ID_NETWORK = 0x83, /**< DEVICE ID NETWORK */ + + TAPI_SAT_DEVICE_ID_RESERVED = 0XFF /**< reserved */ +} TelSatDeviceIdentitiesTagType_t; + +/** + * @enum TelSatTimeUnitType_t + * This enum lists the time units for the duration data object. + */ +typedef enum { + TAPI_SAT_TIME_UNIT_MINUTES = 0x0, /**< time unit - minutes */ + TAPI_SAT_TIME_UNIT_SECONDS = 0x01, /**< time unit - second */ + TAPI_SAT_TIME_UNIT_TENTHS_OF_SECONDS = 0x02, /**< time unit - tenths of seconds */ + TAPI_SAT_TIME_UNIT_RESERVED = 0xFF /**< reserved */ +} TelSatTimeUnitType_t; + +/** + * @enum TelSatResultType_t + * This enum lists the values for the RESULT data object - General Response. + */ +typedef enum { + TAPI_SAT_R_SUCCESS = 0x0, /**< command performed successfully */ + TAPI_SAT_R_SUCCESS_WITH_PARTIAL_COMPREHENSION = 0x01, /**< command performed with partial comprehension */ + TAPI_SAT_R_SUCCESS_WITH_MISSING_INFO = 0x02, /**< command performed, with missing information */ + + TAPI_SAT_R_REFRESH_PERFORMED_WITH_ADDITIONAL_EFS_READ = 0x03, /**< REFRESH PERFORMED WITH ADDITIONAL EFS READ */ + TAPI_SAT_R_SUCCESS_BUT_REQUESTED_ICON_NOT_DISPLAYED = 0x04, /**< command performed but REQUESTED ICON NOT DISPLAYED */ + TAPI_SAT_R_SUCCESS_BUT_MODIFIED_BY_CALL_CONTROL_BY_SIM = 0x05, /**< command performed but MODIFIED BY CALL CONTROL BY SIM */ + TAPI_SAT_R_SUCCESS_LIMITED_SERVICE = 0x06, /**< command performed with LIMITED SERVICE */ + TAPI_SAT_R_SUCCESS_WITH_MODIFICATION = 0x07, /**< command performed with MODIFICATION */ + TAPI_SAT_R_REFRESH_PRFRMD_BUT_INDICATED_USIM_NOT_ACTIVE = 0x08, /**< REFRESH PERFORMED BUT INDICATED USIM NOT ACTIVE */ + + TAPI_SAT_R_PROACTIVE_SESSION_TERMINATED_BY_USER = 0x10, /**< proactive sim application session terminated by user */ + TAPI_SAT_R_BACKWARD_MOVE_BY_USER = 0x11, /**< backward move in the proactive sim application session request by the user */ + TAPI_SAT_R_NO_RESPONSE_FROM_USER = 0x12, /**< no response from user */ + + TAPI_SAT_R_HELP_INFO_REQUIRED_BY_USER = 0x13, /**< HELP INFO REQUIRED BY USER */ + TAPI_SAT_R_USSD_OR_SS_TRANSACTION_TERMINATED_BY_USER = 0x14, /**< USSD OR SS TRANSACTION TERMINATED BY USER */ + + TAPI_SAT_R_ME_UNABLE_TO_PROCESS_COMMAND = 0x20, /**< ME currently unable to process command */ + TAPI_SAT_R_NETWORK_UNABLE_TO_PROCESS_COMMAND = 0x21, /**< Network currently unable to process command */ + TAPI_SAT_R_USER_DID_NOT_ACCEPT_CALL_SETUP_REQ = 0x22, /**< User did not accept call setup request */ + TAPI_SAT_R_USER_CLEAR_DOWN_CALL_BEFORE_CONN = 0x23, /**< User cleared down call before connection or network released */ + + TAPI_SAT_R_INTERACTION_WITH_CC_BY_SIM_IN_TMP_PRBLM = 0x25, /**< INTERACTION WITH CALL CONTROL BY SIM IN TEMPORARY PROBLEM */ + TAPI_SAT_R_LAUNCH_BROWSER_GENERIC_ERROR_CODE = 0x26, /**< LAUNCH BROWSER GENERIC ERROR CODE */ + + TAPI_SAT_R_BEYOND_ME_CAPABILITIES = 0x30, /**< command beyond ME's capabilities */ + TAPI_SAT_R_COMMAND_TYPE_NOT_UNDERSTOOD_BY_ME = 0x31, /**< command type not understood by ME */ + TAPI_SAT_R_COMMAND_DATA_NOT_UNDERSTOOD_BY_ME = 0x32, /**< command data not understood by ME */ + TAPI_SAT_R_COMMAND_NUMBER_NOT_KNOWN_BY_ME = 0x33, /**< command number not known by ME */ + TAPI_SAT_R_SS_RETURN_ERROR = 0x34, /**< SS return error */ + TAPI_SAT_R_SMS_RP_ERROR = 0x35, /**< SMS rp-error */ + TAPI_SAT_R_ERROR_REQUIRED_VALUES_ARE_MISSING = 0x36, /**< Error, required values are missing */ + + TAPI_SAT_R_USSD_RETURN_ERROR = 0x37, /**< USSD_RETURN_ERROR */ + TAPI_SAT_R_INTRCTN_WITH_CC_OR_SMS_CTRL_PRMNT_PRBLM = 0x39, /**< INTERACTION WITH CALL CONTROL OR SMS CONTROL PERMANENT PROBLEM */ + TAPI_SAT_R_BEARER_INDEPENDENT_PROTOCOL_ERROR = 0x3A, /**< BEARER INDEPENDENT PROTOCOL ERROR */ + TAPI_SAT_R_FRAMES_ERROR = 0x3C /**< FRAMES ERROR */ +} TelSatResultType_t; + +/** + * @enum TelSatMeProblemType_t + * This enum lists the values for the Additional response for the RESULT object and specifies a particular ME PROBLEM. + */ +typedef enum { + TAPI_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE = 0x0, /**< ME problem with NO SPECIFIC CAUSE */ + TAPI_SAT_ME_PROBLEM_SCREEN_BUSY = 0x01, /**< ME problem with SCREEN BUSY */ + TAPI_SAT_ME_PROBLEM_ME_BUSY_ON_CALL = 0x02, /**< ME problem with ME BUSY ON CALL */ + TAPI_SAT_ME_PROBLEM_ME_BUSY_ON_SS = 0x03, /**< ME problem with ME_BUSY ON SS */ + TAPI_SAT_ME_PROBLEM_NO_SERVICE = 0x04, /**< ME problem with NO SERVICE */ + TAPI_SAT_ME_PROBLEM_ACCESS_CONTROL_CLASS_BAR = 0x05, /**< ME problem with ACCESS CONTROL CLASS BAR */ + TAPI_SAT_ME_PROBLEM_RADIO_RES_NOT_GRANTED = 0x06, /**< ME problem with RADIO RES NOT GRANTED */ + TAPI_SAT_ME_PROBLEM_NOT_IN_SPEECH_CALL = 0x07, /**< ME problem with NOT IN SPEECH CALL */ + TAPI_SAT_ME_PROBLEM_ME_BUSY_ON_USSD = 0x08, /**< ME problem with ME BUSY ON USSD */ + TAPI_SAT_ME_PROBLEM_ME_BUSY_ON_SEND_DTMF_CMD = 0x09, /**< ME problem with ME BUSY ON SEND DTMF CMD */ + TAPI_SAT_ME_PROBLEM_NO_USIM_ACTIVE = 0x0A, /**< ME problem with NO USIM ACTIVE */ + TAPI_SAT_ME_PROBLEM_INVALID = 0xFF /**< ME problem with INVALID */ +} TelSatMeProblemType_t; + +/** + * @enum TelSatNetworkProblemType_t + * This enum lists the values for the Additional response for the RESULT object and specifies a particular network PROBLEM. + */ +typedef enum { + TAPI_SAT_NETWORK_PROBLEM_NO_SPECIFIC_CAUSE = 0x0, /**< Network problem with no specific cause */ + TAPI_SAT_NETWORK_PROBLEM_USER_BUSY = 0x91 /**< Network problem with USER BUSY */ +} TelSatNetworkProblemType_t; + +/** + * @enum TelSatSsProblemType_t + * This enum lists the values for the Additional response for the RESULT object related to SEND SS. + */ +typedef enum { + TAPI_SAT_SS_PROBLEM_NO_SPECIFIC_CAUSE = 0, /**< SS problem with no specific cause */ + TAPI_SAT_SS_PROBLEM_FACILITY_NOT_SUPPORTED = 0x15 /**< SS problem with FACILITY NOT SUPPORTED */ +} TelSatSsProblemType_t; + +/** + * @enum TelSatSmsProblemType_t + * This enum lists the values for the Additional response for the RESULT object related to SEND SMS. + */ +typedef enum { + TAPI_SAT_SMS_PROBLEM_NO_SPECIFIC_CAUSE = 0 /**< SMS problem with no specific cause */ +} TelSatSmsProblemType_t; + +/** + * @enum TelSatUssdProblemType_t + * This enum lists the values for the Additional response for the RESULT object related to SEND USSD STRING. + */ +typedef enum { + TAPI_SAT_USSD_PROBLEM_NO_SPECIFIC_CAUSE = 0, /**< USSD problem with no specific cause */ + TAPI_SAT_USSD_PROBLEM_UNKNOWN_ALPHABET = 0x47 /**< USSD problem with UNKNOWN ALPHABET */ +} TelSatUssdProblemType_t; + +/** + * @enum TelSatCallCtrlProblemType_t + * This enum lists the values for the Additional response for the RESULT object related to CALL CONTROL or MO SMS CONTROL. + */ +typedef enum { + TAPI_SAT_CC_PROBLEM_NO_SPECIFIC_CAUSE = 0, /**< Call Control problem with no specific cause */ + TAPI_SAT_CC_PROBLEM_ACTION_NOT_ALLOWED = 1, /**< Call Control problem with action not allowed */ + TAPI_SAT_CC_PROBLEM_REQUEST_TYPE_HAS_CHANGED = 2 /**< Call Control problem with request type has changed */ +} TelSatCallCtrlProblemType_t; + +/** + * @enum TelSatLaunchBrowserProblemType_t + * This enum lists the values for the Additional response for the RESULT object related to LAUNCH BROWSER PROBLEM + */ +typedef enum { + TAPI_SAT_BROWSER_PROBLEM_NO_SPECIFIC_CAUSE = 0, /**< Browser problem with no specific cause */ + TAPI_SAT_BROWSER_PROBLEM_BEARER_UNAVAILABLE = 1, /**< Browser problem with bearer unavailable */ + TAPI_SAT_BROWSER_PROBLEM_BROWSER_UNAVAILABLE = 2, /**< Browser problem with browser unavailable */ + TAPI_SAT_BROWSER_PRBLM_ME_UNABLE_TO_READ_PROV_DATA = 3 /**< Browser problem with ME unable to read provisioning data */ +} TelSatLaunchBrowserProblemType_t; + +/** + * @enum TelSatBipProblemType_t + * This enum lists the values for the Additional response for the RESULT object. + * Permanent Problems ::: 12.12.11 ADDITIONAL INFORMATION : BEARER INDEPENDENT PROTOCOL + */ +typedef enum { + TAPI_SAT_BIP_PROBLEM_NO_SPECIFIC_CAUSE = 0x00, /**< BIP problem with no specific cause */ + TAPI_SAT_BIP_PROBLEM_NO_CHANNEL_AVAILABLE = 0x01, /**< BIP problem with no channel available */ + TAPI_SAT_BIP_PROBLEM_CHANNEL_CLOSED = 0x02, /**< BIP problem with channel closed */ + TAPI_SAT_BIP_PROBLEM_CHANNEL_ID_NOT_VALID = 0x03, /**< BIP problem with channel id not valid */ + TAPI_SAT_BIP_PROBLEM_BUF_SIZE_NOT_AVAILABLE = 0x04, /**< BIP problem with buffer size not available */ + TAPI_SAT_BIP_PROBLEM_SECURITY_ERROR = 0x05, /**< BIP problem with security error */ + TAPI_SAT_BIP_PRBLM_SIM_ME_IF_TRNSPRT_LEVEL_NOT_AVL = 0x06, /**< BIP problem with SIM ME interface transport level not available */ + TAPI_SAT_BIP_REMOTE_DEV_NOT_REACHABLE = 0x07, /**< BIP problem with remote device not reachable */ + TAPI_SAT_BIP_SERVICE_ERROR = 0x08, /**< BIP service error */ + TAPI_SAT_BIP_SERVICE_IDENTIFIER_UNKNOWN = 0x09 /**< BIP service identifier unknown */ +} TelSatBipProblemType_t; + +/** + * @enum TelSatSmsTpduType_t + * This enum lists the values for the SMS TPDU type. + */ +typedef enum { + TAPI_SAT_SMS_TPDU_TYPE_DELIVER_TPDU = 0, /**< sms tpdu type - DELIVER TPDU */ + TAPI_SAT_SMS_TPDU_TYPE_DELIVER_RPT = 1, /**< sms tpdu type - DELIVER RPT */ + TAPI_SAT_SMS_TPDU_TYPE_SUBMIT_TPDU = 2, /**< sms tpdu type - SUBMIT TPDU */ + TAPI_SAT_SMS_TPDU_TYPE_SUBMIT_RPT = 3, /**< sms tpdu type - SUBMIT RPT */ + TAPI_SAT_SMS_TPDU_TYPE_STATUS_RPT = 4, /**< sms tpdu type - STATUS RPT */ + TAPI_SAT_SMS_TPDU_TYPE_TPDU_CMD = 5 /**< sms tpdu type - TPDU CMD */ +} TelSatSmsTpduType_t; + +/** + * @enum TelSatToneType_t + * This enum lists the values tones type. + */ +typedef enum { + // standard supervisory tones + TAPI_SAT_DIAL_TONE = 0x01, /**< TONE TYPE DIAL TONE */ + TAPI_SAT_CALLED_SUBSCRIBER_BUSY = 0x02, /**< TONE TYPE CALLED SUBSCRIBER BUSY */ + TAPI_SAT_CONGESTION = 0x03, /**< TONE TYPE CONGESTION */ + TAPI_SAT_RADIO_PATH_ACK = 0x04, /**< TONE TYPE RADIO PATH ACK */ + TAPI_SAT_RADIO_PATH_NOT_AVAILABLE_CALL_DROPPED = 0x05, /**< TONE TYPE RADIO PATH NOT AVAILABLE CALL DROPPED */ + TAPI_SAT_ERR_SPECIAL_INFO = 0x06, /**< TONE TYPE ERR SPECIAL INFO */ + TAPI_SAT_CALL_WAITING_TONE = 0x07, /**< TONE TYPE CALL WAITING TONE */ + TAPI_SAT_RINGING_TONE = 0x08, /**< TONE TYPE RINGING TONE */ + + // ME proprietary tones + TAPI_SAT_GENERAL_BEEP = 0x10, /**< TONE TYPE GENERAL BEEP */ + TAPI_SAT_POSITIVE_ACK_TONE = 0x11, /**< TONE TYPE POSITIVE ACK TONE */ + TAPI_SAT_NEGATIVE_ACK_OR_ERROR_TONE = 0x12, /**< TONE TYPE NEGATIVE ACK OR ERROR TONE */ + TAPI_SAT_RINGING_TONE_SLCTD_BY_USR_FOR_INCOM_SPEECH_CALL = 0x13, /**< TONE TYPE RINGING TONE SELECTED BY USER FOR INCOMING SPEECH CALL */ + TAPI_SAT_ALERT_TONE_SELECTED_BY_USER_FOR_INCOMING_SMS = 0x14, /**< TONE TYPE ALERT TONE SELECTED BY USER FOR INCOMING SMS */ + TAPI_SAT_CRITICAL_ALERT = 0x15, /**< TONE TYPE CRITICAL ALERT */ + + //Themed tones + TAPI_SAT_HAPPY_TONE = 0x30, /**< TONE TYPE HAPPY TONE */ + TAPI_SAT_SAD_TONE = 0x31, /**< TONE TYPE SAD TONE */ + TAPI_SAT_URGENT_ACTION_TONE = 0x32, /**< TONE TYPE URGENT ACTION TONE */ + TAPI_SAT_QUESTION_TONE = 0x33, /**< TONE TYPE QUESTION TONE */ + TAPI_SAT_MESSAGE_RECEIVED_TONE = 0x34, /**< TONE TYPE MESSAGE RECEIVED TONE */ + + //Melody tones + TAPI_SAT_MELODY_1 = 0x40, /**< TONE TYPE MELODY 1 */ + TAPI_SAT_MELODY_2 = 0x41, /**< TONE TYPE MELODY 2 */ + TAPI_SAT_MELODY_3 = 0x42, /**< TONE TYPE MELODY 3 */ + TAPI_SAT_MELODY_4 = 0x43, /**< TONE TYPE MELODY 4 */ + TAPI_SAT_MELODY_5 = 0x44, /**< TONE TYPE MELODY 5 */ + TAPI_SAT_MELODY_6 = 0x45, /**< TONE TYPE MELODY 6 */ + TAPI_SAT_MELODY_7 = 0x46, /**< TONE TYPE MELODY 7 */ + TAPI_SAT_MELODY_8 = 0x47, /**< TONE TYPE MELODY 8 */ + + TAPI_SAT_TONE_TYPE_RESERVED = 0xFF /**< TONE TYPE RESERVED */ +} TelSatToneType_t; + +/** + * @enum TelSatEventDownloadType_t + * This enum lists event types required by ME to monitor and report to SIM. + */ +typedef enum { + TAPI_EVENT_SAT_DW_TYPE_MT_CALL = 0, + TAPI_EVENT_SAT_DW_TYPE_CALL_CONNECTED = 1, + TAPI_EVENT_SAT_DW_TYPE_CALL_DISCONNECTED = 2, + TAPI_EVENT_SAT_DW_TYPE_LOCATION_STATUS = 3, + TAPI_EVENT_SAT_DW_TYPE_USER_ACTIVITY = 4, /**< data download type - USER_ACTIVITY */ + TAPI_EVENT_SAT_DW_TYPE_IDLE_SCREEN_AVAILABLE = 5, /**< data download type - IDLE SCREEN AVAILABLE */ + TAPI_EVENT_SAT_DW_TYPE_CARD_READER_STATUS = 6, + TAPI_EVENT_SAT_DW_TYPE_LANGUAGE_SELECTION = 7, /**< data download type - LANGUAGE SELECTION */ + TAPI_EVENT_SAT_DW_TYPE_BROWSER_TERMINATION = 8, /**< data download type - BROWSER TERMINATION */ + TAPI_EVENT_SAT_DW_TYPE_DATA_AVAILABLE = 9, /**< data download type -DATA AVAILABLE */ + TAPI_EVENT_SAT_DW_TYPE_CHANNEL_STATUS = 0x0A, /**< data download type - CHANNEL STATUS */ + TAPI_EVENT_SAT_DW_TYPE_ACCESS_TECHNOLOGY_CHANGED = 0x0B, + TAPI_EVENT_SAT_DW_TYPE_DISPLAY_PARAMETERS_CHANGED = 0x0C, + TAPI_EVENT_SAT_DW_TYPE_LOCAL_CONNECTION = 0x0D, + TAPI_EVENT_SAT_DW_TYPE_NW_SEARCH_MODE_CHANGED = 0X0E, + TAPI_EVENT_SAT_DW_TYPE_BROWSING_STATUS = 0X0F, + TAPI_EVENT_SAT_DW_TYPE_FRAMES_INFORMATION_CHANGED = 0X10, + TAPI_EVENT_SAT_DW_TYPE_RESERVED_FOR_3GPP = 0X11, + TAPI_EVENT_SAT_DW_TYPE_UNKNOWN = 0xFF /**< data download type - unknown */ +} TelSatEventDownloadType_t; + +/** + * @enum TelSatImageCodingSchemeType_t + * This enum lists image coding scheme types required by ME to show. + */ +typedef enum { + TAPI_SAT_SIM_IMAGE_CODING_SCHEME_BASIC = 0x11, /**< IMAGE CODING SCHEME BASIC */ + TAPI_SAT_SIM_IMAGE_CODING_SCHEME_COLOUR = 0x21, /**< IMAGE CODING SCHEME COLOUR */ + TAPI_SAT_SIM_IMAGE_CODING_SCHEME_RESERVED = 0xFF /**< RESERVED */ +} TelSatImageCodingSchemeType_t; + +/** + * @enum TelSatIconQualifierType_t + * This enum defines the icon qualifier. + */ +typedef enum { + TAPI_SAT_ICON_QUALI_SELF_EXPLANATORY = 0, /**< ICON QUALI SELF EXPLANATORY */ + TAPI_SAT_ICON_QUALI_NOT_SELF_EXPLANATORY = 1, /**< ICON QUALI NOT SELF EXPLANATORY */ + TAPI_SAT_ICON_QUALI_RESERVED = 0xFF /**< RESERVED */ +} TelSatIconQualifierType_t; + +/** + * @enum TelSatBcRepeatIndicatorType_t + * This enum defines the SIM ATK BC repeat indicator type. + */ +typedef enum { + TAPI_SAT_BC_REPEAT_INDI_ALTERNATE_MODE = 0x01, /**< BC REPEAT ALTERNATE MODE */ + TAPI_SAT_BC_REPEAT_INDI_SEQUENTIAL_MODE = 0x03, /**< BC REPEAT SEQUENTIAL MODE */ + TAPI_SAT_BC_REPEAT_INDI_RESERVED = 0xFF /**< RESERVED */ +} TelSatBcRepeatIndicatorType_t; + +/** + * @enum TelSatCallCtrlStringType_t + * This enum defines call control string type. + */ +typedef enum { + TAPI_SAT_CC_VOICE = 0x00, /**< Call Control String Type - voice */ + TAPI_SAT_CC_SS = 0x01, /**< Call Control String Type - ss */ + TAPI_SAT_CC_USSD = 0x02, /**< Call Control String Type - ussd */ + TAPI_SAT_CC_NONE = 0xFF /**< Call Control String Type - none */ +} TelSatCallCtrlStringType_t; + +/** + * @enum TelSatLanguageType_t + * This enum lists the language values. + */ +typedef enum { + TAPI_SAT_LP_GERMAN = 0x00, /**< GERMAN */ + TAPI_SAT_LP_ENGLISH = 0x01, /**< ENGLISH */ + TAPI_SAT_LP_ITALIAN = 0x02, /**< ITALIAN */ + TAPI_SAT_LP_FRENCH = 0x03, /**< FRENCH */ + TAPI_SAT_LP_SPANISH = 0x04, /**< SPANISH */ + TAPI_SAT_LP_DUTCH = 0x05, /**< DUTCH */ + TAPI_SAT_LP_SWEDISH = 0x06, /**< SWEDISH */ + TAPI_SAT_LP_DANISH = 0x07, /**< DANISH */ + TAPI_SAT_LP_PORTUGUESE = 0x08, /**< PORTUGUESE */ + TAPI_SAT_LP_FINNISH = 0x09, /**< FINNISH */ + TAPI_SAT_LP_NORWEGIAN = 0x0A, /**< NORWEGIAN */ + TAPI_SAT_LP_GREEK = 0x0B, /**< GREEK */ + TAPI_SAT_LP_TURKISH = 0x0C, /**< TURKISH */ + TAPI_SAT_LP_HUNGARIAN = 0x0D, /**< HUNGARIAN */ + TAPI_SAT_LP_POLISH = 0x0E, /**< POLISH */ + TAPI_SAT_LP_LANG_UNSPECIFIED = 0x0F /**< LANGUAGE UNSPECIFIED */ +} TelSatLanguageType_t; + +/** + * @enum TelSatBrowserIdentityType_t + * This enum lists the SAT browser identity type. + */ +typedef enum { + TAPI_SAT_BROWSER_ID_DEFAULT = 0x0, /**< DEFAULT BROWSER */ + TAPI_SAT_BROWSER_ID_WML, /**< BROWSER WML */ + TAPI_SAT_BROWSER_ID_HTML, /**< BROWSER HTML */ + TAPI_SAT_BROWSER_ID_XHTML, /**< BROWSER XHTML */ + TAPI_SAT_BROWSER_ID_CHTML, /**< BROWSER CHTML */ + TAPI_SAT_BROWSER_ID_RESERVED = 0xFF /**< RESERVED */ +} TelSatBrowserIdentityType_t; + +/** + * @enum TelSatBearerType_t + * This enum lists the SAT bearer type. + */ +typedef enum { + TAPI_SAT_BEARER_TYPE_SMS = 0x0, /**< BEARER SMS */ + TAPI_SAT_BEARER_TYPE_CSD = 0x1, /**< BEARER CSD */ + TAPI_SAT_BEARER_TYPE_USSD = 0x2, /**< BEARER USSD */ + TAPI_SAT_BEARER_TYPE_GPRS = 0x3, /**< BEARER GPRS */ + TAPI_SAT_BEARER_TYPE_RESERVED = 0xFF /**< BEARER RESERVED */ +} TelSatBearerType_t; + +/** + * @enum TelSatBrowserTerminationCauseType_t + * This enum lists the SAT browser termination cause type. + */ +typedef enum { + TAPI_SAT_BROWSER_TERMINATED_BY_USER = 0, /**< BROWSER TERMINATED BY USER */ + TAPI_SAT_BROWSER_TERMINATED_BY_ERROR = 1, /**< BROWSER TERMINATED BY ERROR */ +} TelSatBrowserTerminationCauseType_t; + +/** + * @enum TelSatBearerDescType_t + * This enum lists the SAT bearer destination type. + */ +typedef enum { + TAPI_SAT_BEARER_CSD = 0x1, /**< BEARER DESC CSD */ + TAPI_SAT_BEARER_GPRS = 0x2, /**< BEARER DESC GPRS */ + TAPI_SAT_BEARER_DEFAULT_BEARER_FROM_TRANSPORT_LAYER = 0x3, /**< BEARER DESC DEFAULT BEARER FROM TRANSPORT LAYER */ + TAPI_SAT_BEARER_LOCAL_LINK_TECHNOLOGY_INDEPENDENT = 0x4, /**< BEARER DESC LOCAL LINK TECHNOLOGY INDEPENDENT */ + TAPI_SAT_BEARER_BLUETOOTH = 0x5, /**< BEARER DESC BLUETOOTH */ + TAPI_SAT_BEARER_IrDA = 0x6, /**< BEARER DESC IrDA */ + TAPI_SAT_BEARER_RS232 = 0x7, /**< BEARER DESC RS232 */ + TAPI_SAT_BEARER_USB = 0x10, /**< BEARER DESC USB */ + TAPI_SAT_BEARER_RESERVED = 0xFF /**< RESERVED */ +} TelSatBearerDescType_t; + +/** + * @enum TelSatBearerParamCsdDataRateType_t + * This enum lists the SAT bearer parameter csd data rate. refer TS 27.007 + */ +typedef enum { + TAPI_SAT_BIP_DR_AUTOBAUDING = 0, /**< CSD data rate - AUTOBAUDING */ + TAPI_SAT_BIP_DR_300BPS_V21 = 1, /**< CSD data rate -300BPS V21 */ + TAPI_SAT_BIP_DR_1200BPS_V22 = 2, /**< CSD data rate - 1200BPS V22 */ + TAPI_SAT_BIP_DR_1200_75BPS_V23 = 3, /**< CSD data rate -1200 75BPS V23 */ + TAPI_SAT_BIP_DR_2400BPS_V22 = 4, /**< CSD data rate -2400BPS V22 */ + TAPI_SAT_BIP_DR_2400BPS_V26 = 5, /**< CSD data rate - 2400BPS V26 */ + TAPI_SAT_BIP_DR_4800BPS_V32 = 6, /**< CSD data rate - 4800BPS V32 */ + TAPI_SAT_BIP_DR_9600BPS_V32 = 7, /**< CSD data rate - 9600BPS V32 */ + TAPI_SAT_BIP_DR_9600BPS_V34 = 12, /**< CSD data rate - 9600BPS_V34 */ + TAPI_SAT_BIP_DR_14400BPS_V34 = 14, /**< CSD data rate -14400BPS V34 */ + TAPI_SAT_BIP_DR_19200BPS_V34 = 15, /**< CSD data rate -19200BPS V34 */ + TAPI_SAT_BIP_DR_28800BPS_V34 = 16, /**< CSD data rate -28800BPS V34 */ + TAPI_SAT_BIP_DR_33600BPS_V34 = 17, /**< CSD data rate -33600BPS V34 */ + TAPI_SAT_BIP_DR_1200BPS_V120 = 34, /**< CSD data rate -1200BPS V120 */ + TAPI_SAT_BIP_DR_2400BPS_V120 = 36, /**< CSD data rate -2400BPS V120 */ + TAPI_SAT_BIP_DR_4800BPS_V120 = 38, /**< CSD data rate -4800BPS V120 */ + TAPI_SAT_BIP_DR_9600BPS_V120 = 39, /**< CSD data rate -9600BPS V120 */ + TAPI_SAT_BIP_DR_14400BPS_V120 = 43, /**< CSD data rate -14400BPS V120 */ + TAPI_SAT_BIP_DR_19200BPS_V120 = 47, /**< CSD data rate -19200BPS V120 */ + TAPI_SAT_BIP_DR_28800BPS_V120 = 48, /**< CSD data rate -28800BPS V120 */ + TAPI_SAT_BIP_DR_38400BPS_V120 = 49, /**< CSD data rate -38400BPS V120 */ + TAPI_SAT_BIP_DR_48000BPS_V120 = 50, /**< CSD data rate -48000BPS V120 */ + TAPI_SAT_BIP_DR_56000BPS_V120 = 51, /**< CSD data rate -56000BPS V120 */ + TAPI_SAT_BIP_DR_300BPS_V110 = 65, /**< CSD data rate - 300BPS V110 */ + TAPI_SAT_BIP_DR_1200BPS_V110 = 66, /**< CSD data rate -1200BPS V110 */ + TAPI_SAT_BIP_DR_2400BPS_V110_OR_X31_FALG_STUFFING = 68, /**< CSD data rate - 2400BPS V110 OR X31 FALG STUFFING */ + TAPI_SAT_BIP_DR_4800BPS_V110_OR_X31_FALG_STUFFING = 70, /**< CSD data rate - 4800BPS V110 OR X31 FALG STUFFING */ + TAPI_SAT_BIP_DR_9600BPS_V110_OR_X31_FALG_STUFFING = 71, /**< CSD data rate - 9600BPS V110 OR X31 FALG STUFFING */ + TAPI_SAT_BIP_DR_14400BPS_V110_OR_X31_FALG_STUFFING = 75, /**< CSD data rate - 14400BPS V110 OR X31 FALG STUFFING */ + TAPI_SAT_BIP_DR_19200BPS_V110_OR_X31_FALG_STUFFING = 79, /**< CSD data rate -19200BPS V110 OR X31 FALG STUFFING */ + TAPI_SAT_BIP_DR_28800BPS_V110_OR_X31_FALG_STUFFING = 80, /**< CSD data rate -28800BPS V110 OR X31 FALG STUFFING */ + TAPI_SAT_BIP_DR_38400BPS_V110_OR_X31_FALG_STUFFING = 81, /**< CSD data rate -38400BPS V110 OR X31 FALG STUFFING */ + TAPI_SAT_BIP_DR_48000BPS_V110_OR_X31_FALG_STUFFING = 82, /**< CSD data rate -48000BPS V110 OR X31 FALG STUFFING */ + TAPI_SAT_BIP_DR_56000BPS_V110_OR_X31_FALG_STUFFING = 83, /**< CSD data rate -56000BPS V110 OR X31 FALG STUFFING */ + TAPI_SAT_BIP_DR_64000BPS = 84, /**< CSD data rate -64000BPS */ + TAPI_SAT_BIP_DR_56000BPS_BIT_TRANSPERENT = 115, /**< CSD data rate -56000BPS BIT TRANSPERENT */ + TAPI_SAT_BIP_DR_64000BPS_BIT_TRANSPERENT = 116, /**< CSD data rate -64000BPS BIT TRANSPERENT */ + TAPI_SAT_BIP_DR_32000BPS_PIAFS32K = 120, /**< CSD data rate -32000BPS PIAFS32K */ + TAPI_SAT_BIP_DR_64000BPS_PIAFS64K = 121, /**< CSD data rate - 64000BPS PIAFS64K */ + TAPI_SAT_BIP_DR_28800BPS_MULTIMEDIA = 130, /**< CSD data rate -28800BPS MULTIMEDIA */ + TAPI_SAT_BIP_DR_32000BPS_MULTIMEDIA = 131, /**< CSD data rate -32000BPS MULTIMEDIA */ + TAPI_SAT_BIP_DR_33600BPS_MULTIMEDIA = 132, /**< CSD data rate - 33600BPS MULTIMEDIA */ + TAPI_SAT_BIP_DR_56000BPS_MULTIMEDIA = 133, /**< CSD data rate -56000BPS MULTIMEDIA */ + TAPI_SAT_BIP_DR_64000BPS_MULTIMEDIA = 134 /**< CSD data rate -64000BPS MULTIMEDIA */ +} TelSatBearerParamCsdDataRateType_t; + +/** + * @enum TelSatBearerParamCsdBearerServiceType_t + * This enum lists the SAT bearer parameter csd bearer service + */ +typedef enum { + TAPI_SAT_BIP_CSD_BS_DATA_CIRCUIT_ASYNC_UDI = 0, /**< CSD Bearer service - DATA CIRCUIT ASYNCHRONOUS UDI */ + TAPI_SAT_BIP_CSD_BS_DATA_CIRCUIT_SYNC = 1, /**< CSD Bearer service - DATA CIRCUIT SYNCHRONOUS UDI */ + TAPI_SAT_BIP_CSD_BS_PAD_ACCESS_ASYNC_UDI = 2, /**< CSD Bearer service - PAD ACCESS ASYNCHRONOUS UDI */ + TAPI_SAT_BIP_CSD_BS_PACKET_ACCESS_SYNC = 3, /**< CSD Bearer service - PACKET ACCESS SYNCHRONOUS UDI */ + TAPI_SAT_BIP_CSD_BS_DATA_CIRCUIT_ASYNC_RDI = 4, /**< CSD Bearer service - DATA CIRCUIT ASYNCHRONOUS RDI */ + TAPI_SAT_BIP_CSD_BS_DATA_CIRCUIT_SYNC_RDI = 5, /**< CSD Bearer service - DATA CIRCUIT SYNCHRONOUS RDI */ + TAPI_SAT_BIP_CSD_BS_PAD_ACCESS_ASYNC_RDI = 6, /**< CSD Bearer service - PAD ACCESS ASYNCHRONOUS RDI */ + TAPI_SAT_BIP_CSD_BS_PACKET_ACCESS_SYNC_RDI = 7 /**< CSD Bearer service - PACKET ACCESS SYNCHRONOUS RDI */ +} TelSatBearerParamCsdBearerServiceType_t; + +/** + * @enum TelSatBearerParamCsdConnectionElementType_t + * This enum lists the SAT bearer parameter csd connection element + */ +typedef enum { + TAPI_SAT_BIP_CSD_CONN_ELEM_TRANSPARENT = 0, /**< CSD connection element - TRANSPARENT */ + TAPI_SAT_BIP_CSD_CONN_ELEM_NON_TRANSPARENT = 1, /**< CSD connection element - NON TRANSPARENT */ + TAPI_SAT_BIP_CSD_CONN_ELEM_BOTH_TRANSPARENT_PREF = 2, /**< CSD connection element -BOTH TRANSPARENT PREFFERED */ + TAPI_SAT_BIP_CSD_CONN_ELEM_BOTH_NON_TRANSPARENT_PREF = 3 /**< CSD connection element - NON TRANSPARENT PREFFERED */ +} TelSatBearerParamCsdConnectionElementType_t; + +/** + * @enum TelSatBearerParamGprsPrecedenceClassType_t + * This enum lists the SAT bearer parameter GPRS precedence class. refer TS 23.107 + */ +typedef enum { + TAPI_SAT_BIP_GPRS_PRECED_CLASS_HIGH_PRIORITY = 0x01, /**< GPRS precedence class -HIGH PRIORITY */ + TAPI_SAT_BIP_GPRS_PRECED_CLASS_NORM_PRIORITY = 0x02, /**< GPRS precedence class -NORM PRIORITY */ + TAPI_SAT_BIP_GPRS_PRECED_CLASS_LOW_PRIORITY = 0x03 /**< GPRS precedence class - LOW PRIORITY */ +} TelSatBearerParamGprsPrecedenceClassType_t; + +/** + * @enum TelSatBearerParamGprsDelayClassType_t + * This enum lists the SAT bearer parameter GPRS delay class. + */ +typedef enum { + TAPI_SAT_BIP_GPRS_DELAY_CLASS_1 = 0x01, /**< GPRS delay class - 1 */ + TAPI_SAT_BIP_GPRS_DELAY_CLASS_2 = 0x02, /**< GPRS delay class - 2 */ + TAPI_SAT_BIP_GPRS_DELAY_CLASS_3 = 0x03, /**< GPRS delay class - 3 */ + TAPI_SAT_BIP_GPRS_DELAY_CLASS_4 = 0x04 /**< GPRS delay class - 4 */ +} TelSatBearerParamGprsDelayClassType_t; + +/** + * @enum TelSatBearerParamGprsReliabilityClassType_t + * This enum lists the SAT bearer parameter GPRS Reliability class. + */ +typedef enum { + TAPI_SAT_BIP_GPRS_RELIABILITY_CLASS_1 = 0x01, /**< GPRS Reliability class -1 */ + TAPI_SAT_BIP_GPRS_RELIABILITY_CLASS_2 = 0x02, /**< GPRS Reliability class -2 */ + TAPI_SAT_BIP_GPRS_RELIABILITY_CLASS_3 = 0x03, /**< GPRS Reliability class -3 */ + TAPI_SAT_BIP_GPRS_RELIABILITY_CLASS_4 = 0x04, /**< GPRS Reliability class -4 */ + TAPI_SAT_BIP_GPRS_RELIABILITY_CLASS_5 = 0x05 /**< GPRS Reliability class -5 */ +} TelSatBearerParamGprsReliabilityClassType_t; + +/** + * @enum TelSatBearerParamGprsPeakThroughputClassType_t + * This enum lists the SAT bearer parameter GPRS peak throughput class. + */ +typedef enum { + TAPI_SAT_BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_8KBPS = 0x01, /**< GPRS peak throughput class- UPTO 8KBPS */ + TAPI_SAT_BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_16KBPS = 0x02, /**< GPRS peak throughput class- UPTO 16KBPS */ + TAPI_SAT_BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_32KBPS = 0x03, /**< GPRS peak throughput class-UPTO 32KBPS */ + TAPI_SAT_BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_64KBPS = 0x04, /**< GPRS peak throughput class-UPTO 64KBPS */ + TAPI_SAT_BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_128KBPS = 0x05, /**< GPRS peak throughput class- UPTO 128KBPS */ + TAPI_SAT_BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_256KBPS = 0x06, /**< GPRS peak throughput class- UPTO 256KBPS */ + TAPI_SAT_BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_512KBPS = 0x07, /**< GPRS peak throughput class- UPTO 512KBPS */ + TAPI_SAT_BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_1024KBPS = 0x08, /**< GPRS peak throughput class-UPTO 1024KBPS */ + TAPI_SAT_BIP_GPRS_PEAK_THROUGHPUT_CLASS_UPTO_2048KBPS = 0x09 /**< GPRS peak throughput class- UPTO 2048KBPS */ +} TelSatBearerParamGprsPeakThroughputClassType_t; + +/** + * @enum TelSatBearerParamGprsMeanThroughputClassType_t + * This enum lists the SAT bearer parameter GPRS mean throughput class. + */ +typedef enum { + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_DOT_22_BPS = 0x01, /**< GPRS mean throughput class - DOT 22 BPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_DOT_44_BPS = 0x02, /**< GPRS mean throughput class - DOT 44 BPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_1_DOT_11_BPS = 0x03, /**< GPRS mean throughput class -1 DOT 11 BPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_2_DOT_2_BPS = 0x04, /**< GPRS mean throughput class -2 DOT 2 BPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_2_DOT_4_BPS = 0x05, /**< GPRS mean throughput class -2 DOT 4 BPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_11_DOT_1_BPS = 0x06, /**< GPRS mean throughput class - 11 DOT 1 BPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_22BPS = 0x07, /**< GPRS mean throughput class -22BPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_44BPS = 0x08, /**< GPRS mean throughput class - 44BPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_111BPS = 0x09, /**< GPRS mean throughput class - 111BPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_DOT_22_KBPS = 0x0A, /**< GPRS mean throughput class - DOT 22 KBPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_DOT_44_KBPS = 0x0B, /**< GPRS mean throughput class -DOT 44 KBPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_1_DOT_11_KBPS = 0x0C, /**< GPRS mean throughput class -1 DOT 11 KBPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_2_DOT_2_KBPS = 0x0D, /**< GPRS mean throughput class -2 DOT 2 KBPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_4_DOT_4_KBPS = 0x0E, /**< GPRS mean throughput class - 4 DOT 4 KBPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_11_DOT_1_KBPS = 0x0F, /**< GPRS mean throughput class -11 DOT 1 KBPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_22KBPS = 0x10, /**< GPRS mean throughput class - 22KBPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_44KBPS = 0x11, /**< GPRS mean throughput class - 44KBPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_111KBPS = 0x12, /**< GPRS mean throughput class -111KBPS */ + TAPI_SAT_BIP_GPRS_MEAN_THROUGHPUT_CLASS_BEST_EFFORT = 0x13 /**< GPRS mean throughput class - BEST EFFORT */ +} TelSatBearerParamGprsMeanThroughputClassType_t; + +/** + * @enum TelSatBearerParamGprsPdpType_t + * This enum lists the SAT bearer parameter GPRS pdp type. + */ +typedef enum { + TAPI_SAT_BIP_GPRS_PDP_TYPE_IP = 0x02, /**< bearer parameter GPRS pdp type - IP */ + TAPI_SAT_BIP_GPRS_PDP_TYPE_RESERVED = 0xff /**< reserved */ +} TelSatBearerParamGprsPdpType_t; + +/** + * @enum TelSatBearerParamLocalLinksServiceIdentityType_t + * This enum lists the SAT bearer parameters local links service identity. + */ +typedef enum { + TAPI_SAT_BIP_LL_SERVICE_IDENT_VALUE_ASSIGNED_BY_USIM = 0x00, /**< local links service identity - value assigned by USIM */ + TAPI_SAT_BIP_LL_SERVICE_IDENT_VALUE_ASSIGNED_BY_REMOTED_DEVICE = 0xFF /**< local links service identity - value assigned by remote service */ +} TelSatBearerParamLocalLinksServiceIdentityType_t; + +/** + * @enum TelSatChannelStatusType_t + * This enum lists the SAT channel status type. + */ +typedef enum { + TAPI_SAT_CS_LINK_ESTABLISHED_OR_PDP_CTX_NOT_ACTIVATED, /**< channel status type-CS LINK ESTABLISHED OR PDP CTX NOT ACTIVATED */ + TAPI_SAT_CS_LINK_ESTABLISHED_OR_PDP_CTX_ACTIVATED, /**< channel status type-CS LINK ESTABLISHED OR PDP CTX ACTIVATED */ + TAPI_SAT_UICC_SERVER_MODE_TCP_IN_CLOSED_STATE, /**< channel status type-UICC SERVER MODE TCP IN CLOSED STATE */ + TAPI_SAT_UICC_SERVER_MODE_TCP_IN_LISTEN_STATE, /**< channel status type-UICC SERVER MODE TCP IN LISTEN STATE */ + TAPI_SAT_UICC_SERVER_MODE_TCP_IN_ESTABLISHED_STATE, /**< channel status type-UICC SERVER MODE TCP IN ESTABLISHED STATE */ + TAPI_SAT_UICC_SERVER_MODE_RESERVED /**< reserved */ +} TelSatChannelStatusType_t; + +/** + * @enum TelSatChannelStatusInfoType_t + * This enum lists the SAT channel status info type. + */ +typedef enum { + TAPI_SAT_CHANNEL_STATUS_NO_FURTHER_INFO_AVAILABLE = 0, /**< CHANNEL STATUS NO FURTHER INFO AVAILABLE */ + TAPI_SAT_CHANNEL_STATUS_NOT_USED = 1, /**< CHANNEL STATUS NOT USED */ + TAPI_SAT_CHANNEL_STATUS_LINK_DROPPED = 5 /**< CHANNEL STATUS LINK DROPPED */ +} TelSatChannelStatusInfoType_t; + +/** + * @enum TelSatAddressType_t + * This enum lists the SAT address type. + */ +typedef enum { + TAPI_SAT_ADDR_TYPE_IPv4 = 0x21, /**< address type - IPv4 */ + TAPI_SAT_ADDR_TYPE_IPv6 = 0x57, /**< address type - IPv6 */ + TAPI_SAT_ADDR_RESERVED = 0xFF /**< reserved */ +} TelSatAddressType_t; + +/** + * @enum TelSatTransportProtocolType_t + * This enum lists the SAT transport protocol type. + */ +typedef enum { + TAPI_SAT_TP_TYPE_UDP_UICC_CLIENT = 0x01, /**< transport protocol type- UDP UICC CLIENT */ + TAPI_SAT_TP_TYPE_TCP_UICC_CLIENT = 0x02, /**< transport protocol type-TCP UICC CLIENT */ + TAPI_SAT_TP_TYPE_TCP_UICC_SERVER = 0x03 /**< transport protocol type- TCP UICC SERVER */ +} TelSatTransportProtocolType_t; + +/** + * @enum TelSatRemoteEntityAddrCodingType_t + * This enum lists the SAT remote entity address coding type. + */ +typedef enum { + TAPI_SAT_REMOTE_ENTITY_ADDR_CODING_TYPE_IEEE802_48BIT = 0, /**< remote entity address coding type- IEEE802 48BIT */ + TAPI_SAT_REMOTE_ENTITY_ADDR_CODING_TYPE_IRDA_32BIT = 1, /**< remote entity address coding type- IRDA 32BIT */ + TAPI_SAT_REMOTE_ENTITY_ADDR_CODING_TYPE_RESERVED = 0xFF /**< reserved */ +} TelSatRemoteEntityAddrCodingType_t; + +/** + * This structure defines the Address data object. + */ +typedef struct { + TelSimTypeOfNum_t ton; /**< type of number */ + TelSimNumberingPlanIdentity_t npi; /**< number plan identity */ + unsigned char diallingNumberLen; /**< dialing number length */ + char diallingNumber[TAPI_SAT_DIALLING_NUMBER_LEN_MAX]; /**< dialing number */ +} TelSatAddressInfo_t; + +/** + * This structure defines the data coding scheme object. + */ +typedef struct { + int bIsCompressedFormat; /**< flag to verify compressed format */ + TelSatAlphabetFormatType_t alphabetFormat; /**< alphabet format Type */ + TelSatMsgClassType_t msgClass; /**< Type of message class */ + unsigned char rawDcs; /**< raw dcs info */ +} TelSatDataCodingSchemeInfo_t; + +/** + * This structure defines the Alpha ID data object. + */ +typedef struct { + int bIsPresent; /**< flag for checking existence of alpha identifier */ + TelSatDataCodingSchemeInfo_t dcs; /**< dcs info */ + unsigned char stringLen; /**< alpha identifier length */ + char string[TAPI_SAT_ALPHA_ID_LEN_MAX]; /**< alpha identifier info */ +} TelSatAlphaIdentifierInfo_t; + +/** + * This structure defines the Sub Address data object. + */ +typedef struct { + unsigned char subAddressLen; /**< sub address length */ + char subAddress[TAPI_SAT_SUB_ADDR_LEN_MAX]; /**< sub address */ +} TelSatSubAddressInfo_t; + +/** + * This structure defines the Capability Configuration Parameters data object. + */ +typedef struct { + unsigned char dataLen; /**< capability configuration parameter length */ + char data[TAPI_SAT_CCP_DATA_LEN_MAX]; /**< capability configuration parameter */ +} TelSatCapaConfigParamInfo_t; + +/** + * This struct defines the Command qualifier values for send SMS command. + */ +typedef struct { + int bIsPackingByMeRequired; /**< flag to verify packing requirement, if FALSE, packing by ME not required */ +} TelSatCmdQualiSendSms_t; + +/** + * This struct defines the Command qualifier values for display text command. + */ +typedef struct { + TelSatDisplayTextPriorityType_t msgPriority; /**< message priority */ + TelSatDisplayTextMsgClearType_t msgClear; /**< message clear type */ +} TelSatCmdQualiDisplayText_t; + +/** + * This struct defines the Command qualifier values for get inkey command. + */ +typedef struct { + TelSatInkeyType_t inkeyType; /**< inkey type */ + int bIsUsingAlphabetSet; /**< flag for checking whether using alphabet set or not. if FALSE, digits(0-9,*,#and+) only */ + TelSatUseInputAlphabetType_t alphabetType; /**< alphabet type */ + int bIsImmediateResponseRequired;/**< flag for checking whether immediate response required or not */ + int bIsHelpInfoAvailable; /**< flag for checking whether help info available or not. if FALSE, no help information available */ +} TelSatCmdQualiGetInkey_t; + +/** + * This struct defines the Command qualifier values for get input command. + */ +typedef struct { + int bIsUsingAlphabetSet; /**< flag for checking whether using alphabet set. if FALSE, digits(0-9,*,#and+) only */ + TelSatUseInputAlphabetType_t alphabetType; /**< alphabet type. only using alphabet set case. */ + int bIsMeEchoUserInput; /**< flag for checking whether ME should echo user input. if FALSE, user input shall not be displayed*/ + int bIsUserInputUnpackedFormat; /**< flag for checking whether user input is in unpacked format or not. if FALSE, user input in SMS packed format */ + int bIsHelpInfoAvailable; /**< flag to verify if help info available or not. if FALSE, no help information available */ +} TelSatCmdQualiGetInput_t; + +/** + * This struct defines the Command qualifier values for play tone command. + */ +typedef struct { + TelSatDisplayVibrateAlertType_t vibrateAlert; /**< type of vibrate alert */ +} TelSatCmdQualiPlayTone_t; + +/** + * This struct defines the Command qualifier values for select item command. + */ +typedef struct { + TelSatPresentationType_t presentationType; /**< type of presentation. only presentation type specified */ + TelSatSelectionPreferenceType_t selectionPreference; /**< type of selection preference */ + int bIsHelpInfoAvailable; /**< flag for checking whether help info available or not. if FALSE, no help information available */ +} TelSatCmdQualiSelectItem_t; + +/** + * This struct defines the Command qualifier values for setup menu command. + */ +typedef struct { + TelSatSelectionPreferenceType_t selectionPreference; /**< type of selection preference */ + int bIsHelpInfoAvailable; /**< flag to verify help info available or not. if FALSE, no help information available */ +} TelSatCmdQualiSetupMenu_t; + +/** + * This struct defines the Command qualifier values for language notification command. + */ +typedef struct { + int bSpecificLanguageNotification; /**< flag for specific language notification. if FALSE, non-specific language notification */ +} TelSatCmdQualiLanguageNotification_t; + +/** + * SAT command qualifier open channel + */ +typedef struct { + int bIsEstablishImmediateLink; /**< flag whether establishing immediate link or not. if FALSE, on demand link establishment */ + int bIsAutomaticReconnection; /**< flag whether automatic reconnection or not. if FALSE, no automatic reconnection */ + int bIsModeBackground; /**< flag whether background mode or not. */ +} TelSatCmdQualiOpenChannel_t; + +/** + * SAT command qualifier send data + */ +typedef struct { + int bIsSendDataImmediately; /**< flag whether to send data immediately or not. if FALSE, store data in Tx buffer*/ +} TelSatCmdQualiSendData_t; + +/** + * This structure contains the command number, type and the qualifier objects of a SATK command. + */ +typedef struct { + unsigned char commandNumber; /**< specific command number */ + TelSatCommandType_t commandType; /**< proactive command type */ + + union { + TelSatCmdQualiRefresh_t cmdQualiRefresh; /**< refresh command qualifier info */ + TelSatCmdQualiSetupCall_t cmdQualiSetupCall; /**< setup call command qualifier info */ + TelSatCmdQualiSendSms_t cmdQualiSendSms; /**< send sms command qualifier info */ + TelSatCmdQualiDisplayText_t cmdQualiDisplayText; /**< display text command qualifier info */ + TelSatCmdQualiGetInkey_t cmdQualiGetInkey; /**< get inkey command qualifier info */ + TelSatCmdQualiGetInput_t cmdQualiGetInput; /**< get input command qualifier info */ + TelSatCmdQualiPlayTone_t cmdQualiPlayTone; /**< play tone command qualifier info */ + TelSatCmdQualiSelectItem_t cmdQualiSelectItem; /**< select item command qualifier info */ + TelSatCmdQualiSetupMenu_t cmdQualiSetupMenu; /**< setup menu command qualifier info */ + TelSatCmdQualiProvideLocalInfo_t cmdQualiProvideLocalInfo;/**< provide local info command qualifier info */ + TelSatCmdQualiLanguageNotification_t cmdQualiLanguageNotification;/**< language notification command qualifier info */ + TelSatCmdQualiLaunchBrowser_t cmdQualiLaunchBrowser; /**< launch Browser command qualifier info */ + TelSatCmdQualiOpenChannel_t cmdQualiOpenChannel; /**< Open channel command qualifier info */ + TelSatCmdQualiSendData_t cmdQualiSendData; /**< send data command qualifier info */ + } u; /**< Union */ +} TelSatCommandDetailInfo_t; + +/** + * This struct defines the device identity values. + */ +typedef struct { + TelSatDeviceIdentitiesTagType_t source; /**< device identity tag for source */ + TelSatDeviceIdentitiesTagType_t destination; /**< device identity for destination */ +} TelSatDeviceIdentitiesInfo_t; + +/** + * This structure defines the Duration data object. + */ +typedef struct { + TelSatTimeUnitType_t timeUnit; /**< time units for the duration data */ + unsigned char timeInterval; /**< time interval */ +} TelSatDurationInfo_t; + +/** + * This structure defines the menu item data object. + */ +typedef struct { + unsigned char itemId; /**< item identifier */ + unsigned char textLen; /**< text length */ + unsigned char text[TAPI_SAT_ITEM_TEXT_LEN_MAX + 1]; /**< text information */ +} TelSatMenuItemInfo_t; + +/** + * This structure defines the item identifier object. + */ +typedef struct { + unsigned char selectedItemIdentifier; /**< selected item identifier */ +} TelSatItemIdentifierInfo_t; + +/** + * This structure defines expected user response length. + */ +typedef struct { + unsigned char min; /**< user response length minimum value */ + unsigned char max; /**< user response length maximum value */ +} TelSatRespLenInfo_t; + +/** + * This structure defines RESUlT data object. + */ +typedef struct { + TelSatResultType_t generalResult; /**< general result */ + TelSatMeProblemType_t meProblem; /**< additional information on general result */ +} TelSatResultInfo_t; + +/** + * This structure defines RESUlT data object. + */ +typedef struct { + TelSatSmsTpduType_t tpduType; /**< SMS TPDU TYPE */ + unsigned char dataLen; /**< SMS TPDU DATA LENGTH */ + unsigned char data[TAPI_SAT_SMS_TPDU_SMS_DATA_LEN_MAX]; /**< SMS TPDU DATA*/ +} TelSatSmsTpduInfo_t; + +/** + * This structure defines SS STRING data object. + */ +typedef struct { + TelSimTypeOfNum_t ton; /**< type of number */ + TelSimNumberingPlanIdentity_t npi; /**< number plan identity */ + unsigned char stringLen; /**< ss string length */ + char string[TAPI_SAT_SS_STRING_LEN_MAX]; /**< ss string */ +} TelSatSsStringInfo_t; + +/** + * This structure defines TEXT STRING data object. + */ +typedef struct { + int bIsDigitOnly; /**< flag for checking whether only digits used or not */ + TelSatDataCodingSchemeInfo_t dcs; /**< data coding scheme */ + unsigned short stringLen; /**< text length */ + char string[TAPI_SAT_TEXT_STRING_LEN_MAX + 1]; /**< text string */ +} TelSatTextTypeInfo_t; + +/** + * This structure defines menu item text object. + */ +typedef struct { + int bIsDigitOnly; /**< flag for checking whether only digits used or not */ + TelSatDataCodingSchemeInfo_t dcs; /**< data coding scheme */ + unsigned char stringLen; /**< menu item string length */ + char* pString; /**< Menu Item String */ +} TelSatMenuItemTextInfo_t; + +/** + * This structure defines tone object. + */ +typedef struct { + TelSatToneType_t type; /**< tone type */ +} TelSatToneInfo_t; + +/** + * This structure defines USSD string data object. + */ +typedef struct { + TelSatDataCodingSchemeInfo_t dcs; /**< data coding scheme */ + unsigned char ussdStringLen; /**< ussd string length */ + char ussdString[TAPI_SAT_USSD_STRING_LEN_MAX]; /**< ussd string */ +} TelSatUssdStringInfo_t; + +/** + * This structure defines File list data object. + */ +typedef struct { + unsigned char fileCount; /**< file count */ +// TelSimFileName_t fileId[TAPI_SAT_FILE_ID_LIST_MAX_COUNT]; /**< file identifier */ +} TelSatFileListInfo_t; + +/** + * This structure defines default text data object. + */ +typedef struct { + int bIsPresent; /**< flag for checking whether default text exists or not */ + int bIsDigitOnly; /**< flag for checking whether only digits used or not */ + TelSatDataCodingSchemeInfo_t dcs; /**< data coding scheme */ + unsigned char stringLen; /**< default text string length */ + char string[TAPI_SAT_TEXT_STRING_LEN_MAX]; /**< default text */ +} TelSatDefaultTextInfo_t; + +/** + * This structure defines Next Action Indicator List data object. + */ +typedef struct { + unsigned char listCount; /**< next action identifier count */ + unsigned char list[TAPI_SAT_ITEMS_NEXT_ACTION_INDI_LIST_MAX_COUNT]; /**< next action identifier list */ +} TelSatItemsNextActionIndiListInfo_t; + +/** + * This structure defines event list data object. + */ +typedef struct { + unsigned char eventListCount; /**< event list count */ + TelSatEventDownloadType_t list[TAPI_SAT_EVENT_LIST_MAX_COUNT]; /**< event list */ +} TelSatEventListInfo_t; + +/** + * This structure defines icon info object. + */ +typedef struct { + unsigned char width; /**< icon width */ + unsigned char height; /**< icon height */ + TelSatImageCodingSchemeType_t ics; /**< image coding scheme */ + unsigned short iconDataLen; /**< icon data length */ + unsigned short clutDataLen; /**< clut data length */ + char iconFile[TAPI_SAT_IMG_DATA_FILE_PATH_LEN_MAX]; + char clutFile[TAPI_SAT_IMG_DATA_FILE_PATH_LEN_MAX]; +} TelSatIconInfo_t; + +/** + * This structure defines icon data object. + */ +typedef struct { + int bIsPresent; /**< flag for checking whether icon identifier exists or not */ + TelSatIconQualifierType_t iconQualifier; /**< icon qualifier type */ + unsigned char iconIdentifier; /**< icon identifier */ + TelSatIconInfo_t iconInfo; /**< icon info */ +} TelSatIconIdentifierInfo_t; + +/** + * This structure defines icon identifier data object. + */ +typedef struct { + int bIsPresent; /**< flag for checking whether icon identifier exists or not */ + TelSatIconQualifierType_t iconListQualifier; /**< icon list qualifier */ + unsigned char iconCount; /**< icon count */ + unsigned char iconIdentifierList[TAPI_SAT_ICON_LIST_MAX_COUNT]; /**< icon identifier list */ + TelSatIconInfo_t iconInfo[TAPI_SAT_ICON_LIST_MAX_COUNT]; /**< icon list info */ +} TelSatIconIdentifierListInfo_t; + +/** + * This structure defines SAT bc repeat indicator Info + */ +typedef struct { + TelSatBcRepeatIndicatorType_t indType; /**< bc repeat indicator type */ +} TelSatBcRepeatIndicatorInfo_t; + +/** + * This structure defines call control strings. + */ +typedef struct { + TelSatCallCtrlStringType_t callCtrlStringType; /**< call control type */ + union { + TelSatAddressInfo_t voiceString; /**< voice call string */ + TelSatSsStringInfo_t ssString; /**< ss string */ + TelSatUssdStringInfo_t ussdString; /**< ussd string */ + } u; /**< Union */ +} TelSatCallCtrlAddressStringInfo_t; + +/** + * This structure defines the Action requested call control data. + */ +typedef struct { + TelSatCallCtrlAddressStringInfo_t callCtrlAddString; /**< Call control address string */ + TelSatCapaConfigParamInfo_t ccp1; /**< Capability configuration parameter 1 */ + TelSatSubAddressInfo_t subAddress; /**< Subaddress */ + TelSatAlphaIdentifierInfo_t alphaId; /**< Alpha identifier */ + TelSatBcRepeatIndicatorInfo_t bcRepeatIndicator; /**< Bc repeat indicator */ + TelSatCapaConfigParamInfo_t ccp2; /**< Capability configuration parameter 2 */ +} TelSatCallCtrlRequestedActionInfo_t; + +/** + * This structure defines dtmf string data object. + */ +typedef struct { + unsigned char stringLen; /**< dtmf string lengh */ + char dtmfTone[TAPI_SAT_DTMF_STRING_LEN_MAX]; /**< dtmf tone data */ +} TelSatDtmfStringInfo_t; + +/** + * This structure defines language data object. + */ +typedef struct { + TelSatLanguageType_t language; /**< language type */ +} TelSatLanguageInfo_t; + +/** + * This structure defines date time and time zone data object. + */ +typedef struct { + unsigned char year; /**< year */ + unsigned char month; /**< month */ + unsigned char day; /**< day */ + unsigned char hour; /**< hour */ + unsigned char minute; /**< minute */ + unsigned char second; /**< second */ + unsigned char timeZone; /**< timeZone */ +} TelSatDataTimeZoneInfo_t; + +/** + * This structure defines SAT browser identities. + */ +typedef struct { + TelSatBrowserIdentityType_t browserIdentity; /**< browser identity */ +} TelSatBrowserIdentitiesInfo_t; + +/** + * This structure defines SAT browser URL Data Object. + */ +typedef struct { + char string[TAPI_SAT_URL_LEN_MAX + 1]; /**< url string */ +} TelSatUrlInfo_t; + +/** + * This structure defines SAT bearer type. + */ +typedef struct { + unsigned char listLen; /**< bearer list length */ + TelSatBearerType_t bearerList[TAPI_SAT_BEARER_LIST_MAX_COUNT]; /**< bearer list */ +} TelSatBearerInfo_t; + +/** + * This structure defines SAT provisioning reference. + */ +typedef struct { + char provisioningFilePath[TAPI_SAT_PROVISIONING_FILE_PATH_LEN_MAX]; /**< provisioning file path */ +} TelSatProvisioningRefInfo_t; + +/** + * This structure defines SAT browser termination cause. + */ +typedef struct { + TelSatBrowserTerminationCauseType_t cause; /**< browser termination cause */ +} TelSatBrowserTerminationCauseInfo_t; + +/** + * This structure defines SAT Csd bearer parameters . + */ +typedef struct { + TelSatBearerParamCsdDataRateType_t dataRate; /**< bearer csd data rate */ + TelSatBearerParamCsdBearerServiceType_t bearerService; /**< bearer csd service type */ + TelSatBearerParamCsdConnectionElementType_t connectionElement; /**< bearer connection element type */ +} TelSatBearerParametersCsdInfo_t; + +/** + * This structure defines SAT bearer parameters GPRS. + */ +typedef struct { + TelSatBearerParamGprsPrecedenceClassType_t precedenceClass; /**< bearer gprs precedence class */ + TelSatBearerParamGprsDelayClassType_t delayClass; /**< bearer gprs delay */ + TelSatBearerParamGprsReliabilityClassType_t reliabilityClass; /**< bearer gprs reliability */ + TelSatBearerParamGprsPeakThroughputClassType_t peakThroughputClass;/**< bearer gprs peak throughput */ + TelSatBearerParamGprsMeanThroughputClassType_t meanThroughputClass;/**< bearer gprs mean throughput */ + TelSatBearerParamGprsPdpType_t pdpType; /**< bearer gprs pdp type */ +} TelSatBearerParametersGprsInfo_t; + +/** + * This structure defines SAT bearer parameters local links. + */ +typedef struct { + TelSatBearerParamLocalLinksServiceIdentityType_t serviceIdentifier; /**< bearer local link service identifier */ + char serviceRecord[TAPI_SAT_BEARER_PARAMS_LEN_MAX]; /**< bearer local link service record */ +} TelSatBearerParametersLocalLinksInfo_t; + +/** + * This structure defines SAT bearer description. + */ +typedef struct { + TelSatBearerDescType_t bearerType; /**< bearer type */ + union { + TelSatBearerParametersCsdInfo_t bearerParamsCsd; /**< csd */ + TelSatBearerParametersGprsInfo_t bearerParamsGprs; /**< gprs */ + TelSatBearerParametersLocalLinksInfo_t bearerParamsLocalLinks; /**< local link */ + } bearer_params; /** + * + * 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. + */ + +/** + * @open + * @ingroup TelephonyAPI + * @addtogroup SAT_TAPI SAT + * @{ + * + * @file TelSatProactvCmd.h + + @brief This file serves as a "C" header file defines structures for Tapi SAT Proactive commands and terminal response Services. \n + It contains a sample set of constants, enums, structs that would be required by applications. + */ + +#ifndef _TEL_SAT_PROACTV_CMD_H_ +#define _TEL_SAT_PROACTV_CMD_H_ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define TAPI_SAT_MENU_ITEM_COUNT_MAX 40 /**< max count of sat menu items */ +#define TAPI_SAT_PROVISIONING_REF_MAX_COUNT 10 /**< max count of sat provisioning reference */ + +/** + * This structure contains the data objects for DISPLAY TEXT proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ +} TelSatMoreTimeIndInfo_t; + +/** + * This structure contains the data objects for DISPLAY TEXT proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatTextTypeInfo_t text; /**< display text info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + int bImmediateRespRequested; /**< flag for checking whether immediate response required or not */ + TelSatDurationInfo_t duration; /**< duration for which text should be displayed */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatDisplayTextIndInfo_t; + +/** + * This structure contains the data objects for GET INKEY proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatTextTypeInfo_t text; /**< display text info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatDurationInfo_t duration; /**< duration for which text should be displayed */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatGetInkeyIndInfo_t; + +/** + * This structure contains the data objects for GET INPUT proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatTextTypeInfo_t text; /**< display text info */ + TelSatRespLenInfo_t respLen; /**< input response length */ + TelSatTextTypeInfo_t defaultText; /**< default text info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatGetInputIndInfo_t; + +/** + * This structure contains the data objects for PLAY TONE proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatToneInfo_t tone; /**< tone info */ + TelSatDurationInfo_t duration; /**< duration for which tone should be played */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatPlayToneIndInfo_t; + +/** + * This structure contains the data objects for SETUP MENU proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + unsigned char menuItemCount; /**< count of menu items */ + TelSatMenuItemInfo_t menuItem[TAPI_SAT_MENU_ITEM_COUNT_MAX]; /**< menu item data */ + TelSatItemsNextActionIndiListInfo_t itemNextActionIndList; /**< next action indication list */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatIconIdentifierListInfo_t iconIdList; /**< icon identifier list info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ + TelSatTextAttributeListInfo_t itemTextAttributeList; /**< item text attribute list */ +} TelSatSetupMenuIndInfo_t; + +/** + * This structure contains the data objects for SELECT ITEM proactive command indication data. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatItemsNextActionIndiListInfo_t itemNextActionIndList; /**< next action indication list */ + unsigned char defaultItemIdentifier; /**< default item identifier(default selected item id) */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatIconIdentifierListInfo_t iconIdList; /**< icon identifier list info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ + TelSatTextAttributeListInfo_t itemTextAttributeList; /**< item text attribute list */ + unsigned char menuItemCount; /**< count of menu items */ + TelSatMenuItemInfo_t menuItem[TAPI_SAT_MENU_ITEM_COUNT_MAX]; /**< menu item data */ +} TelSatSelectItemIndInfo_t; + +/** + * This structure contains the data objects for SEND SHORT MESSAGE proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatAddressInfo_t address; /**< address for sending sms */ + TelSatSmsTpduInfo_t smsTpdu; /**< sms tpdu info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatSendSmsIndInfo_t; + +/** + * This structure contains the data objects for SEND SS proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatSsStringInfo_t ssString; /**< ss string */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatSendSsIndInfo_t; + +/** + * This structure contains the data objects for SEND USSD proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatUssdStringInfo_t ussdString; /**< ussd string info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatSendUssdIndInfo_t; + +/** + * This structure contains the data objects for SETUP CALL proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAddressInfo_t address; /**< setup call address info*/ + TelSatCapaConfigParamInfo_t ccp; /**< capability configuration parameter */ + TelSatSubAddressInfo_t subAddress; /**< setup call sub address */ + TelSatDurationInfo_t duration; /**< command execution time duration */ + TelSatAlphaIdentifierInfo_t userConfirmPhaseAlphaId;/**< user Confirmation Phase AlphaId */ + TelSatAlphaIdentifierInfo_t callSetupPhaseAlphaId; /**< call Setup Phase AlphaId */ + TelSatIconIdentifierInfo_t userConfirmPhaseIconId; /**< user Confirmation Phase IconId */ + TelSatIconIdentifierInfo_t callSetupPhaseIconId; /**< call Setup Phase IconId */ + TelSatTextAttributeInfo_t userConfirmPhaseTextAttribute; /**< user Confirmation Phase Text Attribute */ + TelSatTextAttributeInfo_t callSetupPhaseTextAttribute; /**< call Setup PhaseText Attribute */ +} TelSatSetupCallIndInfo_t; + +/** + * This structure contains the data objects for REFRESH proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatFileListInfo_t fileList; /**< file list for refresh */ + TelSatAidInfo_t aid; /**< application Id */ +} TelSatRefreshIndInfo_t; + +/** + * This structure contains the data objects for PROVIDE LOCAL INFO proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + +} TelSatProvideLocalInfoIndInfo_t; + +/** + * This structure contains the data objects for SETUP EVENT LIST proactive command indication data. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatEventListInfo_t eventList; /**< event list contains events which are required by USIM application */ + +} TelSatSetupEventListIndInfo_t; + +/** + * This structure contains the data objects for SETUP IDLE MODE TEXT proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatTextTypeInfo_t text; /**< text to be shown on idle screen */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatSetupIdleModeTextIndInfo_t; + +/** + * This structure contains the data objects for SEND DTMF COMMAND proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatDtmfStringInfo_t dtmfString; /**< dtmf string */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatSendDtmfIndInfo_t; + +/** + * This structure contains the data objects for LANGUAGE NOTIFICATION proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatLanguageInfo_t language; /**< language info from USIM application */ +} TelSatLanguageNotificationIndInfo_t; + +/** + * This structure contains the data objects for LAUNCH BROWSER proactive command indication. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatBrowserIdentitiesInfo_t browserId; /**< browser identity */ + TelSatUrlInfo_t url; /**< url */ + TelSatBearerInfo_t bearer; /**< bearer which is used by browser */ + unsigned char provisioningRefCount; /**< provisioning reference count */ + TelSatProvisioningRefInfo_t provisioningRef[TAPI_SAT_PROVISIONING_REF_MAX_COUNT]; /**< provisioning reference data */ + TelSatTextTypeInfo_t text; /**< display text info */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatLaunchBrowserIndInfo_t; + +/** + * This structure contains the data objects for OPEN CHANNEL CSB proactive command indication data. + */ +typedef struct { + TelSatAddressInfo_t address; /**< channel address */ + TelSatSubAddressInfo_t subAddress; /**< channel sub address */ + TelSatDurationInfo_t duration1; /**< connection require time */ + TelSatDurationInfo_t duration2; /**< connection require time2 */ + TelSatBearerParametersCsdInfo_t bearerParamsCsd; /**< csd info */ + TelSatBufferSizeInfo_t bufferSize; /**< bufferSize */ + TelSatOtherAddressInfo_t otherAddress; /**< otherAddress */ + TelSatTextTypeInfo_t userLogin; /**< userLogin */ + TelSatTextTypeInfo_t userPassword; /**< userPassword */ + TelSatSimMeInterfaceTransportLevelInfo_t simMeInterfaceTransportLevel; /**< simMeInterfaceTransportLevel */ + TelSatOtherAddressInfo_t dataDestinationAddress; /**< dataDestinationAddress */ +} TelSatOpenChannelCsbInfo_t; + +/** + * This structure contains the data objects for OPEN CHANNEL (packet) proactive command indication data. + */ +typedef struct { + TelSatBearerParametersGprsInfo_t bearerParamsGprs; /**< gprs info */ + TelSatBufferSizeInfo_t bufferSize; /**< bufferSize */ + TelSatnetworkAccessNameInfo_t networkAccessName; /**< networkAccessName */ + TelSatOtherAddressInfo_t otherAddress; /**< otherAddress */ + TelSatTextTypeInfo_t userLogin; /**< userLogin */ + TelSatTextTypeInfo_t userPassword; /**< userPassword */ + TelSatSimMeInterfaceTransportLevelInfo_t simMeInterfaceTransportLevel; /**< simMeInterfaceTransportLevel */ + TelSatOtherAddressInfo_t dataDestinationAddress; /**< dataDestinationAddress */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatOpenChannelpdbInfo_t; + +/** + * This structure contains the data objects for OPEN CHANNEL LOCAL LINK proactive command indication data. + */ +typedef struct { + TelSatDurationInfo_t duration1; /**< command execution time duration1 */ + TelSatDurationInfo_t duration2; /**< command execution time duration2 */ + TelSatBearerParametersLocalLinksInfo_t bearerParamsLocalLinks; /**< local link info */ + TelSatBufferSizeInfo_t bufferSize; /**< bufferSize */ + TelSatTextTypeInfo_t userPassword; /**< userPassword */ + TelSatSimMeInterfaceTransportLevelInfo_t simMeInterfaceTransportLevel; /**< simMeInterfaceTransportLevel */ + TelSatOtherAddressInfo_t dataDestinationAddress; /**< dataDestinationAddress */ + TelSatRemoteEntityAddressInfo_t remoteEntityAddress; /**< remoteEntityAddress */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatOpenChannelLocalBearerInfo_t; + +/** + * This structure contains the data objects for OPEN CHANNEL (DEFAULT BEARER) proactive command indication data. + */ +typedef struct { + TelSatBufferSizeInfo_t bufferSize; /**< bufferSize */ + TelSatOtherAddressInfo_t otherAddress; /**< otherAddress */ + TelSatTextTypeInfo_t userLogin; /**< userLogin */ + TelSatTextTypeInfo_t userPassword; /**< userPassword */ + TelSatSimMeInterfaceTransportLevelInfo_t simMeInterfaceTransportLevel;/**< simMeInterfaceTransportLevel */ + TelSatOtherAddressInfo_t dataDestinationAddress; /**< dataDestinationAddress */ +} TelSatOpenChannelDefaultBearerInfo_t; + +/** + * This structure contains the data objects for OPEN CHANNEL (UICC Server Mode) proactive command indication data. + */ +typedef struct { + TelSatBufferSizeInfo_t bufferSize; /**< bufferSize */ + TelSatSimMeInterfaceTransportLevelInfo_t simMeInterfaceTransportLevel; /**< simMeInterfaceTransportLevel */ +} TelSatOpenChannelUiccServerModeInfo_t; + +/** + * This structure contains the data objects for OPEN CHANNEL proactive command indication data. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + int bIsUiccServerMode; /**< flag whether UICC server mode or not */ + TelSatBearerDescType_t bearerType; /**< bearer destination type */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + union { + TelSatOpenChannelCsbInfo_t csBearer; /**< cs info */ + TelSatOpenChannelpdbInfo_t pdBearer; /**< pbd info */ + TelSatOpenChannelLocalBearerInfo_t locBearer; /**< local link info */ + TelSatOpenChannelDefaultBearerInfo_t defaultBearer; /**< defaultBearer */ + TelSatOpenChannelUiccServerModeInfo_t uiccServerMode; /**< uiccServerMode */ + } details; /**< Open Channel Details */ +} TelSatOpenChannelIndInfo_t; + +/** + * This structure contains the data objects for CLOSE CHANNEL proactive command indication data. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatTextAttributeInfo_t textAttribute; /**< text attribute info -e.g. bold, center align */ +} TelSatCloseChannelIndInfo_t; + +/** + * This structure contains the data objects for RECEIVE DATA proactive command indication data. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatChannelDataLengthInfo_t channelDataLen; /**< channel data length */ +} TelSatReceiveDataIndInfo_t; + +/** + * This structure contains the data objects for SEND DATA proactive command indication data. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ + TelSatAlphaIdentifierInfo_t alphaId; /**< alpha identifier(string) info */ + TelSatIconIdentifierInfo_t iconId; /**< icon identifier info */ + TelSatChannelDataInfo_t channel_data; /**< channel data for sending */ +} TelSatSendDataIndInfo_t; + +/** + * This structure contains the data objects for GET CHANNEL STATUS proactive command indication data. + */ +typedef struct { + TelSatCommandDetailInfo_t commandDetail; /**< command detail info. includes command number, type, qualifier */ + TelSatDeviceIdentitiesInfo_t deviceIdentities; /**< device identities info. includes source and destination devices */ +} TelSatGetChannelStatusIndInfo_t; + +/** + * This structure contains the data object for END PROACTIVE SESSION command indication. + */ +typedef struct { + TelSatCommandType_t commandType; /**< proactive command type */ +} TelSatEndProactiveSessionIndInfo_t; + +/** + * This structure contains the data objects for PROACTIVE command indication union data. + */ +typedef struct { + union { + TelSatMoreTimeIndInfo_t moreTime; + TelSatDisplayTextIndInfo_t displayText; /**< Parsed proactive command info from TLV to Telephony data type - display text */ + TelSatGetInkeyIndInfo_t getInkey; /**< Parsed proactive command info from TLV to Telephony data type - getInkey */ + TelSatGetInputIndInfo_t getInput; /**< Parsed proactive command info from TLV to Telephony data type - getInput */ + TelSatPlayToneIndInfo_t playTone; /**< Parsed proactive command info from TLV to Telephony data type - play tone */ + TelSatSetupMenuIndInfo_t setupMenu; /**< Parsed proactive command info from TLV to Telephony data type - setup menu */ + TelSatSelectItemIndInfo_t selectItem; /**< Parsed proactive command info from TLV to Telephony data type - select item */ + TelSatSendSmsIndInfo_t sendSms; /**< Parsed proactive command info from TLV to Telephony data type - send sms */ + TelSatSendSsIndInfo_t sendSs; /**< Parsed proactive command info from TLV to Telephony data type - send ss */ + TelSatSendUssdIndInfo_t sendUssd; /**< Parsed proactive command info from TLV to Telephony data type - send ussd */ + TelSatSetupCallIndInfo_t setupCall; /**< Parsed proactive command info from TLV to Telephony data type - setup call */ + TelSatRefreshIndInfo_t refresh; /**< Parsed proactive command info from TLV to Telephony data type - refresh */ + TelSatProvideLocalInfoIndInfo_t provideLocInfo; /**< Parsed proactive command info from TLV to Telephony data type - provide local info */ + TelSatLaunchBrowserIndInfo_t launchBrowser; /**< Parsed proactive command info from TLV to Telephony data type - launch browser */ + TelSatSetupIdleModeTextIndInfo_t idleText; /**< Parsed proactive command info from TLV to Telephony data type - setup idle mode text */ + TelSatSendDtmfIndInfo_t sendDtmf; /**< Parsed proactive command info from TLV to Telephony data type - send dtmf */ + TelSatLanguageNotificationIndInfo_t languageNotification;/**< Parsed proactive command info from TLV to Telephony data type - language notification */ + TelSatSetupEventListIndInfo_t setupEventList; /**< Parsed proactive command info from TLV to Telephony data type - setup event list */ + TelSatOpenChannelIndInfo_t openChannel; /**< Parsed proactive command info from TLV to Telephony data type - open channel */ + TelSatCloseChannelIndInfo_t closeChannel; /**< Parsed proactive command info from TLV to Telephony data type - close channel */ + TelSatReceiveDataIndInfo_t receiveData; /**< Parsed proactive command info from TLV to Telephony data type - receive data */ + TelSatSendDataIndInfo_t sendData; /**< Parsed proactive command info from TLV to Telephony data type - send data */ + TelSatGetChannelStatusIndInfo_t getChannelStatus; /**< Parsed proactive command info from TLV to Telephony data type - get channel status */ + } cmdInfo; /**< Union */ +} TelSatProactiveCmdData_t; + +/** + * This structure contains the data objects for the Terminal Response of DISPLAY TEXT proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ +} TelSatDisplayTextRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of GET INKEY proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + TelSatTextTypeInfo_t text; /**< inserted key info */ + TelSatDurationInfo_t duration; +} TelSatGetInkeyRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of PLAY TONE proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ +} TelSatPlayToneRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of MORE TIME proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ +} TelSatMoreTimeRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SETUP MENU proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ +} TelSatSetupMenuRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of GET INPUT proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + TelSatTextTypeInfo_t text; /**< inserted string info */ +} TelSatGetInputRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SELECT ITEM proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + int bOtherInfo; /**< flag to check whether other information is required or not */ + unsigned char itemIdentifier; /**< item identifier */ +} TelSatSelectItemRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of PROVIDE LOCAL INFORMATION proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + int bOtherInfo; /**< flag to check whether other information is required or not */ + TelSatCmdQualiProvideLocalInfo_t infoType; /**< local info type - e.g. time zone or language info, etc */ + union { + TelSatDataTimeZoneInfo_t timeZoneInfo; /**< current time zone info */ + TelSatLanguageInfo_t languageInfo; /**< current ME language setting info */ + } u; /**< Union */ +} TelSatProvideLocalInfoRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SETUP EVENT LIST proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ +} TelSatSetupEventListRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SEND SMS proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + TelSatCallCtrlProblemType_t additionalCallCtrlProblemInfo; /**< call control problem */ +} TelSatSendSmsRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SET UP CALL proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + int bOtherInfo; /**< flag to check whether other information are required or not */ + TelSatNetworkProblemType_t networkProblem; /**< network problem during setup call */ + TelSatCallCtrlProblemType_t permanentCallCtrlProblem; /**< permanent call control problem */ + TelSatCallCtrlRequestedActionInfo_t callCtrlRequestedAction; /**< call control requested action info */ + TelSatResultInfo_t result2; /**< additional response on general result */ + TelSatTextTypeInfo_t text; /**< text string info */ + int bIsTapiCause; /**< flag to check whether tapi makes problem or not */ + unsigned long tapiCause; /**< tapi call level cause */ + unsigned long tapiSsCause; /**< tapi ss level cause */ +} TelSatSetupCallRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SEND SS proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + int bOtherInfo; /**< flag to check whether whether other information is required or not */ + TelSatSsProblemType_t additionalSsProblemInfo; /**< additional ss problem */ + TelSatCallCtrlProblemType_t additionalCallCtrlProblemInfo; /**< additional call control problem */ + TelSatCallCtrlRequestedActionInfo_t callCtrlRequestedAction; /**< call control requested action info */ + TelSatResultInfo_t result2; /**< additional response on general result */ + TelSatTextTypeInfo_t text; /**< text string info */ +} TelSatSendSsRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SEND USSD proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + int bOtherInfo; /**< flag to check whether other information is required or not */ + TelSatUssdProblemType_t additionalUssdProblemInfo; /**< additional ussd problem */ + TelSatCallCtrlProblemType_t additionalCallCtrlProblemInfo; /**< additional call control problem */ + int bCallCtrlHasModification; /**< flag to check whether modification happens during call control */ + TelSatTextTypeInfo_t text; /**< text string info */ + TelSatCallCtrlRequestedActionInfo_t callCtrlRequestedAction; /**< call control requested action info */ + TelSatResultInfo_t result2; /**< additional response on general result */ + TelSatTextTypeInfo_t text2; /**< text string info */ +} TelSatSendUssdRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of REFRESH proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ +} TelSatRefreshRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of GET CHANNEL STATUS proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + int bOtherInfo; /**< flag whether other information are required or not */ + TelSatBipProblemType_t additionalProblemInfo; /**< bip specific problem info */ + TelSatChannelStatusInfo_t channelStatus; /**< channel Status */ +} TelSatGetChannelStatusRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of CLOSE CHANNEL proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + TelSatBipProblemType_t additionalProblemInfo; /**< bip specific problem info */ +} TelSatCloseChannelRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of OPEN CHANNEL proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + int bOtherInfo; /**< flag whether other information are required or not */ + TelSatBearerDescriptionInfo_t bearerDescription; /**< bearerDescription */ + TelSatBipProblemType_t additionalProblemInfo; /**< bip specific problem info */ + TelSatChannelStatusInfo_t channelStatus; /**< channelStatus */ + TelSatBufferSizeInfo_t bufferSize; /**< bufferSize */ +} TelSatOpenChannelRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of LANGAUGE NOTIFICATION proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ +} TelSatLanguageNotificationRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of LAUNCH BROWSER proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + TelSatLaunchBrowserProblemType_t additionalProblemInfo; /**< browser specific problem info */ +} TelSatLaunchBrowserRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of RECEIVE DATA proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + TelSatBipProblemType_t additionalProblemInfo; /**< bip specific problem info */ + int bOtherInfo; /**< flag whether other information are required or not */ + TelSatChannelDataInfo_t channel_data; /**< channel data */ + unsigned char channelDataLen; /**< channel data length */ +} TelSatReceiveDataRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SEND DATA proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ + TelSatBipProblemType_t additionalProblemInfo; /**< bip specific problem info */ + unsigned char channelDataLen; /**< channel data length */ +} TelSatSendDataRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SETUP IDLE MODE TEXT proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ +} TelSatSetupIdlemodeTextRespInfo_t; + +/** + * This structure contains the data objects for the Terminal Response of SEND DTMF proactive command. + */ +typedef struct { + TelSatResultInfo_t result; /**< result whether current proactive command request was executed successfully or not */ +} TelSatSendDtmfRespInfo_t; + +/** + * This contains the data structures to be used to send proactive command response. + */ +typedef struct { + unsigned char commandNumber; /**< proactive command number */ + TelSatCommandType_t commandType; /**< proactive command type */ + union { + TelSatMoreTimeRespInfo_t moreTime; + TelSatDisplayTextRespInfo_t displayText; /**< terminal response info from displayText proactive command */ + TelSatGetInkeyRespInfo_t getInkey; /**< terminal response info from getInkey proactive command */ + TelSatGetInputRespInfo_t getInput; /**< terminal response info from getInput proactive command */ + TelSatPlayToneRespInfo_t playTone; /**< terminal response info from playTone proactive command */ + TelSatSetupMenuRespInfo_t setupMenu; /**< terminal response info from setupMenu proactive command */ + TelSatSelectItemRespInfo_t selectItem; /**< terminal response info from selectItem proactive command */ + TelSatSendSmsRespInfo_t sendSms; /**< terminal response info from sendSms proactive command */ + TelSatSendSsRespInfo_t sendSs; /**< terminal response info from sendSs proactive command */ + TelSatSendUssdRespInfo_t sendUssd; /**< terminal response info from sendUssd proactive command */ + TelSatSetupCallRespInfo_t setupCall; /**< terminal response info from setupCall proactive command */ + TelSatRefreshRespInfo_t refresh; /**< terminal response info from refresh proactive command */ + TelSatProvideLocalInfoRespInfo_t provideLocInfo; /**< terminal response info from provide Local Info proactive command */ + TelSatLaunchBrowserRespInfo_t launchBrowser; /**< terminal response info from launch Browser proactive command */ + TelSatSetupIdlemodeTextRespInfo_t idleText; /**< terminal response info from setup idle mode text proactive command */ + TelSatSendDtmfRespInfo_t sendDtmf; /**< terminal response info from send Dtmf proactive command */ + TelSatLanguageNotificationRespInfo_t languageNotification; /**< terminal response info from language Notification proactive command */ + TelSatSetupEventListRespInfo_t setupEventList; /**< terminal response info from setup Event List proactive command */ + TelSatOpenChannelRespInfo_t openChannel; /**< terminal response info from openChannel proactive command */ + } terminalRespInfo; /**< Union */ +} TelSatRespInfo_t; + +/* + *SAT Icon Data + */ + +typedef struct { + unsigned char iconId; + unsigned char imgType; + unsigned char imgLen; + unsigned char imgData[256]; +} TelSatIconDataResp_t; + +typedef struct { + unsigned char iconId; + unsigned char imgType; + unsigned char fileId[2]; + unsigned char reqDataLen[2]; + unsigned char offset[2]; +} TelsatIconDataGet_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _TEL_SAT_PROACTV_CMD_H_ */ + +/** + * @} + */ diff --git a/src/sat_ui_support/TelSim.h b/src/sat_ui_support/TelSim.h new file mode 100644 index 0000000..66593d0 --- /dev/null +++ b/src/sat_ui_support/TelSim.h @@ -0,0 +1,1384 @@ +/* + * libslp-tapi + * + * Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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. + */ + +/** + * @open + * @ingroup TelephonyAPI + * @addtogroup SIM_TAPI SIM + * @{ + * + * @file TelSim.h + + @brief This file serves as a "C" header file defines structures for Tapi SIM Services. \n + It contains a sample set of constants, enums, structs that would be required by applications. + */ + +#ifndef _TELSIM_H_ +#define _TELSIM_H_ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** Maximum ICCID Length */ +#define TAPI_SIM_ICCID_LEN_MAX 20 + +/** Alpha Id max length */ +#define TAPI_SIM_XDN_ALPHA_ID_MAX_LEN 30 + +/** Dialing number max length */ +#define TAPI_SIM_XDN_DIALING_NUMBER_LEN 20 + +/** MSISDN number max length */ +#define TAPI_SIM_MSISDN_DIALING_NUMBER_LEN 26 + +/** CSP profile entry count max length */ +#define TAPI_SIM_CPHS_CUSTOMER_SERVICE_PROFILE_ENTRY_COUNT_MAX 11 + +/** Authentication code max length */ +#define TAPI_SIM_AUTH_MAX_REQ_DATA_LEN 256 + +/** Authentication response data max length */ +#define TAPI_SIM_AUTH_MAX_RESP_DATA_LEN 128 + +/** SAP APDU max length */ +/** 2048 is for QMI definition. (1024 : general length, 1024 : extra length for additional response) */ +#define TAPI_SIM_APDU_MAX_LEN 2048 + +/** SIM 3G Phone book EF Max count */ +#define TAPI_SIM_PB_3G_FILE_MAX_COUNT 13 + +/** SIM Phone book Record name max length */ +#define TAPI_SIM_PB_RECORD_NAME_MAX_LEN 255 + +/** SIM Phone book Record number max length */ +#define TAPI_SIM_PB_RECORD_NUMBER_MAX_LEN 255 + +/** SIM Phone book Record email max length */ +#define TAPI_SIM_PB_RECORD_EMAIL_MAX_LEN 255 + +/** SAP Answer to Reset data max length */ +#define TAPI_SIM_SAP_ATR_DATA 256 + +#define TAPI_SIM_NET_FULL_NAME_MAX_LEN 40 + +#define TAPI_SIM_NET_SHORT_NAME_MAX_LEN 10 + +#define TAPI_SIM_MSP_CNT_MAX 2 + +#define TAPI_SIM_OPERATION_TIMEOUT 1234 + +#define TAPI_SIM_SST_SERVICE_CNT_MAX 56 + +#define TAPI_SIM_UST_SERVICE_CNT_MAX 64 + +/** + * @enum TelSimCardType_t + * This enumeration defines the card type. + */ +typedef enum { + TAPI_SIM_CARD_TYPE_UNKNOWN, /**< Unknown card */ + TAPI_SIM_CARD_TYPE_GSM, /**< SIm(GSM) card*/ + TAPI_SIM_CARD_TYPE_USIM, /**< USIM card */ + TAPI_SIM_CARD_TYPE_RUIM, + TAPI_SIM_CARD_TYPE_IMS, +} TelSimCardType_t; + +/** + * @enum TelSimFileID_t + * This enumeration defines the card type. + */ +typedef enum { + TAPI_SIM_EF_DIR = 0x2F00, /**< Root Directory for the USIM */ + TAPI_SIM_EF_ICCID = 0x2FE2, /**< the ICC Identification file */ + TAPI_SIM_EF_IMSI = 0x6F07, /**< the IMSI file */ + TAPI_SIM_EF_SST = 0x6F38, /**< the SIM Service Table file */ + TAPI_SIM_EF_EST = 0x6F56, /**< the Enabled Service Table file */ + TAPI_SIM_EF_OPLMN_ACT = 0x6F61, /**< the OPLMN List file*/ + TAPI_SIM_EF_GID1 = 0x6F3E, /**< the Group Identifier Level 1 */ + TAPI_SIM_EF_GID2 = 0x6F3F, /**< the Group Identifier Level 2 */ + + TAPI_SIM_EF_ELP = 0x2F05, /**< the Extended Language Preference file */ + TAPI_SIM_EF_LP = 0x6F05, /**< SIM: Language preference */ + TAPI_SIM_EF_ECC = 0x6FB7, /**< the Emergency Call Codes */ + TAPI_SIM_EF_SPN = 0x6F46, /**< the Service Provider Name */ + TAPI_SIM_EF_SPDI = 0x6FCD, /**< the Service provider display information*/ + TAPI_SIM_EF_PNN = 0x6FC5, /**< the PLMN Network Name File*/ + TAPI_SIM_EF_OPL = 0x6FC6, /**< the Operator PLMN List File*/ + TAPI_SIM_EF_MSISDN = 0x6F40, /**< MSISDN */ + + TAPI_SIM_EF_SMS = 0x6F3C, /** < Short Messages file */ + TAPI_SIM_EF_SMSP = 0x6F42, /** < SMS Parameter */ + TAPI_SIM_EF_SMSS = 0x6F43, /** < SMS Status */ + TAPI_SIM_EF_CBMI = 0x6F45, /** < Cell Broadcast Message Identifier */ + TAPI_SIM_EF_MBDN = 0x6FC7, /** < SIM Mail Box Dialing Number file */ + + TAPI_SIM_EF_USIM_MBI = 0x6FC9, /** < Mailbox Identifier -linear fixed*/ + TAPI_SIM_EF_USIM_MWIS = 0x6FCA, /** < Message Waiting Indication Status -linear fixed*/ + TAPI_SIM_EF_USIM_CFIS = 0x6FCB, /** < Call forward indication status -linear fixed*/ + + /* CPHS FILE ID */ + TAPI_SIM_EF_CPHS_VOICE_MSG_WAITING = 0x6F11, /** < CPHS voice MSG waiting indication */ + TAPI_SIM_EF_CPHS_SERVICE_STRING_TABLE = 0x6F12, /** < CPHS service string table */ + TAPI_SIM_EF_CPHS_CALL_FORWARD_FLAGS = 0x6F13, /** < CPHS call forward flags */ + TAPI_SIM_EF_CPHS_OPERATOR_NAME_STRING = 0x6F14, /** < CPHS operator name string */ + TAPI_SIM_EF_CPHS_CUSTOMER_SERVICE_PROFILE = 0x6F15, /** < CPHS customer service profile */ + TAPI_SIM_EF_CPHS_CPHS_INFO = 0x6F16, /** < CPHS information */ + TAPI_SIM_EF_CPHS_MAILBOX_NUMBERS = 0x6F17, /** < CPHS mail box numbers */ + TAPI_SIM_EF_CPHS_OPERATOR_NAME_SHORT_FORM_STRING = 0x6F18, /** < CPHS operator name short form string */ + TAPI_SIM_EF_CPHS_INFORMATION_NUMBERS = 0x6F19, /** < CPHS information numbers */ + /* CPHS ALS FILE ID */ + TAPI_SIM_EF_CPHS_DYNAMICFLAGS = 0x6F9F, /** < CPHS Dynamics flags */ + TAPI_SIM_EF_CPHS_DYNAMIC2FLAG = 0x6F92, /** < CPHS Dynamics2 flags */ + TAPI_SIM_EF_CPHS_CUSTOMER_SERVICE_PROFILE_LINE2 = 0x6F98, /** < CPHS CSP2 */ + + /* Invalid File ID, All the file ID are less than this Value*/ + TAPI_SIM_EF_INVALID = 0xFFFF, /**< Invalid file.*/ + TAPI_SIM_EF_OTHERS, /**< Element to indicate an unknown file.*/ +}TelSimFileID_t; + +/** + * @enum TelSimFacilityStatus_t + * This enumeration defines the pin status. + */ +typedef enum { + TAPI_SIM_FACILITY_DISABLED = 0x00, + TAPI_SIM_FACILITY_ENABLED = 0x01, + TAPI_SIM_FACILITY_UNKNOWN = 0xFF +} TelSimFacilityStatus_t; + +/** + * @enum TelSimPinOperationResult_t + * This enumeration defines the pin operation result from the lower layers. + */ +typedef enum { + TAPI_SIM_PIN_OPERATION_SUCCESS, /**< Operation involving PIN (verification/change/enable/disable, etc) is successful. */ + TAPI_SIM_BUSY, /**< SIM is busy */ + TAPI_SIM_CARD_ERROR, /**< SIM card error - General errors */ + TAPI_SIM_INCOMPATIBLE_PIN_OPERATION, /**< SIM Incompatible pin operation that is in case when invalid SIM command is given or incorrect parameters are supplied to the SIM. */ + TAPI_SIM_PIN_INCORRECT_PASSWORD, /**< SIM PIN Incorrect password */ + TAPI_SIM_PUK_INCORRECT_PASSWORD, /**< SIM PUK Incorrect Password */ + TAPI_SIM_PUK_REQUIRED, /**< PUK Required */ + TAPI_SIM_PIN_REQUIRED, /**< PIN Required */ + TAPI_SIM_NCK_REQUIRED, /**< Network Control Key Required */ + TAPI_SIM_NSCK_REQUIRED, /**< Network Subset Control Key Required */ + TAPI_SIM_SPCK_REQUIRED, /**< Service Provider Control Key Required */ + TAPI_SIM_CCK_REQUIRED, /**< Corporate Control Key Required */ + TAPI_SIM_LOCK_REQUIRED, /**< PH-SIM (phone-SIM) locked state **/ + TAPI_SIM_PERM_BLOCKED /**< Permanently Blocked **/ +} TelSimPinOperationResult_t; + +/** + * @enum TelSimAccessResult_t + * This enumeration defines the SIM access result from the lower layers. + */ +typedef enum { + TAPI_SIM_ACCESS_SUCCESS, /**< Access to file successful. */ + TAPI_SIM_ACCESS_CARD_ERROR, /**< SIM card error */ + TAPI_SIM_ACCESS_FILE_NOT_FOUND, /**< File not found */ + TAPI_SIM_ACCESS_ACCESS_CONDITION_NOT_SATISFIED, /**< Access condition is not fulfilled */ + TAPI_SIM_ACCESS_FAILED, /**< Access failed. */ +} TelSimAccessResult_t; + +/** + * @enum TelSimPinType_t + * This enumeration defines the pin type. + */ +typedef enum { + TAPI_SIM_PTYPE_PIN1 = 0x00, /**< PIN 1 code */ + TAPI_SIM_PTYPE_PIN2 = 0x01, /**< PIN 2 code */ + TAPI_SIM_PTYPE_PUK1 = 0x02, /**< PUK 1 code */ + TAPI_SIM_PTYPE_PUK2 = 0x03, /**< PUK 2 code */ + TAPI_SIM_PTYPE_UPIN = 0x04, /**< Universal PIN - Unused now */ + TAPI_SIM_PTYPE_ADM = 0x05, /**< Administrator - Unused now */ + TAPI_SIM_PTYPE_SIM = 0x06 /**< SIM Lock code */ +} TelSimPinType_t; + +/** + * @enum TelSimTypeOfNum_t + * This enumeration defines the type of number. + */ +typedef enum { + TAPI_SIM_TON_UNKNOWN = 0, /**< unknown */ + TAPI_SIM_TON_INTERNATIONAL = 1, /**< international number */ + TAPI_SIM_TON_NATIONAL = 2, /**< national number */ + TAPI_SIM_TON_NETWORK_SPECIFIC = 3, /**< network specific number */ + TAPI_SIM_TON_DEDICATED_ACCESS = 4, /**< subscriber number */ + TAPI_SIM_TON_ALPHA_NUMERIC = 5, /**< alphanumeric, GSM 7-bit default alphabet) */ + TAPI_SIM_TON_ABBREVIATED_NUMBER = 6, /**< abbreviated number */ + TAPI_SIM_TON_RESERVED_FOR_EXT = 7 /**< reserved for extension */ +} TelSimTypeOfNum_t; + +/** + * @enum TelSimTextEncrypt_t + * This enumeration defines the text encryption types + */ +typedef enum { + TAPI_SIM_TEXT_ENC_ASCII, /**< ASCII Encoding */ + TAPI_SIM_TEXT_ENC_GSM7BIT, /**< GSM 7 Bit Encoding */ + TAPI_SIM_TEXT_ENC_UCS2, /**< UCS2 Encoding */ + TAPI_SIM_TEXT_ENC_HEX, /**< HEX Encoding */ +} TelSimTextEncrypt_t; + +/** + * @enum TelSimNumberingPlanIdentity_t + * This enumeration defines the numbering plan identifier. + */ +typedef enum { + TAPI_SIM_NPI_UNKNOWN = 0, /**< Unknown */ + TAPI_SIM_NPI_ISDN_TEL = 1, /**< ISDN/Telephone numbering plan */ + TAPI_SIM_NPI_DATA_NUMBERING_PLAN = 3, /**< Data numbering plan */ + TAPI_SIM_NPI_TELEX = 4, /**< Telex numbering plan */ + TAPI_SIM_NPI_SVC_CNTR_SPECIFIC_PLAN = 5, /**< Service Center Specific plan */ + TAPI_SIM_NPI_SVC_CNTR_SPECIFIC_PLAN2 = 6, /**< Service Center Specific plan */ + TAPI_SIM_NPI_NATIONAL = 8, /**< National numbering plan */ + TAPI_SIM_NPI_PRIVATE = 9, /**< Private numbering plan */ + TAPI_SIM_NPI_ERMES_NUMBERING_PLAN = 10, /**< ERMES numbering plan */ + TAPI_SIM_NPI_RESERVED_FOR_EXT = 0xF /**< Reserved for extension */ +} TelSimNumberingPlanIdentity_t; + +/** + * @enum TelSimEccEmergencyServiceInfo_t + * This enumeration defines the emergency service type. + */ +typedef enum { + TAPI_SIM_ECC_ESC_POLICE = 0x01, /**< Police */ + TAPI_SIM_ECC_ESC_AMBULANCE = 0x02, /**< Ambulance */ + TAPI_SIM_ECC_ESC_FIREBRIGADE = 0x04, /**< Fire brigade */ + TAPI_SIM_ECC_ESC_MARAINEGUARD = 0x08, /**< Marine guard */ + TAPI_SIM_ECC_ESC_MOUTAINRESCUE = 0x10, /**< Mountain rescue */ + TAPI_SIM_ECC_ESC_SPARE = 0x00 /**< Spare */ +} TelSimEccEmergencyServiceInfo_t; + +/** + * @enum TelSimLanguagePreferenceCode_t + * This enumeration defines the language indication code. + */ +typedef enum { + TAPI_SIM_LP_GERMAN = 0x00, /**< German */ + TAPI_SIM_LP_ENGLISH = 0x01, /**< English */ + TAPI_SIM_LP_ITALIAN = 0x02, /**< Italian */ + TAPI_SIM_LP_FRENCH = 0x03, /**< French */ + TAPI_SIM_LP_SPANISH = 0x04, /**< Spanish */ + TAPI_SIM_LP_DUTCH = 0x05, /**< Dutch */ + TAPI_SIM_LP_SWEDISH = 0x06, /**< Swedish */ + TAPI_SIM_LP_DANISH = 0x07, /**< Danish */ + TAPI_SIM_LP_PORTUGUESE = 0x08, /**< Portuguese */ + TAPI_SIM_LP_FINNISH = 0x09, /**< Finnish */ + TAPI_SIM_LP_NORWEGIAN = 0x0A, /**< Norwegian */ + TAPI_SIM_LP_GREEK = 0x0B, /**< Greek */ + TAPI_SIM_LP_TURKISH = 0x0C, /**< Turkish */ + TAPI_SIM_LP_HUNGARIAN = 0x0D, /**< Hungarian */ + TAPI_SIM_LP_POLISH = 0x0E, /**< Polish */ + TAPI_SIM_LP_KOREAN = 0x0F, /**< Korean */ + TAPI_SIM_LP_CHINESE = 0x10, /**< Chinese */ + TAPI_SIM_LP_RUSSIAN = 0x11, /**< Russian */ + TAPI_SIM_LP_JAPANESE = 0x12, /**< Japanese */ + TAPI_SIM_LP_LANG_UNSPECIFIED = 0xFF /**< Unspecified */ +} TelSimLanguagePreferenceCode_t; + +/** + * @enum TelSimCardStatus_t + * This enumeration defines the SIM card status + */ +typedef enum { + TAPI_SIM_STATUS_CARD_ERROR = 0x00, /**< Bad card / On the fly SIM gone bad **/ + TAPI_SIM_STATUS_CARD_NOT_PRESENT = 0x01, /**< Card not present **/ + TAPI_SIM_STATUS_SIM_INITIALIZING = 0x02, /**< SIM is Initializing state **/ + TAPI_SIM_STATUS_SIM_INIT_COMPLETED = 0x03, /**< SIM Initialization ok **/ + TAPI_SIM_STATUS_SIM_PIN_REQUIRED = 0x04, /**< PIN required state **/ + TAPI_SIM_STATUS_SIM_PUK_REQUIRED = 0x05, /**< PUK required state **/ + TAPI_SIM_STATUS_CARD_BLOCKED = 0x06, /**< PIN/PUK blocked(permanently blocked- All the attempts for PIN/PUK failed) **/ + TAPI_SIM_STATUS_SIM_NCK_REQUIRED = 0x07, /**< Network Control Key required state **/ + TAPI_SIM_STATUS_SIM_NSCK_REQUIRED = 0x08, /**< Network Subset Control Key required state **/ + TAPI_SIM_STATUS_SIM_SPCK_REQUIRED = 0x09, /**< Service Provider Control Key required state **/ + TAPI_SIM_STATUS_SIM_CCK_REQUIRED = 0x0a, /**< Corporate Control Key required state **/ + TAPI_SIM_STATUS_CARD_REMOVED = 0x0b, /**< Card removed **/ + TAPI_SIM_STATUS_SIM_LOCK_REQUIRED = 0x0c, /**< PH-SIM (phone-SIM) locked state **/ + TAPI_SIM_STATUS_CARD_CRASHED = 0x0d, /**< Runtime SIM card error **/ + TAPI_SIM_STATUS_UNKNOWN = 0xff /**< Unknown status. It can be initial status **/ +} TelSimCardStatus_t; + +/** + * @enum TelSimCphsPhaseType_t + * This enum gives the current CPHS phase of SIM card. + */ +typedef enum { + TAPI_SIM_CPHS_PHASE1 = 0x01, /**< phase1 */ + TAPI_SIM_CPHS_PHASE2 = 0x02, /**< phase2 */ + TAPI_SIM_CPHS_PHASE_RFU = 0xff /**< RFU */ +} TelSimCphsPhaseType_t; + +/** + * @enum TelSimCphsIndexLevelIndicator_t + * This struct gives CPHS index level indication. + */ +typedef enum { + TAPI_SIM_CPHS_INDEX_LEVEL_ONE = 0x01, /**< SIM cphs index level one */ + TAPI_SIM_CPHS_INDEX_LEVEL_TWO = 0x02, /**< SIM cphs index level two */ + TAPI_SIM_CPHS_INDEX_LEVEL_THREE = 0x03, /**< SIM cphs index level three */ + TAPI_SIM_CPHS_INDEX_LEVEL_RFU = 0xff /**< SIM cphs index level rfu */ +} TelSimCphsIndexLevelIndicator_t; + +/** + * @enum TelSimCphsCustomerServiceGroup_t + * This struct gives CPHS group service type information . + */ +typedef enum { + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_CALL_OFFERING = 0x01, /**< Group csp offering*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_CALL_RESTRICTION = 0x02, /**< Group csp restriction*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_OTHER_SUPP_SERVICES = 0x03, /**< Group csp supplementary services*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_CALL_COMPLETION = 0x04, /**< Group csp completion*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_TELESERVICES = 0x05, /**< Group csp teleservices*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_CPHS_TELESERVICES = 0x06, /**< Group csp cphs teleservies*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_CPHS_FEATURES = 0x07, /**< Group csp cphs features*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_NUMBER_IDENTIFIERS = 0x08, /**< Group csp number identifiers*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_PHASE_SERVICES = 0x09, /**< Group csp phase services*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_VALUE_ADDED_SERVICES = 0xC0, /**< Group csp value added services*/ + TAPI_SIM_CPHS_CSP_SERVICE_GROUP_INFORMATION_NUMBERS = 0xD5 /**< Group csp information numbers*/ +} TelSimCphsCustomerServiceGroup_t; + +/** + * @enum TelSimMailboxType_t + * This enum gives mailbox type. + */ +typedef enum { + TAPI_SIM_MAILBOX_VOICE = 0x01, /**< Voicemail*/ + TAPI_SIM_MAILBOX_FAX = 0x02, /**< Fax*/ + TAPI_SIM_MAILBOX_EMAIL = 0x03, /**< Email*/ + TAPI_SIM_MAILBOX_OTHER = 0x04, /**< Other*/ + TAPI_SIM_MAILBOX_VIDEO = 0x05, /**< Videomail*/ + TAPI_SIM_MAILBOX_DATA = 0x06, /**< Data*/ +} TelSimMailboxType_t; + +/** + * @enum TelSimDynamicFlagsSelectedLineId_t + * This enum gives dynamics flag selected line information. + */ +typedef enum { + TAPI_SIM_DYNAMIC_FLAGS_LINE1 = 0x01, /**< line 1 */ + TAPI_SIM_DYNAMIC_FLAGS_LINE2 = 0x00, /**< line 2*/ + TAPI_SIM_DYNAMIC_FLAGS_RFU = 0xff /**< rfu*/ +} TelSimDynamicFlagsSelectedLineId_t; + +/** + * @enum tapi_sim_dynamic2_flag_als_status_t + * This enum gives dynamics2 flag selected line information. + */ +typedef enum { + TAPI_SIM_PIN2_ACCESSIBLE_FLAGS_LOCKED = 0x01, /**< Dynamic flags locked */ + TAPI_SIM_PIN2_ACCESSIBLE_FLAGS_UNLOCKED = 0x00, /**< Dynamic flags unlocked */ + TAPI_SIM_PIN2_ACCESSIBLE_FLAGS_RFU = 0xff /**< rfu */ +} TelSimDynamic2FlagAlsStatus_t; + + +/** + * @enum TelSimAuthenticationType_t + * This is used for Authentication Procedure by using SIM. + */ +typedef enum { + TAPI_SIM_AUTH_TYPE_IMS = 0x00, /**< IMS Authentication */ + TAPI_SIM_AUTH_TYPE_GSM, /**< GSM Authentication */ + TAPI_SIM_AUTH_TYPE_3G, /**< 3G Authentication */ + TAPI_SIM_AUTH_TYPE_MAX /**< TBD */ +} TelSimAuthenticationType_t; + +/** + * @enum TelSimAuthenticationResult_t + * This is used for Authentication Procedure. + */ +typedef enum { + TAPI_SIM_AUTH_NO_ERROR = 0x00, /**< ISIM no error */ + TAPI_SIM_AUTH_CANNOT_PERFORM, /**< status - can't perform authentication */ + TAPI_SIM_AUTH_SKIP_RESPONSE, /**< status - skip authentication response */ + TAPI_SIM_AUTH_MAK_CODE_FAILURE, /**< status - MAK(Multiple Activation Key) code failure */ + TAPI_SIM_AUTH_SQN_FAILURE, /**< status - SQN(SeQuenceNumber) failure */ + TAPI_SIM_AUTH_SYNCH_FAILURE, /**< status - synch failure */ + TAPI_SIM_AUTH_UNSUPPORTED_CONTEXT, /**< status - unsupported context */ + TAPI_SIM_AUTH_MAX /**< TBD */ +} TelSimAuthenticationResult_t; + +/** + * @enum TelSimLockType_t + * This structure gives security lock type enum values + */ +typedef enum { + TAPI_SIM_LOCK_PS = 0x01, /** < PH-SIM (phone-SIM) locked.Lock Phone to SIM/UICC card + * (MT asks password when other than current SIM/UICC card inserted; + * MT may remember certain amount of previously used cards thus not + * requiring password when they are inserted + */ + TAPI_SIM_LOCK_PF, /** < PH-FSIM (phone-first-SIM) Lock Phone to the very + * First inserted SIM/UICC card(MT asks password when other than the first SIM/UICC + * card is inserted + */ + TAPI_SIM_LOCK_SC, /** < SIM Lock (PIN, PIN2, PUK, PUK2) Lock SIM/UICC card ( SIM asks password in ME power-up and + * when this command is issued + */ + TAPI_SIM_LOCK_FD, /** < FDN - SIM card or active application in the UICC (GSM or USIM) + * fixed dialing memory feature */ + TAPI_SIM_LOCK_PN, /**< Network Personalization */ + TAPI_SIM_LOCK_PU, /** < network subset Personalization */ + TAPI_SIM_LOCK_PP, /** < service Provider Personalization */ + TAPI_SIM_LOCK_PC, /** < Corporate Personalization */ +} TelSimLockType_t; + +/** + * @enum TelSimLockKey_t + * This structure gives security lock key information enum values + */ +typedef enum { + TAPI_SIM_LOCK_KEY_NOT_NEED = 0x00, /**< key not need */ + TAPI_SIM_LOCK_KEY_PIN = 0x01, /**< PIN required */ + TAPI_SIM_LOCK_KEY_PUK = 0x02, /**< PUK required */ + TAPI_SIM_LOCK_KEY_PIN2 = 0x03, /**< PIN2 required */ + TAPI_SIM_LOCK_KEY_PUK2 = 0x04, /**< PUK2 required */ + TAPI_SIM_LOCK_PERM_BLOCKED = 0x05, /**< Permanent block SIM */ +} TelSimLockStatus_t; + +/** + * @enum TelSimSapPowerMode_t + * This enum gives the SAP message Ids between SAP client and SAP server. + */ +typedef enum { + TAPI_SIM_SAP_POWER_SIM_ON_REQ, /**< SAP Client request about power SIM on in Server */ + TAPI_SIM_SAP_POWER_SIM_OFF_REQ, /**< SAP Client request about power SIM off in Server */ + TAPI_SIM_SAP_RESET_SIM_REQ, /**< SAP Client request about SIM reset in Server */ +} TelSimSapPowerMode_t; + +/** + * @enum TelSimSapConnectionStatus_t + * This enum gives the SAP connection status information . + */ +typedef enum { + TAPI_SIM_SAP_CONNECTION_STATUS_OK = 0x00, /**< connect successfully */ + TAPI_SIM_SAP_CONNECTION_STATUS_UNABLE_TO_ESTABLISH, /**< unable to establish connection */ + TAPI_SIM_SAP_CONNECTION_STATUS_NOT_SUPPORT_MAX_SIZE, /**< when server does not support message length that client want send */ + TAPI_SIM_SAP_CONNECTION_STATUS_TOO_SMALL_MAX_SIZE /**< when client want to connect with very small message length which is not supported by Server */ +} TelSimSapConnectionStatus_t; + +/** + * @enum TelSimSapDissconnectType_t + * This enum gives the SAP disconnect type information. + */ +typedef enum { + TAPI_SIM_SAP_DISCONNECT_TYPE_GRACEFUL = 0x00, /**< disconnection procedure ends after finishing current work */ + TAPI_SIM_SAP_DISCONNECT_TYPE_IMMEDIATE /**< disconnection procedure ends immediately*/ +} TelSimSapDissconnectType_t; + +/** + * @enum TelSimSapStatusInfo_t + * This enum gives the SAP current connection status information + */ +typedef enum { + TAPI_SIM_SAP_STATUS_UNKNOWN = 0x00, /**< SAP server connection status - unknown*/ + TAPI_SIM_SAP_STATUS_NO_SIM, /**< SAP server connection status - no SIM*/ + TAPI_SIM_SAP_STATUS_NOT_READY, /**< SAP server connection status - not ready*/ + TAPI_SIM_SAP_STATUS_READY, /**< SAP server connection status - ready*/ + TAPI_SIM_SAP_STATUS_CONNECTED /**< SAP server connection status - connected*/ +} TelSimSapStatusInfo_t; + +/** + * @enum TelSimSapCardStatus_t + * This enum gives the SIM card status if server`s status changed about connection with subscription module + */ +typedef enum { + TAPI_SIM_SAP_CARD_STATUS_UNKNOWN = 0x00, /**< SAP server status(card reader status) - unknown*/ + TAPI_SIM_SAP_CARD_STATUS_RESET, /**< SAP server status(card reader status) - reset*/ + TAPI_SIM_SAP_CARD_STATUS_NOT_ACCESSIBLE, /**< SAP server status(card reader status) - not accessible*/ + TAPI_SIM_SAP_CARD_STATUS_REMOVED, /**< SAP server status(card reader status) - removed*/ + TAPI_SIM_SAP_CARD_STATUS_INSERTED, /**< SAP server status(card reader status) - inserted*/ + TAPI_SIM_SAP_CARD_STATUS_RECOVERED /**< SAP server status(card reader status) - recovered*/ +} TelSimSapCardStatus_t; + +/** + * @enum TelSimSapResultCode_t + * This enum gives the SAP result information. + */ +typedef enum { + TAPI_SIM_SAP_RESULT_CODE_OK = 0x00, /**< SAP operation result - ok*/ + TAPI_SIM_SAP_RESULT_CODE_NO_REASON, /**< SAP operation result - no reason*/ + TAPI_SIM_SAP_RESULT_CODE_CARD_NOT_ACCESSIBLE, /**< SAP operation result - not accessible*/ + TAPI_SIM_SAP_RESULT_CODE_CARD_ALREADY_POWER_OFF, /**< SAP operation result - card already power off*/ + TAPI_SIM_SAP_RESULT_CODE_CARD_REMOVED, /**< SAP operation result - card removed*/ + TAPI_SIM_SAP_RESULT_CODE_CARD_ALREADY_POWER_ON, /**< SAP operation result - card already power on*/ + TAPI_SIM_SAP_RESULT_CODE_DATA_NOT_AVAILABLE, /**< SAP operation result - data not available*/ + TAPI_SIM_SAP_RESULT_CODE_NOT_SUPPORT /**< SAP operation result - not support*/ +} TelSimSapResultCode_t; + +/** + * @enum TelSimSapProtocol_t + * This enum gives SAP transport protocol type + */ +typedef enum { + TAPI_SIM_SAP_PROTOCOL_T0, /**< T = 0, character*/ + TAPI_SIM_SAP_PROTOCOL_T1 /**< T = 1, block*/ +} TelSimSapProtocol_t; + +/** + * @enum TelSimPbAccessResult_t + * This enumeration defines the Phone book access result + */ +typedef enum { + TAPI_SIM_PB_SUCCESS, /**< SIM phonebook operation successful. */ + TAPI_SIM_PB_FAIL, /**< SIM phonebook operation failure. */ + TAPI_SIM_PB_INVALID_INDEX, /**< The index passed was not a valid index. */ + TAPI_SIM_PB_INVALID_NUMBER_LENGTH, /**< The number length is exceeds the max length allowed (or 0). */ + TAPI_SIM_PB_INVALID_NAME_LENGTH, /**< The name length is exceeds the max length allowed (or 0). */ + TAPI_SIM_PB_ACCESS_CONDITION_NOT_SATISFIED, /**< Access condition for PB file is not satisfied. */ +} TelSimPbAccessResult_t; + +/** + * @enum TelSimPbFileType_t + * This enumeration defines different storage types to be selected in SIM or USIM + */ +typedef enum { + TAPI_SIM_PB_FDN, /**< Fixed Dialing Number */ + TAPI_SIM_PB_ADN, /**< SIM - ADN */ + TAPI_SIM_PB_SDN, /**< Service Dialing Number */ + TAPI_SIM_PB_3GSIM, /**< USIM - 3G phone book */ + TAPI_SIM_PB_AAS, /**< Additional number Alpha String */ + TAPI_SIM_PB_GAS, /**< Grouping identifier Alpha String */ + TAPI_SIM_PB_UNKNOWNN = 0xFF, /**< Unknown file type */ +} TelSimPbType_t; + +/** + * @enum TelSimPb3GFileType_t + * This enumeration defines the different storage field types in 3G Phone book. + */ +typedef enum { + /* for 3G phone storage field type */ + TAPI_PB_3G_NAME = 0x01, /**< Name */ + TAPI_PB_3G_NUMBER, /**< Number */ + TAPI_PB_3G_ANR1, /**< First Another number*/ + TAPI_PB_3G_ANR2, /**< Second Another number */ + TAPI_PB_3G_ANR3, /**< Third Another number */ + TAPI_PB_3G_EMAIL1, /**< First Email */ + TAPI_PB_3G_EMAIL2, /**< Second Email */ + TAPI_PB_3G_EMAIL3, /**< Third Email */ + TAPI_PB_3G_EMAIL4, /**< Fourth Email */ + TAPI_PB_3G_SNE, /**< Second name entry of main name*/ + TAPI_PB_3G_GRP, /**< Group */ + TAPI_PB_3G_PBC, /** <1 byte control info and 1 byte hidden info*/ +} TelSimPb3GFileType_t; + +/** + * @enum TelSimSSTService_t + * This enumeration defines the list of SST services in SIM Service Table. (GSM) + */ +typedef enum { + // service 1 ~ 8 + TAPI_SIM_SST_CHV1_DISABLE_FUNC = 0, /**< CHV1 disable function */ + TAPI_SIM_SST_ADN, /**< abbreviated Dialing number */ + TAPI_SIM_SST_FDN, /**< fixed Dialing number */ + TAPI_SIM_SST_SMS, /**< short message storage */ + TAPI_SIM_SST_AOC, /**< advice of charge */ + TAPI_SIM_SST_CCP, /**< capability configuration parameters */ + TAPI_SIM_SST_PLMN_SELECTOR, /**< plmn selector */ + TAPI_SIM_SST_RFU1, /**< rfu */ + + // service 9 ~ 16 + TAPI_SIM_SST_MSISDN = 8, /**< msisdn */ + TAPI_SIM_SST_EXT1, /**< extension1 */ + TAPI_SIM_SST_EXT2, /**< extension2 */ + TAPI_SIM_SST_SMS_PARAMS, /**< sms parameteres */ + TAPI_SIM_SST_LND, /**< last number dialed */ + TAPI_SIM_SST_CELL_BROADCAST_MSG_ID, /**< cell broadcast message identifier */ + TAPI_SIM_SST_GID_LV1, /**< group identifier level 1 */ + TAPI_SIM_SST_GID_LV2, /**< group identifier level 2 */ + + // service 17 ~ 24 + TAPI_SIM_SST_SPN = 16, /**< service provider name */ + TAPI_SIM_SST_SDN, /**< service Dialing number */ + TAPI_SIM_SST_EXT3, /**< extension3 */ + TAPI_SIM_SST_RFU2, /**< rfu */ + TAPI_SIM_SST_VGCS_GID_LIST, /**< vgcs group identifier (EF-VGCS, EF-VGCSS) */ + TAPI_SIM_SST_VBS_GID_LIST, /**< vbs group identifier (EF-VBS, EF-VBSS) */ + TAPI_SIM_SST_ENHANCED_MULTI_LV_PRECEDENCE_PREEMPTION_SRVC, /**< enhanced multi-level precedence and pre-emption service */ + TAPI_SIM_SST_AUTO_ANSWER_FOR_EMLPP, /**< automatic answer fro eMLPP */ + + // service 25 ~ 32, + TAPI_SIM_SST_DATA_DOWNLOAD_VIA_SMS_CB = 24, /**< data download via sms-cb */ + TAPI_SIM_SST_DATA_DOWNLOAD_VIA_SMS_PP, /**< data download via sms-pp */ + TAPI_SIM_SST_MENU_SELECTION, /**< menu selection */ + TAPI_SIM_SST_CALL_CTRL, /**< call control */ + TAPI_SIM_SST_PROACTIVE_SIM, /**< proactive sim command */ + TAPI_SIM_SST_CELL_BROADCAST_MSG_ID_RANGES, /**< cell broadcast message identifier ranges */ + TAPI_SIM_SST_BDN, /**< barred Dialing numbers */ + TAPI_SIM_SST_EXT4, /**< extension 4 */ + + // service 33 ~ 40 + TAPI_SIM_SST_DEPERSONALIZATION_CTRL_KEYS = 32, /**< de-personalization control keys */ + TAPI_SIM_SST_COOPERATIVE_NETWORK_LIST, /**< co-operative network list */ + TAPI_SIM_SST_SMS_STATUS_REPORTS, /**< short message status reports */ + TAPI_SIM_SST_NIA, /**< network's indication of alerting in the MS (NIA) */ + TAPI_SIM_SST_MO_SMS_CTRL_BY_SIM, /**< mobile-originated short message control by sim */ + TAPI_SIM_SST_GPRS, /**< gprs */ + TAPI_SIM_SST_IMG, /**< image */ + TAPI_SIM_SST_SOLSA, /**< support of local service area */ + + // service 41 ~ 48 + TAPI_SIM_SST_USSD_STR_DATA_OBJECT_SUPPORTED_IN_CALL_CTRL = 40, /**< ussd string data object supported in call control */ + TAPI_SIM_SST_RUN_AT_CMD_CMD, /**< RUN AT COMMAND command */ + TAPI_SIM_SST_USER_CTRLED_PLMN_SELECTOR_WACT, /**< user controlled PLMN selector with Access technology */ + TAPI_SIM_SST_OPERATOR_CTRLED_PLMN_SELECTOR_WACT, /**< operator controlled PLMN selector with Access technology */ + TAPI_SIM_SST_HPLMN_SELECTOR_WACT, /**< HPLMN selector with access technology */ + TAPI_SIM_SST_CPBCCH_INFO, /**< CPBCCH information */ + TAPI_SIM_SST_INVESTIGATION_SCAN, /**< investigation scan */ + TAPI_SIM_SST_EXTENDED_CAPA_CONF_PARAMS, /**< extended capability configuration parameters */ + + // service 49 ~ 56 + TAPI_SIM_SST_MEXE = 48, /**< MExE */ + TAPI_SIM_SST_RPLMN_LAST_USED_ACCESS_TECH, /**< RPLMN last used access technology */ + TAPI_SIM_SST_PLMN_NETWORK_NAME, /*PLMN Network Name*/ + TAPI_SIM_SST_OPERATOR_PLMN_LIST, /*Operator PLMN List*/ + TAPI_SIM_SST_MBDN, /*Mailbox Dialling Numbers*/ + TAPI_SIM_SST_MWIS, /*Message Waiting Indication Status*/ + TAPI_SIM_SST_CFIS, /*Call Forwarding Indication Status*/ + TAPI_SIM_SST_SPDI, /*Service Provider Display Information*/ +} TelSimSSTService_t; + +/** + * @enum TelSimUSTService_t + * This enumeration defines the list of UST services in SIM Service Table. (USIM) + */ +typedef enum { + // service 1 ~ 8 + TAPI_SIM_UST_LOCAL_PB = 0, /**< local phone book */ + TAPI_SIM_UST_FDN, /**< fixed Dialing number */ + TAPI_SIM_UST_EXT2, /**< extension2 */ + TAPI_SIM_UST_SDN, /**< service Dialing number */ + TAPI_SIM_UST_EXT3, /**< extension3 */ + TAPI_SIM_UST_BDN, /**< barred Dialing numbers */ + TAPI_SIM_UST_EXT4, /**< extension 4 */ + TAPI_SIM_UST_OUTGOING_CALL_INFO, /**< outgoing call information */ + + // service 9 ~ 16 + TAPI_SIM_UST_INCOMING_CALL_INFO = 8, /**< incoming call information */ + TAPI_SIM_UST_SMS, /**< short message storage */ + TAPI_SIM_UST_SMS_STATUS_REPORTS, /**< short message status reports */ + TAPI_SIM_UST_SMS_PARAMS, /**< sms parameteres */ + TAPI_SIM_UST_AOC, /**< advice of charge */ + TAPI_SIM_UST_CCP, /**< capability configuration parameters */ + TAPI_SIM_UST_CELL_BROADCAST_MSG_ID, /**< cell broadcast message identifier */ + TAPI_SIM_UST_CELL_BROADCAST_MSG_ID_RANGES, /**< cell broadcast message identifier ranges */ + + // service 17 ~ 24 + TAPI_SIM_UST_GID_LV1 = 16, /**< group identifier level 1 */ + TAPI_SIM_UST_GID_LV2, /**< group identifier level 2 */ + TAPI_SIM_UST_SPN, /**< service provider name */ + TAPI_SIM_UST_USER_CTRLED_PLMN_SELECTOR_WACT, /**< user controlled PLMN selector with Access technology */ + TAPI_SIM_UST_MSISDN, /**< msisdn */ + TAPI_SIM_UST_IMG, /**< image */ + TAPI_SIM_UST_SOLSA, /**< support of local service area */ + TAPI_SIM_UST_ENHANCED_MULTI_LV_PRECEDENCE_PREEMPTION_SRVC, /**< enhanced multi-level precedence and pre-emption service */ + + // service 25 ~ 32 + TAPI_SIM_UST_AUTO_ANSWER_FOR_EMLPP = 24, /**< automatic answer fro eMLPP */ + TAPI_SIM_UST_RFU1, /**< rfu */ + TAPI_SIM_UST_GSM_ACCESS, /**< gsm access */ + TAPI_SIM_UST_DATA_DOWNLOAD_VIA_SMS_PP, /**< data download via sms-pp */ + TAPI_SIM_UST_DATA_DOWNLOAD_VIA_SMS_CB, /**< data download via sms-cb */ + TAPI_SIM_UST_CALL_CTRL, /**< call control by usim*/ + TAPI_SIM_UST_MO_SMS_CTRL, /**< mobile-originated short message control by usim */ + TAPI_SIM_UST_RUN_AT_CMD_CMD, /**< RUN AT COMMAND command */ + + // service 33 ~ 40 + TAPI_SIM_UST_SHALL_BE_SET_TO_ONE = 32, /**< shall be set to 1 */ + TAPI_SIM_UST_ENABLED_SRVC_TABLE, /**< enabled service table */ + TAPI_SIM_UST_ACL, /**< APN control list */ + TAPI_SIM_UST_DEPERSONALIZATION_CTRL_KEYS, /**< de-personalization control keys */ + TAPI_SIM_UST_COOPERATIVE_NETWORK_LIST, /**< co-operative network list */ + TAPI_SIM_UST_GSM_SEC_CONTEXT, /**< gsm security context */ + TAPI_SIM_UST_CPBCCH_INFO, /**< CPBCCH information */ + TAPI_SIM_UST_INVESTIGATION_SCAN, /**< investigation scan */ + + // service 41 ~ 48 + TAPI_SIM_UST_MEXE = 40, /**< MExE */ + TAPI_SIM_UST_OPERATOR_CTRLED_PLMN_SELECTOR_WACT, /**< operator controlled PLMN selector with Access technology */ + TAPI_SIM_UST_HPLMN_SELECTOR_WACT, /**< HPLMN selector with access technology */ + TAPI_SIM_UST_EXT5, /**< extension 5 */ + TAPI_SIM_UST_PLMN_NETWORK_NAME, /*PLMN Network Name*/ + TAPI_SIM_UST_OPERATOR_PLMN_LIST, /*Operator PLMN List*/ + TAPI_SIM_UST_MBDN, /*Mailbox Dialling Numbers*/ + TAPI_SIM_UST_MWIS, /*Message Waiting Indication Status*/ + + // service 49 ~ 56 + TAPI_SIM_UST_CFIS = 48, /*Call Forwarding Indication Status*/ + TAPI_SIM_UST_RPLMN_LAST_USED_ACCESS_TECH, /**< RPLMN last used access technology */ + TAPI_SIM_UST_SPDI, /*Service Provider Display Information*/ + TAPI_SIM_UST_MMS, /**< multi media messaging service */ + TAPI_SIM_UST_EXT8, /**< extension 8 */ + TAPI_SIM_UST_CALL_CTRL_ON_GPRS, /**< call control on gprs by usim */ + TAPI_SIM_UST_MMS_USER_CONNECTIVITY_PARAMS, /**< mms user connectivity parameters */ + TAPI_SIM_UST_NIA, /**< network's indication of alerting in the MS (NIA) */ + + // service 57 ~ 64 + TAPI_SIM_UST_VGCS_GID_LIST = 56, /**< vgcs group identifier List (EF-VGCS, EF-VGCSS) */ + TAPI_SIM_UST_VBS_GID_LIST, /**< vbs group identifier List (EF-VBS, EF-VBSS) */ + TAPI_SIM_UST_PSEUDONYM, + TAPI_SIM_UST_USER_CTRLED_PLMN_SELECTOR_IWLAN, /**< user controlled PLMN selector for I-WLAN access */ + TAPI_SIM_UST_OPERATOR_CTRLED_PLMN_SELECTOR_IWLAN, /**< operator controlled PLMN selector for I-WLAN access */ + TAPI_SIM_UST_USER_CTRLED_WSID_LIST, + TAPI_SIM_UST_OPERATOR_CTRLED_WSID_LIST, + TAPI_SIM_UST_VGCS_SEC, +} TelSimUSTService_t; + +typedef struct { + char service[TAPI_SIM_SST_SERVICE_CNT_MAX]; // should access with 'enum TelSimSSTService_t' as index +} TelSimSST_t; + +typedef struct { + char service[TAPI_SIM_UST_SERVICE_CNT_MAX]; // should access with 'enum TelSimUSTService_t' as index +} TelSimUST_t; + +typedef struct { + TelSimCardType_t sim_type; + union { + TelSimSST_t sst; + TelSimUST_t ust; + } table; +} TelSimServiceTable_t; + +/** + * This data structure defines the data for the Imsi information. + */ +typedef struct { + char szMcc[3 + 1]; /**< mobile country code */ + char szMnc[3 + 1]; /**< mobile network code */ + char szMsin[10 + 1]; /**< mobile station identification number */ +} TelSimImsiInfo_t; + +typedef struct { + char name[30+1]; + char number[6+1]; + TelSimEccEmergencyServiceInfo_t category; +}TelSimEcc_t; + +typedef struct { + int ecc_count; + TelSimEcc_t list[15]; +}TelSimEccList_t; + +typedef struct { + int icc_length; /**< Integrated Circuit Card number length */ + char icc_num[TAPI_SIM_ICCID_LEN_MAX]; /**< Integrated Circuit Card number */ +} TelSimIccIdInfo_t; + +typedef struct { + int b_cphs; + int rec_index; /**< index which stands for the location where record is saved in SIM*/ + int profile_num; /**< SIM profile index*/ + TelSimMailboxType_t mb_type; + int alpha_id_max_len; /**< alpha max length in SIM - READ ONLY*/ + char alpha_id[TAPI_SIM_XDN_ALPHA_ID_MAX_LEN + 1]; /**< Alpha Identifier */ + TelSimTypeOfNum_t ton; /**< Type Of Number */ + TelSimNumberingPlanIdentity_t npi; /**< Number Plan Identity */ + char num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1]; /**< Dialing Number/SSC String */ + unsigned char cc_id; /**< Capability/Configuration Identifier */ + unsigned char ext1_id; /**< Extensiion1 Record Identifier */ +}TelSimMailBoxNumber_t; + +typedef struct { + int count; + TelSimMailBoxNumber_t list[TAPI_SIM_MSP_CNT_MAX*5]; //max is 10 +}TelSimMailboxList_t; + +typedef struct { + int rec_index; + unsigned char msp_num; /**< MSP number*/ + unsigned char cfu_status; /**< call forwarding unconditional indication status*/ + TelSimTypeOfNum_t ton; /**< TON*/ + TelSimNumberingPlanIdentity_t npi; /**< NPI*/ + char cfu_num[TAPI_SIM_XDN_DIALING_NUMBER_LEN + 1];/**< Dialing Number/SSC String*/ + unsigned char cc2_id; /**< Capability/Configuration2 Record Identifier */ + unsigned char ext7_id; /**< Extension 7 Record Identifier */ +}TelSimCfis_t; + +typedef struct { + int profile_count; + TelSimCfis_t cf[TAPI_SIM_MSP_CNT_MAX]; +}TelSimCfisList_t; + +typedef struct { + int b_line1; /**< CallForwardUnconditionalLine 1 */ + int b_line2; /**< CallForwardUnconditionalLine 2 */ + int b_fax; /**< CallForwardUnconditional FAX */ + int b_data; /** + * + * 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. + */ + +/** + * @open + * @ingroup TelephonyAPI + * @addtogroup SS_TAPI SS(Supplementary services) + * @{ + * + * @file TelSs.h + + @brief This file serves as a "C" header file and defines structures for Tapi Supplementary Services\n + It contains a sample set of constants, enums, structs that would be required by applications. + */ + +#ifndef _TEL_SS_H_ +#define _TEL_SS_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** maximum length of barring password */ +#define TAPI_SS_GSM_BARR_PW_LEN_MAX 4 /** +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "TelSat.h" +#include "sat_ui_support.h" +#include "package-manager.h" + +struct sat_ui_app_launch_data { + bundle *bundle_data; /**bundle_data) { + err("bundle_data not present"); + goto EXIT; + } + if(!app_data->slot_info) { + err("slot_info not present"); + goto EXIT; + } + + for (i=0; islot_info , "0")){ + dbg("slot 0"); + rv = aul_launch_app("org.tizen.sat-ui", app_data->bundle_data); + } else if (g_str_has_suffix(app_data->slot_info , "1")){ + dbg("slot 1"); + rv = aul_launch_app("org.tizen.sat-ui-2", app_data->bundle_data); + } else { + err("invalid sim slot id"); + break; + } + + dbg("AUL return value:[%d]", rv); + if ((rv == AUL_R_ECOMM) || (rv == AUL_R_ETERMINATING)) { + err("Need to retry."); + usleep(RELAUNCH_INTERVAL); + } else { + dbg("AUL launches SAT UI app"); + break; + } + } + +EXIT: + if (app_data) { + bundle_free(app_data->bundle_data); + g_free(app_data->slot_info); + g_free(app_data); + app_data = NULL; + } + return NULL; +} + +static gboolean __dispatch_on_new_thread(gchar *name, GThreadFunc thread_cb, gpointer thread_data) +{ + GThread *thread; + if (!name || !thread_cb) { + err("Wrong Input Parameter"); + return FALSE; + } + thread = g_thread_new(name, thread_cb, thread_data); + if (thread == NULL){ + return FALSE; + }else{ + dbg("Thread %p is created for %s", thread, name); + } + + return TRUE; +} + +static gboolean __sat_ui_support_app_launch(bundle *bundle_data, char *slot_info) +{ + struct sat_ui_app_launch_data *app_data = NULL; + + app_data= g_malloc0(sizeof(struct sat_ui_app_launch_data)); + if (!app_data) { + err("malloc failed"); + return FALSE; + } + app_data->bundle_data = bundle_data; + app_data->slot_info = g_strdup(slot_info); + + if (FALSE == __dispatch_on_new_thread((gchar *)"SAT UI app", __launch_sat_ui_app, (gpointer)app_data)) { + err("Unable to create thread"); + bundle_free(app_data->bundle_data); + g_free(app_data->slot_info); + g_free(app_data); + app_data = NULL; + return FALSE; + } + return TRUE; +} + +static gboolean _sat_ui_support_processing_setup_menu_ind(GVariant *data, char *slot_info) +{ + gboolean rv = FALSE; + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd_type = NULL; + TelSatSetupMenuInfo_t setup_menu; + + gchar *title = NULL; + gint command_id, item_cnt; + gboolean b_present, b_helpinfo, b_updated; + GVariant *items = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id, *icon_list; + int local_index = 0, icon_index = 0; + /* Used to get menu items */ + GVariant *unbox; + GVariantIter *iter, *iter2; + gchar *item_str; + gint item_id; + /* Used to get icon data */ + gboolean is_exist; + gint icon_quali, icon_identifier, width, height, ics, icon_data_len; + gchar *icon_data = NULL; + /* Used to get icon list data */ + GVariant *unbox_list, *unbox_list_info ; + GVariant *icon_list_info; + gboolean is_list_exist; + gint icon_list_quali, list_cnt, icon_list_identifier, list_width, list_height, list_ics, icon_list_data_len; + gchar *icon_list_data = NULL; +#else + int local_index = 0; + GVariant *unbox; + GVariantIter *iter; + gchar *item_str; + gint item_id; +#endif + memset(&setup_menu, 0, sizeof(TelSatSetupMenuInfo_t)); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(ibs@vibb@v@v)", &command_id, &b_present, &title, &items, &item_cnt, + &b_helpinfo, &b_updated, &icon_id, &icon_list); +#else + g_variant_get(data, "(ibs@vibb)", &command_id, &b_present, &title, &items, &item_cnt, + &b_helpinfo, &b_updated); +#endif + setup_menu.commandId = command_id; + setup_menu.bIsMainMenuPresent = (b_present ? 1 : 0); + memcpy(setup_menu.satMainTitle, title, TAPI_SAT_DEF_TITLE_LEN_MAX+1); + g_free(title); + + setup_menu.satMainMenuNum = item_cnt; + if(items && item_cnt > 0){ + unbox = g_variant_get_variant(items); + dbg("items(%p) items type_format(%s)", items, g_variant_get_type_string(unbox)); + + g_variant_get(unbox, "a(si)", &iter); + while(g_variant_iter_loop(iter,"(si)",&item_str, &item_id)){ + setup_menu.satMainMenuItem[local_index].itemId = item_id; + memcpy(setup_menu.satMainMenuItem[local_index].itemString, item_str, TAPI_SAT_DEF_ITEM_STR_LEN_MAX + 6); + local_index++; + } + g_variant_iter_free(iter); + } + setup_menu.bIsSatMainMenuHelpInfo = (b_helpinfo ? 1 : 0); + setup_menu.bIsUpdatedSatMainMenu = (b_updated ? 1 : 0); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + if(icon_id) { + unbox = g_variant_get_variant(icon_id); + g_variant_get(unbox, "a(biiiiiis)", &iter); + + while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)){ + if(!is_exist) + break; + setup_menu.iconId.bIsPresent = is_exist; + setup_menu.iconId.iconQualifier = icon_quali; + setup_menu.iconId.iconIdentifier = icon_identifier; + setup_menu.iconId.iconInfo.width = width; + setup_menu.iconId.iconInfo.height = height; + setup_menu.iconId.iconInfo.ics = ics; + if(icon_data_len > 0) { + setup_menu.iconId.iconInfo.iconDataLen = icon_data_len; + memcpy(setup_menu.iconId.iconInfo.iconFile, icon_data, icon_data_len); + } + dbg("icon exist(%d), icon_quali: (%d), icon_id: (%d), width: (%d), height: (%d), ics: (%d), icon_data_len: (%d)", setup_menu.iconId.bIsPresent, setup_menu.iconId.iconQualifier, setup_menu.iconId.iconIdentifier, setup_menu.iconId.iconInfo.width, + setup_menu.iconId.iconInfo.height, setup_menu.iconId.iconInfo.ics, setup_menu.iconId.iconInfo.iconDataLen); + } + g_variant_iter_free(iter); + } + + if(icon_list){ + unbox_list = g_variant_get_variant(icon_list); + g_variant_get(unbox_list, "a(biiv)", &iter); + + while(g_variant_iter_loop(iter,"(biiv)", &is_list_exist, &icon_list_quali, &list_cnt, &icon_list_info)){ + if(!is_list_exist) + break; + setup_menu.iconIdList.bIsPresent = is_list_exist; + setup_menu.iconIdList.iconListQualifier = icon_list_quali; + setup_menu.iconIdList.iconCount = list_cnt; + + unbox_list_info = g_variant_get_variant(icon_list_info); + g_variant_get(unbox_list_info, "a(iiiiis)", &iter2); + + while(g_variant_iter_loop(iter2,"(iiiiis)",&icon_list_identifier, &list_width, &list_height, &list_ics, &icon_list_data_len, &icon_list_data)){ + setup_menu.iconIdList.iconIdentifierList[icon_index]= icon_identifier; + setup_menu.iconIdList.iconInfo[icon_index].width = list_width; + setup_menu.iconIdList.iconInfo[icon_index].height = list_height; + setup_menu.iconIdList.iconInfo[icon_index].ics = list_ics; + if(icon_list_data_len > 0) { + setup_menu.iconIdList.iconInfo[icon_index].iconDataLen = icon_list_data_len; + memcpy(setup_menu.iconIdList.iconInfo[icon_index].iconFile, icon_list_data, icon_list_data_len); + } + icon_index++; + } + g_variant_iter_free(iter2); + } + g_variant_iter_free(iter); + } +#endif + cmd_type = g_strdup_printf("%d", SAT_PROATV_CMD_SETUP_MENU); + encoded_data = g_base64_encode((const guchar*)&setup_menu, sizeof(TelSatSetupMenuInfo_t)); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + bundle_add(bundle_data, "data", encoded_data); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = __sat_ui_support_app_launch(bundle_data, slot_info); + + g_free(encoded_data); + g_free(cmd_type); + + return rv; +} + +static gboolean _sat_ui_support_processing_display_text_ind(GVariant *data, char *slot_info) +{ + gboolean rv = FALSE; + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd_type = NULL; + TelSatDisplayTextInd_t display_text; + + gchar* text = NULL; + gint command_id, text_len, duration; + gboolean high_priority, user_rsp_required, immediately_rsp; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; + GVariant *unbox = NULL; + gboolean is_exist; + gint icon_quali, icon_identifier, width, height, ics, icon_data_len; + gchar *icon_data = NULL; + GVariantIter *iter; +#endif + memset(&display_text, 0, sizeof(TelSatDisplayTextInd_t)); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isiibbb@v)", &command_id, &text, &text_len, &duration, + &high_priority, &user_rsp_required, &immediately_rsp, &icon_id); +#else + g_variant_get(data, "(isiibbb)", &command_id, &text, &text_len, &duration, + &high_priority, &user_rsp_required, &immediately_rsp); +#endif + display_text.commandId = command_id; + memcpy(display_text.text.string, text, TAPI_SAT_DEF_TEXT_STRING_LEN_MAX+1); + g_free(text); + + display_text.text.stringLen = text_len; + display_text.duration = duration; + display_text.bIsPriorityHigh = (high_priority ? 1 : 0); + display_text.bIsUserRespRequired = (user_rsp_required ? 1 : 0); + display_text.b_immediately_resp = (immediately_rsp ? 1 : 0); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + if(icon_id) { + unbox = g_variant_get_variant(icon_id); + g_variant_get(unbox, "a(biiiiiis)", &iter); + + while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)) { + if(!is_exist) + break; + display_text.iconId.bIsPresent = is_exist; + display_text.iconId.iconQualifier = icon_quali; + display_text.iconId.iconIdentifier = icon_identifier; + display_text.iconId.iconInfo.width = width; + display_text.iconId.iconInfo.height = height; + display_text.iconId.iconInfo.ics = ics; + if(icon_data_len > 0) { + display_text.iconId.iconInfo.iconDataLen = icon_data_len; + memcpy(display_text.iconId.iconInfo.iconFile, icon_data, icon_data_len); + } + dbg("icon exist(%d), icon_quali: (%d), icon_id: (%d), width: (%d), height: (%d), ics: (%d), icon_data_len: (%d)", display_text.iconId.bIsPresent, display_text.iconId.iconQualifier, display_text.iconId.iconIdentifier, display_text.iconId.iconInfo.width, + display_text.iconId.iconInfo.height, display_text.iconId.iconInfo.ics, display_text.iconId.iconInfo.iconDataLen); + } + g_variant_iter_free(iter); + } +#endif + dbg("duration(%d) user_rsp(%d) immediately_rsp(%d)", duration, user_rsp_required, immediately_rsp); + + cmd_type = g_strdup_printf("%d", SAT_PROATV_CMD_DISPLAY_TEXT); + encoded_data = g_base64_encode((const guchar*)&display_text, sizeof(TelSatDisplayTextInd_t)); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + bundle_add(bundle_data, "data", encoded_data); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = __sat_ui_support_app_launch(bundle_data, slot_info); + + g_free(encoded_data); + g_free(cmd_type); + + return rv; +} + +static gboolean _sat_ui_support_processing_select_item_ind(GVariant *data, char *slot_info) +{ + gboolean rv = FALSE; + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd_type = NULL; + TelSatSelectItemInd_t select_item; + + gboolean help_info ; + gchar *selected_text = NULL; + gint command_id, default_item_id, menu_cnt, text_len =0; + GVariant *menu_items; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id, *icon_list; + int local_index = 0, icon_index = 0; + /* Used to get menu items */ + GVariant *unbox; + GVariantIter *iter, *iter2; + gchar *item_str; + gint item_id, item_len; + /* Used to get icon data */ + gboolean is_exist; + gint icon_quali, icon_identifier, width, height, ics, icon_data_len; + gchar *icon_data = NULL; + /* Used to get icon list data */ + GVariant *unbox_list, *unbox_list_info ; + GVariant *icon_list_info; + gboolean is_list_exist; + gint icon_list_quali, list_cnt, icon_list_identifier, list_width, list_height, list_ics, icon_list_data_len; + gchar *icon_list_data = NULL; +#else + int local_index = 0; + GVariant *unbox; + GVariantIter *iter; + gchar *item_str; + gint item_id, item_len; +#endif + memset(&select_item, 0, sizeof(TelSatSelectItemInd_t)); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(ibsiii@v@v@v)", &command_id, &help_info, &selected_text, + &text_len, &default_item_id, &menu_cnt, &menu_items, &icon_id, &icon_list); +#else + g_variant_get(data, "(ibsiii@v)", &command_id, &help_info, &selected_text, + &text_len, &default_item_id, &menu_cnt, &menu_items); +#endif + select_item.commandId = command_id; + select_item.bIsHelpInfoAvailable = (help_info ? 1 : 0); + memcpy(select_item.text.string, selected_text, TAPI_SAT_DEF_TEXT_STRING_LEN_MAX+1); + g_free(selected_text); + + select_item.text.stringLen = text_len; + select_item.defaultItemIndex = default_item_id; + select_item.menuItemCount = menu_cnt; + if(menu_items && menu_cnt > 0){ + unbox = g_variant_get_variant(menu_items); + dbg("items(%p) items type_format(%s)", menu_items, g_variant_get_type_string(unbox)); + + g_variant_get(unbox, "a(iis)", &iter); + while(g_variant_iter_loop(iter,"(iis)",&item_id, &item_len, &item_str)){ + select_item.menuItem[local_index].itemId = item_id; + select_item.menuItem[local_index].textLen = item_len; + memcpy(select_item.menuItem[local_index].text, item_str, TAPI_SAT_ITEM_TEXT_LEN_MAX + 1); + local_index++; + } + g_variant_iter_free(iter); + } + +#if defined(TIZEN_SUPPORT_SAT_ICON) + if(icon_id) { + unbox = g_variant_get_variant(icon_id); + g_variant_get(unbox, "a(biiiiiis)", &iter); + + while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)) { + if(!is_exist) + break; + select_item.iconId.bIsPresent = is_exist; + select_item.iconId.iconQualifier = icon_quali; + select_item.iconId.iconIdentifier = icon_identifier; + select_item.iconId.iconInfo.width = width; + select_item.iconId.iconInfo.height = height; + select_item.iconId.iconInfo.ics = ics; + if(icon_data_len > 0) { + select_item.iconId.iconInfo.iconDataLen = icon_data_len; + memcpy(select_item.iconId.iconInfo.iconFile, icon_data, icon_data_len); + } + dbg("icon exist(%d), icon_quali: (%d), icon_id: (%d), width: (%d), height: (%d), ics: (%d), icon_data_len: (%d)", select_item.iconId.bIsPresent, select_item.iconId.iconQualifier, select_item.iconId.iconIdentifier, select_item.iconId.iconInfo.width, + select_item.iconId.iconInfo.height, select_item.iconId.iconInfo.ics, select_item.iconId.iconInfo.iconDataLen); + } + g_variant_iter_free(iter); + } + + if(icon_list){ + unbox_list = g_variant_get_variant(icon_list); + g_variant_get(unbox_list, "a(biiv)", &iter); + + while(g_variant_iter_loop(iter,"(biiv)", &is_list_exist, &icon_list_quali, &list_cnt, &icon_list_info)) { + if(!is_list_exist) + break; + select_item.iconIdList.bIsPresent = is_list_exist; + select_item.iconIdList.iconListQualifier = icon_list_quali; + select_item.iconIdList.iconCount = list_cnt; + + unbox_list_info = g_variant_get_variant(icon_list_info); + g_variant_get(unbox_list_info, "a(iiiiis)", &iter2); + + while(g_variant_iter_loop(iter2,"(iiiiis)",&icon_list_identifier, &list_width, &list_height, &list_ics, &icon_list_data_len, &icon_list_data)){ + select_item.iconIdList.iconIdentifierList[icon_index]= icon_identifier; + select_item.iconIdList.iconInfo[icon_index].width = list_width; + select_item.iconIdList.iconInfo[icon_index].height = list_height; + select_item.iconIdList.iconInfo[icon_index].ics = list_ics; + if(icon_list_data_len > 0) { + select_item.iconIdList.iconInfo[icon_index].iconDataLen = icon_list_data_len; + memcpy(select_item.iconIdList.iconInfo[icon_index].iconFile, icon_list_data, icon_list_data_len); + } + icon_index++; + } + g_variant_iter_free(iter2); + } + g_variant_iter_free(iter); + } +#endif + cmd_type = g_strdup_printf("%d", SAT_PROATV_CMD_SELECT_ITEM); + encoded_data = g_base64_encode((const guchar*)&select_item, sizeof(TelSatSelectItemInd_t)); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + bundle_add(bundle_data, "data", encoded_data); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = __sat_ui_support_app_launch(bundle_data, slot_info); + + g_free(encoded_data); + g_free(cmd_type); + + return rv; +} + +static gboolean _sat_ui_support_processing_get_inkey_ind(GVariant *data, char *slot_info) +{ + gboolean rv = FALSE; + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd_type = NULL; + TelSatGetInkeyInd_t get_inkey; + + gint command_id, key_type, input_character_mode; + gint text_len, duration; + gboolean b_numeric, b_help_info; + gchar *text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; + GVariant *unbox = NULL; + gboolean is_exist; + gint icon_quali, icon_identifier, width, height, ics, icon_data_len; + gchar *icon_data = NULL; + GVariantIter *iter; +#endif + memset(&get_inkey, 0, sizeof(TelSatGetInkeyInd_t)); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(iiibbsii@v)", &command_id, &key_type, &input_character_mode, + &b_numeric,&b_help_info, &text, &text_len, &duration, &icon_id); +#else + g_variant_get(data, "(iiibbsii)", &command_id, &key_type, &input_character_mode, + &b_numeric,&b_help_info, &text, &text_len, &duration); +#endif + get_inkey.commandId = command_id; + get_inkey.keyType = key_type; + get_inkey.inputCharMode = input_character_mode; + get_inkey.bIsNumeric = (b_numeric ? 1 : 0); + get_inkey.bIsHelpInfoAvailable = (b_help_info ? 1 : 0); + memcpy(get_inkey.text.string, text, TAPI_SAT_DEF_TEXT_STRING_LEN_MAX+1); + g_free(text); + + get_inkey.text.stringLen = text_len; + get_inkey.duration = duration; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + if(icon_id) { + unbox = g_variant_get_variant(icon_id); + g_variant_get(unbox, "a(biiiiiis)", &iter); + + while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)) { + if(!is_exist) + break; + get_inkey.iconId.bIsPresent = is_exist; + get_inkey.iconId.iconQualifier = icon_quali; + get_inkey.iconId.iconIdentifier = icon_identifier; + get_inkey.iconId.iconInfo.width = width; + get_inkey.iconId.iconInfo.height = height; + get_inkey.iconId.iconInfo.ics = ics; + if(icon_data_len > 0) { + get_inkey.iconId.iconInfo.iconDataLen = icon_data_len; + memcpy(get_inkey.iconId.iconInfo.iconFile, icon_data, icon_data_len); + } + dbg("icon exist(%d), icon_quali: (%d), icon_id: (%d), width: (%d), height: (%d), ics: (%d), icon_data_len: (%d)", get_inkey.iconId.bIsPresent, get_inkey.iconId.iconQualifier, get_inkey.iconId.iconIdentifier, get_inkey.iconId.iconInfo.width, + get_inkey.iconId.iconInfo.height, get_inkey.iconId.iconInfo.ics, get_inkey.iconId.iconInfo.iconDataLen); + } + g_variant_iter_free(iter); + } +#endif + cmd_type = g_strdup_printf("%d", SAT_PROATV_CMD_GET_INKEY); + encoded_data = g_base64_encode((const guchar*)&get_inkey, sizeof(TelSatGetInkeyInd_t)); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + bundle_add(bundle_data, "data", encoded_data); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = __sat_ui_support_app_launch(bundle_data, slot_info); + + g_free(encoded_data); + g_free(cmd_type); + + return rv; +} + +static gboolean _sat_ui_support_processing_get_input_ind(GVariant *data, char *slot_info) +{ + gboolean rv = FALSE; + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd_type = NULL; + TelSatGetInputInd_t get_input; + + gint command_id, input_character_mode; + gint text_len, def_text_len, rsp_len_min, rsp_len_max; + gboolean b_numeric, b_help_info, b_echo_input; + gchar *text = NULL, *def_text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; + GVariant *unbox = NULL; + gboolean is_exist; + gint icon_quali, icon_identifier, width, height, ics, icon_data_len; + gchar *icon_data = NULL; + GVariantIter *iter; +#endif + memset(&get_input, 0, sizeof(TelSatGetInputInd_t)); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(iibbbsiiisi@v)", &command_id, &input_character_mode, &b_numeric, &b_help_info, &b_echo_input, + &text, &text_len, &rsp_len_max, &rsp_len_min, &def_text, &def_text_len, &icon_id); +#else + g_variant_get(data, "(iibbbsiiisi)", &command_id, &input_character_mode, &b_numeric, &b_help_info, &b_echo_input, + &text, &text_len, &rsp_len_max, &rsp_len_min, &def_text, &def_text_len); +#endif + get_input.commandId = command_id; + get_input.inputCharMode = input_character_mode; + get_input.bIsNumeric = (b_numeric ? 1 : 0); + get_input.bIsHelpInfoAvailable = (b_help_info ? 1 : 0); + get_input.bIsEchoInput = (b_echo_input ? 1 : 0); + memcpy(get_input.text.string, text, TAPI_SAT_DEF_TEXT_STRING_LEN_MAX+1); + get_input.text.stringLen = text_len; + get_input.respLen.max = rsp_len_max; + get_input.respLen.min = rsp_len_min; + memcpy(get_input.defaultText.string, def_text, TAPI_SAT_DEF_TEXT_STRING_LEN_MAX+1); + get_input.defaultText.stringLen = def_text_len; + g_free(text); + g_free(def_text); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + if(icon_id) { + unbox = g_variant_get_variant(icon_id); + g_variant_get(unbox, "a(biiiiiis)", &iter); + + while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)) { + if(!is_exist) + break; + get_input.iconId.bIsPresent = is_exist; + get_input.iconId.iconQualifier = icon_quali; + get_input.iconId.iconIdentifier = icon_identifier; + get_input.iconId.iconInfo.width = width; + get_input.iconId.iconInfo.height = height; + get_input.iconId.iconInfo.ics = ics; + if(icon_data_len > 0) { + get_input.iconId.iconInfo.iconDataLen = icon_data_len; + memcpy(get_input.iconId.iconInfo.iconFile, icon_data, icon_data_len); + } + dbg("icon exist(%d), icon_quali: (%d), icon_id: (%d), width: (%d), height: (%d), ics: (%d), icon_data_len: (%d)", get_input.iconId.bIsPresent, get_input.iconId.iconQualifier, get_input.iconId.iconIdentifier, get_input.iconId.iconInfo.width, + get_input.iconId.iconInfo.height, get_input.iconId.iconInfo.ics, get_input.iconId.iconInfo.iconDataLen); + } + g_variant_iter_free(iter); + } +#endif + cmd_type = g_strdup_printf("%d", SAT_PROATV_CMD_GET_INPUT); + encoded_data = g_base64_encode((const guchar*)&get_input, sizeof(TelSatGetInputInd_t)); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + bundle_add(bundle_data, "data", encoded_data); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = __sat_ui_support_app_launch(bundle_data, slot_info); + + g_free(encoded_data); + g_free(cmd_type); + + return rv; +} + +static gboolean _sat_ui_support_processing_refresh_ind(GVariant *data, char *slot_info) +{ + gboolean rv = FALSE; + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd_type = NULL; + TelSatRefreshIndUiInfo_t refresh_info; + + gint command_id = 0; + gint refresh_type =0; + GVariant *file_list = NULL; + + memset(&refresh_info, 0, sizeof(TelSatRefreshIndUiInfo_t)); + + dbg("refresh type_format(%s)", g_variant_get_type_string(data)); + g_variant_get(data, "(ii@v)", &command_id, &refresh_type, &file_list); + + refresh_info.commandId = command_id; + + refresh_info.duration = 3000; + +#if defined(TIZEN_SUPPORT_STK_HIDE_ALPHA_ID) + refresh_info.duration = 0; +#endif + + refresh_info.refreshType = refresh_type; + + cmd_type = g_strdup_printf("%d", SAT_PROATV_CMD_REFRESH); + encoded_data = g_base64_encode((const guchar*)&refresh_info, sizeof(TelSatRefreshIndUiInfo_t)); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + bundle_add(bundle_data, "data", encoded_data); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = __sat_ui_support_app_launch(bundle_data, slot_info); + + g_free(encoded_data); + g_free(cmd_type); + + return rv; +} + +static gboolean _sat_ui_support_processing_play_tone_ind(GVariant *data, char *slot_info) +{ + gboolean rv = FALSE; + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd_type = NULL; + TelSatPlayToneInd_t play_tone_info; + + gint command_id, tone_type, duration; + gint text_len; + gchar* text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; + GVariant *unbox = NULL; + gboolean is_exist; + gint icon_quali, icon_identifier, width, height, ics, icon_data_len; + gchar *icon_data = NULL; + GVariantIter *iter; +#endif + memset(&play_tone_info, 0, sizeof(TelSatPlayToneInd_t)); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &tone_type, &duration); +#else + g_variant_get(data, "(isiii)", &command_id, &text, &text_len, &tone_type, &duration); +#endif + play_tone_info.commandId = command_id; + play_tone_info.duration = duration; + play_tone_info.text.stringLen = text_len; + memcpy(play_tone_info.text.string, text, TAPI_SAT_DEF_TEXT_STRING_LEN_MAX+1); + g_free(text); + + play_tone_info.tone.type = tone_type; + +#if defined(TIZEN_SUPPORT_SAT_ICON) + if(icon_id) { + unbox = g_variant_get_variant(icon_id); + g_variant_get(unbox, "a(biiiiiis)", &iter); + + while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)) { + if(!is_exist) + break; + play_tone_info.iconId.bIsPresent = is_exist; + play_tone_info.iconId.iconQualifier = icon_quali; + play_tone_info.iconId.iconIdentifier = icon_identifier; + play_tone_info.iconId.iconInfo.width = width; + play_tone_info.iconId.iconInfo.height = height; + play_tone_info.iconId.iconInfo.ics = ics; + if(icon_data_len > 0) { + play_tone_info.iconId.iconInfo.iconDataLen = icon_data_len; + memcpy(play_tone_info.iconId.iconInfo.iconFile, icon_data, icon_data_len); + } + dbg("icon exist(%d), icon_quali: (%d), icon_id: (%d), width: (%d), height: (%d), ics: (%d), icon_data_len: (%d)", play_tone_info.iconId.bIsPresent, play_tone_info.iconId.iconQualifier, play_tone_info.iconId.iconIdentifier, play_tone_info.iconId.iconInfo.width, + play_tone_info.iconId.iconInfo.height, play_tone_info.iconId.iconInfo.ics, play_tone_info.iconId.iconInfo.iconDataLen); + } + g_variant_iter_free(iter); + } +#endif + cmd_type = g_strdup_printf("%d", SAT_PROATV_CMD_PLAY_TONE); + encoded_data = g_base64_encode((const guchar*)&play_tone_info, sizeof(TelSatPlayToneInd_t)); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + bundle_add(bundle_data, "data", encoded_data); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = __sat_ui_support_app_launch(bundle_data, slot_info); + + g_free(encoded_data); + g_free(cmd_type); + + return rv; +} + +static gboolean _sat_ui_support_processing_idle_mode_text_ind(GVariant *data, char *slot_info) +{ + gboolean rv = FALSE; + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd_type = NULL; + TelSatSetupIdleModeTextInd_t idle_mode_text_info; + + gint command_id, text_len; + gchar* text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; + GVariant *unbox = NULL; + gboolean is_exist; + gint icon_quali, icon_identifier, width, height, ics, icon_data_len; + gchar *icon_data = NULL; + GVariantIter *iter; +#endif + memset(&idle_mode_text_info, 0, sizeof(TelSatSetupIdleModeTextInd_t)); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isi@v)", &command_id, &text, &text_len, &icon_id); +#else + g_variant_get(data, "(isi)", &command_id, &text, &text_len); +#endif + idle_mode_text_info.commandId = command_id; + idle_mode_text_info.text.stringLen = text_len; + memcpy(idle_mode_text_info.text.string, text, TAPI_SAT_DEF_TEXT_STRING_LEN_MAX+1); + g_free(text); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + if(icon_id) { + unbox = g_variant_get_variant(icon_id); + g_variant_get(unbox, "a(biiiiiis)", &iter); + + while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)) { + if(!is_exist) + break; + idle_mode_text_info.iconId.bIsPresent = is_exist; + idle_mode_text_info.iconId.iconQualifier = icon_quali; + idle_mode_text_info.iconId.iconIdentifier = icon_identifier; + idle_mode_text_info.iconId.iconInfo.width = width; + idle_mode_text_info.iconId.iconInfo.height = height; + idle_mode_text_info.iconId.iconInfo.ics = ics; + if(icon_data_len > 0) { + idle_mode_text_info.iconId.iconInfo.iconDataLen = icon_data_len; + memcpy(idle_mode_text_info.iconId.iconInfo.iconFile, icon_data, icon_data_len); + } + dbg("icon exist(%d), icon_quali: (%d), icon_id: (%d), width: (%d), height: (%d), ics: (%d), icon_data_len: (%d)", idle_mode_text_info.iconId.bIsPresent, idle_mode_text_info.iconId.iconQualifier, idle_mode_text_info.iconId.iconIdentifier, idle_mode_text_info.iconId.iconInfo.width, + idle_mode_text_info.iconId.iconInfo.height, idle_mode_text_info.iconId.iconInfo.ics, idle_mode_text_info.iconId.iconInfo.iconDataLen); + } + g_variant_iter_free(iter); + } +#endif + cmd_type = g_strdup_printf("%d", SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT); + encoded_data = g_base64_encode((const guchar*)&idle_mode_text_info, sizeof(TelSatSetupIdleModeTextInd_t)); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + bundle_add(bundle_data, "data", encoded_data); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = __sat_ui_support_app_launch(bundle_data, slot_info); + + g_free(encoded_data); + g_free(cmd_type); + + /* P130527-4589 (I8800): Megafone Russia SIM cards. + * Need to check for debug without execption handling. + */ + if (rv != TRUE) { + err("result is error"); + } + + return TRUE; +} + +static gboolean _sat_ui_support_processing_ui_info_ind(enum tel_sat_proactive_cmd_type cmd, GVariant *data, char *slot_info) +{ + gboolean rv = FALSE; + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd_type = NULL; + TelSatSendUiInfo_t ui_info; + + gint command_id, text_len; + gboolean user_confirm; + gchar *text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *unbox = NULL; + gboolean is_exist; + gint icon_quali, icon_identifier, width, height, ics, icon_data_len; + gchar *icon_data = NULL; + GVariant *icon_id = NULL; + GVariantIter *iter; +#endif + memset(&ui_info, 0, sizeof(TelSatSendUiInfo_t)); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isib@v)", &command_id, &text, &text_len, &user_confirm, &icon_id); +#else + g_variant_get(data, "(isib)", &command_id, &text, &text_len, &user_confirm); +#endif + dbg("command_id(%d) data(%s) len(%d) user_confirm(%d)", command_id, text, text_len, user_confirm); + + ui_info.commandId = command_id; + memcpy(ui_info.text.string, text, TAPI_SAT_DEF_TEXT_STRING_LEN_MAX+1); + g_free(text); + + ui_info.text.stringLen = text_len; + ui_info.user_confirm = (user_confirm ? 1 : 0); + +#if defined(TIZEN_SUPPORT_SAT_ICON) + if(icon_id) { + unbox = g_variant_get_variant(icon_id); + g_variant_get(unbox, "a(biiiiiis)", &iter); + + while(g_variant_iter_loop(iter,"(biiiiiis)", &is_exist, &icon_quali, &icon_identifier, &width, &height, &ics, &icon_data_len, &icon_data)) { + if(!is_exist) + break; + ui_info.iconId.bIsPresent = is_exist; + ui_info.iconId.iconQualifier = icon_quali; + ui_info.iconId.iconIdentifier = icon_identifier; + ui_info.iconId.iconInfo.width = width; + ui_info.iconId.iconInfo.height = height; + ui_info.iconId.iconInfo.ics = ics; + if(icon_data_len > 0) { + ui_info.iconId.iconInfo.iconDataLen = icon_data_len; + memcpy(ui_info.iconId.iconInfo.iconFile, icon_data, icon_data_len); + } + dbg("icon exist(%d), icon_quali: (%d), icon_id: (%d), width: (%d), height: (%d), ics: (%d), icon_data_len: (%d)", ui_info.iconId.bIsPresent, ui_info.iconId.iconQualifier, ui_info.iconId.iconIdentifier, ui_info.iconId.iconInfo.width, + ui_info.iconId.iconInfo.height, ui_info.iconId.iconInfo.ics, ui_info.iconId.iconInfo.iconDataLen); + } + g_variant_iter_free(iter); + } +#endif + cmd_type = g_strdup_printf("%d", cmd); + encoded_data = g_base64_encode((const guchar*)&ui_info, sizeof(TelSatSendUiInfo_t)); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + bundle_add(bundle_data, "data", encoded_data); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = __sat_ui_support_app_launch(bundle_data, slot_info); + + g_free(encoded_data); + g_free(cmd_type); + + return rv; +} + +gboolean sat_ui_check_app_is_running(const char* app_id) +{ + gboolean rv = FALSE; + rv = aul_app_is_running(app_id); + dbg("check the app(%s) is running rv(%d)", app_id, rv); + return rv; +} + +gboolean sat_ui_support_terminate_sat_ui() +{ + gint rv; + bundle *bundle_data = 0; + gchar *cmd_type = NULL; + + cmd_type = g_strdup_printf("%d", SAT_PROATV_CMD_TYPE_END_PROACTIVE_SESSION); + + bundle_data = bundle_create(); + bundle_add(bundle_data, "KEY_EXEC_TYPE", "1"); + bundle_add(bundle_data, "cmd_type", cmd_type); + + rv = aul_launch_app("org.tizen.sat-ui", bundle_data); + dbg("session end aul (%d)", rv); + + bundle_free(bundle_data); + g_free(cmd_type); + + return TRUE; +} + +gboolean sat_ui_support_launch_sat_ui(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id) +{ + gboolean result = FALSE; + char slot_info[2] = {0,}; + + snprintf(slot_info, 2, "%d", slot_id); + dbg("slot_id : [%s]", slot_info); + + switch(cmd_type){ + case SAT_PROATV_CMD_NONE: + case SAT_PROATV_CMD_SEND_DTMF: + case SAT_PROATV_CMD_LAUNCH_BROWSER: + case SAT_PROATV_CMD_SEND_SMS: + result = _sat_ui_support_processing_ui_info_ind(cmd_type, data, slot_info); + break; + case SAT_PROATV_CMD_SETUP_MENU: + result = _sat_ui_support_processing_setup_menu_ind(data, slot_info); + break; + case SAT_PROATV_CMD_DISPLAY_TEXT: + result = _sat_ui_support_processing_display_text_ind(data, slot_info); + break; + case SAT_PROATV_CMD_SELECT_ITEM: + result = _sat_ui_support_processing_select_item_ind(data, slot_info); + break; + case SAT_PROATV_CMD_GET_INKEY: + result = _sat_ui_support_processing_get_inkey_ind(data, slot_info); + break; + case SAT_PROATV_CMD_GET_INPUT: + result = _sat_ui_support_processing_get_input_ind(data, slot_info); + break; + case SAT_PROATV_CMD_REFRESH: + result = _sat_ui_support_processing_refresh_ind(data, slot_info); + break; + case SAT_PROATV_CMD_PLAY_TONE: + result = _sat_ui_support_processing_play_tone_ind(data, slot_info); + break; + case SAT_PROATV_CMD_SETUP_IDLE_MODE_TEXT: + result = _sat_ui_support_processing_idle_mode_text_ind(data, slot_info); + break; + case SAT_PROATV_CMD_SETUP_EVENT_LIST: + break; + default: + dbg("does not need to launch sat-ui"); + break; + } + + return result; +} + +gboolean sat_ui_support_launch_call_application(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id) +{ + char buffer[300]; + char slot_info[2] = {0,}; + bundle *bundle_data = 0; + + dbg("launch call application by aul"); + bundle_data = bundle_create(); + + appsvc_set_operation(bundle_data, APPSVC_OPERATION_CALL); + appsvc_set_uri(bundle_data,"tel:MT"); + + switch(cmd_type){ + case SAT_PROATV_CMD_SETUP_CALL:{ + gint command_id, call_type, confirm_text_len, text_len, duration; + gchar *confirm_text = NULL, *text = NULL, *call_number = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + dbg("setup call type_format(%s)", g_variant_get_type_string(data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isisi@visi)", &command_id, &confirm_text, &confirm_text_len, &text, &text_len, &icon_id, &call_type, &call_number, &duration); +#else + g_variant_get(data, "(isisiisi)", &command_id, &confirm_text, &confirm_text_len, &text, &text_len, &call_type, &call_number, &duration); +#endif + appsvc_add_data(bundle_data, "launch-type","SATSETUPCALL"); + + snprintf(buffer, 300, "%d",command_id); + appsvc_add_data(bundle_data, "cmd_id",buffer); + dbg("cmd_id(%s)",buffer); + + snprintf(buffer, 300, "%d",call_type); + appsvc_add_data(bundle_data, "cmd_qual", buffer); + dbg("cmd_qual(%s)",buffer); + + snprintf(buffer, 300, "%s", text); + appsvc_add_data(bundle_data, "disp_text", buffer); + dbg("disp_text(%s)",buffer); + + snprintf(buffer, 300, "%s", call_number); + appsvc_add_data(bundle_data, "call_num", buffer); + dbg("call_num(%s)",buffer); + + snprintf(buffer, 300, "%d", duration); + appsvc_add_data(bundle_data, "dur", buffer); + dbg("dur(%s)",buffer); + + g_free(confirm_text); + g_free(text); + g_free(call_number); + } break; + + default: + bundle_free(bundle_data); + return FALSE; + break; + } + + snprintf(slot_info, 2, "%d", slot_id); + appsvc_add_data(bundle_data, "slot_id", slot_info); + dbg("slot_id : [%s]", slot_info); + + appsvc_run_service(bundle_data, 0, NULL, NULL); + dbg("call app is called"); + bundle_free(bundle_data); + + return TRUE; +} + +gboolean sat_ui_support_launch_browser_application(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id) +{ + char buffer[300]; + char slot_info[2] = {0,}; + bundle *bundle_data = 0; + + dbg("launch browser application by aul"); + bundle_data = bundle_create(); + + appsvc_set_pkgname(bundle_data, "org.tizen.browser"); + + switch(cmd_type){ + case SAT_PROATV_CMD_LAUNCH_BROWSER:{ + gint command_id, launch_type, browser_id; + gint url_len, text_len, gateway_proxy_len; + gchar *url = NULL, *text = NULL, *gateway_proxy = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id = NULL; +#endif + dbg("launch_browser type_format(%s)", g_variant_get_type_string(data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(iiisisisi@v)", &command_id, &launch_type, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len, &icon_id); +#else + g_variant_get(data, "(iiisisisi)", &command_id, &launch_type, &browser_id, &url, &url_len, &gateway_proxy, &gateway_proxy_len, &text, &text_len); +#endif + if(!url || strlen(url) < 7){ + g_free(url); + url = g_strdup("http://"); + } + dbg("url (%s)", url); + appsvc_set_uri(bundle_data, url); + g_free(url); + + snprintf(buffer, 300, "%d",TRUE); + appsvc_add_data(bundle_data, "sat",buffer); + + snprintf(buffer, 300, "%d",command_id); + appsvc_add_data(bundle_data, "cmd_id",buffer); + dbg("cmd_id(%s)",buffer); + + snprintf(buffer, 300, "%d",launch_type); + appsvc_add_data(bundle_data, "launch_type", buffer); + dbg("launch_type(%s)",buffer); + + snprintf(buffer, 300, "%s", gateway_proxy); + appsvc_add_data(bundle_data, "proxy", buffer); + dbg("proxy(%s)",buffer); + + g_free(text); + g_free(gateway_proxy); + + } break; + + default: + bundle_free(bundle_data); + return FALSE; + break; + } + + snprintf(slot_info, 2, "%d", slot_id); + appsvc_add_data(bundle_data, "slot_id", slot_info); + dbg("slot_id(%s)", slot_info); + + appsvc_run_service(bundle_data, 0, NULL, NULL); + dbg("browser app is called"); + bundle_free(bundle_data); + + return TRUE; +} + +gboolean sat_ui_support_launch_ciss_application(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id) +{ + bundle *bundle_data = 0; + gchar *encoded_data = NULL, *cmd = NULL; + char slot_info[2] = {0,}; + + dbg("launch ciss application by aul"); + bundle_data = bundle_create(); + appsvc_set_pkgname(bundle_data, "org.tizen.ciss"); + + switch(cmd_type){ + case SAT_PROATV_CMD_SEND_SS:{ + TelSatSendSsIndSsData_t ss_info; + + gint command_id, ton, npi; + gint text_len, ss_str_len; + gchar* text = NULL, *ss_string = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + dbg("launch ciss ui for send ss proactive cmd"); + + memset(&ss_info, 0, sizeof(TelSatSendSsIndSsData_t)); + + dbg("send ss type_format(%s)", g_variant_get_type_string(data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isi@viiis)", &command_id, &text, &text_len, &icon_id, &ton, &npi, &ss_str_len, &ss_string); +#else + g_variant_get(data, "(isiiiis)", &command_id, &text, &text_len, &ton, &npi, &ss_str_len, &ss_string); +#endif + ss_info.commandId = command_id; + ss_info.ton = ton; + ss_info.npi = npi; + memcpy(ss_info.ssString, ss_string, TAPI_SAT_DEF_SS_LEN_MAX+1); + ss_info.ssStringLen = ss_str_len; + g_free(text); + g_free(ss_string); + + cmd = g_strdup_printf("%d", cmd_type); + encoded_data = g_base64_encode((const guchar*)&ss_info, sizeof(TelSatSendSsIndSsData_t)); + } break; + + case SAT_PROATV_CMD_SEND_USSD:{ + TelSatSendUssdIndUssdData_t ussd_info; + + gint command_id; + gint text_len, ussd_str_len; + guchar dcs; + gchar* text = NULL, *ussd_string = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + dbg("launch ciss ui for send ussd proactive cmd"); + + memset(&ussd_info, 0, sizeof(TelSatSendUssdIndUssdData_t)); + + dbg("send ussd type_format(%s)", g_variant_get_type_string(data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isi@vyis)", &command_id, &text, &text_len, &icon_id, &dcs, &ussd_str_len, &ussd_string); +#else + g_variant_get(data, "(isiyis)", &command_id, &text, &text_len, &dcs, &ussd_str_len, &ussd_string); +#endif + ussd_info.commandId = command_id; + ussd_info.rawDcs = dcs; + memcpy(ussd_info.ussdString, ussd_string, TAPI_SAT_DEF_USSD_LEN_MAX+1); + ussd_info.ussdStringLen = ussd_str_len; + g_free(text); + g_free(ussd_string); + + cmd = g_strdup_printf("%d", cmd_type); + encoded_data = g_base64_encode((const guchar*)&ussd_info, sizeof(TelSatSendUssdIndUssdData_t)); + } break; + + default: + bundle_free(bundle_data); + return FALSE; + break; + } + + snprintf(slot_info, 2, "%d", slot_id); + dbg("slot_id : [%s]", slot_info); + + appsvc_add_data(bundle_data, "CISS_LAUNCHING_MODE", "RESP"); + appsvc_add_data(bundle_data, "KEY_EVENT_TYPE", cmd); + appsvc_add_data(bundle_data, "KEY_ENCODED_DATA", encoded_data); + appsvc_add_data(bundle_data, "KEY_SLOT_ID", slot_info); + g_free(encoded_data); + g_free(cmd); + + appsvc_run_service(bundle_data, 0, NULL, NULL); + dbg("ciss is called"); + bundle_free(bundle_data); + + return TRUE; +} + +gboolean sat_ui_support_launch_setting_application(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id) +{ + gint rv; + char buffer[300]; + bundle *bundle_data = 0; + char slot_info[2] = {0,}; + + dbg("launch setting application by aul"); + + /*TODO : need to make a sync with app engineer*/ + + switch(cmd_type){ + case SAT_PROATV_CMD_LANGUAGE_NOTIFICATION:{ + gint command_id, call_type, text_len, duration; + gchar *text = NULL, *call_number = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + dbg("setup call type_format(%s)", g_variant_get_type_string(data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isi@visi)", &command_id, &text, &text_len, &icon_id, &call_type, &call_number, &duration); +#else + g_variant_get(data, "(isiisi)", &command_id, &text, &text_len, &call_type, &call_number, &duration); +#endif + bundle_add(bundle_data, "launch-type","SATSETUPCALL"); + + snprintf(buffer, 300, "%d",command_id); + bundle_add(bundle_data, "cmd_id",buffer); + dbg("cmd_id(%s)",buffer); + + snprintf(buffer, 300, "%d",call_type); + bundle_add(bundle_data, "cmd_qual", buffer); + dbg("cmd_qual(%s)",buffer); + + snprintf(buffer, 300, "%s", text); + bundle_add(bundle_data, "disp_text", buffer); + dbg("disp_text(%s)",buffer); + + snprintf(buffer, 300, "%s", call_number); + bundle_add(bundle_data, "call_num", buffer); + dbg("call_num(%s)",buffer); + + snprintf(buffer, 300, "%d", duration); + bundle_add(bundle_data, "dur", buffer); + dbg("dur(%s)",buffer); + + g_free(text); + g_free(call_number); + } break; + + case SAT_PROATV_CMD_PROVIDE_LOCAL_INFO: + break; + + default: + return FALSE; + break; + } + + snprintf(slot_info, 2, "%d", slot_id); + dbg("slot_id : [%s]", slot_info); + bundle_add(bundle_data, "slot_id", slot_info); + + rv = aul_launch_app("org.tizen.call",bundle_data); + dbg("rv of aul_launch_app()=[%d]", rv); + bundle_free(bundle_data); + + return TRUE; +} + +gboolean sat_ui_support_exec_bip(GDBusConnection *connection, const gchar *path, enum tel_sat_proactive_cmd_type cmd_type, GVariant *data) +{ + gboolean rv = FALSE; + gchar *signal_name = NULL; + GVariant *out_param = NULL; + + switch(cmd_type){ + case SAT_PROATV_CMD_OPEN_CHANNEL:{ + gint command_id, bearer_type, protocol_type, dest_addr_type; + gboolean immediate_link, auto_reconnection, bg_mode; + gint text_len, buffer_size, port_number; + gchar *text = NULL, *dest_address = NULL; + GVariant *bearer_param; + GVariant *bearer_detail; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + dbg("open channel type_format(%s)", g_variant_get_type_string(data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data,"(isi@vbbbiviiiisv)", &command_id, &text, &text_len, &icon_id, &immediate_link, &auto_reconnection, &bg_mode, + &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); +#else + g_variant_get(data,"(isibbbiviiiisv)", &command_id, &text, &text_len, &immediate_link, &auto_reconnection, &bg_mode, + &bearer_type, &bearer_param, &buffer_size, &protocol_type, &port_number, &dest_addr_type, &dest_address, &bearer_detail); +#endif + out_param = g_variant_new("(isibbbiviiiisv)", command_id, text, text_len, immediate_link, auto_reconnection, bg_mode, + bearer_type, bearer_param, buffer_size, protocol_type, port_number, dest_addr_type, dest_address, bearer_detail); + signal_name = g_strdup("OpenChannel"); + + g_free(text); + g_free(dest_address); + } break; + case SAT_PROATV_CMD_CLOSE_CHANNEL:{ + gint command_id, channel_id, text_len; + gchar *text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + dbg("close channel type_format(%s)", g_variant_get_type_string(data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isi@vi)", &command_id, &text, &text_len, &icon_id, &channel_id); +#else + g_variant_get(data, "(isii)", &command_id, &text, &text_len, &channel_id); +#endif + out_param = g_variant_new("(isii)", command_id, text, text_len, channel_id); + signal_name = g_strdup("CloseChannel"); + + g_free(text); + } break; + case SAT_PROATV_CMD_RECEIVE_DATA:{ + gint command_id, text_len, channel_id, channel_data_len = 0; + gchar *text = NULL; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + dbg("receive data type_format(%s)", g_variant_get_type_string(data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isi@vii)", &command_id, &text, &text_len, &icon_id, &channel_id, &channel_data_len); +#else + g_variant_get(data, "(isiii)", &command_id, &text, &text_len, &channel_id, &channel_data_len); +#endif + out_param = g_variant_new("(isiii)", command_id, text, text_len, channel_id, channel_data_len); + signal_name = g_strdup("ReceiveData"); + + g_free(text); + } break; + case SAT_PROATV_CMD_SEND_DATA:{ + gint command_id, channel_id, text_len, channel_data_len; + gboolean send_data_immediately; + gchar *text = NULL; + GVariant *channel_data; +#if defined(TIZEN_SUPPORT_SAT_ICON) + GVariant *icon_id; +#endif + dbg("send data type_format(%s)", g_variant_get_type_string(data)); +#if defined(TIZEN_SUPPORT_SAT_ICON) + g_variant_get(data, "(isi@vibvi)", &command_id, &text, &text_len, &icon_id, &channel_id, &send_data_immediately, &channel_data, &channel_data_len); +#else + g_variant_get(data, "(isiibvi)", &command_id, &text, &text_len, &channel_id, &send_data_immediately, &channel_data, &channel_data_len); +#endif + out_param = g_variant_new("(isiibvi)", command_id, text, text_len, channel_id, send_data_immediately, channel_data, channel_data_len); + signal_name = g_strdup("SendData"); + + g_free(text); + } break; + case SAT_PROATV_CMD_GET_CHANNEL_STATUS:{ + gint command_id; + + dbg("get channel status type_format(%s)", g_variant_get_type_string(data)); + g_variant_get(data, "(i)", &command_id); + + out_param = g_variant_new("(i)", command_id); + signal_name = g_strdup("GetChannelStatus"); + } break; + case SAT_PROATV_CMD_SETUP_EVENT_LIST:{ + gint event_cnt; + GVariant *evt_list; + + dbg("setup event list type_format(%s)", g_variant_get_type_string(data)); + g_variant_get(data, "(iv)", &event_cnt, &evt_list); + + out_param = g_variant_new("(iv)", event_cnt, evt_list); + signal_name = g_strdup("SetupEventList"); + } break; + default: + dbg("no matched command"); + return FALSE; + break; + } + + dbg("dbus conn(%p), path(%s)", connection, path); + rv = g_dbus_connection_emit_signal(connection, "org.tizen.bip-manager", path, "org.tizen.telephony.SAT", signal_name, out_param, NULL); + g_free(signal_name); + + dbg("send signal to bip-mananger result (%d)", rv); + + return rv; +} + +gboolean sat_ui_support_exec_evtdw(GDBusConnection *connection, const gchar *path, enum tel_sat_proactive_cmd_type cmd_type, GVariant *data) +{ + gboolean rv = FALSE; + gchar *signal_name = NULL; + GVariant *out_param = NULL; + gchar *interface_name = NULL; + gint event_cnt; + GVariant *evt_list; + + dbg("dbus conn(%p), path(%s)", connection, path); + + if(g_str_has_suffix(path , "0")){ + interface_name = g_strdup("org.tizen.sat-event-downloader"); + + } else if (g_str_has_suffix(path , "1")){ + interface_name = g_strdup("org.tizen.sat-event-downloader-2"); + } else { + err("invalid sim slot id"); + return FALSE; + } + + if (cmd_type == SAT_PROATV_CMD_SETUP_EVENT_LIST){ + dbg("setup event list type_format(%s)", g_variant_get_type_string(data)); + g_variant_get(data, "(iv)", &event_cnt, &evt_list); + + out_param = g_variant_new("(iv)", event_cnt, evt_list); + signal_name = g_strdup("SetupEventList"); + } else { + err("invalid cmd_type:[%d]", cmd_type); + g_free(interface_name); + return FALSE; + } + + rv = g_dbus_connection_emit_signal(connection, interface_name, path, "org.tizen.telephony.SAT", signal_name, out_param, NULL); + dbg("send signal to sat-event-downloader result (%d)", rv); + + g_free(interface_name); + g_free(signal_name); + return rv; +} diff --git a/src/sat_ui_support/sat_ui_support.h b/src/sat_ui_support/sat_ui_support.h new file mode 100755 index 0000000..e1a06af --- /dev/null +++ b/src/sat_ui_support/sat_ui_support.h @@ -0,0 +1,30 @@ +#ifndef SAT_UI_SUPPORT_H_ +#define SAT_UI_SUPPORT_H_ + +#include +#include + +#include +#include +#include +#include +#include "../common.h" + +#define PKG_ID_SAT_UI "org.tizen.sat-ui" +#define PKG_ID_SAT_UI_2 "org.tizen.sat-ui-2" + +#define RELAUNCH_INTERVAL 50*1000 //100ms +#define RETRY_MAXCOUNT 3 + +gboolean sat_ui_support_terminate_sat_ui(void); +gboolean sat_ui_check_app_is_running(const char* app_id); +gboolean sat_ui_support_launch_call_application(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id); +gboolean sat_ui_support_launch_browser_application(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id); +gboolean sat_ui_support_launch_ciss_application(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id); +gboolean sat_ui_support_launch_setting_application(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id); +gboolean sat_ui_support_launch_sat_ui(enum tel_sat_proactive_cmd_type cmd_type, GVariant *data, enum dbus_tapi_sim_slot_id slot_id); +gboolean sat_ui_support_exec_bip(GDBusConnection *connection, const gchar *path, enum tel_sat_proactive_cmd_type cmd_type, GVariant *data); +gboolean sat_ui_support_exec_evtdw(GDBusConnection *connection, const gchar *path, enum tel_sat_proactive_cmd_type cmd_type, GVariant *data); +gboolean sat_ui_support_storage_init(Server *server); + +#endif /* SAT_UI_SUPPORT_H_ */ diff --git a/src/sim.c b/src/sim.c new file mode 100755 index 0000000..3eaa6b2 --- /dev/null +++ b/src/sim.c @@ -0,0 +1,3208 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + +#define DBUS_SIM_STATUS_ERROR "SIM STATUS ERROR" +#define DBUS_SIM_NOT_FOUND "SIM NOT FOUND" +#define DBUS_SIM_PERM_BLOCKED "SIM PERM BLOCKED" +#define DBUS_SIM_CARD_ERROR "SIM CARD ERROR" +#define DBUS_SIM_NOT_INITIALIZED "SIM NOT INITIALIZED" +#define DBUS_SIM_INIT_COMPLETED "SIM INIT COMPLETED" +#define DBUS_SIM_LOCKED "SIM LOCKED" +#define DBUS_SIM_NOT_READY "SIM NOT READY" +#define DBUS_SIM_RESPONSE_DATA_ERROR "SIM RESPONSE DATA ERROR" +#define DBUS_SIM_SERVICE_IS_DISABLED "SIM SERVICE IS DISABLED" +#define DBUS_SIM_SERVICE_NOT_SUPPORTED_FOR_NVSIM "SERVICE NOT SUPPORTED FOR NVSIM" + +#define DBUS_SIM_GET_COSIM(invocation, co_sim, server) { \ + co_sim = __get_sim_co_by_cp_name(server, GET_CP_NAME(invocation)); \ + if (!co_sim) { \ + err("SIM Core object is NULL"); \ + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); \ + return TRUE; \ + } \ +} + +#define DBUS_SIM_CHECK_SIM_STATUS(op_type, co_sim) {\ + if (__check_sim_state(op_type, tcore_sim_get_status(co_sim)) == FALSE) { \ + err("Invalid SIM status"); \ + __return_fail_response(invocation, tcore_sim_get_status(co_sim)); \ + return TRUE; \ + } \ +} + +#define DBUS_SIM_CHECK_SIM_TYPE(co_sim, request) {\ + if (tcore_sim_get_type(co_sim) == SIM_TYPE_NVSIM) { \ + err("[%s] is not supported for NVSIM", request); \ + FAIL_RESPONSE(invocation, DBUS_SIM_SERVICE_NOT_SUPPORTED_FOR_NVSIM); \ + return TRUE; \ + } \ +} + +#define DBUS_SIM_CHECK_SIM_SERVICE_TABLE(op_type, co_sim) {\ + gboolean b_cphs = FALSE; \ + b_cphs = tcore_sim_get_cphs_status(co_sim); \ + if (b_cphs && op_type != GET_MSISDN) { \ + dbg("CPHS SIM... Do not check SST"); \ + } else { \ + struct tel_sim_service_table* svct = tcore_sim_get_service_table(co_sim); \ + if (svct != NULL) { \ + if (__check_sim_service_table(op_type, svct) == FALSE) { \ + err("'Service' is disabled in SST"); \ + FAIL_RESPONSE(invocation, DBUS_SIM_SERVICE_IS_DISABLED); \ + free(svct); \ + return TRUE; \ + } else { \ + dbg("Request to modem"); \ + free(svct); \ + } \ + } \ + } \ +} + +#define DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation, ur) {\ + if (ret != TCORE_RETURN_SUCCESS) { \ + if (ret == TCORE_RETURN_SIM_DISABLED_IN_SST) { \ + err("'Service' is disabled in SST"); \ + FAIL_RESPONSE (invocation, DBUS_SIM_SERVICE_IS_DISABLED); \ + } else { \ + err("Dispatch request failed: [0x%x]", ret); \ + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); \ + } \ + tcore_user_request_unref(ur); \ + } \ +} + +enum dbus_tapi_sim_gdbus_method_name { + /* EF Get */ + GET_INIT_STATUS = 1, + GET_CARD_TYPE, + GET_IMSI, + GET_ECC, + GET_ICCID = 5, + GET_LANGUAGE, + SET_LANGUAGE, + GET_CALL_FORWARDING, + SET_CALL_FORWARDING, + GET_MESSAGE_WAITING = 10, + SET_MESSAGE_WAITING, + GET_MAILBOX, + SET_MAILBOX, + GET_CPHS_INFO, + GET_SVCT = 15, + GET_MSISDN, + GET_OPLMWACT, + GET_SPN, + GET_CPHS_NET_NAME, + + /* Misc */ + AUTHENTICATION = 20, + VERIFY_SEC, + VERIFY_PUK, + CHANGE_PIN, + DISABLE_FACILITY, + ENABLE_FACILITY = 25, + GET_FACILITY, + GET_LOCK_INFO, + TRANSFER_APDU, + GET_ATR, + GET_FIELDS = 30, //for get various data at once + GET_GID, + SET_POWERSTATE, + GET_IMPI, + GET_IMPU, + GET_DOMAIN, + GET_PCSCF, + GET_APP_LIST, + GET_ISIM_SERVICE_TABLE, + + /* Notification */ + STATUS = 100, + REFRESHED, +}; + +static gboolean __is_valid_sim_status(enum tel_sim_status sim_status) +{ + switch(sim_status) { + case SIM_STATUS_INIT_COMPLETED: + case SIM_STATUS_INITIALIZING: + case SIM_STATUS_PIN_REQUIRED: + case SIM_STATUS_PUK_REQUIRED: + case SIM_STATUS_LOCK_REQUIRED: + case SIM_STATUS_CARD_BLOCKED: + case SIM_STATUS_NCK_REQUIRED: + case SIM_STATUS_NSCK_REQUIRED: + case SIM_STATUS_SPCK_REQUIRED: + case SIM_STATUS_CCK_REQUIRED: + return TRUE; + default: + return FALSE; + } +} + +static CoreObject *__get_sim_co_by_cp_name(Server *server, char *cp_name) +{ + TcorePlugin *plugin = NULL; + + if (!server) { + err("server is NULL"); + return NULL; + } + + plugin = tcore_server_find_plugin(server, cp_name); + return tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM); +} + +static CoreObject* __get_sim_co_from_ur(Server *server, UserRequest *ur) +{ + CoreObject *co_sim = NULL; + char *modem_name = NULL; + + modem_name = tcore_user_request_get_modem_name(ur); + if (!modem_name) { + err("Modem name is NULL"); + return co_sim; + } + + co_sim = __get_sim_co_by_cp_name(server, modem_name); + free(modem_name); + + return co_sim; +} + +static gboolean __check_sim_state(enum dbus_tapi_sim_gdbus_method_name method, enum tel_sim_status sim_status) +{ + gboolean ret = TRUE; + + if ((int)sim_status < SIM_STATUS_CARD_ERROR) { + err("SIM status is NOT valid"); + return FALSE; + } + + switch (method) { + case GET_CARD_TYPE: + case GET_ECC: + case GET_ICCID: + case GET_LANGUAGE: + case GET_CPHS_INFO: + case GET_SPN: + case AUTHENTICATION: + case TRANSFER_APDU: + case GET_ATR: + // Regarding Lock facilities + case CHANGE_PIN: + case ENABLE_FACILITY: + case DISABLE_FACILITY: + case GET_FACILITY: + case GET_LOCK_INFO: + case VERIFY_SEC: + case VERIFY_PUK: + if (sim_status == SIM_STATUS_CARD_ERROR + || sim_status == SIM_STATUS_CARD_BLOCKED + || sim_status == SIM_STATUS_CARD_NOT_PRESENT + || sim_status == SIM_STATUS_CARD_REMOVED + || sim_status == SIM_STATUS_UNKNOWN + || sim_status == SIM_STATUS_CARD_POWEROFF) { + ret = FALSE; + } + break; + case GET_IMSI: + case GET_SVCT: + case GET_MSISDN: + case GET_OPLMWACT: + case GET_CPHS_NET_NAME: + case GET_CALL_FORWARDING: + case SET_CALL_FORWARDING: + case GET_MESSAGE_WAITING: + case SET_MESSAGE_WAITING: + case GET_MAILBOX: + case SET_MAILBOX: + case SET_LANGUAGE: + case GET_FIELDS: + case GET_IMPI: + case GET_IMPU: + case GET_GID: + case GET_DOMAIN: + case GET_PCSCF: + case GET_APP_LIST: + case GET_ISIM_SERVICE_TABLE: + if (sim_status != SIM_STATUS_INIT_COMPLETED) { + ret = FALSE; + } + break; + case SET_POWERSTATE: + if (sim_status != SIM_STATUS_INIT_COMPLETED + && sim_status != SIM_STATUS_INITIALIZING + && sim_status != SIM_STATUS_PIN_REQUIRED + && sim_status != SIM_STATUS_CARD_BLOCKED + && sim_status != SIM_STATUS_CARD_POWEROFF) { + ret = FALSE; + } + break; + case GET_INIT_STATUS: + case STATUS: + case REFRESHED: + default: + err("Unhandled/Unknown operation: [%d]", method); + break; + } + return ret; +} + +static gboolean __check_sim_service_table(enum dbus_tapi_sim_gdbus_method_name method, struct tel_sim_service_table *svct) +{ + gboolean ret = TRUE; + + switch (method) { + case GET_MSISDN: + if ( !(svct->sim_type == SIM_TYPE_GSM && svct->table.sst.service[SIM_SST_MSISDN]) && + !(svct->sim_type == SIM_TYPE_USIM && svct->table.ust.service[SIM_UST_MSISDN]) ) { + ret = FALSE; + } + break; + case GET_CALL_FORWARDING: + case SET_CALL_FORWARDING: + if ( !(svct->sim_type == SIM_TYPE_GSM && svct->table.sst.service[SIM_SST_CFIS]) && + !(svct->sim_type == SIM_TYPE_USIM && svct->table.ust.service[SIM_UST_CFIS]) ) { + ret = FALSE; + } + break; + case GET_MESSAGE_WAITING: + case SET_MESSAGE_WAITING: + if ( !(svct->sim_type == SIM_TYPE_GSM && svct->table.sst.service[SIM_SST_MWIS]) && + !(svct->sim_type == SIM_TYPE_USIM && svct->table.ust.service[SIM_UST_MWIS]) ) { + ret = FALSE; + } + break; + case GET_MAILBOX: + case SET_MAILBOX: + if ( !(svct->sim_type == SIM_TYPE_GSM && svct->table.sst.service[SIM_SST_MBDN]) && + !(svct->sim_type == SIM_TYPE_USIM && svct->table.ust.service[SIM_UST_MBDN]) ) { + ret = FALSE; + } + break; + default: + err("Unhandled/Unknown operation: [%d]", method); + break; + } + + return ret; +} + +static void __return_fail_response(GDBusMethodInvocation *invocation, enum tel_sim_status sim_status) +{ + dbg("SIM Status: [%d]", sim_status); + + switch (sim_status) { + case SIM_STATUS_CARD_NOT_PRESENT: + case SIM_STATUS_CARD_REMOVED: + FAIL_RESPONSE(invocation, DBUS_SIM_NOT_FOUND); + break; + case SIM_STATUS_CARD_BLOCKED: + FAIL_RESPONSE(invocation, DBUS_SIM_PERM_BLOCKED); + break; + case SIM_STATUS_CARD_ERROR: + case SIM_STATUS_CARD_CRASHED: + FAIL_RESPONSE(invocation, DBUS_SIM_CARD_ERROR); + break; + case SIM_STATUS_INITIALIZING: + FAIL_RESPONSE(invocation, DBUS_SIM_NOT_INITIALIZED); + break; + case SIM_STATUS_INIT_COMPLETED: + FAIL_RESPONSE(invocation, DBUS_SIM_INIT_COMPLETED); + break; + case SIM_STATUS_PIN_REQUIRED: + case SIM_STATUS_PUK_REQUIRED: + case SIM_STATUS_NCK_REQUIRED: + case SIM_STATUS_NSCK_REQUIRED: + case SIM_STATUS_SPCK_REQUIRED: + case SIM_STATUS_CCK_REQUIRED: + case SIM_STATUS_LOCK_REQUIRED: + FAIL_RESPONSE(invocation, DBUS_SIM_LOCKED); + break; + case SIM_STATUS_UNKNOWN: + FAIL_RESPONSE(invocation, DBUS_SIM_NOT_READY); + break; + default: + dbg("Unhandled/Unknown status: [%d]", sim_status); + FAIL_RESPONSE(invocation, DBUS_SIM_STATUS_ERROR); + break; + } +} + +static gboolean on_sim_get_init_status(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + enum tel_sim_status sim_status = SIM_STATUS_UNKNOWN; + gboolean sim_changed = FALSE; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + + sim_status = tcore_sim_get_status(co_sim); + sim_changed = tcore_sim_get_identification(co_sim); + dbg("SIM - Status: [%d] Changed: [%s]", + sim_status, (sim_changed ? "Yes" : "No")); + + telephony_sim_complete_get_init_status(sim, invocation, sim_status, sim_changed); + + return TRUE; +} + +static gboolean on_sim_get_card_type(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + enum tel_sim_type sim_type = SIM_TYPE_UNKNOWN; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_CARD_TYPE, co_sim); + + sim_type = tcore_sim_get_type(co_sim); + + telephony_sim_complete_get_card_type(sim, invocation, sim_type); + + return TRUE; +} + +static gboolean on_sim_get_imsi(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct tel_sim_imsi *n_imsi; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_IMSI, co_sim); + + n_imsi = tcore_sim_get_imsi(co_sim); + if (!n_imsi) { + FAIL_RESPONSE (invocation, DBUS_SIM_RESPONSE_DATA_ERROR); + return TRUE; + } else { + telephony_sim_complete_get_imsi(sim, invocation, n_imsi->plmn, n_imsi->msin); + free(n_imsi); + } + + return TRUE; +} + +static gboolean on_sim_get_ecc(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + CoreObject *co_sim = NULL; + struct tel_sim_ecc_list *ecc_list = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_ECC, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get ECC"); + + ecc_list = tcore_sim_get_ecc_list(co_sim); + if (!ecc_list) { + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + dbg("po->ecc_list is NULL. Request to Modem."); + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_command(ur, TREQ_SIM_GET_ECC); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + } else { + GVariant *gv = NULL; + GVariantBuilder b; + int i; + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i = 0; iecc_count; i++) { + dbg("ecc[%d] : ecc_category=[0x%x], ecc_num=[%s], ecc_string=[%s]", + i, ecc_list->ecc[i].ecc_category, ecc_list->ecc[i].ecc_num, ecc_list->ecc[i].ecc_string); + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "category", g_variant_new_int32(ecc_list->ecc[i].ecc_category)); + g_variant_builder_add(&b, "{sv}", "number", g_variant_new_string(ecc_list->ecc[i].ecc_num)); + g_variant_builder_add(&b, "{sv}", "name", g_variant_new_string(ecc_list->ecc[i].ecc_string)); + g_variant_builder_close(&b); + } + gv = g_variant_builder_end(&b); + if (!gv) + dbg("error - ecc gv is NULL"); + + telephony_sim_complete_get_ecc(sim, invocation, gv); + + free(ecc_list); + } + + return TRUE; +} + +static gboolean on_sim_get_iccid(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct tel_sim_iccid* iccid = NULL; + + dbg("Func Entrance"); + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_ICCID, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get ICCID"); + + iccid = tcore_sim_get_iccid(co_sim); + + if (!iccid) { + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_ICCID); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + } else { + telephony_sim_complete_get_iccid(sim, invocation, SIM_ACCESS_SUCCESS, + iccid->iccid); + free(iccid); + } + + return TRUE; +} + +static gboolean on_sim_get_language(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_LANGUAGE, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Language"); + + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_LANGUAGE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_set_language(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_language, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_set_language set_language; + + if (!check_access_control (invocation, AC_SIM, "w")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(SET_LANGUAGE, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Set Language"); + + memset(&set_language, 0, sizeof(struct treq_sim_set_language)); + set_language.language = arg_language; + + dbg("set_language.language[%d]", set_language.language); + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_sim_set_language), &set_language); + tcore_user_request_set_command(ur, TREQ_SIM_SET_LANGUAGE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_call_forwarding(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_CALL_FORWARDING, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Call Forwarding"); + DBUS_SIM_CHECK_SIM_SERVICE_TABLE(GET_CALL_FORWARDING, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_command(ur, TREQ_SIM_GET_CALLFORWARDING); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation, ur); + + return TRUE; +} + +static gboolean on_sim_set_call_forwarding(TelephonySim *sim, GDBusMethodInvocation *invocation, + gboolean arg_cphs, + gint arg_rec_index, + gint arg_msp_num, + guchar arg_cfu_status, + gint arg_ton, + gint arg_npi, + const gchar *arg_number, + gint arg_cc2_id, + gint arg_ext7_id, + gboolean arg_cphs_line1, + gboolean arg_cphs_line2, + gboolean arg_cphs_fax, + gboolean arg_cphs_data, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_set_callforwarding req_cf; + + if (!check_access_control (invocation, AC_SIM, "w")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(SET_CALL_FORWARDING, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Set Call Forwarding"); + DBUS_SIM_CHECK_SIM_SERVICE_TABLE(SET_CALL_FORWARDING, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + + memset(&req_cf, 0, sizeof(struct treq_sim_set_callforwarding)); + + req_cf.b_cphs = arg_cphs; + + if (req_cf.b_cphs) { + req_cf.cphs_cf.b_line1 = arg_cphs_line1; + req_cf.cphs_cf.b_line2 = arg_cphs_line2; + req_cf.cphs_cf.b_fax = arg_cphs_fax; + req_cf.cphs_cf.b_data = arg_cphs_data; + dbg("b_line1[%d], b_line2[%d], b_fax[%d], b_data[%d]", + req_cf.cphs_cf.b_line1, req_cf.cphs_cf.b_line2, + req_cf.cphs_cf.b_fax, req_cf.cphs_cf.b_data); + } else { + req_cf.cf.rec_index = arg_rec_index; + req_cf.cf.msp_num = arg_msp_num; + req_cf.cf.cfu_status = arg_cfu_status; + req_cf.cf.ton = arg_ton; + req_cf.cf.npi = arg_npi; + memcpy(&req_cf.cf.cfu_num, arg_number, strlen(arg_number)); + req_cf.cf.cc2_id = arg_cc2_id; + req_cf.cf.ext7_id = arg_ext7_id; + dbg("rec_index[%d], msp_num[%d], cfu_status[0x%x], ton[%d], " + "npi[%d], cfu_num[%s], cc2_id[%d], ext7_id[%d]", + req_cf.cf.rec_index, req_cf.cf.msp_num, req_cf.cf.cfu_status, req_cf.cf.ton, + req_cf.cf.npi, req_cf.cf.cfu_num, req_cf.cf.cc2_id, req_cf.cf.ext7_id); + } + + tcore_user_request_set_data(ur, sizeof(struct treq_sim_set_callforwarding), &req_cf); + tcore_user_request_set_command(ur, TREQ_SIM_SET_CALLFORWARDING); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation, ur); + + return TRUE; +} + +static gboolean on_sim_get_message_waiting(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_MESSAGE_WAITING, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Message Waiting"); + DBUS_SIM_CHECK_SIM_SERVICE_TABLE(GET_MESSAGE_WAITING, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_command(ur, TREQ_SIM_GET_MESSAGEWAITING); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation, ur); + + return TRUE; +} + +static gboolean on_sim_set_message_waiting(TelephonySim *sim, GDBusMethodInvocation *invocation, + gboolean arg_cphs, + gint arg_rec_index, + guchar arg_indicator_status, + gint arg_voice_cnt, + gint arg_fax_cnt, + gint arg_email_cnt, + gint arg_other_cnt, + gint arg_video_cnt, + gboolean arg_cphs_voice1, + gboolean arg_cphs_voice2, + gboolean arg_cphs_fax, + gboolean arg_cphs_data, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_set_messagewaiting req_mw; + + if (!check_access_control (invocation, AC_SIM, "w")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(SET_MESSAGE_WAITING, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Set Message Waiting"); + DBUS_SIM_CHECK_SIM_SERVICE_TABLE(SET_MESSAGE_WAITING, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + + memset(&req_mw, 0, sizeof(struct treq_sim_set_messagewaiting)); + + req_mw.b_cphs = arg_cphs; + + if (req_mw.b_cphs) { + req_mw.cphs_mw.b_voice1 = arg_cphs_voice1; + req_mw.cphs_mw.b_voice2 = arg_cphs_voice2; + req_mw.cphs_mw.b_fax = arg_cphs_fax; + req_mw.cphs_mw.b_data = arg_cphs_data; + dbg("b_voice1[%d],b_voice2[%d],b_fax[%d], b_data[%d]", + req_mw.cphs_mw.b_voice1, + req_mw.cphs_mw.b_voice2, + req_mw.cphs_mw.b_fax, + req_mw.cphs_mw.b_data); + } else { + req_mw.mw.rec_index = arg_rec_index; + req_mw.mw.indicator_status = arg_indicator_status; + req_mw.mw.voice_count = arg_voice_cnt; + req_mw.mw.fax_count = arg_fax_cnt; + req_mw.mw.email_count = arg_email_cnt; + req_mw.mw.other_count = arg_other_cnt; + req_mw.mw.video_count = arg_video_cnt; + dbg("rec_index[%d], indicator_status[0x%x], voice_count[%d], fax_count[%d], email_count[%d], other_count[%d], video_count[%d]", + req_mw.mw.rec_index, + req_mw.mw.indicator_status, + req_mw.mw.voice_count, + req_mw.mw.fax_count, + req_mw.mw.email_count, + req_mw.mw.other_count, + req_mw.mw.video_count); + } + + tcore_user_request_set_data(ur, sizeof(struct treq_sim_set_messagewaiting), &req_mw); + tcore_user_request_set_command(ur, TREQ_SIM_SET_MESSAGEWAITING); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation, ur); + + return TRUE; +} + +static gboolean on_sim_get_mailbox(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_MAILBOX, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Mailbox"); + DBUS_SIM_CHECK_SIM_SERVICE_TABLE(GET_MAILBOX, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_command(ur, TREQ_SIM_GET_MAILBOX); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation, ur); + + return TRUE; +} + +static gboolean on_sim_set_mailbox(TelephonySim *sim, GDBusMethodInvocation *invocation, + gboolean arg_cphs, + gint arg_type, + gint arg_rec_index, + gint arg_profile_number, + gint arg_alpha_id_max_len, + const gchar *arg_alpha_id, + gint arg_ton, + gint arg_npi, + const gchar *arg_number, + gint arg_cc_id, + gint arg_ext1_id, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_set_mailbox req_mb; + + if (!check_access_control (invocation, AC_SIM, "w")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(SET_MAILBOX, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Set Mailbox"); + DBUS_SIM_CHECK_SIM_SERVICE_TABLE(SET_MAILBOX, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + + memset(&req_mb, 0, sizeof(struct treq_sim_set_mailbox)); + + req_mb.b_cphs = arg_cphs; + + req_mb.mb_info.mb_type = arg_type; + req_mb.mb_info.rec_index = arg_rec_index; + req_mb.mb_info.profile_number = arg_profile_number; + req_mb.mb_info.number_info.alpha_id_max_len = arg_alpha_id_max_len; + if (strlen(arg_alpha_id)) + memcpy(&req_mb.mb_info.number_info.alpha_id, arg_alpha_id, strlen(arg_alpha_id)); + req_mb.mb_info.number_info.ton = arg_npi; + req_mb.mb_info.number_info.npi = arg_npi; + if (strlen(arg_number)) + memcpy(&req_mb.mb_info.number_info.num, arg_number, strlen(arg_number)); + req_mb.mb_info.number_info.cc_id = arg_ext1_id; + req_mb.mb_info.number_info.ext1_id = arg_ext1_id; + + dbg("b_cphs[%d] mb_type[%d], rec_index[%d], profile_number[%d], alpha_id_max_len[%d], " + "alpha_id[%s], ton[%d], npi[%d], num[%s], cc_id[%d], ext1_id[%d]", + req_mb.b_cphs, + req_mb.mb_info.mb_type, + req_mb.mb_info.rec_index, + req_mb.mb_info.profile_number, + req_mb.mb_info.number_info.alpha_id_max_len, + req_mb.mb_info.number_info.alpha_id, + req_mb.mb_info.number_info.ton, + req_mb.mb_info.number_info.npi, + req_mb.mb_info.number_info.num, + req_mb.mb_info.number_info.cc_id, + req_mb.mb_info.number_info.ext1_id) + + tcore_user_request_set_data(ur, sizeof(struct treq_sim_set_mailbox), &req_mb); + tcore_user_request_set_command(ur, TREQ_SIM_SET_MAILBOX); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation, ur); + + return TRUE; +} + +static gboolean on_sim_get_cphsinfo(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_CPHS_INFO, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get CPHS Info"); + + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_CPHS_INFO); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_service_table(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + CoreObject *co_sim = NULL; + struct tel_sim_service_table *svct = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_SVCT, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get SVCT"); + + svct = tcore_sim_get_service_table(co_sim); + if (!svct) { + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + ur = MAKE_UR(ctx, sim, invocation); + + dbg("Not cached. Request to modem"); + tcore_user_request_set_command(ur, TREQ_SIM_GET_SERVICE_TABLE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + } else { + GVariantBuilder builder; + GVariant * inner_gv = NULL; + GVariant *svct_gv = NULL; + int i =0; + dbg("TRESP_SIM_GET_SERVICE_TABLE"); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + if (svct->sim_type == SIM_TYPE_GSM) { + for (i = 0; i < SIM_SST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add (&builder, "y", svct->table.sst.service[i]); + } + } else if (svct->sim_type == SIM_TYPE_USIM) { + for (i = 0; i < SIM_UST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add (&builder, "y", svct->table.ust.service[i]); + } + } else if(svct->sim_type == SIM_TYPE_RUIM) { + if(SIM_CDMA_SVC_TABLE == svct->table.cst.cdma_svc_table) { + for(i = 0; i < SIM_CDMA_ST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add (&builder, "iy", svct->table.cst.cdma_svc_table, + svct->table.cst.service.cdma_service[i]); + } + } else if(SIM_CSIM_SVC_TABLE == svct->table.cst.cdma_svc_table) { + for(i = 0; i < SIM_CSIM_ST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add (&builder, "iy", svct->table.cst.cdma_svc_table, + svct->table.cst.service.csim_service[i]); + } + } else { + err("Invalid cdma_svc_table:[%d]", svct->table.cst.cdma_svc_table); + } + } else { + err("Unknown SIM type: [%d]", svct->sim_type); + } + inner_gv = g_variant_builder_end(&builder); + svct_gv = g_variant_new("v", inner_gv); + + telephony_sim_complete_get_service_table (sim, invocation, + SIM_ACCESS_SUCCESS, + svct->sim_type, + svct_gv); + + free(svct); + } + return TRUE; +} + +static gboolean on_sim_get_msisdn(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + TReturn ret; + CoreObject *co_sim = NULL; + struct tel_sim_msisdn_list *msisdn_list = NULL; + gboolean read_from_modem = FALSE; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_MSISDN, co_sim); + DBUS_SIM_CHECK_SIM_SERVICE_TABLE(GET_MSISDN, co_sim); + + if(SIM_TYPE_NVSIM == tcore_sim_get_type(co_sim)) { + dbg("In NV SIM, don't use MSISDN cached"); + read_from_modem = TRUE; + } else { + msisdn_list = tcore_sim_get_msisdn_list(co_sim); + if (msisdn_list) + read_from_modem = FALSE; + else + read_from_modem = TRUE; + } + + if(read_from_modem) { + UserRequest *ur = NULL; + + ur = MAKE_UR(ctx, sim, invocation); + dbg("Not cached. Request to modem"); + tcore_user_request_set_command(ur, TREQ_SIM_GET_MSISDN); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + DBUS_SIM_CHECK_DISPATCH_RET(ret, invocation, ur); + } else { + GVariant *gv = NULL; + int i; + GVariantBuilder b; + dbg("TRESP_SIM_GET_MSISDN"); + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + dbg("msisdn_list->count = %d", msisdn_list->count); + for (i = 0;i < msisdn_list->count; i++) { + g_variant_builder_open(&b,G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "name", g_variant_new_string((const gchar *)msisdn_list->msisdn[i].name)); + if (msisdn_list->msisdn[i].ton == SIM_TON_INTERNATIONAL) { + unsigned char *tmp = (unsigned char *)calloc(SIM_MSISDN_NUMBER_LEN_MAX + 1, 1); + if (tmp!=NULL) { + tmp[0] = '+'; + strncpy((char *)tmp+1, (const char*)msisdn_list->msisdn[i].num, SIM_MSISDN_NUMBER_LEN_MAX - 1); + tmp[SIM_MSISDN_NUMBER_LEN_MAX] = '\0'; + g_variant_builder_add(&b, "{sv}", "number", g_variant_new_string((const gchar *)tmp)); + free(tmp); + } else { + dbg("calloc failed."); + g_variant_builder_add(&b, "{sv}", "number", g_variant_new_string((const gchar *)msisdn_list->msisdn[i].num)); + } + } else { + g_variant_builder_add(&b, "{sv}", "number", g_variant_new_string((const gchar *)msisdn_list->msisdn[i].num)); + } + g_variant_builder_close(&b); + } + gv = g_variant_builder_end(&b); + + telephony_sim_complete_get_msisdn (sim, invocation, SIM_ACCESS_SUCCESS, gv); + free(msisdn_list); + } + + return TRUE; +} + +static gboolean on_sim_get_oplmnwact(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_OPLMWACT, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get OPLMNWACT"); + + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_OPLMNWACT); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_spn(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct tel_sim_spn* spn = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_SPN, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get SPN"); + + spn = tcore_sim_get_spn(co_sim); + + if (!spn) { + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_SPN); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + } else { + telephony_sim_complete_get_spn (sim, invocation, SIM_ACCESS_SUCCESS, + spn->display_condition, (const gchar *)spn->spn); + free(spn); + } + return TRUE; +} + +static gboolean on_sim_get_cphs_netname(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct tel_sim_cphs_netname *cphs_netname = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_CPHS_NET_NAME, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get CPHS Net Name"); + + cphs_netname = tcore_sim_get_cphs_netname(co_sim); + + if (!cphs_netname) { + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_CPHS_NETNAME); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + } else { + telephony_sim_complete_get_cphs_net_name (sim, invocation, SIM_ACCESS_SUCCESS, + (const gchar *)cphs_netname->full_name, + (const gchar *)cphs_netname->short_name); + free(cphs_netname); + } + + return TRUE; +} + +static gboolean on_sim_get_gid(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_GID, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get GID"); + + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_GID); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_authentication(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_type, + GVariant *arg_rand, + GVariant *arg_autn, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + GVariantIter *iter = NULL; + GVariant *rand_gv = NULL; + GVariant *autn_gv = NULL; + guchar rt_i; + int i =0; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_req_authentication req_auth; + + if (!check_access_control (invocation, AC_SIM, "x")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(AUTHENTICATION, co_sim); + + memset(&req_auth, 0, sizeof(struct treq_sim_req_authentication)); + + req_auth.auth_type = arg_type; + + rand_gv = g_variant_get_variant(arg_rand); + g_variant_get(rand_gv, "ay", &iter); + while ( g_variant_iter_loop (iter, "y", &rt_i)) { + req_auth.rand_data[i] = rt_i; + i++; + } + req_auth.rand_length = (unsigned int)i; + + i = 0; + autn_gv = g_variant_get_variant(arg_autn); + g_variant_get(autn_gv, "ay", &iter); + while ( g_variant_iter_loop (iter, "y", &rt_i)) { + req_auth.autn_data[i] = rt_i; + i++; + } + req_auth.autn_length = (unsigned int)i; + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sim_req_authentication), &req_auth); + tcore_user_request_set_command(ur, TREQ_SIM_REQ_AUTHENTICATION); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + GVariantBuilder builder; + GVariant *ak = NULL; + GVariant *cp = NULL; + GVariant *it = NULL; + GVariant *resp = NULL; + GVariant *ak_gv = NULL; + GVariant *cp_gv = NULL; + GVariant *it_gv = NULL; + GVariant *resp_gv = NULL; + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + ak = g_variant_builder_end(&builder); + ak_gv = g_variant_new("v", ak); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + cp = g_variant_builder_end(&builder); + cp_gv = g_variant_new("v", cp); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + it = g_variant_builder_end(&builder); + it_gv = g_variant_new("v", it); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + resp = g_variant_builder_end(&builder); + resp_gv = g_variant_new("v", resp); + + telephony_sim_complete_authentication (sim, invocation, SIM_ACCESS_FAILED, 0, 0, ak_gv, cp_gv, it_gv, resp_gv); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_verify_sec(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_type, + const gchar *arg_password, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_verify_pins verify_pins; + + if (!check_access_control (invocation, AC_SIM, "x")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(VERIFY_SEC, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Verify Sec"); + + memset(&verify_pins, 0, sizeof(struct treq_sim_verify_pins)); + + verify_pins.pin_type = arg_type; + verify_pins.pin_length = strlen(arg_password); + memcpy(verify_pins.pin, arg_password, verify_pins.pin_length); + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sim_verify_pins), &verify_pins); + tcore_user_request_set_command(ur, TREQ_SIM_VERIFY_PINS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_verify_puk(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_type, + const gchar *arg_puk, + const gchar *arg_new_pin, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_verify_puks verify_puks; + + if (!check_access_control (invocation, AC_SIM, "x")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(VERIFY_PUK, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Verify PUK"); + + memset(&verify_puks, 0, sizeof(struct treq_sim_verify_puks)); + + verify_puks.puk_type = arg_type; + verify_puks.puk_length = strlen(arg_puk); + memcpy(verify_puks.puk, arg_puk, verify_puks.puk_length); + verify_puks.pin_length = strlen(arg_new_pin); + memcpy(verify_puks.pin, arg_new_pin, verify_puks.pin_length); + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sim_verify_puks), &verify_puks); + tcore_user_request_set_command(ur, TREQ_SIM_VERIFY_PUKS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_change_pin(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_type, + const gchar *arg_old_password, + const gchar *arg_new_password, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_change_pins change_pins; + + if (!check_access_control (invocation, AC_SIM, "x")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(CHANGE_PIN, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Change PIN"); + + memset(&change_pins, 0, sizeof(struct treq_sim_change_pins)); + + change_pins.type = arg_type; + change_pins.old_pin_length = strlen(arg_old_password); + memcpy(change_pins.old_pin, arg_old_password, change_pins.old_pin_length); + change_pins.new_pin_length = strlen(arg_new_password); + memcpy(change_pins.new_pin, arg_new_password, change_pins.new_pin_length); + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sim_change_pins), &change_pins); + tcore_user_request_set_command(ur, TREQ_SIM_CHANGE_PINS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_disable_facility(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_type, + const gchar *arg_password, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_sim_disable_facility dis_facility; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "x")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(DISABLE_FACILITY, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Diable Facility"); + + memset(&dis_facility, 0, sizeof(struct treq_sim_disable_facility)); + + dbg("arg_type[%d]", arg_type); + switch (arg_type) { + case 1: + dis_facility.type = SIM_FACILITY_PS; + break; + case 3: + dis_facility.type = SIM_FACILITY_SC; + break; + case 4: + dis_facility.type = SIM_FACILITY_FD; + break; + case 5: + dis_facility.type = SIM_FACILITY_PN; + break; + case 6: + dis_facility.type = SIM_FACILITY_PU; + break; + case 7: + dis_facility.type = SIM_FACILITY_PP; + break; + case 8: + dis_facility.type = SIM_FACILITY_PC; + break; + default: + err("Unhandled/Unknown type[0x%x]", arg_type); + break; + } + dis_facility.password_length = strlen(arg_password); + memcpy(dis_facility.password, arg_password, dis_facility.password_length); + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sim_disable_facility), &dis_facility); + tcore_user_request_set_command(ur, TREQ_SIM_DISABLE_FACILITY); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_enable_facility(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_type, + const gchar *arg_password, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_sim_enable_facility en_facility; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "x")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(ENABLE_FACILITY, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Enable Facility"); + + memset(&en_facility, 0, sizeof(struct treq_sim_enable_facility)); + + dbg("arg_type[%d]", arg_type); + switch (arg_type) { + case 1: + en_facility.type = SIM_FACILITY_PS; + break; + case 3: + en_facility.type = SIM_FACILITY_SC; + break; + case 4: + en_facility.type = SIM_FACILITY_FD; + break; + case 5: + en_facility.type = SIM_FACILITY_PN; + break; + case 6: + en_facility.type = SIM_FACILITY_PU; + break; + case 7: + en_facility.type = SIM_FACILITY_PP; + break; + case 8: + en_facility.type = SIM_FACILITY_PC; + break; + default: + err("Unhandled/Unknown type[0x%x]", arg_type); + break; + } + en_facility.password_length = strlen(arg_password); + memcpy(en_facility.password, arg_password, en_facility.password_length); + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sim_enable_facility), &en_facility); + tcore_user_request_set_command(ur, TREQ_SIM_ENABLE_FACILITY); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_facility(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_type, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + struct treq_sim_get_facility_status facility; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_FACILITY, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Facility"); + + memset(&facility, 0, sizeof(struct treq_sim_get_facility_status)); + + dbg("arg_type[%d]", arg_type); + + switch (arg_type) { + case 1: + facility.type = SIM_FACILITY_PS; + break; + case 3: + facility.type = SIM_FACILITY_SC; + break; + case 4: + facility.type = SIM_FACILITY_FD; + break; + case 5: + facility.type = SIM_FACILITY_PN; + break; + case 6: + facility.type = SIM_FACILITY_PU; + break; + case 7: + facility.type = SIM_FACILITY_PP; + break; + case 8: + facility.type = SIM_FACILITY_PC; + break; + default: + err("Unhandled/Unknown type[0x%x]", arg_type); + break; + } + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sim_get_facility_status), &facility); + tcore_user_request_set_command(ur, TREQ_SIM_GET_FACILITY_STATUS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_lock_info(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_type, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_get_lock_info lock_info; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_LOCK_INFO, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get Lock Info"); + + memset(&lock_info, 0, sizeof(struct treq_sim_get_lock_info)); + + dbg("arg_type[%d]", arg_type); + switch (arg_type) { + case 1: + lock_info.type = SIM_FACILITY_PS; + break; + case 3: + lock_info.type = SIM_FACILITY_SC; + break; + case 4: + lock_info.type = SIM_FACILITY_FD; + break; + case 5: + lock_info.type = SIM_FACILITY_PN; + break; + case 6: + lock_info.type = SIM_FACILITY_PU; + break; + case 7: + lock_info.type = SIM_FACILITY_PP; + break; + case 8: + lock_info.type = SIM_FACILITY_PC; + break; + default: + err("Unhandled/Unknown type[0x%x]", arg_type); + break; + } + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sim_get_lock_info), &lock_info); + tcore_user_request_set_command(ur, TREQ_SIM_GET_LOCK_INFO); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_transfer_apdu(TelephonySim *sim, GDBusMethodInvocation *invocation, + GVariant *arg_apdu, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + struct treq_sim_transmit_apdu send_apdu; + GVariantIter *iter = NULL; + GVariant *inner_gv = NULL; + guchar rt_i; + TReturn ret; + CoreObject *co_sim = NULL; + int i =0; + + if (!check_access_control (invocation, AC_SIM, "x")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(TRANSFER_APDU, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Transfer APDU"); + + memset(&send_apdu, 0, sizeof(struct treq_sim_transmit_apdu)); + + inner_gv = g_variant_get_variant(arg_apdu); + + g_variant_get(inner_gv, "ay", &iter); + while ( g_variant_iter_loop (iter, "y", &rt_i)) { + send_apdu.apdu[i] = rt_i; + i++; + } + send_apdu.apdu_length = (unsigned int)i; + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + g_variant_unref(arg_apdu); + + tcore_util_hex_dump("[APDU_REQ] ", send_apdu.apdu_length, send_apdu.apdu); + + ur = MAKE_UR(ctx, sim, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sim_transmit_apdu), &send_apdu); + tcore_user_request_set_command(ur, TREQ_SIM_TRANSMIT_APDU); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_atr(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_ATR, co_sim); + DBUS_SIM_CHECK_SIM_TYPE(co_sim, "Get ATR"); + + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_ATR); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_fields(TelephonySim *sim, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct tel_sim_imsi *n_imsi = NULL; + //struct tel_sim_msisdn_list *msisdn_list = NULL; + //struct tel_sim_iccid *iccid = NULL; + //struct tel_sim_spn *spn= NULL; + CoreObject *co_sim = NULL; + GVariantBuilder b; + GVariant *gv_fields = NULL; + + dbg("Func Entrance"); + + if (!check_access_control (invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + + g_variant_builder_init(&b, G_VARIANT_TYPE("a{svv}}")); + + DBUS_SIM_CHECK_SIM_STATUS(GET_IMSI, co_sim); + + n_imsi = tcore_sim_get_imsi(co_sim); + if (n_imsi != NULL) { + g_variant_builder_add(&b, "{svv}", "imsi", g_variant_new_string("plmn"), g_variant_new_string(n_imsi->plmn)); + g_variant_builder_add(&b, "{svv}", "imsi", g_variant_new_string("msin"), g_variant_new_string(n_imsi->msin)); + free(n_imsi); + } + + DBUS_SIM_CHECK_SIM_STATUS(GET_ICCID, co_sim); + //n_imsi = tcore_sim_get_imsi(co_sim); + //if (n_imsi != NULL) { + g_variant_builder_add(&b, "{svv}", "iccid", g_variant_new_string(""), g_variant_new_string("")); + //free(n_imsi); + //} + + DBUS_SIM_CHECK_SIM_STATUS(GET_MSISDN, co_sim); + g_variant_builder_add(&b, "{svv}", "msisdn", g_variant_new_string("name"), g_variant_new_string("number")); + + DBUS_SIM_CHECK_SIM_STATUS(GET_SPN, co_sim); + g_variant_builder_add(&b, "{svv}", "spn", g_variant_new_uint16(255), g_variant_new_string("network name")); + + DBUS_SIM_CHECK_SIM_STATUS(GET_INIT_STATUS, co_sim); + g_variant_builder_add(&b, "{svv}", "init_status", g_variant_new_uint16(0), g_variant_new_boolean(TRUE)); + + gv_fields = g_variant_builder_end(&b); + + telephony_sim_complete_get_fields(sim, invocation, 0, gv_fields); + + return TRUE; +} + +static gboolean on_sim_set_power_state(TelephonySim *sim, GDBusMethodInvocation *invocation, + gint arg_state, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + struct treq_sim_set_powerstate set_powerstate; + + if (!check_access_control (invocation, AC_SIM, "w")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(SET_POWERSTATE, co_sim); + + memset(&set_powerstate, 0, sizeof(struct treq_sim_set_powerstate)); + set_powerstate.state = arg_state; + + dbg("set_powerstate.state[%d]", set_powerstate.state); + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_sim_set_powerstate), &set_powerstate); + tcore_user_request_set_command(ur, TREQ_SIM_SET_POWERSTATE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_impi(TelephonySim *sim, + GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control(invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_IMPI, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_IMPI); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + err("[ERROR] tcore_communicator_dispatch_request(): [%d]", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_impu(TelephonySim *sim, + GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control(invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_IMPU, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_IMPU); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + err("[ERROR] tcore_communicator_dispatch_request(): [%d]", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_domain(TelephonySim *sim, + GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control(invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_DOMAIN, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_DOMAIN); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + err("[ERROR] tcore_communicator_dispatch_request(): [%d]", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_pcscf(TelephonySim *sim, + GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret; + CoreObject *co_sim = NULL; + + if (!check_access_control(invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_PCSCF, co_sim); + + ur = MAKE_UR(ctx, sim, invocation); + + tcore_user_request_set_command(ur, TREQ_SIM_GET_PCSCF); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + err("[ERROR] tcore_communicator_dispatch_request(): [%d]", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean on_sim_get_app_list(TelephonySim *sim, + GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + CoreObject *co_sim = NULL; + unsigned char app_list = 0; + + dbg("Func Entrance"); + + if (!check_access_control(invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_APP_LIST, co_sim); + + app_list = tcore_sim_get_app_list(co_sim); + telephony_sim_complete_get_app_list(sim, invocation, app_list); + return TRUE; +} + +static gboolean on_sim_get_isim_service_table(TelephonySim *sim, + GDBusMethodInvocation *invocation, gpointer user_data) +{ + struct custom_data *ctx = user_data; + struct tel_sim_ist *ist = NULL; + CoreObject *co_sim = NULL; + + dbg("Func Entrance"); + + if (!check_access_control(invocation, AC_SIM, "r")) + return TRUE; + + DBUS_SIM_GET_COSIM(invocation, co_sim, ctx->server); + DBUS_SIM_CHECK_SIM_STATUS(GET_ISIM_SERVICE_TABLE, co_sim); + + ist = tcore_sim_get_isim_service_table(co_sim); + if (ist) { + GVariantBuilder builder; + GVariant *ist_gv = NULL; + GVariant *inner_gv = NULL; + int i; + + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay")); + for (i = 0; i < SIM_IST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add(&builder, "y", ist->service[i]); + } + inner_gv = g_variant_builder_end(&builder); + ist_gv = g_variant_new("v", inner_gv); + + telephony_sim_complete_get_isim_service_table(sim, invocation, + SIM_ACCESS_SUCCESS, ist_gv); + g_free(ist); + } else { + UserRequest *ur = NULL; + TReturn ret; + ur = MAKE_UR(ctx, sim, invocation); + + dbg("Not cached. Request to modem"); + tcore_user_request_set_command(ur, TREQ_SIM_GET_ISIM_SERVICE_TABLE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ERROR] tcore_communicator_dispatch_request(): [%d]", ret); + tcore_user_request_unref(ur); + } + } + return TRUE; +} + +gboolean dbus_plugin_setup_sim_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonySim *sim; + + sim = telephony_sim_skeleton_new(); + telephony_object_skeleton_set_sim(object, sim); + g_object_unref(sim); + + dbg("sim: [%p]", sim); + + telephony_sim_set_cf_state(sim, FALSE); + + g_signal_connect (sim, + "handle-get-init-status", + G_CALLBACK (on_sim_get_init_status), + ctx); + + g_signal_connect (sim, + "handle-get-card-type", + G_CALLBACK (on_sim_get_card_type), + ctx); + + g_signal_connect (sim, + "handle-get-imsi", + G_CALLBACK (on_sim_get_imsi), + ctx); + + g_signal_connect (sim, + "handle-get-ecc", + G_CALLBACK (on_sim_get_ecc), + ctx); + + g_signal_connect (sim, + "handle-get-iccid", + G_CALLBACK (on_sim_get_iccid), + ctx); + + g_signal_connect (sim, + "handle-get-language", + G_CALLBACK (on_sim_get_language), + ctx); + + g_signal_connect (sim, + "handle-set-language", + G_CALLBACK (on_sim_set_language), + ctx); + + g_signal_connect (sim, + "handle-get-call-forwarding", + G_CALLBACK (on_sim_get_call_forwarding), + ctx); + + g_signal_connect (sim, + "handle-set-call-forwarding", + G_CALLBACK (on_sim_set_call_forwarding), + ctx); + + g_signal_connect (sim, + "handle-get-message-waiting", + G_CALLBACK (on_sim_get_message_waiting), + ctx); + + g_signal_connect (sim, + "handle-set-message-waiting", + G_CALLBACK (on_sim_set_message_waiting), + ctx); + + g_signal_connect (sim, + "handle-get-mailbox", + G_CALLBACK (on_sim_get_mailbox), + ctx); + + g_signal_connect (sim, + "handle-set-mailbox", + G_CALLBACK (on_sim_set_mailbox), + ctx); + + g_signal_connect (sim, + "handle-get-cphsinfo", + G_CALLBACK (on_sim_get_cphsinfo), + ctx); + + g_signal_connect (sim, + "handle-get-service-table", + G_CALLBACK (on_sim_get_service_table), + ctx); + + g_signal_connect (sim, + "handle-get-msisdn", + G_CALLBACK (on_sim_get_msisdn), + ctx); + + g_signal_connect (sim, + "handle-get-oplmnwact", + G_CALLBACK (on_sim_get_oplmnwact), + ctx); + + g_signal_connect (sim, + "handle-get-spn", + G_CALLBACK (on_sim_get_spn), + ctx); + + g_signal_connect (sim, + "handle-get-cphs-net-name", + G_CALLBACK (on_sim_get_cphs_netname), + ctx); + + g_signal_connect (sim, + "handle-get-gid", + G_CALLBACK (on_sim_get_gid), + ctx); + + g_signal_connect (sim, + "handle-authentication", + G_CALLBACK (on_sim_authentication), + ctx); + + g_signal_connect (sim, + "handle-verify-sec", + G_CALLBACK (on_sim_verify_sec), + ctx); + + g_signal_connect (sim, + "handle-verify-puk", + G_CALLBACK (on_sim_verify_puk), + ctx); + + g_signal_connect (sim, + "handle-change-pin", + G_CALLBACK (on_sim_change_pin), + ctx); + + g_signal_connect (sim, + "handle-disable-facility", + G_CALLBACK (on_sim_disable_facility), + ctx); + + g_signal_connect (sim, + "handle-enable-facility", + G_CALLBACK (on_sim_enable_facility), + ctx); + + g_signal_connect (sim, + "handle-get-facility", + G_CALLBACK (on_sim_get_facility), + ctx); + + g_signal_connect (sim, + "handle-get-lock-info", + G_CALLBACK (on_sim_get_lock_info), + ctx); + + g_signal_connect (sim, + "handle-transfer-apdu", + G_CALLBACK (on_sim_transfer_apdu), + ctx); + + g_signal_connect (sim, + "handle-get-atr", + G_CALLBACK (on_sim_get_atr), + ctx); + + g_signal_connect (sim, + "handle-get-fields", + G_CALLBACK (on_sim_get_fields), + ctx); + + g_signal_connect (sim, + "handle-set-powerstate", + G_CALLBACK (on_sim_set_power_state), + ctx); + + g_signal_connect (sim, + "handle-get-impi", + G_CALLBACK (on_sim_get_impi), + ctx); + + g_signal_connect (sim, + "handle-get-impu", + G_CALLBACK (on_sim_get_impu), + ctx); + + g_signal_connect (sim, + "handle-get-domain", + G_CALLBACK (on_sim_get_domain), + ctx); + + g_signal_connect (sim, + "handle-get-pcscf", + G_CALLBACK (on_sim_get_pcscf), + ctx); + + g_signal_connect (sim, + "handle-get-app-list", + G_CALLBACK (on_sim_get_app_list), + ctx); + + g_signal_connect (sim, + "handle-get-isim-service-table", + G_CALLBACK (on_sim_get_isim_service_table), + ctx); + + return TRUE; +} + +gboolean dbus_plugin_sim_response(struct custom_data *ctx, UserRequest *ur, + struct dbus_request_info *dbus_info, enum tcore_response_command command, + unsigned int data_len, const void *data) +{ + dbg("Response!!! Command: [0x%x] CP Name: [%s]", + command, GET_CP_NAME(dbus_info->invocation)); + + switch (command) { + case TRESP_SIM_GET_ECC: { + const struct tresp_sim_read *resp_read = data; + CoreObject *co_sim = NULL; + GVariant *gv = NULL; + GVariantBuilder b; + int i = 0; + + dbg("TRESP_SIM_GET_ECC - Result: [%s])", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + co_sim = __get_sim_co_from_ur(ctx->server, ur); + if (!co_sim) { + err("SIM Core object is NULL"); + return FALSE; + } + + if (resp_read->result == SIM_ACCESS_SUCCESS) { + tcore_sim_set_ecc_list(co_sim, &resp_read->data.ecc); + } else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND) { + tcore_sim_set_ecc_list(co_sim, NULL); + } + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i = 0; i < resp_read->data.ecc.ecc_count; i++) { + dbg("ecc[%d] : ecc_category=[0x%x], ecc_num=[%s], ecc_string=[%s]", i, + resp_read->data.ecc.ecc[i].ecc_category, + resp_read->data.ecc.ecc[i].ecc_num, + resp_read->data.ecc.ecc[i].ecc_string); + + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "category", g_variant_new_int32(resp_read->data.ecc.ecc[i].ecc_category)); + g_variant_builder_add(&b, "{sv}", "number", g_variant_new_string(resp_read->data.ecc.ecc[i].ecc_num)); + g_variant_builder_add(&b, "{sv}", "name", g_variant_new_string(resp_read->data.ecc.ecc[i].ecc_string)); + g_variant_builder_close(&b); + } + gv = g_variant_builder_end(&b); + + telephony_sim_complete_get_ecc (dbus_info->interface_object, dbus_info->invocation, gv); + } + break; + + case TRESP_SIM_GET_ICCID: { + const struct tresp_sim_read *resp_read = data; + CoreObject *co_sim = NULL; + + dbg("TRESP_SIM_GET_ICCID - Result: [%s] ICCID: [%s])", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"), + resp_read->data.iccid.iccid); + + co_sim = __get_sim_co_from_ur(ctx->server, ur); + if (!co_sim) { + err("SIM Core object is NULL"); + return FALSE; + } + + if (resp_read->result == SIM_ACCESS_SUCCESS) { + tcore_sim_set_iccid(co_sim, &resp_read->data.iccid); + } else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND) { + tcore_sim_set_iccid(co_sim, NULL); + } + + telephony_sim_complete_get_iccid(dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + resp_read->data.iccid.iccid); + } + break; + + case TRESP_SIM_GET_LANGUAGE: { + const struct tresp_sim_read *resp_read = data; + + dbg("TRESP_SIM_GET_LANGUAGE - Result: [%s] Language: [0x%2x]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"), + resp_read->data.language.language[0]); + + telephony_sim_complete_get_language(dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + resp_read->data.language.language[0]); + } + break; + + case TRESP_SIM_SET_LANGUAGE: { + const struct tresp_sim_set_data *resp_set_data = data; + + dbg("TRESP_SIM_SET_LANGUAGE - Result: [%s]", + (resp_set_data->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + telephony_sim_complete_set_language(dbus_info->interface_object, dbus_info->invocation, + resp_set_data->result); + } + break; + + case TRESP_SIM_GET_CALLFORWARDING: { + const struct tresp_sim_read *resp_read = data; + GVariant *gv_cf = NULL; + GVariant *gv_cphs_cf = NULL; + GVariantBuilder b; + + dbg("TRESP_SIM_GET_CALLFORWARDING - Result: [%s] CPHS: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"), + (resp_read->data.cf.b_cphs ? "Yes" : "No")); + + if (resp_read->data.cf.b_cphs) { + dbg("b_line1[%d], b_line2[%d], b_fax[%d], b_data[%d]", + resp_read->data.cf.cphs_cf.b_line1, resp_read->data.cf.cphs_cf.b_line2, + resp_read->data.cf.cphs_cf.b_fax, resp_read->data.cf.cphs_cf.b_data); + + g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "b_line1", g_variant_new_boolean(resp_read->data.cf.cphs_cf.b_line1)); + g_variant_builder_add(&b, "{sv}", "b_line2", g_variant_new_boolean(resp_read->data.cf.cphs_cf.b_line2)); + g_variant_builder_add(&b, "{sv}", "b_fax", g_variant_new_boolean(resp_read->data.cf.cphs_cf.b_fax)); + g_variant_builder_add(&b, "{sv}", "b_data", g_variant_new_boolean(resp_read->data.cf.cphs_cf.b_data)); + gv_cphs_cf = g_variant_builder_end(&b); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + gv_cf = g_variant_builder_end(&b); + + } else { + int i =0; + + dbg("profile_count[%d]",resp_read->data.cf.cf_list.profile_count); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i = 0; i < resp_read->data.cf.cf_list.profile_count; i++) { + dbg("[%d] : rec_index[0x%x], msp_num[0x%x], cfu_status[0x%x], " + "cfu_num[%s], ton[0x%x], npi[0x%x], cc2_id[0x%x], ext7_id[0x%x]", + i, resp_read->data.cf.cf_list.cf[i].rec_index, resp_read->data.cf.cf_list.cf[i].msp_num, + resp_read->data.cf.cf_list.cf[i].cfu_status, resp_read->data.cf.cf_list.cf[i].cfu_num, + resp_read->data.cf.cf_list.cf[i].ton, resp_read->data.cf.cf_list.cf[i].npi, + resp_read->data.cf.cf_list.cf[i].cc2_id, resp_read->data.cf.cf_list.cf[i].ext7_id); + + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "rec_index", g_variant_new_int32(resp_read->data.cf.cf_list.cf[i].rec_index)); + g_variant_builder_add(&b, "{sv}", "msp_num", g_variant_new_byte(resp_read->data.cf.cf_list.cf[i].msp_num)); + g_variant_builder_add(&b, "{sv}", "cfu_status", g_variant_new_byte(resp_read->data.cf.cf_list.cf[i].cfu_status)); + g_variant_builder_add(&b, "{sv}", "cfu_num", g_variant_new_string(resp_read->data.cf.cf_list.cf[i].cfu_num)); + g_variant_builder_add(&b, "{sv}", "ton", g_variant_new_int32(resp_read->data.cf.cf_list.cf[i].ton)); + g_variant_builder_add(&b, "{sv}", "npi", g_variant_new_int32(resp_read->data.cf.cf_list.cf[i].npi)); + g_variant_builder_add(&b, "{sv}", "cc2_id", g_variant_new_byte(resp_read->data.cf.cf_list.cf[i].cc2_id)); + g_variant_builder_add(&b, "{sv}", "ext7_id", g_variant_new_byte(resp_read->data.cf.cf_list.cf[i].ext7_id)); + g_variant_builder_close(&b); + } + gv_cf = g_variant_builder_end(&b); + + g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); + gv_cphs_cf = g_variant_builder_end(&b); + } + + telephony_sim_complete_get_call_forwarding (dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + resp_read->data.cf.b_cphs, + gv_cf, + gv_cphs_cf); + } + break; + + case TRESP_SIM_SET_CALLFORWARDING: { + const struct tresp_sim_set_data *resp_set_data = data; + + dbg("TRESP_SIM_SET_CALLFORWARDING - Result: [%s]", + (resp_set_data->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + telephony_sim_complete_set_call_forwarding(dbus_info->interface_object, dbus_info->invocation, + resp_set_data->result); + } + break; + + case TRESP_SIM_GET_MESSAGEWAITING: { + const struct tresp_sim_read *resp_read = data; + GVariant *gv_mw = NULL; + GVariant *gv_cphs_mw = NULL; + GVariantBuilder b; + + dbg("TRESP_SIM_GET_MESSAGEWAITING - Result: [%s] CPHS: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"), + (resp_read->data.mw.b_cphs ? "Yes" : "No")); + + if (resp_read->data.mw.b_cphs) { + dbg("b_voice1[%d], b_voice2[%d], b_fax[%d], b_data[%d]", + resp_read->data.mw.cphs_mw.b_voice1, resp_read->data.mw.cphs_mw.b_voice2, + resp_read->data.mw.cphs_mw.b_fax, resp_read->data.mw.cphs_mw.b_data); + + g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "b_voice1", g_variant_new_boolean(resp_read->data.mw.cphs_mw.b_voice1)); + g_variant_builder_add(&b, "{sv}", "b_voice2", g_variant_new_boolean(resp_read->data.mw.cphs_mw.b_voice2)); + g_variant_builder_add(&b, "{sv}", "b_fax", g_variant_new_boolean(resp_read->data.mw.cphs_mw.b_fax)); + g_variant_builder_add(&b, "{sv}", "b_data", g_variant_new_boolean(resp_read->data.mw.cphs_mw.b_data)); + gv_cphs_mw = g_variant_builder_end(&b); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + gv_mw = g_variant_builder_end(&b); + + } else { + int i =0; + + dbg("profile_count[%d]", resp_read->data.mw.mw_list.profile_count); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i = 0; i data.mw.mw_list.profile_count; i++) { + dbg("[%d] : rec_index[0x%x], indicator_status[0x%x], voice_count[0x%x], " + "fax_count[0x%x] email_count[0x%x], other_count[0x%x], video_count[0x%x]", + i, resp_read->data.mw.mw_list.mw[i].rec_index, resp_read->data.mw.mw_list.mw[i].indicator_status, + resp_read->data.mw.mw_list.mw[i].voice_count, resp_read->data.mw.mw_list.mw[i].fax_count, + resp_read->data.mw.mw_list.mw[i].email_count, resp_read->data.mw.mw_list.mw[i].other_count, + resp_read->data.mw.mw_list.mw[i].video_count); + + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b,"{sv}", "rec_index", g_variant_new_int32( resp_read->data.mw.mw_list.mw[i].rec_index)); + g_variant_builder_add(&b, "{sv}", "indicator_status", g_variant_new_byte(resp_read->data.mw.mw_list.mw[i].indicator_status)); + g_variant_builder_add(&b,"{sv}", "voice_count", g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].voice_count)); + g_variant_builder_add(&b,"{sv}", "fax_count", g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].fax_count)); + g_variant_builder_add(&b, "{sv}", "email_count", g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].email_count)); + g_variant_builder_add(&b, "{sv}", "other_count", g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].other_count)); + g_variant_builder_add(&b, "{sv}", "video_count", g_variant_new_int32(resp_read->data.mw.mw_list.mw[i].video_count)); + g_variant_builder_close(&b); + } + gv_mw = g_variant_builder_end(&b); + g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}")); + gv_cphs_mw = g_variant_builder_end(&b); + } + + telephony_sim_complete_get_message_waiting(dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + resp_read->data.mw.b_cphs, + gv_mw, + gv_cphs_mw); + } + break; + + case TRESP_SIM_SET_MESSAGEWAITING: { + const struct tresp_sim_set_data *resp_set_data = data; + + dbg("TRESP_SIM_SET_MESSAGEWAITING - Result: [%s]", + (resp_set_data->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + telephony_sim_complete_set_message_waiting(dbus_info->interface_object, dbus_info->invocation, + resp_set_data->result); + } + break; + + case TRESP_SIM_GET_MAILBOX: { + const struct tresp_sim_read *resp_read = data; + GVariant *gv = NULL; + GVariantBuilder b; + int i =0; + + dbg("TRESP_SIM_GET_MAILBOX - Result: [%s] CPHS: [%s] Count: [%d])", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"), + (resp_read->data.mb.b_cphs ? "Yes" : "No"), + resp_read->data.mb.count); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i =0; i < resp_read->data.mb.count; i++) { + dbg("resp_read->data.mb.mb[%d] : " + "rec_index[%d], profile_number[%d], mb_type[%d], alpha_id_max_len[%d]" + "alpha_id[%s], ton[%d], npi[%d], num[%s], cc_id[%d], ext1_id[%d]", + i, resp_read->data.mb.mb[i].rec_index, resp_read->data.mb.mb[i].profile_number, + resp_read->data.mb.mb[i].mb_type, resp_read->data.mb.mb[i].number_info.alpha_id_max_len, + resp_read->data.mb.mb[i].number_info.alpha_id, resp_read->data.mb.mb[i].number_info.ton, + resp_read->data.mb.mb[i].number_info.npi, resp_read->data.mb.mb[i].number_info.num, + resp_read->data.mb.mb[i].number_info.cc_id, resp_read->data.mb.mb[i].number_info.ext1_id); + + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "rec_index", g_variant_new_int32(resp_read->data.mb.mb[i].rec_index)); + g_variant_builder_add(&b, "{sv}", "profile_num", g_variant_new_int32(resp_read->data.mb.mb[i].profile_number)); + g_variant_builder_add(&b, "{sv}", "mb_type", g_variant_new_int32(resp_read->data.mb.mb[i].mb_type)); + g_variant_builder_add(&b, "{sv}", "alpha_id_max_len", g_variant_new_int32(resp_read->data.mb.mb[i].number_info.alpha_id_max_len)); + g_variant_builder_add(&b, "{sv}", "alpha_id", g_variant_new_string(resp_read->data.mb.mb[i].number_info.alpha_id)); + g_variant_builder_add(&b, "{sv}", "ton", g_variant_new_int32(resp_read->data.mb.mb[i].number_info.ton)); + g_variant_builder_add(&b, "{sv}", "npi", g_variant_new_int32(resp_read->data.mb.mb[i].number_info.npi)); + g_variant_builder_add(&b, "{sv}", "num", g_variant_new_string(resp_read->data.mb.mb[i].number_info.num)); + g_variant_builder_add(&b, "{sv}", "cc_id", g_variant_new_byte(resp_read->data.mb.mb[i].number_info.cc_id)); + g_variant_builder_add(&b, "{sv}", "ext1_id", g_variant_new_byte(resp_read->data.mb.mb[i].number_info.ext1_id)); + g_variant_builder_close(&b); + } + + gv = g_variant_builder_end(&b); + + telephony_sim_complete_get_mailbox (dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + resp_read->data.mb.b_cphs, + gv); + } + break; + + case TRESP_SIM_SET_MAILBOX: { + const struct tresp_sim_set_data *resp_set_data = data; + + dbg("TRESP_SIM_SET_MAILBOX - Result: [%s]", + (resp_set_data->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + telephony_sim_complete_set_mailbox(dbus_info->interface_object, dbus_info->invocation, + resp_set_data->result); + } + break; + + case TRESP_SIM_GET_CPHS_INFO: { + const struct tresp_sim_read *resp_read = data; + + dbg("TRESP_SIM_GET_CPHS_INFO - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + telephony_sim_complete_get_cphsinfo (dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + resp_read->data.cphs.CphsPhase, + resp_read->data.cphs.CphsServiceTable.bOperatorNameShortForm, + resp_read->data.cphs.CphsServiceTable.bMailBoxNumbers, + resp_read->data.cphs.CphsServiceTable.bServiceStringTable, + resp_read->data.cphs.CphsServiceTable.bCustomerServiceProfile, + resp_read->data.cphs.CphsServiceTable.bInformationNumbers); + } + break; + + case TRESP_SIM_GET_SERVICE_TABLE: { + const struct tresp_sim_read *resp_read = data; + CoreObject *co_sim = NULL; + GVariantBuilder builder; + GVariant * inner_gv = NULL; + GVariant *svct_gv = NULL; + int i =0; + + dbg("TRESP_SIM_GET_SERVICE_TABLE - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + co_sim = __get_sim_co_from_ur(ctx->server, ur); + if (!co_sim) { + err("SIM Core object is NULL"); + return FALSE; + } + + if (resp_read->result == SIM_ACCESS_SUCCESS) { + tcore_sim_set_service_table(co_sim, &resp_read->data.svct); + } else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND) { + tcore_sim_set_service_table(co_sim, NULL); + } + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + + if (resp_read->data.svct.sim_type == SIM_TYPE_GSM) { + for (i = 0; i < SIM_SST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add (&builder, "y", resp_read->data.svct.table.sst.service[i]); + } + } else if (resp_read->data.svct.sim_type == SIM_TYPE_USIM) { + for (i = 0; i < SIM_UST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add (&builder, "y", resp_read->data.svct.table.ust.service[i]); + } + } else if(resp_read->data.svct.sim_type == SIM_TYPE_RUIM) { + if(SIM_CDMA_SVC_TABLE == resp_read->data.svct.table.cst.cdma_svc_table) { + for(i = 0; i < SIM_CDMA_ST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add (&builder, "iy", resp_read->data.svct.table.cst.cdma_svc_table, + resp_read->data.svct.table.cst.service.cdma_service[i]); + } + } else if(SIM_CSIM_SVC_TABLE == resp_read->data.svct.table.cst.cdma_svc_table) { + for(i = 0; i < SIM_CSIM_ST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add (&builder, "iy", resp_read->data.svct.table.cst.cdma_svc_table, + resp_read->data.svct.table.cst.service.csim_service[i]); + } + } else { + err("Invalid cdma_svc_table:[%d]", resp_read->data.svct.table.cst.cdma_svc_table); + } + } else { + dbg("unknown sim type."); + } + inner_gv = g_variant_builder_end(&builder); + svct_gv = g_variant_new("v", inner_gv); + + telephony_sim_complete_get_service_table (dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + resp_read->data.svct.sim_type, + svct_gv); + } break; + + case TRESP_SIM_GET_SPN: { + const struct tresp_sim_read *resp_read = data; + CoreObject *co_sim = NULL; + + dbg("TRESP_SIM_GET_SPN - Result: [%s] Display condition: [%d] SPN: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail"), + resp_read->data.spn.display_condition, (const gchar *)resp_read->data.spn.spn); + + co_sim = __get_sim_co_from_ur(ctx->server, ur); + if (!co_sim) { + err("SIM Core object is NULL"); + return FALSE; + } + + if (resp_read->result == SIM_ACCESS_SUCCESS) { + tcore_sim_set_spn(co_sim, &resp_read->data.spn); + } else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND) { + tcore_sim_set_spn(co_sim, NULL); + } + + telephony_sim_complete_get_spn (dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + resp_read->data.spn.display_condition, (const gchar *)resp_read->data.spn.spn); + } + break; + + case TRESP_SIM_GET_CPHS_NETNAME: { + const struct tresp_sim_read *resp_read = data; + CoreObject *co_sim = NULL; + + dbg("TRESP_SIM_GET_CPHS_NETNAME - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + co_sim = __get_sim_co_from_ur(ctx->server, ur); + if (!co_sim) { + err("SIM Core object is NULL"); + return FALSE; + } + + if (resp_read->result == SIM_ACCESS_SUCCESS) { + tcore_sim_set_cphs_netname(co_sim, &resp_read->data.cphs_net); + } else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND) { + tcore_sim_set_cphs_netname(co_sim, NULL); + } + + telephony_sim_complete_get_cphs_net_name (dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + (const gchar *)resp_read->data.cphs_net.full_name, (const gchar *)resp_read->data.cphs_net.short_name); + } + break; + + case TRESP_SIM_GET_GID: { + const struct tresp_sim_read *resp_read = data; + GVariantBuilder *builder = NULL; + GVariant * inner_gv = NULL; + GVariant *gid_gv = NULL; + int i =0; + + dbg("TRESP_SIM_GET_GID - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + builder = g_variant_builder_new (G_VARIANT_TYPE ("ay")); + + for(i = 0; i < resp_read->data.gid.GroupIdentifierLen; i++) { + g_variant_builder_add (builder, "y", resp_read->data.gid.szGroupIdentifier[i]); + } + inner_gv = g_variant_builder_end(builder); + gid_gv = g_variant_new("v", inner_gv); + + telephony_sim_complete_get_gid (dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + resp_read->data.gid.GroupIdentifierLen, + gid_gv); + } + break; + + case TRESP_SIM_GET_MSISDN:{ + const struct tresp_sim_read *resp_read = data; + CoreObject *co_sim = NULL; + GVariant *gv = NULL; + GVariantBuilder b; + int i =0; + + dbg("TRESP_SIM_GET_MSISDN - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + co_sim = __get_sim_co_from_ur(ctx->server, ur); + if (!co_sim) { + err("SIM Core object is NULL"); + return FALSE; + } + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + if (resp_read->result == SIM_ACCESS_SUCCESS) { + tcore_sim_set_msisdn_list(co_sim, &resp_read->data.msisdn_list); + } else if (resp_read->result == SIM_ACCESS_FILE_NOT_FOUND) { + tcore_sim_set_msisdn_list(co_sim, NULL); + } + + for (i = 0; i < resp_read->data.msisdn_list.count; i++) { + g_variant_builder_open(&b,G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "name", g_variant_new_string((const gchar *)resp_read->data.msisdn_list.msisdn[i].name)); + if (resp_read->data.msisdn_list.msisdn[i].ton == SIM_TON_INTERNATIONAL) { + unsigned char *tmp = (unsigned char *)calloc(SIM_MSISDN_NUMBER_LEN_MAX + 1, 1); + if (tmp!=NULL) { + tmp[0] = '+'; + strncpy((char *)tmp+1, (const char*)resp_read->data.msisdn_list.msisdn[i].num, SIM_MSISDN_NUMBER_LEN_MAX - 1); + tmp[SIM_MSISDN_NUMBER_LEN_MAX] = '\0'; + g_variant_builder_add(&b, "{sv}", "number", g_variant_new_string((const gchar *)tmp)); + free(tmp); + } else { + dbg("calloc failed."); + g_variant_builder_add(&b, "{sv}", "number", g_variant_new_string((const gchar *)resp_read->data.msisdn_list.msisdn[i].num)); + } + } else { + g_variant_builder_add(&b, "{sv}", "number", g_variant_new_string((const gchar *)resp_read->data.msisdn_list.msisdn[i].num)); + } + g_variant_builder_close(&b); + } + gv = g_variant_builder_end(&b); + + telephony_sim_complete_get_msisdn (dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + gv); + } + break; + + case TRESP_SIM_GET_OPLMNWACT: { + const struct tresp_sim_read *resp_read = data; + GVariant *gv = NULL; + GVariantBuilder b; + int i =0; + + dbg("TRESP_SIM_GET_OPLMNWACT - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i = 0;i < resp_read->data.opwa.opwa_count; i++) { + g_variant_builder_open(&b,G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "plmn", g_variant_new_string((const gchar *)resp_read->data.opwa.opwa[i].plmn)); + g_variant_builder_add(&b, "{sv}", "b_umts", g_variant_new_boolean(resp_read->data.opwa.opwa[i].b_umts)); + g_variant_builder_add(&b, "{sv}", "b_gsm", g_variant_new_boolean(resp_read->data.opwa.opwa[i].b_gsm)); + g_variant_builder_close(&b); + } + gv = g_variant_builder_end(&b); + + telephony_sim_complete_get_oplmnwact (dbus_info->interface_object, dbus_info->invocation, + resp_read->result, + gv); + } + break; + + case TRESP_SIM_REQ_AUTHENTICATION: { + const struct tresp_sim_req_authentication *resp_auth = data; + GVariantBuilder builder; + GVariant *ak = NULL; + GVariant *cp = NULL; + GVariant *it = NULL; + GVariant *resp = NULL; + GVariant *ak_gv = NULL; + GVariant *cp_gv = NULL; + GVariant *it_gv = NULL; + GVariant *resp_gv = NULL; + int i =0; + + dbg("TRESP_SIM_REQ_AUTHENTICATION - Result: [%s]", + (resp_auth->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + tcore_util_hex_dump("[AUTH_KEY] ", resp_auth->authentication_key_length, resp_auth->authentication_key); + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + for (i = 0; i < (int)resp_auth->authentication_key_length; i++) { + g_variant_builder_add (&builder, "y", resp_auth->authentication_key[i]); + } + ak = g_variant_builder_end(&builder); + ak_gv = g_variant_new("v", ak); + + tcore_util_hex_dump("[CIPHER_DATA] ", resp_auth->cipher_length, resp_auth->cipher_data); + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + for (i = 0; i < (int)resp_auth->cipher_length; i++) { + g_variant_builder_add (&builder, "y", resp_auth->cipher_data[i]); + } + cp = g_variant_builder_end(&builder); + cp_gv = g_variant_new("v", cp); + + tcore_util_hex_dump("[INTEGRITY_DATA] ", resp_auth->integrity_length, resp_auth->integrity_data); + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + for (i = 0; i < (int)resp_auth->integrity_length; i++) { + g_variant_builder_add (&builder, "y", resp_auth->integrity_data[i]); + } + it = g_variant_builder_end(&builder); + it_gv = g_variant_new("v", it); + + tcore_util_hex_dump("[RESP_DATA] ", resp_auth->resp_length, resp_auth->resp_data); + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + for (i = 0; i < (int)resp_auth->resp_length; i++) { + g_variant_builder_add (&builder, "y", resp_auth->resp_data[i]); + } + resp = g_variant_builder_end(&builder); + resp_gv = g_variant_new("v", resp); + + telephony_sim_complete_authentication (dbus_info->interface_object, dbus_info->invocation, + resp_auth->result, + resp_auth->auth_type, + resp_auth->auth_result, + ak_gv, + cp_gv, + it_gv, + resp_gv); + } + break; + + case TRESP_SIM_VERIFY_PINS: { + const struct tresp_sim_verify_pins *resp_verify_pins = data; + + dbg("TRESP_SIM_VERIFY_PINS - Result: [%s] PIN Type: [%d] Re-try count: [%d]", + (resp_verify_pins->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"), + resp_verify_pins->pin_type, resp_verify_pins->retry_count); + + telephony_sim_complete_verify_sec(dbus_info->interface_object, dbus_info->invocation, + resp_verify_pins->result, + resp_verify_pins->pin_type, + resp_verify_pins->retry_count); + } + break; + + case TRESP_SIM_VERIFY_PUKS: { + const struct tresp_sim_verify_puks *resp_verify_puks = data; + + dbg("TRESP_SIM_VERIFY_PUKS - Result: [%s] PIN Type: [%d] Re-try count: [%d]", + (resp_verify_puks->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"), + resp_verify_puks->pin_type, resp_verify_puks->retry_count); + + telephony_sim_complete_verify_puk (dbus_info->interface_object, dbus_info->invocation, + resp_verify_puks->result, + resp_verify_puks->pin_type, + resp_verify_puks->retry_count); + } + break; + + case TRESP_SIM_CHANGE_PINS: { + const struct tresp_sim_change_pins *resp_change_pins = data; + + dbg("TRESP_SIM_CHANGE_PINS - Result: [%s] PIN Type: [%d] Re-try count: [%d]", + (resp_change_pins->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"), + resp_change_pins->pin_type, resp_change_pins->retry_count); + + telephony_sim_complete_change_pin(dbus_info->interface_object, dbus_info->invocation, + resp_change_pins->result, + resp_change_pins->pin_type, + resp_change_pins->retry_count); + } + break; + + case TRESP_SIM_DISABLE_FACILITY: { + const struct tresp_sim_disable_facility *resp_dis_facility = data; + gint f_type =0; + + dbg("TRESP_SIM_DISABLE_FACILITY - Result: [%s] Type: [%d] Re-try count: [%d]", + (resp_dis_facility->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"), + resp_dis_facility->type, resp_dis_facility->retry_count); + + switch (resp_dis_facility->type) { + case SIM_FACILITY_PS: + f_type = 1; + break; + case SIM_FACILITY_SC: + f_type = 3; + break; + case SIM_FACILITY_FD: + f_type = 4; + break; + case SIM_FACILITY_PN: + f_type = 5; + break; + case SIM_FACILITY_PU: + f_type = 6; + break; + case SIM_FACILITY_PP: + f_type = 7; + break; + case SIM_FACILITY_PC: + f_type = 8; + break; + default: + err("Unhandled/Unknown type[0x%x]", resp_dis_facility->type); + break; + } + + telephony_sim_complete_disable_facility(dbus_info->interface_object, dbus_info->invocation, + resp_dis_facility->result, + f_type, + resp_dis_facility->retry_count); + } + break; + + case TRESP_SIM_ENABLE_FACILITY: { + const struct tresp_sim_enable_facility *resp_en_facility = data; + gint f_type =0; + + dbg("TRESP_SIM_ENABLE_FACILITY - Result: [%s] Type: [%d] Re-try count: [%d]", + (resp_en_facility->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"), + resp_en_facility->type, resp_en_facility->retry_count); + + switch (resp_en_facility->type) { + case SIM_FACILITY_PS: + f_type = 1; + break; + case SIM_FACILITY_SC: + f_type = 3; + break; + case SIM_FACILITY_FD: + f_type = 4; + break; + case SIM_FACILITY_PN: + f_type = 5; + break; + case SIM_FACILITY_PU: + f_type = 6; + break; + case SIM_FACILITY_PP: + f_type = 7; + break; + case SIM_FACILITY_PC: + f_type = 8; + break; + default: + err("Unhandled/Unknown type[0x%x]", resp_en_facility->type); + break; + } + + telephony_sim_complete_enable_facility(dbus_info->interface_object, dbus_info->invocation, + resp_en_facility->result, + f_type, + resp_en_facility->retry_count); + } + break; + + case TRESP_SIM_GET_FACILITY_STATUS: { + const struct tresp_sim_get_facility_status *resp_get_facility = data; + gint f_type =0; + + dbg("TRESP_SIM_GET_FACILITY_STATUS - Result: [%s] Type: [%d] Enable: [%s]", + (resp_get_facility->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"), + resp_get_facility->type, + (resp_get_facility->b_enable ? "Yes" : "No")); + + switch (resp_get_facility->type) { + case SIM_FACILITY_PS: + f_type = 1; + break; + case SIM_FACILITY_SC: + f_type = 3; + break; + case SIM_FACILITY_FD: + f_type = 4; + break; + case SIM_FACILITY_PN: + f_type = 5; + break; + case SIM_FACILITY_PU: + f_type = 6; + break; + case SIM_FACILITY_PP: + f_type = 7; + break; + case SIM_FACILITY_PC: + f_type = 8; + break; + default: + err("Unhandled/Unknown type[0x%x]", resp_get_facility->type); + break; + } + + telephony_sim_complete_get_facility(dbus_info->interface_object, dbus_info->invocation, + resp_get_facility->result, + f_type, + resp_get_facility->b_enable); + } + break; + + case TRESP_SIM_GET_LOCK_INFO: { + const struct tresp_sim_get_lock_info *resp_lock = data; + gint f_type =0; + + dbg("TRESP_SIM_GET_LOCK_INFO - Result: [%s] Type: [%d] Re-try count: [%d]", + (resp_lock->result == SIM_PIN_OPERATION_SUCCESS ? "Success" : "Fail"), + resp_lock->type, resp_lock->retry_count); + + switch (resp_lock->type) { + case SIM_FACILITY_PS: + f_type = 1; + break; + case SIM_FACILITY_SC: + f_type = 3; + break; + case SIM_FACILITY_FD: + f_type = 4; + break; + case SIM_FACILITY_PN: + f_type = 5; + break; + case SIM_FACILITY_PU: + f_type = 6; + break; + case SIM_FACILITY_PP: + f_type = 7; + break; + case SIM_FACILITY_PC: + f_type = 8; + break; + default: + err("Unhandled/Unknown type[0x%x]", resp_lock->type); + break; + } + + telephony_sim_complete_get_lock_info(dbus_info->interface_object, dbus_info->invocation, + resp_lock->result, + f_type, + resp_lock->lock_status, + resp_lock->retry_count); + } + break; + + case TRESP_SIM_TRANSMIT_APDU: { + const struct tresp_sim_transmit_apdu *resp_apdu = data; + GVariantBuilder builder; + GVariant * apdu_gv = NULL; + GVariant *inner_gv = NULL; + int i =0; + + dbg("TRESP_SIM_TRANSMIT_APDU - Result: [%s]", + (resp_apdu->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + tcore_util_hex_dump("[APDU_RESP] ", + resp_apdu->apdu_resp_length, resp_apdu->apdu_resp); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + for (i = 0; i < (int)resp_apdu->apdu_resp_length; i++) { + g_variant_builder_add (&builder, "y", resp_apdu->apdu_resp[i]); + } + inner_gv = g_variant_builder_end(&builder); + apdu_gv = g_variant_new("v", inner_gv); + + telephony_sim_complete_transfer_apdu(dbus_info->interface_object, dbus_info->invocation, + resp_apdu->result, + apdu_gv); + } + break; + + case TRESP_SIM_GET_ATR:{ + const struct tresp_sim_get_atr *resp_get_atr = data; + GVariantBuilder builder; + GVariant * atr_gv = NULL; + GVariant *inner_gv = NULL; + int i =0; + + dbg("TRESP_SIM_GET_ATR - Result: [%s]", + (resp_get_atr->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + tcore_util_hex_dump("[ATR_RESP] ", + resp_get_atr->atr_length, resp_get_atr->atr); + + g_variant_builder_init (&builder, G_VARIANT_TYPE ("ay")); + for (i = 0; i < (int)resp_get_atr->atr_length; i++) { + g_variant_builder_add (&builder, "y", resp_get_atr->atr[i]); + } + inner_gv = g_variant_builder_end(&builder); + atr_gv = g_variant_new("v", inner_gv); + + telephony_sim_complete_get_atr(dbus_info->interface_object, dbus_info->invocation, + resp_get_atr->result, + atr_gv); + } + break; + + case TRESP_SIM_SET_POWERSTATE: { + const struct tresp_sim_set_powerstate *resp_power = data; + + dbg("TRESP_SIM_SET_POWERSTATE - Result: [%s]", + (resp_power->result == SIM_POWER_SET_SUCCESS ? "Success" : "Fail")); + + telephony_sim_complete_set_powerstate(dbus_info->interface_object, dbus_info->invocation, + resp_power->result); + } + break; + + case TRESP_SIM_GET_IMPI: { + const struct tresp_sim_read *resp_read = data; + + dbg("TRESP_SIM_GET_IMPI - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + telephony_sim_complete_get_impi(dbus_info->interface_object, + dbus_info->invocation, resp_read->result, + resp_read->data.impi.impi); + } + break; + + case TRESP_SIM_GET_IMPU: { + const struct tresp_sim_read *resp_read = data; + GVariant *gv = NULL; + GVariantBuilder b; + unsigned int i; + + dbg("TRESP_SIM_GET_IMPU - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i = 0; i < resp_read->data.impu_list.count; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "impu", g_variant_new_string(resp_read->data.impu_list.impu[i].impu)); + g_variant_builder_close(&b); + } + gv = g_variant_builder_end(&b); + + telephony_sim_complete_get_impu(dbus_info->interface_object, + dbus_info->invocation, resp_read->result, gv); + } + break; + + case TRESP_SIM_GET_DOMAIN: { + const struct tresp_sim_read *resp_read = data; + + dbg("TRESP_SIM_GET_DOMAIN - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + telephony_sim_complete_get_domain(dbus_info->interface_object, + dbus_info->invocation, resp_read->result, + resp_read->data.domain.domain); + } + break; + + case TRESP_SIM_GET_PCSCF: { + const struct tresp_sim_read *resp_read = data; + GVariant *gv = NULL; + GVariantBuilder b; + unsigned int i; + + dbg("TRESP_SIM_GET_PCSCF - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + for (i = 0; i < resp_read->data.pcscf_list.count; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "type", + g_variant_new_int32(resp_read->data.pcscf_list.pcscf[i].type)); + g_variant_builder_add(&b, "{sv}", "pcscf", + g_variant_new_string(resp_read->data.pcscf_list.pcscf[i].pcscf)); + g_variant_builder_close(&b); + } + gv = g_variant_builder_end(&b); + + telephony_sim_complete_get_pcscf(dbus_info->interface_object, + dbus_info->invocation, resp_read->result, gv); + } + break; + + case TRESP_SIM_GET_ISIM_SERVICE_TABLE: { + const struct tresp_sim_read *resp_read = data; + GVariantBuilder builder; + GVariant *ist_gv = NULL; + GVariant *inner_gv = NULL; + int i; + + dbg("TRESP_SIM_GET_ISIM_SERVICE_TABLE - Result: [%s]", + (resp_read->result == SIM_ACCESS_SUCCESS ? "Success" : "Fail")); + + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay")); + for (i = 0; i < SIM_IST_SERVICE_CNT_MAX; i++) { + g_variant_builder_add(&builder, "y", resp_read->data.ist.service[i]); + } + inner_gv = g_variant_builder_end(&builder); + ist_gv = g_variant_new("v", inner_gv); + + telephony_sim_complete_get_isim_service_table(dbus_info->interface_object, + dbus_info->invocation, resp_read->result, ist_gv); + } + break; + + default: + err("Unhandled/Unknown Response!!!"); + break; + } + + return TRUE; +} + +gboolean dbus_plugin_sim_notification(struct custom_data *ctx, CoreObject *source, + TelephonyObjectSkeleton *object, enum tcore_notification_command command, + unsigned int data_len, const void *data) +{ + TelephonySim *sim; + const char *cp_name; + + cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source)); + + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, cp_name); + + sim = telephony_object_peek_sim(TELEPHONY_OBJECT(object)); + dbg("sim: [%p]", sim); + + switch (command) { + case TNOTI_SIM_STATUS: { + const struct tnoti_sim_status *n_sim_status = data; + int count = 0; + + info("[DBUSINFO][%s] SIM_STATUS : [%d]", cp_name, n_sim_status->sim_status); + +#ifdef ENABLE_KPI_LOGS + if (n_sim_status->sim_status == SIM_STATUS_INIT_COMPLETED) + TIME_CHECK("[%s] SIM Initialized", cp_name); +#endif + + telephony_sim_emit_status(sim, n_sim_status->sim_status); + + if (__is_valid_sim_status(ctx->sim1_status)) + count++; + if (__is_valid_sim_status(ctx->sim2_status)) + count++; + + if (ctx->valid_sim_count != count) { + ctx->valid_sim_count = count; + telephony_manager_emit_sim_inserted(ctx->mgr, count); + } + } + break; + + case TNOTI_SIM_REFRESHED: { + const struct tnoti_sim_refreshed *n_sim_refreshed = data; + info("[DBUSINFO][%s] SIM_REFRESHED : b_full_file_changed: [%s] changed_file_count: [%d]", + cp_name, (n_sim_refreshed->b_full_file_changed ? "Yes" : "No"), n_sim_refreshed->file_list.file_count); + + telephony_sim_emit_refreshed(sim, n_sim_refreshed->cmd_type); + } + break; + + case TNOTI_SIM_CALL_FORWARD_STATE: { + const struct tnoti_sim_call_forward_state *info = data; + info("[DBUSINFO][%s] SIM_CALL_FORWARD_STATE : [%s]", + cp_name, info->b_forward ? "ON" : "OFF"); + + telephony_sim_set_cf_state(sim, info->b_forward); + } + break; + + default: + err("Unhandled/Unknown Notification!!!"); + break; + } + + return TRUE; +} + diff --git a/src/sms.c b/src/sms.c new file mode 100755 index 0000000..e201d88 --- /dev/null +++ b/src/sms.c @@ -0,0 +1,1389 @@ +/* + * tel-plugin-socket-communicator + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + +static gboolean +on_sms_send_msg(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint format, + GVariant *sca, + gint tpdu_length, + GVariant *tpdu_data, + gint moreMsg, + gpointer user_data) +{ + struct treq_sms_send_msg sendMsg; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + int i = 0; + GVariantIter *iter = 0; + GVariant *inner_gv = 0; + + if (!check_access_control (invocation, AC_SMS, "x")) + return TRUE; + + memset(&sendMsg, 0 , sizeof(struct treq_sms_send_msg)); + + inner_gv = g_variant_get_variant( sca ); + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop(iter, "y", &sendMsg.msgDataPackage.sca[i] ) ) { + i++; + if( i >= SMS_SMSP_ADDRESS_LEN ) + break; + } + + sendMsg.msgDataPackage.msgLength = tpdu_length; + + i = 0; + inner_gv = g_variant_get_variant( tpdu_data ); + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop(iter, "y", &sendMsg.msgDataPackage.tpduData[i] ) ) { + i++; + if( i >= SMS_SMDATA_SIZE_MAX + 1 ) + break; + } + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + + sendMsg.msgDataPackage.format = format; + sendMsg.more = moreMsg; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_send_msg), &sendMsg); + + if (SMS_NETTYPE_3GPP == format) { + tcore_user_request_set_command(ur, TREQ_SMS_SEND_UMTS_MSG); + } else if (SMS_NETTYPE_3GPP2 == format){ + tcore_user_request_set_command(ur, TREQ_SMS_SEND_CDMA_MSG); + } else { + err("Invalid Format Received:[%d]", format); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + return TRUE; + } + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_read_msg(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_index, + gpointer user_data) +{ + struct treq_sms_read_msg readMsg = {0,}; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "r")) + return TRUE; + + readMsg.index = arg_index; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_read_msg), &readMsg); + tcore_user_request_set_command(ur, TREQ_SMS_READ_MSG); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_save_msg(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint format, + gint arg_msg_status, + GVariant * arg_sca, + gint arg_tpdu_length, + GVariant * arg_tpdu_data, + gpointer user_data) +{ + struct treq_sms_save_msg saveMsg = {0,}; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + int i = 0; + GVariantIter *iter = 0; + GVariant *inner_gv = 0; + + if (!check_access_control (invocation, AC_SMS, "w")) + return TRUE; + + if (SMS_NETTYPE_3GPP == format) { + saveMsg.msgDataPackage.format = SMS_NETTYPE_3GPP; + } else if (SMS_NETTYPE_3GPP2 == format){ + saveMsg.msgDataPackage.format = SMS_NETTYPE_3GPP2; + } else { + err("Invalid Format Received:[%d]", format); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + return TRUE; + } + + saveMsg.simIndex = 0xffff; + saveMsg.msgStatus = arg_msg_status; + + inner_gv = g_variant_get_variant( arg_sca ); + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop(iter, "y", &saveMsg.msgDataPackage.sca[i] ) ) { + i++; + if( i >= SMS_SMSP_ADDRESS_LEN ) + break; + } + + i = 0; + inner_gv = g_variant_get_variant( arg_tpdu_data ); + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop(iter, "y", &saveMsg.msgDataPackage.tpduData[i] ) ) { + i++; + if( i >= SMS_SMDATA_SIZE_MAX + 1 ) + break; + } + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + + saveMsg.msgDataPackage.msgLength = arg_tpdu_length; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_save_msg), &saveMsg); + tcore_user_request_set_command(ur, TREQ_SMS_SAVE_MSG); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_delete_msg(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_index, + gpointer user_data) +{ + struct treq_sms_delete_msg deleteMsg = {0,}; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "x")) + return TRUE; + + deleteMsg.index = arg_index; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_delete_msg), &deleteMsg); + tcore_user_request_set_command(ur, TREQ_SMS_DELETE_MSG); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_get_msg_count(TelephonySms *sms, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "r")) + return TRUE; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, 0, NULL); + tcore_user_request_set_command(ur, TREQ_SMS_GET_COUNT); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_get_sca(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_index, + gpointer user_data) +{ + struct treq_sms_get_sca getSca = {0,}; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "r")) + return TRUE; + + getSca.index = arg_index; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_sca), &getSca); + tcore_user_request_set_command(ur, TREQ_SMS_GET_SCA); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_set_sca(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_index, + gint arg_ton, + gint arg_npi, + gint arg_dialNumberLength, + GVariant *arg_dialNumber, + gpointer user_data) +{ + struct treq_sms_set_sca setSca; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + int i = 0; + GVariantIter *iter = 0; + GVariant *inner_gv = 0; + + if (!check_access_control (invocation, AC_SMS, "w")) + return TRUE; + + memset(&setSca, 0, sizeof(struct treq_sms_set_sca)); + + setSca.index = arg_index; + setSca.scaInfo.dialNumLen = arg_dialNumberLength; + setSca.scaInfo.typeOfNum = arg_ton; + setSca.scaInfo.numPlanId = arg_npi; + + if ((setSca.scaInfo.dialNumLen <= 0) || (setSca.scaInfo.dialNumLen > (SMS_MAX_SMS_SERVICE_CENTER_ADDR + 1))) + { + err("[tcore_SMS] TAPI_API_INVALID_INPUT !!!"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + else if(setSca.index != 0) + { + err("[tcore_SMS] Index except 0 is supported"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + else + { + inner_gv = g_variant_get_variant( arg_dialNumber ); + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop(iter, "y", &setSca.scaInfo.diallingNum[i] ) ) { + i++; + if( i >= SMS_SMSP_ADDRESS_LEN + 1 ) + break; + } + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_sca), &setSca); + tcore_user_request_set_command(ur, TREQ_SMS_SET_SCA); + + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + } + + return TRUE; +} + +static gboolean +on_sms_get_cb_config(TelephonySms *sms, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "r")) + return TRUE; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, 0, NULL); + tcore_user_request_set_command(ur, TREQ_SMS_GET_CB_CONFIG); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_set_cb_config(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_net3gppType, + gboolean arg_cbEnable, + gint arg_msgIdMaxCount, + gint arg_msgIdRangeCount, + GVariant *arg_mdgId, + gpointer user_data) +{ + struct treq_sms_set_cb_config setCbConfig = {0,}; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + GVariant *value = NULL; + GVariant *inner_gv = 0; + GVariantIter *iter = NULL; + GVariantIter *iter_row = NULL; + const gchar *key = NULL; + int i = 0; + + if (!check_access_control (invocation, AC_SMS, "w")) + return TRUE; + + setCbConfig.net3gppType = arg_net3gppType; + setCbConfig.cbEnabled = arg_cbEnable; + setCbConfig.msgIdMaxCount = arg_msgIdMaxCount; + setCbConfig.msgIdRangeCount = arg_msgIdRangeCount; + + inner_gv = g_variant_get_variant( arg_mdgId ); + g_variant_get(inner_gv, "aa{sv}", &iter); + + while (g_variant_iter_next(iter, "a{sv}", &iter_row)) { + while (g_variant_iter_loop(iter_row, "{sv}", &key, &value)) { + if (!g_strcmp0(key, "FromMsgId")) { + setCbConfig.msgIDs[i].net3gpp.fromMsgId = g_variant_get_uint16(value); + } + if (!g_strcmp0(key, "ToMsgId")) { + setCbConfig.msgIDs[i].net3gpp.toMsgId = g_variant_get_uint16(value); + } + if (!g_strcmp0(key, "CBCategory")) { + setCbConfig.msgIDs[i].net3gpp2.cbCategory = g_variant_get_uint16(value); + } + if (!g_strcmp0(key, "CBLanguage")) { + setCbConfig.msgIDs[i].net3gpp2.cbLanguage = g_variant_get_uint16(value); + } + if (!g_strcmp0(key, "Selected")) { + setCbConfig.msgIDs[i].net3gpp2.selected = g_variant_get_byte(value); + } + } + i++; + g_variant_iter_free(iter_row); + if ( i >= SMS_GSM_SMS_CBMI_LIST_SIZE_MAX ) + break; + } + g_variant_iter_free(iter); + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_cb_config), &setCbConfig); + tcore_user_request_set_command(ur, TREQ_SMS_SET_CB_CONFIG); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_set_mem_status(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_memoryStatus, + gpointer user_data) +{ + struct treq_sms_set_mem_status memStatus = {0,}; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "w")) + return TRUE; + + memStatus.memory_status = arg_memoryStatus; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_mem_status), &memStatus); + tcore_user_request_set_command(ur, TREQ_SMS_SET_MEM_STATUS); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_get_pref_bearer(TelephonySms *sms, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct treq_sms_get_pref_bearer getPrefBearer; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "r")) + return TRUE; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_pref_bearer), &getPrefBearer); + tcore_user_request_set_command(ur, TREQ_SMS_GET_PREF_BEARER); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_set_pref_bearer(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_bearerType, + gpointer user_data) +{ + struct treq_sms_set_pref_bearer setPrefBearer = {0,}; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "w")) + return TRUE; + + setPrefBearer.svc = arg_bearerType; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_pref_bearer), &setPrefBearer); + tcore_user_request_set_command(ur, TREQ_SMS_SET_PREF_BEARER); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_set_delivery_report(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint format, + const gchar *arg_sca, + gint arg_tpdu_length, + const gchar *arg_tpdu_data, + gint arg_rpCause, + gpointer user_data) +{ + struct treq_sms_set_delivery_report deliveryReport; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + guchar *decoded_sca = NULL; + guchar *decoded_tpdu = NULL; + + gsize decoded_sca_len = 0; + gsize decoded_tpdu_len = 0; + + if (!check_access_control (invocation, AC_SMS, "w")) + return TRUE; + + memset(&deliveryReport, 0, sizeof(struct treq_sms_set_delivery_report)); + + if (SMS_NETTYPE_3GPP == format) { + deliveryReport.dataInfo.format = SMS_NETTYPE_3GPP; + } else if (SMS_NETTYPE_3GPP2 == format){ + deliveryReport.dataInfo.format = SMS_NETTYPE_3GPP2; + } else { + err("Invalid Format Received:[%d]", format); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + return TRUE; + } + + decoded_sca = g_base64_decode(arg_sca, &decoded_sca_len); + if (NULL == decoded_sca) { + dbg("g_base64_decode: Failed to decode sca"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + + info("[DBUS_INFO]Decoded sca length[%d]", decoded_sca_len); + + if (decoded_sca_len > SMS_SMSP_ADDRESS_LEN) { + err("Invalid Sca length"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + goto EXIT; + } + memcpy(deliveryReport.dataInfo.sca, decoded_sca, decoded_sca_len); + + decoded_tpdu = g_base64_decode(arg_tpdu_data, &decoded_tpdu_len); + if (NULL == decoded_tpdu) { + dbg("g_base64_decode: Failed to decode tpdu"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + goto EXIT; + } + + info("[DBUS_INFO]Decoded tpdu length[%d]", decoded_tpdu_len); + + if (decoded_tpdu_len > SMS_SMDATA_SIZE_MAX+1) { + err("Invalid tpdu length"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + goto EXIT; + } + memcpy(deliveryReport.dataInfo.tpduData, decoded_tpdu, decoded_tpdu_len); + + deliveryReport.dataInfo.msgLength = arg_tpdu_length; + deliveryReport.rspType = arg_rpCause; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_delivery_report), &deliveryReport); + tcore_user_request_set_command(ur, TREQ_SMS_SET_DELIVERY_REPORT); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + +EXIT: + + g_free(decoded_sca); + g_free(decoded_tpdu); + + return TRUE; +} + +static gboolean +on_sms_set_msg_status(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_index, + gint arg_msgStatus, + gpointer user_data) +{ + struct treq_sms_set_msg_status msgStatus = {0,}; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "w")) + return TRUE; + + msgStatus.index = arg_index; + msgStatus.msgStatus = arg_msgStatus; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_msg_status), &msgStatus); + tcore_user_request_set_command(ur, TREQ_SMS_SET_MSG_STATUS); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_get_sms_params(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_index, + gpointer user_data) +{ + struct treq_sms_get_params getParams = {0,}; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "r")) + return TRUE; + + getParams.index = arg_index; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_get_params), &getParams); + tcore_user_request_set_command(ur, TREQ_SMS_GET_PARAMS); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_set_sms_params(TelephonySms *sms, GDBusMethodInvocation *invocation, + gint arg_recordIndex, + gint arg_recordLen, + gint arg_alphaIdLen, + GVariant *arg_alphaId, + gint arg_paramIndicator, + gint arg_destAddr_DialNumLen, + gint arg_destAddr_Ton, + gint arg_destAddr_Npi, + GVariant *arg_destAddr_DiallingNum, + gint arg_svcCntrAddr_DialNumLen, + gint arg_SvcCntrAddr_Ton, + gint arg_svcCntrAddr_Npi, + GVariant *arg_svcCntrAddr_DialNum, + gint arg_protocolId, + gint arg_dataCodingScheme, + gint arg_validityPeriod, + gpointer user_data) +{ + struct treq_sms_set_params setParams; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + int i = 0; + GVariantIter *iter = 0; + GVariant *inner_gv = 0; + + if (!check_access_control (invocation, AC_SMS, "w")) + return TRUE; + + memset(&setParams, 0, sizeof(struct treq_sms_set_params)); + + setParams.params.recordIndex = arg_recordIndex; + setParams.params.recordLen = arg_recordLen; + setParams.params.alphaIdLen = arg_alphaIdLen; + + inner_gv = g_variant_get_variant( arg_alphaId ); + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop(iter, "y", &setParams.params.szAlphaId[i] ) ) { + i++; + if( i >= SMS_SMSP_ALPHA_ID_LEN_MAX + 1 ) + break; + } + + setParams.params.paramIndicator = arg_paramIndicator; + + setParams.params.tpDestAddr.dialNumLen = arg_destAddr_DialNumLen; + setParams.params.tpDestAddr.typeOfNum = arg_destAddr_Ton; + setParams.params.tpDestAddr.numPlanId = arg_destAddr_Npi; + + i = 0; + inner_gv = g_variant_get_variant( arg_destAddr_DiallingNum ); + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop(iter, "y", &setParams.params.tpDestAddr.diallingNum[i] ) ) { + i++; + if( i >= SMS_SMSP_ADDRESS_LEN + 1 ) + break; + } + + setParams.params.tpSvcCntrAddr.dialNumLen = arg_svcCntrAddr_DialNumLen; + setParams.params.tpSvcCntrAddr.typeOfNum = arg_SvcCntrAddr_Ton; + setParams.params.tpSvcCntrAddr.numPlanId = arg_svcCntrAddr_Npi; + + i = 0; + inner_gv = g_variant_get_variant( arg_svcCntrAddr_DialNum ); + g_variant_get(inner_gv, "ay", &iter); + while( g_variant_iter_loop(iter, "y", &setParams.params.tpSvcCntrAddr.diallingNum[i] ) ) { + i++; + if( i >= SMS_SMSP_ADDRESS_LEN + 1 ) + break; + } + + setParams.params.tpProtocolId = arg_protocolId; + setParams.params.tpDataCodingScheme = arg_dataCodingScheme; + setParams.params.tpValidityPeriod = arg_validityPeriod; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, sizeof(struct treq_sms_set_params), &setParams); + tcore_user_request_set_command(ur, TREQ_SMS_SET_PARAMS); + + g_variant_iter_free(iter); + g_variant_unref(inner_gv); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_get_sms_param_cnt(TelephonySms *sms, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + TReturn ret = TCORE_RETURN_SUCCESS; + + if (!check_access_control (invocation, AC_SMS, "r")) + return TRUE; + + ur = MAKE_UR(ctx, sms, invocation); + tcore_user_request_set_data(ur, 0, NULL); + tcore_user_request_set_command(ur, TREQ_SMS_GET_PARAMCNT); + + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_sms_get_sms_ready_status(TelephonySms *sms, GDBusMethodInvocation *invocation, + gpointer user_data) +{ + struct custom_data *ctx = user_data; + GSList *co_list = NULL; + CoreObject *co_sms = NULL; + TcorePlugin *plugin = NULL; + gboolean ready_status = FALSE; + + if (!check_access_control (invocation, AC_SMS, "r")) + return TRUE; + + plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation)); + co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_SMS); + if (!co_list) { + dbg("error- co_list is NULL"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + + co_sms = (CoreObject *)co_list->data; + g_slist_free(co_list); + + if (!co_sms) { + dbg("error- co_sms is NULL"); + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + return TRUE; + } + + ready_status = tcore_sms_get_ready_status(co_sms); + dbg("ready_status = %d", ready_status); + telephony_sms_complete_get_sms_ready_status(sms, invocation, ready_status); + + return TRUE; +} + +gboolean dbus_plugin_setup_sms_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonySms *sms; + + sms = telephony_sms_skeleton_new(); + telephony_object_skeleton_set_sms(object, sms); + g_object_unref(sms); + + g_signal_connect(sms, + "handle-send-msg", + G_CALLBACK (on_sms_send_msg), + ctx); + + g_signal_connect(sms, + "handle-read-msg", + G_CALLBACK (on_sms_read_msg), + ctx); + + g_signal_connect(sms, + "handle-save-msg", + G_CALLBACK (on_sms_save_msg), + ctx); + + g_signal_connect(sms, + "handle-delete-msg", + G_CALLBACK (on_sms_delete_msg), + ctx); + + g_signal_connect(sms, + "handle-get-msg-count", + G_CALLBACK (on_sms_get_msg_count), + ctx); + + g_signal_connect(sms, + "handle-get-sca", + G_CALLBACK (on_sms_get_sca), + ctx); + + g_signal_connect(sms, + "handle-set-sca", + G_CALLBACK (on_sms_set_sca), + ctx); + + g_signal_connect(sms, + "handle-get-cb-config", + G_CALLBACK (on_sms_get_cb_config), + ctx); + + g_signal_connect(sms, + "handle-set-cb-config", + G_CALLBACK (on_sms_set_cb_config), + ctx); + + g_signal_connect(sms, + "handle-set-mem-status", + G_CALLBACK (on_sms_set_mem_status), + ctx); + + g_signal_connect(sms, + "handle-get-pref-bearer", + G_CALLBACK (on_sms_get_pref_bearer), + ctx); + + g_signal_connect(sms, + "handle-set-pref-bearer", + G_CALLBACK (on_sms_set_pref_bearer), + ctx); + + g_signal_connect(sms, + "handle-set-delivery-report", + G_CALLBACK (on_sms_set_delivery_report), + ctx); + + g_signal_connect(sms, + "handle-set-msg-status", + G_CALLBACK (on_sms_set_msg_status), + ctx); + + g_signal_connect(sms, + "handle-get-sms-params", + G_CALLBACK (on_sms_get_sms_params), + ctx); + + g_signal_connect(sms, + "handle-set-sms-params", + G_CALLBACK (on_sms_set_sms_params), + ctx); + + g_signal_connect(sms, + "handle-get-sms-param-cnt", + G_CALLBACK (on_sms_get_sms_param_cnt), + ctx); + + g_signal_connect(sms, + "handle-get-sms-ready-status", + G_CALLBACK (on_sms_get_sms_ready_status), + ctx); + + return TRUE; +} + +gboolean dbus_plugin_sms_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data) +{ + GSList *co_list; + CoreObject *co_sms; + char *modem_name = NULL; + TcorePlugin *p = NULL; + int i; + + modem_name = tcore_user_request_get_modem_name(ur); + if (!modem_name) + return FALSE; + + p = tcore_server_find_plugin(ctx->server, modem_name); + free(modem_name); + if (!p) + return FALSE; + + co_list = tcore_plugin_get_core_objects_bytype(p, CORE_OBJECT_TYPE_SMS); + if (!co_list) { + return FALSE; + } + + co_sms = (CoreObject *)co_list->data; + g_slist_free(co_list); + + if (!co_sms) { + return FALSE; + } + + switch (command) { + case TRESP_SMS_SEND_UMTS_MSG: { + const struct tresp_sms_send_msg *resp = data; + + dbg("receive TRESP_SMS_SEND_UMTS_MSG (result:[0x%x])", resp->result); + telephony_sms_complete_send_msg(dbus_info->interface_object, dbus_info->invocation, resp->result); + + } + break; + + case TRESP_SMS_SEND_CDMA_MSG: { + const struct tresp_sms_send_msg *resp = data; + + dbg("receive TRESP_SMS_SEND_CDMA_MSG (result:[0x%x])", resp->result); + telephony_sms_complete_send_msg(dbus_info->interface_object, dbus_info->invocation, resp->result); + } + break; + + case TRESP_SMS_READ_MSG: { + const struct tresp_sms_read_msg *resp = data; + GVariant *sca = 0, *packet_sca = 0; + GVariant *tpdu = 0, *packet_tpdu = 0; + GVariantBuilder b; + + unsigned int i; + + dbg("receive TRESP_SMS_READ_MSG (result:[0x%x])", resp->result); + g_variant_builder_init (&b, G_VARIANT_TYPE("ay")); + + for( i=0; idataInfo.smsData.sca[i] ); + } + sca = g_variant_builder_end(&b); + + g_variant_builder_init (&b, G_VARIANT_TYPE("ay")); + + for( i=0; idataInfo.smsData.tpduData[i] ); + } + tpdu = g_variant_builder_end(&b); + + packet_sca = g_variant_new("v", sca); + packet_tpdu = g_variant_new("v", tpdu); + + telephony_sms_complete_read_msg(dbus_info->interface_object, dbus_info->invocation, + resp->result, + resp->dataInfo.simIndex, + resp->dataInfo.msgStatus, + resp->dataInfo.smsData.format, + packet_sca, + resp->dataInfo.smsData.msgLength, + packet_tpdu); + } + break; + + case TRESP_SMS_SAVE_MSG: { + const struct tresp_sms_save_msg *resp = data; + + dbg("receive TRESP_SMS_SAVE_MSG (result:[0x%x])", resp->result); + telephony_sms_complete_save_msg (dbus_info->interface_object, dbus_info->invocation, + resp->result, + resp->index); + } + break; + + case TRESP_SMS_DELETE_MSG: { + const struct tresp_sms_delete_msg *resp = data; + + dbg("receive TRESP_SMS_DELETE_MSG (result:[0x%x])", resp->result); + telephony_sms_complete_delete_msg(dbus_info->interface_object, dbus_info->invocation, + resp->result, resp->index); + + } + break; + + case TRESP_SMS_GET_STORED_MSG_COUNT: { + const struct tresp_sms_get_storedMsgCnt *resp = data; + GVariant *list; + GVariantBuilder b; + unsigned int i; + + dbg("receive TRESP_SMS_GET_STORED_MSG_COUNT (result:[0x%x])", resp->result); + g_variant_builder_init (&b, G_VARIANT_TYPE("ai")); + + for (i=0; istoredMsgCnt.totalCount; i++) { + g_variant_builder_add(&b, "i", resp->storedMsgCnt.indexList[i]); + } + list = g_variant_builder_end(&b); + + telephony_sms_complete_get_msg_count(dbus_info->interface_object, dbus_info->invocation, + resp->result, + resp->storedMsgCnt.totalCount, + resp->storedMsgCnt.usedCount, + list); + } + break; + + case TRESP_SMS_GET_SCA: { + const struct tresp_sms_get_sca *resp = data; + GVariant *sca = 0, *packet_sca = 0; + GVariantBuilder b; + unsigned int i; + + dbg("receive TRESP_SMS_GET_SCA (result:[0x%x])", resp->result); + g_variant_builder_init (&b, G_VARIANT_TYPE("ay")); + + for( i=0; iscaAddress.diallingNum[i] ); + } + sca = g_variant_builder_end(&b); + + packet_sca = g_variant_new("v", sca); + + telephony_sms_complete_get_sca(dbus_info->interface_object, dbus_info->invocation, + resp->result, + resp->scaAddress.typeOfNum, + resp->scaAddress.numPlanId, + resp->scaAddress.dialNumLen, + packet_sca); + } + break; + + case TRESP_SMS_SET_SCA: { + const struct tresp_sms_set_sca *resp = data; + + dbg("receive TRESP_SMS_SET_SCA (result:[0x%x])", resp->result); + telephony_sms_complete_set_sca(dbus_info->interface_object, dbus_info->invocation, + resp->result); + + } + break; + + case TRESP_SMS_GET_CB_CONFIG: { + const struct tresp_sms_get_cb_config *resp = data; + GVariant *result = NULL; + GVariantBuilder b; + + dbg("receive TRESP_SMS_GET_CB_CONFIG (result:[0x%x])", resp->result); + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i = 0; i < resp->cbConfig.msgIdRangeCount; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + + if( resp->cbConfig.net3gppType == SMS_NETTYPE_3GPP ) { + g_variant_builder_add(&b, "{sv}", "FromMsgId", g_variant_new_uint16(resp->cbConfig.msgIDs[i].net3gpp.fromMsgId)); + g_variant_builder_add(&b, "{sv}", "ToMsgId", g_variant_new_uint16(resp->cbConfig.msgIDs[i].net3gpp.toMsgId)); + } else if( resp->cbConfig.net3gppType == SMS_NETTYPE_3GPP2) { + g_variant_builder_add(&b, "{sv}", "CBCategory", g_variant_new_uint16(resp->cbConfig.msgIDs[i].net3gpp2.cbCategory)); + g_variant_builder_add(&b, "{sv}", "CBLanguage", g_variant_new_uint16(resp->cbConfig.msgIDs[i].net3gpp2.cbLanguage)); + } else { + dbg("Unknown 3gpp type"); + return FALSE; + } + + g_variant_builder_add(&b, "{sv}", "Selected", g_variant_new_byte(resp->cbConfig.msgIDs[i].net3gpp.selected)); + + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_sms_complete_get_cb_config(dbus_info->interface_object, dbus_info->invocation, + resp->result, + resp->cbConfig.net3gppType, + resp->cbConfig.cbEnabled, + resp->cbConfig.msgIdMaxCount, + resp->cbConfig.msgIdRangeCount, + result); + } + break; + + case TRESP_SMS_SET_CB_CONFIG: { + const struct tresp_sms_set_cb_config *resp = data; + + dbg("receive TRESP_SMS_SET_CB_CONFIG (result:[0x%x])", resp->result); + telephony_sms_complete_set_cb_config(dbus_info->interface_object, dbus_info->invocation, + resp->result); + + } + break; + + case TRESP_SMS_SET_MEM_STATUS: { + const struct tresp_sms_set_mem_status *resp = data; + + dbg("receive TRESP_SMS_SET_MEM_STATUS (result:[0x%x])", resp->result); + telephony_sms_complete_set_mem_status(dbus_info->interface_object, dbus_info->invocation, + resp->result); + + } + break; + case TRESP_SMS_GET_PREF_BEARER: { + const struct tresp_sms_get_pref_bearer *resp = data; + + dbg("receive TRESP_SMS_GET_PREF_BEARER (result:[0x%x] svc:[0x%2x])", resp->result, resp->svc); + telephony_sms_complete_get_pref_bearer(dbus_info->interface_object, dbus_info->invocation, + resp->result, resp->svc); + + } + break; + + case TRESP_SMS_SET_PREF_BEARER: { + const struct tresp_sms_set_pref_bearer *resp = data; + + dbg("receive TRESP_SMS_SET_PREF_BEARER (result:[0x%x])", resp->result); + telephony_sms_complete_set_pref_bearer(dbus_info->interface_object, dbus_info->invocation, + resp->result); + + } + break; + + case TRESP_SMS_SET_DELIVERY_REPORT: { + const struct tresp_sms_set_delivery_report *resp = data; + + dbg("receive TRESP_SMS_SET_DELIVERY_REPORT (result:[0x%x])", resp->result); + telephony_sms_complete_set_delivery_report(dbus_info->interface_object, dbus_info->invocation, + resp->result); + + } + break; + + case TRESP_SMS_SET_MSG_STATUS: { + const struct tresp_sms_set_mem_status *resp = data; + + dbg("receive TRESP_SMS_SET_MSG_STATUS (result:[0x%x])", resp->result); + telephony_sms_complete_set_msg_status(dbus_info->interface_object, dbus_info->invocation, + resp->result); + + } + break; + + case TRESP_SMS_GET_PARAMS: { + const struct tresp_sms_get_params *resp = data; + GVariant *alphaId = 0, *packet_alphaId = 0; + GVariant *destDialNum = 0, *packet_destDialNum = 0; + GVariant *scaDialNum = 0, *packet_scaDialNum = 0; + GVariantBuilder b; + unsigned int i; + + dbg("receive TRESP_SMS_GET_PARAMS (result:[0x%x])", resp->result); + g_variant_builder_init(&b, G_VARIANT_TYPE("ay")); + for( i=0; iparamsInfo.szAlphaId[i] ); + } + alphaId = g_variant_builder_end(&b); + + g_variant_builder_init(&b, G_VARIANT_TYPE("ay")); + for( i=0; iparamsInfo.tpDestAddr.diallingNum[i] ); + } + destDialNum = g_variant_builder_end(&b); + + g_variant_builder_init(&b, G_VARIANT_TYPE("ay")); + for( i=0; iparamsInfo.tpSvcCntrAddr.diallingNum[i] ); + } + scaDialNum = g_variant_builder_end(&b); + + packet_alphaId = g_variant_new("v", alphaId); + packet_destDialNum = g_variant_new("v", destDialNum); + packet_scaDialNum = g_variant_new("v", scaDialNum); + + telephony_sms_complete_get_sms_params(dbus_info->interface_object, dbus_info->invocation, + resp->result, + resp->paramsInfo.recordIndex, + resp->paramsInfo.recordLen, + resp->paramsInfo.alphaIdLen, + packet_alphaId, + resp->paramsInfo.paramIndicator, + resp->paramsInfo.tpDestAddr.dialNumLen, + resp->paramsInfo.tpDestAddr.typeOfNum, + resp->paramsInfo.tpDestAddr.numPlanId, + packet_destDialNum, + resp->paramsInfo.tpSvcCntrAddr.dialNumLen, + resp->paramsInfo.tpSvcCntrAddr.typeOfNum, + resp->paramsInfo.tpSvcCntrAddr.numPlanId, + packet_scaDialNum, + resp->paramsInfo.tpProtocolId, + resp->paramsInfo.tpDataCodingScheme, + resp->paramsInfo.tpValidityPeriod); + } + break; + + case TRESP_SMS_SET_PARAMS:{ + const struct tresp_sms_set_params *resp = data; + + dbg("receive TRESP_SMS_SET_PARAMS (result:[0x%x])", resp->result); + telephony_sms_complete_set_sms_params(dbus_info->interface_object, dbus_info->invocation, + resp->result); + + } + break; + + case TRESP_SMS_GET_PARAMCNT: { + const struct tresp_sms_get_paramcnt *resp = data; + + dbg("receive TRESP_SMS_GET_PARAMCNT (result:[0x%x])", resp->result); + telephony_sms_complete_get_sms_param_cnt(dbus_info->interface_object, dbus_info->invocation, + resp->result, + resp->recordCount); + + } + break; + + default: + break; + } + + return TRUE; +} + +gboolean dbus_plugin_sms_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data) +{ + TelephonySms *sms; + const char *cp_name; + + if (!object) { + dbg("object is NULL"); + return FALSE; + } + + cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source)); + + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, cp_name); + + sms = telephony_object_peek_sms(TELEPHONY_OBJECT(object)); + + switch (command) { + case TNOTI_SMS_INCOM_MSG: { + const struct tnoti_sms_incoming_msg *noti = data; + + gchar *sca = NULL; + gchar *tpdu = NULL; + + info("[DBUSINFO][%s] SMS_INCOM_MSG (len[%d])", cp_name, data_len); + + sca = g_base64_encode((const guchar*)(noti->msgInfo.sca),SMS_SMSP_ADDRESS_LEN); + tpdu = g_base64_encode((const guchar*)(noti->msgInfo.tpduData),SMS_SMDATA_SIZE_MAX + 1); + + telephony_sms_emit_incomming_msg(sms, + noti->msgInfo.format, + sca, + noti->msgInfo.msgLength, + tpdu); + + g_free(sca); + g_free(tpdu); + } + break; + + case TNOTI_SMS_CB_INCOM_MSG: { + const struct tnoti_sms_cellBroadcast_msg *noti = data; + gchar *tpdu = NULL; + + info("[DBUSINFO][%s] SMS_CB_INCOM_MSG (len[%d])", cp_name, data_len); + + tpdu = g_base64_encode((const guchar*)(noti->cbMsg.msgData), SMS_CB_SIZE_MAX+1); + + telephony_sms_emit_incomming_cb_msg(sms, + noti->cbMsg.cbMsgType, + noti->cbMsg.length, + tpdu); + g_free(tpdu); + } + break; + + case TNOTI_SMS_ETWS_INCOM_MSG: { + const struct tnoti_sms_etws_msg *noti = data; + GVariant *msgData = 0, *packet_msgData = 0; + GVariantBuilder b; + unsigned int i; + + info("[DBUSINFO][%s] ETWS_INCOM_MSG (len[%d])", cp_name, data_len); + + g_variant_builder_init (&b, G_VARIANT_TYPE("ay")); + + for( i=0; ietwsMsg.msgData[i] ); + } + msgData = g_variant_builder_end(&b); + packet_msgData = g_variant_new("v", msgData); + + telephony_sms_emit_incomming_etws_msg(sms, + noti->etwsMsg.etwsMsgType, + noti->etwsMsg.length, + packet_msgData); + } + break; + + case TNOTI_SMS_INCOM_EX_MSG: { + info("[DBUSINFO][%s] SMS_INCOM_EX_MSG (len[%d])", cp_name, data_len); + } + break; + + case TNOTI_SMS_CB_INCOM_EX_MSG: { + info("[DBUSINFO][%s] CB_INCOM_EX_MSG (len[%d])", cp_name, data_len); + } + break; + + case TNOTI_SMS_MEMORY_STATUS: { + const struct tnoti_sms_memory_status *noti = data; + info("[DBUSINFO][%s] SMS_MEMORY_STATUS (%d)", cp_name, noti->status); + telephony_sms_emit_memory_status(sms, noti->status); + } + break; + + case TNOTI_SMS_DEVICE_READY: { + const struct tnoti_sms_ready_status *noti = data; + info("[DBUSINFO][%s] SMS_DEVICE_READY (%d)", cp_name, noti->status); +#ifdef ENABLE_KPI_LOGS + if (noti->status != SMS_READY_STATUS_NONE) + TIME_CHECK("[%s] SMS Service Ready", cp_name); +#endif + telephony_sms_emit_sms_ready(sms, noti->status); + + } + break; + + default: + dbg("unknown notification"); + return FALSE; + break; + } + + return TRUE; +} diff --git a/src/ss.c b/src/ss.c new file mode 100755 index 0000000..84bdecf --- /dev/null +++ b/src/ss.c @@ -0,0 +1,1298 @@ +/* + * tel-plugin-dbus-tapi + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Ja-young Gu + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "generated-code.h" +#include "common.h" + +struct ciss_data_type { + int status; + int dcs; + int length; + char data[MAX_SS_USSD_LEN]; +}; + +struct ciss_information { + int err; + int ss_type; +}; + +static void _launch_ciss_information(const struct tnoti_ss_information *info) +{ + gchar *encoded_data; + struct ciss_information ciss_inform; + + bundle *kb = NULL; + + memset(&ciss_inform, 0, sizeof(struct ciss_information)); + ciss_inform.err = info->err; + ciss_inform.ss_type = info->ss_type; + + dbg("Explicit launch ciss application by appsvc"); + + kb = bundle_create(); + if (!kb) { + warn("bundle_create() failed"); + return; + } + + appsvc_set_pkgname(kb, "org.tizen.ciss"); + + encoded_data = g_base64_encode((guchar *)&ciss_inform, sizeof(struct ciss_information)); + + appsvc_add_data(kb, "CISS_LAUNCHING_MODE", "RESP"); + appsvc_add_data(kb, "KEY_EVENT_TYPE", "200"); + appsvc_add_data(kb, "KEY_ENCODED_DATA", encoded_data); + + dbg("ciss appsvc run"); + appsvc_run_service(kb, 0, NULL, NULL); + + bundle_free(kb); + g_free(encoded_data); + + return; +} + + +static void _launch_ciss(const struct tnoti_ss_ussd *ussd, enum dbus_tapi_sim_slot_id slot_id) +{ + gchar *encoded_data; + struct ciss_data_type ciss_data; + char slot_info[2] = {0,}; + + bundle *kb = NULL; + + memset(&ciss_data, 0, sizeof(struct ciss_data_type)); + ciss_data.status = ussd->dcs; + ciss_data.status = ussd->status; + ciss_data.length = ussd->len; + memcpy(ciss_data.data, ussd->str, ciss_data.length); + + snprintf(slot_info, 2, "%d", slot_id); + dbg("slot_id : [%s]", slot_info); + + dbg("Explicit launch ciss application by appsvc"); + + kb = bundle_create(); + if (!kb) { + warn("bundle_create() failed"); + return; + } + + + appsvc_set_pkgname(kb, "org.tizen.ciss"); + + encoded_data = g_base64_encode((guchar *)&ciss_data, sizeof(struct ciss_data_type)); + + appsvc_add_data(kb, "CISS_LAUNCHING_MODE", "RESP"); + appsvc_add_data(kb, "KEY_EVENT_TYPE", "100"); + appsvc_add_data(kb, "KEY_ENCODED_DATA", encoded_data); + appsvc_add_data(kb, "KEY_SLOT_ID", slot_info); + + dbg("ciss appsvc run"); + appsvc_run_service(kb, 0, NULL, NULL); + + bundle_free(kb); + g_free(encoded_data); + + return; +} + +static gboolean +on_ss_activate_barring (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gint barring_mode, + const gchar *barring_password, + gpointer user_data) +{ + char buf[5]; + struct treq_ss_barring req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "x")) + return TRUE; + + memset(&req, 0, sizeof(struct treq_ss_barring)); + + req.class = ss_class; + req.mode = barring_mode; + + memcpy(req.password, barring_password, MAX_SS_BARRING_PASSWORD_LEN); + memcpy(buf, barring_password, MAX_SS_BARRING_PASSWORD_LEN); + + buf[4] = 0; + dbg("req.password = [%s]", buf); + + dbg("class = %d, mode = %d", req.class, req.mode); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_barring), &req); + tcore_user_request_set_command(ur, TREQ_SS_BARRING_ACTIVATE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_deactivate_barring (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gint barring_mode, + const gchar *barring_password, + gpointer user_data) +{ + char buf[5]; + struct treq_ss_barring req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "x")) + return TRUE; + + memset(&req, 0, sizeof(struct treq_ss_barring)); + + req.class = ss_class; + req.mode = barring_mode; + + memcpy(req.password, barring_password, MAX_SS_BARRING_PASSWORD_LEN); + memcpy(buf, barring_password, MAX_SS_BARRING_PASSWORD_LEN); + + buf[4] = 0; + dbg("req.password = [%s]", buf); + dbg("class = %d, mode = %d", req.class, req.mode); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_barring), &req); + tcore_user_request_set_command(ur, TREQ_SS_BARRING_DEACTIVATE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_change_barring_password (TelephonySs *ss, + GDBusMethodInvocation *invocation, + const gchar *barring_password, + const gchar *barring_password_new, + const gchar *barring_password_confirm, + gpointer user_data) +{ + char buf[5]; + struct treq_ss_barring_change_password req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "x")) + return TRUE; + + memset(&req, 0, sizeof(struct treq_ss_barring_change_password)); + + memcpy(req.password_old, barring_password, MAX_SS_BARRING_PASSWORD_LEN); + memcpy(req.password_new, barring_password_new, MAX_SS_BARRING_PASSWORD_LEN); + memcpy(req.password_confirm, barring_password_confirm, MAX_SS_BARRING_PASSWORD_LEN); + + memcpy(buf, barring_password, MAX_SS_BARRING_PASSWORD_LEN); + buf[4] = 0; + + memcpy(buf, barring_password_new, MAX_SS_BARRING_PASSWORD_LEN); + + memcpy(buf, barring_password_confirm, MAX_SS_BARRING_PASSWORD_LEN); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_barring_change_password), &req); + tcore_user_request_set_command(ur, TREQ_SS_BARRING_CHANGE_PASSWORD); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_get_barring_status (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gint barring_mode, + gpointer user_data) +{ + struct treq_ss_barring req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "r")) + return TRUE; + + memset(&req, 0, sizeof(struct treq_ss_barring)); + + req.class = ss_class; + req.mode = barring_mode; + + dbg("class = %d, mode = %d", req.class, req.mode); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_barring), &req); + tcore_user_request_set_command(ur, TREQ_SS_BARRING_GET_STATUS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_register_forwarding (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gint forward_mode, + gint forward_no_reply_time, + gint forward_ton, + gint forward_npi, + const gchar *forward_number, + gpointer user_data) +{ + struct treq_ss_forwarding req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "w")) { + return TRUE; + } + + memset(&req, 0, sizeof(struct treq_ss_forwarding)); + + req.class = ss_class; + req.mode = forward_mode; + req.time = forward_no_reply_time; + req.ton = forward_ton; + req.npi = forward_npi; + snprintf(req.number, MAX_SS_FORWARDING_NUMBER_LEN, "%s", forward_number); + + dbg("class = %d, mode = %d, time = %d, number = %s", + req.class, req.mode, req.time, req.number); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_forwarding), &req); + tcore_user_request_set_command(ur, TREQ_SS_FORWARDING_REGISTER); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_deregister_forwarding (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gint forward_mode, + gint forward_no_reply_time, + gint forward_ton, + gint forward_npi, + const gchar *forward_number, + gpointer user_data) +{ + struct treq_ss_forwarding req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "w")) { + return TRUE; + } + + memset(&req, 0, sizeof(struct treq_ss_forwarding)); + + req.class = ss_class; + req.mode = forward_mode; + req.time = forward_no_reply_time; + req.ton = forward_ton; + req.npi = forward_npi; + snprintf(req.number, MAX_SS_FORWARDING_NUMBER_LEN, "%s", forward_number); + + dbg("class = %d, mode = %d, time = %d, number = %s", + req.class, req.mode, req.time, req.number); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_forwarding), &req); + tcore_user_request_set_command(ur, TREQ_SS_FORWARDING_DEREGISTER); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_activate_forwarding (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gint forward_mode, + gint forward_no_reply_time, + gint forward_ton, + gint forward_npi, + const gchar *forward_number, + gpointer user_data) +{ + struct treq_ss_forwarding req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "w")) { + return TRUE; + } + + memset(&req, 0, sizeof(struct treq_ss_forwarding)); + + req.class = ss_class; + req.mode = forward_mode; + req.time = forward_no_reply_time; + req.ton = forward_ton; + req.npi = forward_npi; + snprintf(req.number, MAX_SS_FORWARDING_NUMBER_LEN, "%s", forward_number); + + dbg("class = %d, mode = %d, time = %d, number = %s", + req.class, req.mode, req.time, req.number); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_forwarding), &req); + tcore_user_request_set_command(ur, TREQ_SS_FORWARDING_ACTIVATE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_deactivate_forwarding (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gint forward_mode, + gint forward_no_reply_time, + gint forward_ton, + gint forward_npi, + const gchar *forward_number, + gpointer user_data) +{ + struct treq_ss_forwarding req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "w")) { + return TRUE; + } + + memset(&req, 0, sizeof(struct treq_ss_forwarding)); + + req.class = ss_class; + req.mode = forward_mode; + req.time = forward_no_reply_time; + req.ton = forward_ton; + req.npi = forward_npi; + snprintf(req.number, MAX_SS_FORWARDING_NUMBER_LEN, "%s", forward_number); + + dbg("class = %d, mode = %d, time = %d, number = %s", + req.class, req.mode, req.time, req.number); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_forwarding), &req); + tcore_user_request_set_command(ur, TREQ_SS_FORWARDING_DEACTIVATE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_get_forwarding_status (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gint forward_mode, + gpointer user_data) +{ + struct treq_ss_forwarding req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "r")) { + return TRUE; + } + + memset(&req, 0, sizeof(struct treq_ss_forwarding)); + + req.class = ss_class; + req.mode = forward_mode; + + dbg("class = %d, mode = %d, time = %d, number = %s", + req.class, req.mode, req.time, req.number); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_forwarding), &req); + tcore_user_request_set_command(ur, TREQ_SS_FORWARDING_GET_STATUS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_activate_waiting (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gpointer user_data) +{ + struct treq_ss_waiting req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "w")) { + return TRUE; + } + + memset(&req, 0, sizeof(struct treq_ss_waiting)); + + req.class = ss_class; + + dbg("class = %d", req.class); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_waiting), &req); + tcore_user_request_set_command(ur, TREQ_SS_WAITING_ACTIVATE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_deactivate_waiting (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gpointer user_data) +{ + struct treq_ss_waiting req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "w")) { + return TRUE; + } + memset(&req, 0, sizeof(struct treq_ss_waiting)); + + req.class = ss_class; + + dbg("class = %d", req.class); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_waiting), &req); + tcore_user_request_set_command(ur, TREQ_SS_WAITING_DEACTIVATE); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_get_waiting_status (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ss_class, + gpointer user_data) +{ + struct treq_ss_waiting req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "r")) { + return TRUE; + } + + memset(&req, 0, sizeof(struct treq_ss_waiting)); + + req.class = ss_class; + + dbg("class = %d", req.class); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_waiting), &req); + tcore_user_request_set_command(ur, TREQ_SS_WAITING_GET_STATUS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_set_cli_status (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint cli_type, + gint cli_status, + gpointer user_data) +{ + struct treq_ss_set_cli req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "w")) { + return TRUE; + } + + memset(&req, 0, sizeof(struct treq_ss_set_cli)); + + req.type = cli_type; + req.status = cli_status; + + dbg("type = %d, status = %d", req.type, req.status); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_set_cli), &req); + tcore_user_request_set_command(ur, TREQ_SS_CLI_SET_STATUS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + + +static gboolean +on_ss_get_cli_status (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint cli_type, + gpointer user_data) +{ + struct treq_ss_cli req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "r")) { + return TRUE; + } + + memset(&req, 0, sizeof(struct treq_ss_cli)); + + req.type = cli_type; + + dbg("type = %d", req.type); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_cli), &req); + tcore_user_request_set_command(ur, TREQ_SS_CLI_GET_STATUS); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +static gboolean +on_ss_send_ussd (TelephonySs *ss, + GDBusMethodInvocation *invocation, + gint ussd_type, + gint ussd_dcs, + gint ussd_len, + const gchar *ussd_string, + gpointer user_data) +{ + struct treq_ss_ussd req; + struct custom_data *ctx = user_data; + UserRequest *ur = NULL; + int ret = 0; + + if (!check_access_control (invocation, AC_SS, "x")) { + return TRUE; + } + memset(&req, 0, sizeof(struct treq_ss_ussd)); + + req.type = ussd_type; + req.dcs = (unsigned char)ussd_dcs; + req.len = (unsigned short)ussd_len; + + snprintf((char*)req.str, MAX_SS_USSD_LEN, "%s", ussd_string); + + dbg("[ check ] type = %d, dcs = %d, len = %d, string = %s", req.type, req.dcs, req.len, req.str); + + ur = MAKE_UR(ctx, ss, invocation); + + tcore_user_request_set_data(ur, sizeof(struct treq_ss_ussd), &req); + tcore_user_request_set_command(ur, TREQ_SS_SEND_USSD); + ret = tcore_communicator_dispatch_request(ctx->comm, ur); + if (ret != TCORE_RETURN_SUCCESS ) { + FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED); + dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret); + tcore_user_request_unref(ur); + } + + return TRUE; +} + +gboolean dbus_plugin_setup_ss_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx) +{ + TelephonySs *ss; + + ss = telephony_ss_skeleton_new(); + telephony_object_skeleton_set_ss(object, ss); + g_object_unref(ss); + + g_signal_connect (ss, + "handle-activate-barring", + G_CALLBACK (on_ss_activate_barring), + ctx); + + g_signal_connect (ss, + "handle-deactivate-barring", + G_CALLBACK (on_ss_deactivate_barring), + ctx); + + g_signal_connect (ss, + "handle-change-barring-password", + G_CALLBACK (on_ss_change_barring_password), + ctx); + + g_signal_connect (ss, + "handle-get-barring-status", + G_CALLBACK (on_ss_get_barring_status), + ctx); + + g_signal_connect (ss, + "handle-register-forwarding", + G_CALLBACK (on_ss_register_forwarding), + ctx); + + g_signal_connect (ss, + "handle-deregister-forwarding", + G_CALLBACK (on_ss_deregister_forwarding), + ctx); + + g_signal_connect (ss, + "handle-activate-forwarding", + G_CALLBACK (on_ss_activate_forwarding), + ctx); + + g_signal_connect (ss, + "handle-deactivate-forwarding", + G_CALLBACK (on_ss_deactivate_forwarding), + ctx); + + g_signal_connect (ss, + "handle-get-forwarding-status", + G_CALLBACK (on_ss_get_forwarding_status), + ctx); + + g_signal_connect (ss, + "handle-activate-waiting", + G_CALLBACK (on_ss_activate_waiting), + ctx); + + g_signal_connect (ss, + "handle-deactivate-waiting", + G_CALLBACK (on_ss_deactivate_waiting), + ctx); + + g_signal_connect (ss, + "handle-get-waiting-status", + G_CALLBACK (on_ss_get_waiting_status), + ctx); + + g_signal_connect (ss, + "handle-set-clistatus", + G_CALLBACK (on_ss_set_cli_status), + ctx); + + g_signal_connect (ss, + "handle-get-clistatus", + G_CALLBACK (on_ss_get_cli_status), + ctx); + + g_signal_connect (ss, + "handle-send-ussd", + G_CALLBACK (on_ss_send_ussd), + ctx); + + return TRUE; +} + +gboolean dbus_plugin_ss_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data) +{ + GVariant *result = 0; + GVariantBuilder b; + int i = 0; + + if ( !data ) { + err("response data : 0"); + return FALSE; + } + + switch (command) { + case TRESP_SS_BARRING_ACTIVATE: { + + const struct tresp_ss_barring *resp = data; + + dbg("receive TRESP_SS_BARRING_ACTIVATE (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_add(&b, "{sv}", "barring_mode", g_variant_new_int32( resp->record[i].mode )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_activate_barring(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_BARRING_DEACTIVATE: { + + const struct tresp_ss_barring *resp = data; + + dbg("receive TRESP_SS_BARRING_DEACTIVATE (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_add(&b, "{sv}", "barring_mode", g_variant_new_int32( resp->record[i].mode )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_deactivate_barring(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_BARRING_CHANGE_PASSWORD: { + + const struct tresp_ss_general *resp = data; + + dbg("receive TRESP_SS_BARRING_CHANGE_PASSWORD (err[%d])", resp->err); + + telephony_ss_complete_change_barring_password(dbus_info->interface_object, dbus_info->invocation, resp->err); + + } break; + + case TRESP_SS_BARRING_GET_STATUS: { + + const struct tresp_ss_barring *resp = data; + + dbg("receive TRESP_SS_BARRING_GET_STATUS (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_add(&b, "{sv}", "barring_mode", g_variant_new_int32( resp->record[i].mode )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_get_barring_status(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_FORWARDING_ACTIVATE: { + const struct tresp_ss_forwarding *resp = data; + + dbg("receive TRESP_SS_FORWARDING_ACTIVATE (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_add(&b, "{sv}", "forwarding_mode", g_variant_new_int32( resp->record[i].mode )); + g_variant_builder_add(&b, "{sv}", "number_present", g_variant_new_int32( resp->record[i].number_present )); + g_variant_builder_add(&b, "{sv}", "no_reply_time", g_variant_new_int32( resp->record[i].time )); + g_variant_builder_add(&b, "{sv}", "type_of_number", g_variant_new_int32( resp->record[i].ton )); + g_variant_builder_add(&b, "{sv}", "numbering_plan_identity", g_variant_new_int32( resp->record[i].npi )); + g_variant_builder_add(&b, "{sv}", "forwarding_number", g_variant_new_string( resp->record[i].number )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_activate_forwarding(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_FORWARDING_DEACTIVATE: { + + const struct tresp_ss_forwarding *resp = data; + + dbg("receive TRESP_SS_FORWARDING_DEACTIVATE (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_add(&b, "{sv}", "forwarding_mode", g_variant_new_int32( resp->record[i].mode )); + g_variant_builder_add(&b, "{sv}", "number_present", g_variant_new_int32( resp->record[i].number_present )); + g_variant_builder_add(&b, "{sv}", "no_reply_time", g_variant_new_int32( resp->record[i].time )); + g_variant_builder_add(&b, "{sv}", "type_of_number", g_variant_new_int32( resp->record[i].ton )); + g_variant_builder_add(&b, "{sv}", "numbering_plan_identity", g_variant_new_int32( resp->record[i].npi )); + g_variant_builder_add(&b, "{sv}", "forwarding_number", g_variant_new_string( resp->record[i].number )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_deactivate_forwarding(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_FORWARDING_REGISTER: { + + const struct tresp_ss_forwarding *resp = data; + + dbg("receive TRESP_SS_FORWARDING_REGISTER (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_add(&b, "{sv}", "forwarding_mode", g_variant_new_int32( resp->record[i].mode )); + g_variant_builder_add(&b, "{sv}", "number_present", g_variant_new_int32( resp->record[i].number_present )); + g_variant_builder_add(&b, "{sv}", "no_reply_time", g_variant_new_int32( resp->record[i].time )); + g_variant_builder_add(&b, "{sv}", "type_of_number", g_variant_new_int32( resp->record[i].ton )); + g_variant_builder_add(&b, "{sv}", "numbering_plan_identity", g_variant_new_int32( resp->record[i].npi )); + g_variant_builder_add(&b, "{sv}", "forwarding_number", g_variant_new_string( resp->record[i].number )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_register_forwarding(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_FORWARDING_DEREGISTER: { + + const struct tresp_ss_forwarding *resp = data; + + dbg("receive TRESP_SS_FORWARDING_DEREGISTER (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_add(&b, "{sv}", "forwarding_mode", g_variant_new_int32( resp->record[i].mode )); + g_variant_builder_add(&b, "{sv}", "number_present", g_variant_new_int32( resp->record[i].number_present )); + g_variant_builder_add(&b, "{sv}", "no_reply_time", g_variant_new_int32( resp->record[i].time )); + g_variant_builder_add(&b, "{sv}", "type_of_number", g_variant_new_int32( resp->record[i].ton )); + g_variant_builder_add(&b, "{sv}", "numbering_plan_identity", g_variant_new_int32( resp->record[i].npi )); + g_variant_builder_add(&b, "{sv}", "forwarding_number", g_variant_new_string( resp->record[i].number )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_deregister_forwarding(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_FORWARDING_GET_STATUS: { + + const struct tresp_ss_forwarding *resp = data; + + dbg("receive TRESP_SS_FORWARDING_GET_STATUS (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_add(&b, "{sv}", "forwarding_mode", g_variant_new_int32( resp->record[i].mode )); + g_variant_builder_add(&b, "{sv}", "number_present", g_variant_new_int32( resp->record[i].number_present )); + g_variant_builder_add(&b, "{sv}", "no_reply_time", g_variant_new_int32( resp->record[i].time )); + g_variant_builder_add(&b, "{sv}", "type_of_number", g_variant_new_int32( resp->record[i].ton )); + g_variant_builder_add(&b, "{sv}", "numbering_plan_identity", g_variant_new_int32( resp->record[i].npi )); + g_variant_builder_add(&b, "{sv}", "forwarding_number", g_variant_new_string( resp->record[i].number )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_get_forwarding_status(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_WAITING_ACTIVATE: { + + const struct tresp_ss_waiting *resp = data; + + dbg("receive TRESP_SS_WAITING_ACTIVATE (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_activate_waiting(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_WAITING_DEACTIVATE: { + + const struct tresp_ss_waiting *resp = data; + + dbg("receive TRESP_SS_WAITING_DEACTIVATE (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_deactivate_waiting(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_WAITING_GET_STATUS: { + + const struct tresp_ss_waiting *resp = data; + + dbg("receive TRESP_SS_WAITING_GET_STATUS (err[%d])", resp->err); + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( resp->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( resp->record[i].status )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + + telephony_ss_complete_get_waiting_status(dbus_info->interface_object, dbus_info->invocation, result, resp->err); + + } break; + + case TRESP_SS_CLI_SET_STATUS: { + + const struct tresp_ss_set_cli *resp = data; + + dbg("receive TRESP_SS_CLI_SET_STATUS (err[%d])", resp->err); + + telephony_ss_complete_set_clistatus(dbus_info->interface_object, dbus_info->invocation, resp->err); + + } break; + + case TRESP_SS_CLI_GET_STATUS: { + + const struct tresp_ss_cli *resp = data; + + dbg("receive TRESP_SS_CLI_GET_STATUS (err[%d])", resp->err); + + telephony_ss_complete_get_clistatus(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->type, resp->status); + + } break; + + case TRESP_SS_SEND_USSD: { + + const struct tresp_ss_ussd *resp = data; + + dbg("receive TRESP_SS_SEND_USSD (err[%d])", resp->err); + dbg("USSD : %s (len : %d, type : 0x%x, status : 0x%x, dcs : 0x%x)", resp->str, resp->len, resp->type, resp->status, resp->dcs); + telephony_ss_complete_send_ussd(dbus_info->interface_object, dbus_info->invocation, resp->err, resp->type, resp->status, resp->dcs, resp->len, (char*)resp->str); + + } break; + + default: + dbg("not handled command[%d]", command); + break; + } + + return TRUE; +} + +gboolean dbus_plugin_ss_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data) +{ + TelephonySs *ss = 0; + GVariant *result = 0; + GVariantBuilder b; + int i = 0; + char *cp_name= NULL; + + if (!object) { + dbg("object is NULL"); + return FALSE; + } + + if (!data) { + err("data is NULL"); + return FALSE; + } + + cp_name = (char*)tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source)); + dbg("Notification!!! Command: [0x%x] CP Name: [%s]", + command, cp_name); + + ss = telephony_object_peek_ss(TELEPHONY_OBJECT(object)); + + switch (command) { + case TNOTI_SS_USSD: { + const struct tnoti_ss_ussd *ussd = data; + enum dbus_tapi_sim_slot_id slot_id; + + slot_id = get_sim_slot_id_by_cp_name(cp_name); + dbg("slot_id: [%d]", slot_id); + + telephony_ss_emit_notify_ussd(ss, + ussd->status, + ussd->dcs, + ussd->len, + (char*)ussd->str); + _launch_ciss(ussd, slot_id); + } break; + + case TNOTI_SS_FORWARDING_STATUS: { + const struct tnoti_ss_forwarding_status *fwrd = data; + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( fwrd->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( fwrd->record[i].status )); + g_variant_builder_add(&b, "{sv}", "forwarding_mode", g_variant_new_int32( fwrd->record[i].mode )); + g_variant_builder_add(&b, "{sv}", "number_present", g_variant_new_int32( fwrd->record[i].number_present )); + g_variant_builder_add(&b, "{sv}", "no_reply_time", g_variant_new_int32( fwrd->record[i].time )); + g_variant_builder_add(&b, "{sv}", "type_of_number", g_variant_new_int32( fwrd->record[i].ton )); + g_variant_builder_add(&b, "{sv}", "numbering_plan_identity", g_variant_new_int32( fwrd->record[i].npi )); + g_variant_builder_add(&b, "{sv}", "forwarding_number", g_variant_new_string( fwrd->record[i].number )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + telephony_ss_emit_notify_forwarding(ss, result); + + } break; + + case TNOTI_SS_BARRING_STATUS: { + + const struct tnoti_ss_barring_status *barr = data; + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( barr->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( barr->record[i].status )); + g_variant_builder_add(&b, "{sv}", "barring_mode", g_variant_new_int32( barr->record[i].mode )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + telephony_ss_emit_notify_barring(ss, result); + + } break; + + case TNOTI_SS_WAITING_STATUS: { + const struct tnoti_ss_waiting_status *wait = data; + + g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + + for (i=0; irecord_num; i++) { + g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}")); + g_variant_builder_add(&b, "{sv}", "ss_class", g_variant_new_int32( wait->record[i].class )); + g_variant_builder_add(&b, "{sv}", "ss_status", g_variant_new_int32( wait->record[i].status )); + g_variant_builder_close(&b); + } + + result = g_variant_builder_end(&b); + telephony_ss_emit_notify_waiting(ss, result); + + } break; + + case TNOTI_SS_RELEASE_COMPLETE: { + int i = 0; + GVariantBuilder builder; + GVariant *msg_data = 0, *packet = NULL; + const struct tnoti_ss_release_complete *msg = data; + if (msg) { + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay")); + for (i = 0; i < msg->data_len; i++) { + g_variant_builder_add(&builder, "y", msg->data[i]); + } + msg_data = g_variant_builder_end(&builder); + packet = g_variant_new("v", msg_data); + + dbg("type_format(%s)", g_variant_get_type_string(packet)); + telephony_ss_emit_release_complete(ss, msg->data_len, packet ); + } else { + dbg("No data is passed in USSD release notification"); + g_variant_builder_init(&builder, G_VARIANT_TYPE ("ay")); + g_variant_builder_add(&builder, "y", '\0'); + msg_data = g_variant_builder_end(&builder); + packet = g_variant_new("v", msg_data); + dbg("type_format(%s)", g_variant_get_type_string(packet)); + telephony_ss_emit_release_complete(ss, 1, packet); + } + } break; + case TNOTI_SS_INFO: { + const struct tnoti_ss_information *ss_info = data; + telephony_ss_emit_notify_ss_info(ss, + ss_info->err, + ss_info->ss_type); + _launch_ciss_information(ss_info); + /* Launch CISS application + _launch_ciss(ss_info); + */ + } break; + default: + dbg("not handled command[%d]", command); + break; + } + + return TRUE; +} + diff --git a/tel-plugin-dbus_tapi.manifest b/tel-plugin-dbus_tapi.manifest new file mode 100644 index 0000000..97e8c31 --- /dev/null +++ b/tel-plugin-dbus_tapi.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/test/network-search.sh b/test/network-search.sh new file mode 100755 index 0000000..6fcaa58 --- /dev/null +++ b/test/network-search.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +dbus-send --print-reply --reply-timeout=60000 --dest=org.tizen.telephony /org/tizen/telephony/SAMSUNG org.tizen.telephony.Network.Search