MESSAGE(${CMAKE_C_FLAGS})
MESSAGE(${pkgs_LDFLAGS})
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/include
+)
+
SET(SRCS
- src/desc-vconf.c
+ src/desc-vconf.c
+ src/vconf_main.c
+ src/vconf_core.c
+ src/vconf_handler.c
)
-Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
-\r
- Apache License\r
- Version 2.0, January 2004\r
- http://www.apache.org/licenses/\r
-\r
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
-\r
- 1. Definitions.\r
-\r
- "License" shall mean the terms and conditions for use, reproduction,\r
- and distribution as defined by Sections 1 through 9 of this document.\r
-\r
- "Licensor" shall mean the copyright owner or entity authorized by\r
- the copyright owner that is granting the License.\r
-\r
- "Legal Entity" shall mean the union of the acting entity and all\r
- other entities that control, are controlled by, or are under common\r
- control with that entity. For the purposes of this definition,\r
- "control" means (i) the power, direct or indirect, to cause the\r
- direction or management of such entity, whether by contract or\r
- otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
- outstanding shares, or (iii) beneficial ownership of such entity.\r
-\r
- "You" (or "Your") shall mean an individual or Legal Entity\r
- exercising permissions granted by this License.\r
-\r
- "Source" form shall mean the preferred form for making modifications,\r
- including but not limited to software source code, documentation\r
- source, and configuration files.\r
-\r
- "Object" form shall mean any form resulting from mechanical\r
- transformation or translation of a Source form, including but\r
- not limited to compiled object code, generated documentation,\r
- and conversions to other media types.\r
-\r
- "Work" shall mean the work of authorship, whether in Source or\r
- Object form, made available under the License, as indicated by a\r
- copyright notice that is included in or attached to the work\r
- (an example is provided in the Appendix below).\r
-\r
- "Derivative Works" shall mean any work, whether in Source or Object\r
- form, that is based on (or derived from) the Work and for which the\r
- editorial revisions, annotations, elaborations, or other modifications\r
- represent, as a whole, an original work of authorship. For the purposes\r
- of this License, Derivative Works shall not include works that remain\r
- separable from, or merely link (or bind by name) to the interfaces of,\r
- the Work and Derivative Works thereof.\r
-\r
- "Contribution" shall mean any work of authorship, including\r
- the original version of the Work and any modifications or additions\r
- to that Work or Derivative Works thereof, that is intentionally\r
- submitted to Licensor for inclusion in the Work by the copyright owner\r
- or by an individual or Legal Entity authorized to submit on behalf of\r
- the copyright owner. For the purposes of this definition, "submitted"\r
- means any form of electronic, verbal, or written communication sent\r
- to the Licensor or its representatives, including but not limited to\r
- communication on electronic mailing lists, source code control systems,\r
- and issue tracking systems that are managed by, or on behalf of, the\r
- Licensor for the purpose of discussing and improving the Work, but\r
- excluding communication that is conspicuously marked or otherwise\r
- designated in writing by the copyright owner as "Not a Contribution."\r
-\r
- "Contributor" shall mean Licensor and any individual or Legal Entity\r
- on behalf of whom a Contribution has been received by Licensor and\r
- subsequently incorporated within the Work.\r
-\r
- 2. Grant of Copyright License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- copyright license to reproduce, prepare Derivative Works of,\r
- publicly display, publicly perform, sublicense, and distribute the\r
- Work and such Derivative Works in Source or Object form.\r
-\r
- 3. Grant of Patent License. Subject to the terms and conditions of\r
- this License, each Contributor hereby grants to You a perpetual,\r
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
- (except as stated in this section) patent license to make, have made,\r
- use, offer to sell, sell, import, and otherwise transfer the Work,\r
- where such license applies only to those patent claims licensable\r
- by such Contributor that are necessarily infringed by their\r
- Contribution(s) alone or by combination of their Contribution(s)\r
- with the Work to which such Contribution(s) was submitted. If You\r
- institute patent litigation against any entity (including a\r
- cross-claim or counterclaim in a lawsuit) alleging that the Work\r
- or a Contribution incorporated within the Work constitutes direct\r
- or contributory patent infringement, then any patent licenses\r
- granted to You under this License for that Work shall terminate\r
- as of the date such litigation is filed.\r
-\r
- 4. Redistribution. You may reproduce and distribute copies of the\r
- Work or Derivative Works thereof in any medium, with or without\r
- modifications, and in Source or Object form, provided that You\r
- meet the following conditions:\r
-\r
- (a) You must give any other recipients of the Work or\r
- Derivative Works a copy of this License; and\r
-\r
- (b) You must cause any modified files to carry prominent notices\r
- stating that You changed the files; and\r
-\r
- (c) You must retain, in the Source form of any Derivative Works\r
- that You distribute, all copyright, patent, trademark, and\r
- attribution notices from the Source form of the Work,\r
- excluding those notices that do not pertain to any part of\r
- the Derivative Works; and\r
-\r
- (d) If the Work includes a "NOTICE" text file as part of its\r
- distribution, then any Derivative Works that You distribute must\r
- include a readable copy of the attribution notices contained\r
- within such NOTICE file, excluding those notices that do not\r
- pertain to any part of the Derivative Works, in at least one\r
- of the following places: within a NOTICE text file distributed\r
- as part of the Derivative Works; within the Source form or\r
- documentation, if provided along with the Derivative Works; or,\r
- within a display generated by the Derivative Works, if and\r
- wherever such third-party notices normally appear. The contents\r
- of the NOTICE file are for informational purposes only and\r
- do not modify the License. You may add Your own attribution\r
- notices within Derivative Works that You distribute, alongside\r
- or as an addendum to the NOTICE text from the Work, provided\r
- that such additional attribution notices cannot be construed\r
- as modifying the License.\r
-\r
- You may add Your own copyright statement to Your modifications and\r
- may provide additional or different license terms and conditions\r
- for use, reproduction, or distribution of Your modifications, or\r
- for any such Derivative Works as a whole, provided Your use,\r
- reproduction, and distribution of the Work otherwise complies with\r
- the conditions stated in this License.\r
-\r
- 5. Submission of Contributions. Unless You explicitly state otherwise,\r
- any Contribution intentionally submitted for inclusion in the Work\r
- by You to the Licensor shall be under the terms and conditions of\r
- this License, without any additional terms or conditions.\r
- Notwithstanding the above, nothing herein shall supersede or modify\r
- the terms of any separate license agreement you may have executed\r
- with Licensor regarding such Contributions.\r
-\r
- 6. Trademarks. This License does not grant permission to use the trade\r
- names, trademarks, service marks, or product names of the Licensor,\r
- except as required for reasonable and customary use in describing the\r
- origin of the Work and reproducing the content of the NOTICE file.\r
-\r
- 7. Disclaimer of Warranty. Unless required by applicable law or\r
- agreed to in writing, Licensor provides the Work (and each\r
- Contributor provides its Contributions) on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
- implied, including, without limitation, any warranties or conditions\r
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
- PARTICULAR PURPOSE. You are solely responsible for determining the\r
- appropriateness of using or redistributing the Work and assume any\r
- risks associated with Your exercise of permissions under this License.\r
-\r
- 8. Limitation of Liability. In no event and under no legal theory,\r
- whether in tort (including negligence), contract, or otherwise,\r
- unless required by applicable law (such as deliberate and grossly\r
- negligent acts) or agreed to in writing, shall any Contributor be\r
- liable to You for damages, including any direct, indirect, special,\r
- incidental, or consequential damages of any character arising as a\r
- result of this License or out of the use or inability to use the\r
- Work (including but not limited to damages for loss of goodwill,\r
- work stoppage, computer failure or malfunction, or any and all\r
- other commercial damages or losses), even if such Contributor\r
- has been advised of the possibility of such damages.\r
-\r
- 9. Accepting Warranty or Additional Liability. While redistributing\r
- the Work or Derivative Works thereof, You may choose to offer,\r
- and charge a fee for, acceptance of support, warranty, indemnity,\r
- or other liability obligations and/or rights consistent with this\r
- License. However, in accepting such obligations, You may act only\r
- on Your own behalf and on Your sole responsibility, not on behalf\r
- of any other Contributor, and only if You agree to indemnify,\r
- defend, and hold each Contributor harmless for any liability\r
- incurred by, or claims asserted against, such Contributor by reason\r
- of your accepting any such warranty or additional liability.\r
-\r
- END OF TERMS AND CONDITIONS\r
-\r
- APPENDIX: How to apply the Apache License to your work.\r
-\r
- To apply the Apache License to your work, attach the following\r
- boilerplate notice, with the fields enclosed by brackets "[]"\r
- replaced with your own identifying information. (Don't include\r
- the brackets!) The text should be enclosed in the appropriate\r
- comment syntax for the file format. We also recommend that a\r
- file or class name and description of purpose be included on the\r
- same "printed page" as the copyright notice for easier\r
- identification within third-party archives.\r
-\r
- Copyright [yyyy] [name of copyright owner]\r
-\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
-\r
- http://www.apache.org/licenses/LICENSE-2.0\r
-\r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
-\r
+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.
+
--- /dev/null
+/*
+ * tel-plugin-vconf
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __VCONF_CORE_H__
+#define __VCONF_CORE_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+#include <tcore.h>
+
+gboolean vconf_core_init(TcorePlugin *plugin);
+void vconf_core_deinit(TcorePlugin *plugin);
+
+__END_DECLS
+
+#endif /* __VCONF_CORE_H__ */
--- /dev/null
+/*
+ * tel-plugin-vconf
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __VCONF_HANDLER_H__
+#define __VCONF_HANDLER_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+#include <tcore.h>
+
+gboolean vconf_handler_init(TcorePlugin *plugin);
+void vconf_handler_deinit(TcorePlugin *plugin);
+
+__END_DECLS
+
+#endif /* __VCONF_HANDLER_H__ */
--- /dev/null
+/*
+ * tel-plugin-vconf
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * 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 __VCONF_MAIN_H__
+#define __VCONF_MAIN_H__
+
+__BEGIN_DECLS
+
+#include <glib.h>
+#include <tcore.h>
+
+/*
+ * TODO -
+ *Keys need to be moved to vconf-internal-keys package
+ */
+#define VCONFKEY_WECONN_ALL_CONNECTED "memory/private/weconn/all_connected" /* True/False */
+#define VCONFKEY_SAP_CONNECTION_TYPE "memory/private/sap/conn_type" /* SAPInterface.h */
+
+gboolean vconf_main_init(TcorePlugin *plugin);
+void vconf_main_deinit(TcorePlugin *plugin);
+
+__END_DECLS
+
+#endif /* __VCONF_MAIN_H__ */
%define major 0
%define minor 2
-%define patchlevel 3
+%define patchlevel 4
Name: tel-plugin-vconf
Version: %{major}.%{minor}.%{patchlevel}
License: Apache-2.0
Summary: Telephony Vconf storage plugin
Group: System/Libraries
-Source0: tel-plugin-vconf-%{version}.tar.gz
+Source0: %{name}-%{version}.tar.gz
BuildRequires: cmake
#BuildRequires: model-build-features
BuildRequires: pkgconfig(glib-2.0)
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/sysinfo.h>
#include <glib.h>
-#include <vconf.h>
#include <tcore.h>
-#include <server.h>
#include <plugin.h>
-#include <storage.h>
-#include <co_network.h>
+
+#include "vconf_main.h"
#ifndef PLUGIN_VERSION
#define PLUGIN_VERSION 1
#endif
-struct vconf_plugin_user_data {
- gboolean b_get_nck_retry_count;
-
- enum modem_state last_modem_power_state;
- gboolean last_flight_mode_state;
- long last_modem_state_timestamp;
-};
-
-#define VCONFKEY_WECONN_ALL_CONNECTED "memory/private/weconn/all_connected" /* True/False */
-#define VCONFKEY_SAP_CONNECTION_TYPE "memory/private/sap/conn_type" /* SAPInterface.h */
-
-#ifndef VCONFKEY_TESTMODE_FAST_DORMANCY
-#define VCONFKEY_TESTMODE_FAST_DORMANCY "memory/testmode/fast_dormancy"
-#endif
-#ifndef VCONFKEY_TESTMODE_FAST_DORMANCY2
-#define VCONFKEY_TESTMODE_FAST_DORMANCY2 "memory/testmode/fast_dormancy2"
-#endif
-
-static void reset_vconf();
-
-static TcoreStorageDispatchCallback callback_dispatch;
-
-static gboolean __vconf_check_process_hook_callback(CoreObject *co)
-{
- const char *cp_name;
-
- cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co));
- dbg("CP name: [%s]", cp_name);
-
- if (cp_name == NULL)
- return FALSE;
-
- return g_str_has_suffix(cp_name, "0");
-}
-
-static void __vconf_write_power_status_log(struct vconf_plugin_user_data *ud, enum modem_state state)
-{
- struct sysinfo sys_info;
-
- if (ud == NULL)
- return;
-
- if (0 != sysinfo(&sys_info))
- err("sysinfo failed.");
-
- if (state == MODEM_STATE_ONLINE) {
- if (ud->last_modem_power_state == MODEM_STATE_LOW) {
- int count = 0;
- if (0 == vconf_get_int(VCONFKEY_TELEPHONY_PRIVATE_MODEM_ON_COUNT, &count)) {
- count++;
- if (0 != vconf_set_int(VCONFKEY_TELEPHONY_PRIVATE_MODEM_ON_COUNT, count))
- err("vconf_set_int failed.");
- } else {
- err("vconf_get_int failed.");
- }
- msg("[MODEM ON/OFF] MODEM LOW => ON in %d secs. (modem_on_count[%d] after boot-up. (uptime %ld secs))",
- sys_info.uptime - ud->last_modem_state_timestamp, count, sys_info.uptime);
- ud->last_modem_power_state = state;
- ud->last_modem_state_timestamp = sys_info.uptime;
- }
- } else if (state == MODEM_STATE_LOW) {
- if (ud->last_modem_power_state == MODEM_STATE_ONLINE) {
- int count = 0;
- if (0 != vconf_get_int(VCONFKEY_TELEPHONY_PRIVATE_MODEM_ON_COUNT, &count))
- err("vconf_get_int failed.");
-
- msg("[MODEM ON/OFF] MODEM ON => LOW in %d secs. (modem_on_count=[%d] after boot-up(uptime %ld secs))",
- sys_info.uptime - ud->last_modem_state_timestamp, count, sys_info.uptime);
- ud->last_modem_power_state = state;
- ud->last_modem_state_timestamp = sys_info.uptime;
- }
- }
-}
-
-static void __vconf_check_and_set_int(const char *in_key, const int intval)
-{
- int current;
- vconf_get_int(in_key, ¤t);
- if (current != intval)
- vconf_set_int(in_key, intval);
-}
-
-static void __vconf_check_and_set_str(const char *in_key, const char *strval)
-{
- char *current = vconf_get_str(in_key);
-
- if (current) {
- if (strval && strcmp(current, strval))
- vconf_set_str(in_key, strval);
-
- free(current);
- } else {
- vconf_set_str(in_key, strval);
- }
-}
-
-static const char *convert_strgkey_to_vconf(enum tcore_storage_key key)
-{
- switch (key) {
- case STORAGE_KEY_TELEPHONY_PLMN:
- return VCONFKEY_TELEPHONY_PLMN;
- case STORAGE_KEY_TELEPHONY_LAC:
- return VCONFKEY_TELEPHONY_LAC;
- case STORAGE_KEY_TELEPHONY_CELLID:
- return VCONFKEY_TELEPHONY_CELLID;
- case STORAGE_KEY_TELEPHONY_SVCTYPE:
- return VCONFKEY_TELEPHONY_SVCTYPE;
- case STORAGE_KEY_TELEPHONY_SVC_CS:
- return VCONFKEY_TELEPHONY_SVC_CS;
- case STORAGE_KEY_TELEPHONY_SVC_PS:
- return VCONFKEY_TELEPHONY_SVC_PS;
- case STORAGE_KEY_TELEPHONY_SVC_ROAM:
- return VCONFKEY_TELEPHONY_SVC_ROAM;
- case STORAGE_KEY_TELEPHONY_SIM_PB_INIT:
- return VCONFKEY_TELEPHONY_SIM_PB_INIT;
- case STORAGE_KEY_TELEPHONY_CALL_FORWARD_STATE:
- return VCONFKEY_TELEPHONY_CALL_FORWARD_STATE;
- case STORAGE_KEY_TELEPHONY_TAPI_STATE:
- return VCONFKEY_TELEPHONY_TAPI_STATE;
- case STORAGE_KEY_TELEPHONY_SPN_DISP_CONDITION:
- return VCONFKEY_TELEPHONY_SPN_DISP_CONDITION;
- case STORAGE_KEY_TELEPHONY_RSSI:
- return VCONFKEY_TELEPHONY_RSSI;
- case STORAGE_KEY_TELEPHONY_READY:
- return VCONFKEY_TELEPHONY_READY;
- case STORAGE_KEY_TELEPHONY_SIM_SLOT:
- return VCONFKEY_TELEPHONY_SIM_SLOT;
- case STORAGE_KEY_TELEPHONY_SIM_SLOT2:
- return VCONFKEY_TELEPHONY_SIM_SLOT2;
- case STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT:
- return VCONFKEY_TELEPHONY_SIM_SLOT_COUNT;
- case STORAGE_KEY_PM_STATE:
- return VCONFKEY_PM_STATE;
- case STORAGE_KEY_PACKET_SERVICE_STATE:
- return VCONFKEY_DNET_STATE;
- case STORAGE_KEY_PACKET_SERVICE_STATE2:
- return VCONFKEY_DNET_STATE2;
- case STORAGE_KEY_PACKET_INDICATOR_STATE:
- return VCONFKEY_PACKET_STATE;
- case STORAGE_KEY_3G_ENABLE:
- return VCONFKEY_3G_ENABLE;
- case STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT:
- return VCONFKEY_TELEPHONY_DB_DEFAULT_DATA_SUBS;
- case STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL:
- return VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL;
- case STORAGE_KEY_TELEPHONY_NWNAME:
- return VCONFKEY_TELEPHONY_NWNAME;
- case STORAGE_KEY_TELEPHONY_SPN_NAME:
- return VCONFKEY_TELEPHONY_SPN_NAME;
- case STORAGE_KEY_CELLULAR_STATE:
- return VCONFKEY_NETWORK_CELLULAR_STATE;
- case STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV:
- return VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV;
- case STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV2:
- return VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2;
- case STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT:
- return VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT;
- case STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT2:
- return VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2;
- case STORAGE_KEY_CELLULAR_PKT_LAST_RCV:
- return VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV;
- case STORAGE_KEY_CELLULAR_PKT_LAST_RCV2:
- return VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2;
- case STORAGE_KEY_CELLULAR_PKT_LAST_SNT:
- return VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT;
- case STORAGE_KEY_CELLULAR_PKT_LAST_SNT2:
- return VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2;
- case STORAGE_KEY_LANGUAGE_SET:
- return VCONFKEY_LANGSET;
- case STORAGE_KEY_FLIGHT_MODE_BOOL:
- return VCONFKEY_TELEPHONY_FLIGHT_MODE;
-#ifdef TIZEN_FEATURE_FAST_DORMANCY_ENABLE
- case STORAGE_KEY_TESTMODE_FAST_DORMANCY:
- return VCONFKEY_TESTMODE_FAST_DORMANCY;
- case STORAGE_KEY_TESTMODE_FAST_DORMANCY2:
- return VCONFKEY_TESTMODE_FAST_DORMANCY2;
-#endif
- case STORAGE_KEY_POWER_SAVING_MODE:
- return VCONFKEY_SETAPPL_PSMODE;
- case STORAGE_KEY_SETAPPL_NETWORK_RESTRICT_MODE:
- return VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE;
- case STORAGE_KEY_SETAPPL_MOBILE_DATA_POPUP_DONE_BOOL:
- return VCONFKEY_SETAPPL_MOBILE_DATA_POPUP_DONE;
- case STORAGE_KEY_MSG_SERVER_READY_BOOL:
- return VCONFKEY_MSG_SERVER_READY;
- case STORAGE_KEY_TELEPHONY_PREFERRED_VOICE_SUBSCRIPTION:
- return VCONFKEY_TELEPHONY_PREFERRED_VOICE_SUBSCRIPTION;
- case STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_SERVICE_INT:
- return VCONFKEY_TELEPHONY_DB_DEFAULT_SUBS;
- case STORAGE_KEY_WIFI_STATE_INT:
- return VCONFKEY_WIFI_STATE;
- case STORAGE_KEY_WECONN_ALL_CONNECTED:
- return VCONFKEY_WECONN_ALL_CONNECTED;
- case STORAGE_KEY_SAP_CONNECTION_TYPE:
- return VCONFKEY_SAP_CONNECTION_TYPE;
-#ifdef PREPAID_SIM_APN_SUPPORT
- case STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL:
- return VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT;
- case STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID:
- return VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID;
- case STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN:
- return VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT_PLMN;
-#endif
- default:
- break;
- }
-
- return NULL;
-}
-
-static enum tcore_storage_key convert_vconf_to_strgkey(const char *key)
-{
- if (g_str_equal(key, VCONFKEY_TELEPHONY_PLMN) == TRUE)
- return STORAGE_KEY_TELEPHONY_PLMN;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_LAC) == TRUE)
- return STORAGE_KEY_TELEPHONY_LAC;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_CELLID) == TRUE)
- return STORAGE_KEY_TELEPHONY_CELLID;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SVCTYPE) == TRUE)
- return STORAGE_KEY_TELEPHONY_SVCTYPE;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SVC_CS) == TRUE)
- return STORAGE_KEY_TELEPHONY_SVC_CS;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SVC_PS) == TRUE)
- return STORAGE_KEY_TELEPHONY_SVC_PS;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SVC_ROAM) == TRUE)
- return STORAGE_KEY_TELEPHONY_SVC_ROAM;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SIM_PB_INIT) == TRUE)
- return STORAGE_KEY_TELEPHONY_SIM_PB_INIT;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_CALL_FORWARD_STATE) == TRUE)
- return STORAGE_KEY_TELEPHONY_CALL_FORWARD_STATE;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_TAPI_STATE) == TRUE)
- return STORAGE_KEY_TELEPHONY_TAPI_STATE;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SPN_DISP_CONDITION) == TRUE)
- return STORAGE_KEY_TELEPHONY_SPN_DISP_CONDITION;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_RSSI) == TRUE)
- return STORAGE_KEY_TELEPHONY_RSSI;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_READY) == TRUE)
- return STORAGE_KEY_TELEPHONY_READY;
- else if (g_str_equal(key, VCONFKEY_3G_ENABLE) == TRUE)
- return STORAGE_KEY_3G_ENABLE;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_DB_DEFAULT_DATA_SUBS) == TRUE)
- return STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT;
- else if (g_str_equal(key, VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL) == TRUE)
- return STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL;
- else if (g_str_equal(key, VCONFKEY_PM_STATE) == TRUE)
- return STORAGE_KEY_PM_STATE;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SIM_SLOT) == TRUE)
- return STORAGE_KEY_TELEPHONY_SIM_SLOT;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SIM_SLOT2) == TRUE)
- return STORAGE_KEY_TELEPHONY_SIM_SLOT2;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SIM_SLOT_COUNT) == TRUE)
- return STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT;
- else if (g_str_equal(key, VCONFKEY_DNET_STATE) == TRUE)
- return STORAGE_KEY_PACKET_SERVICE_STATE;
- else if (g_str_equal(key, VCONFKEY_DNET_STATE2) == TRUE)
- return STORAGE_KEY_PACKET_SERVICE_STATE2;
- else if (g_str_equal(key, VCONFKEY_PACKET_STATE) == TRUE)
- return STORAGE_KEY_PACKET_INDICATOR_STATE;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_NWNAME) == TRUE)
- return STORAGE_KEY_TELEPHONY_NWNAME;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_SPN_NAME) == TRUE)
- return STORAGE_KEY_TELEPHONY_SPN_NAME;
- else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_STATE) == TRUE)
- return STORAGE_KEY_CELLULAR_STATE;
- else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV) == TRUE)
- return STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV;
- else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2) == TRUE)
- return STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV2;
- else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT) == TRUE)
- return STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT;
- else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2) == TRUE)
- return STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT2;
- else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV) == TRUE)
- return STORAGE_KEY_CELLULAR_PKT_LAST_RCV;
- else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2) == TRUE)
- return STORAGE_KEY_CELLULAR_PKT_LAST_RCV2;
- else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT) == TRUE)
- return STORAGE_KEY_CELLULAR_PKT_LAST_SNT;
- else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2) == TRUE)
- return STORAGE_KEY_CELLULAR_PKT_LAST_SNT2;
- else if (g_str_equal(key, VCONFKEY_LANGSET) == TRUE)
- return STORAGE_KEY_LANGUAGE_SET;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_FLIGHT_MODE) == TRUE)
- return STORAGE_KEY_FLIGHT_MODE_BOOL;
-#ifdef TIZEN_FEATURE_FAST_DORMANCY_ENABLE
- else if (g_str_equal(key, VCONFKEY_TESTMODE_FAST_DORMANCY) == TRUE)
- return STORAGE_KEY_TESTMODE_FAST_DORMANCY;
- else if (g_str_equal(key, VCONFKEY_TESTMODE_FAST_DORMANCY2) == TRUE)
- return STORAGE_KEY_TESTMODE_FAST_DORMANCY2;
-#endif
- else if (g_str_equal(key, VCONFKEY_SETAPPL_PSMODE) == TRUE)
- return STORAGE_KEY_POWER_SAVING_MODE;
- else if (g_str_equal(key, VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE) == TRUE)
- return STORAGE_KEY_SETAPPL_NETWORK_RESTRICT_MODE;
- else if (g_str_equal(key, VCONFKEY_SETAPPL_MOBILE_DATA_POPUP_DONE) == TRUE)
- return STORAGE_KEY_SETAPPL_MOBILE_DATA_POPUP_DONE_BOOL;
- else if (g_str_equal(key, VCONFKEY_MSG_SERVER_READY) == TRUE)
- return STORAGE_KEY_MSG_SERVER_READY_BOOL;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_PREFERRED_VOICE_SUBSCRIPTION) == TRUE)
- return STORAGE_KEY_TELEPHONY_PREFERRED_VOICE_SUBSCRIPTION;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_DB_DEFAULT_SUBS) == TRUE)
- return STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_SERVICE_INT;
- else if (g_str_equal(key, VCONFKEY_WIFI_STATE) == TRUE)
- return STORAGE_KEY_WIFI_STATE_INT;
- else if (g_str_equal(key, VCONFKEY_WECONN_ALL_CONNECTED) == TRUE)
- return STORAGE_KEY_WECONN_ALL_CONNECTED;
- else if (g_str_equal(key, VCONFKEY_SAP_CONNECTION_TYPE) == TRUE)
- return STORAGE_KEY_SAP_CONNECTION_TYPE;
-#ifdef PREPAID_SIM_APN_SUPPORT
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT) == TRUE)
- return STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID) == TRUE)
- return STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID;
- else if (g_str_equal(key, VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT_PLMN) == TRUE)
- return STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN;
-#endif
-
- return 0;
-}
-
-static void *create_handle(Storage *strg, const char *path)
-{
- void *tmp = NULL;
- if (!strg)
- return NULL;
-
- tmp = malloc(sizeof(char));
- return tmp;
-}
-
-static gboolean remove_handle(Storage *strg, void *handle)
-{
- if (!strg || !handle)
- return FALSE;
-
- free(handle);
- return TRUE;
-}
-
-static gboolean set_int(Storage *strg, enum tcore_storage_key key, int value)
-{
- const gchar *s_key = NULL;
-
- if (!strg)
- return FALSE;
-
- if (key & STORAGE_KEY_INT)
- s_key = convert_strgkey_to_vconf(key);
-
- if (!s_key)
- return FALSE;
-
- if (vconf_set_int(s_key, value) == 0)
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean set_bool(Storage *strg, enum tcore_storage_key key, gboolean value)
-{
- const gchar *s_key = NULL;
-
- if (!strg)
- return FALSE;
-
- if (key & STORAGE_KEY_BOOL)
- s_key = convert_strgkey_to_vconf(key);
-
- if (!s_key)
- return FALSE;
-
- vconf_set_bool(s_key, value);
- return TRUE;
-}
-
-static gboolean set_string(Storage *strg, enum tcore_storage_key key, const char *value)
-{
- const gchar *s_key = NULL;
-
- if (!strg)
- return FALSE;
-
- if (key & STORAGE_KEY_STRING)
- s_key = convert_strgkey_to_vconf(key);
-
- if (!s_key)
- return FALSE;
-
- vconf_set_str(s_key, value);
- return TRUE;
-}
-
-static int get_int(Storage *strg, enum tcore_storage_key key)
-{
- int value = -1;
- const gchar *s_key = NULL;
-
- if (!strg)
- return value;
-
- if (key & STORAGE_KEY_INT)
- s_key = convert_strgkey_to_vconf(key);
-
- if (s_key != NULL)
- vconf_get_int(s_key, &value);
-
- return value;
-}
-
-static gboolean get_bool(Storage *strg, enum tcore_storage_key key)
-{
- gboolean value = FALSE;
- const gchar *s_key = NULL;
-
- if (!strg)
- return value;
-
- if (key & STORAGE_KEY_BOOL)
- s_key = convert_strgkey_to_vconf(key);
-
- if (s_key != NULL)
- vconf_get_bool(s_key, &value);
-
- return value;
-}
-
-static char *get_string(Storage *strg, enum tcore_storage_key key)
-{
- const gchar *s_key = NULL;
-
- if (!strg)
- return NULL;
-
- if (key & STORAGE_KEY_STRING)
- s_key = convert_strgkey_to_vconf(key);
-
- if (s_key != NULL)
- return vconf_get_str(s_key);
-
- return NULL;
-}
-
-static void __vconfkey_callback(keynode_t *node, void *data)
-{
- int type = 0;
- const char *vkey = NULL;
- GVariant *value = NULL;
- enum tcore_storage_key s_key = 0;
- Storage *strg = NULL;
-
- strg = (Storage *)data;
- vkey = vconf_keynode_get_name(node);
- type = vconf_keynode_get_type(node);
- if (vkey != NULL)
- s_key = convert_vconf_to_strgkey(vkey);
-
- if (type == VCONF_TYPE_STRING) {
- gchar *tmp;
- tmp = (char *)vconf_keynode_get_str(node);
- value = g_variant_new_string(tmp);
- } else if (type == VCONF_TYPE_INT) {
- gint32 tmp = 0;
- tmp = vconf_keynode_get_int(node);
- value = g_variant_new_int32(tmp);
- } else if (type == VCONF_TYPE_DOUBLE) {
- gdouble tmp = 0;
- tmp = vconf_keynode_get_dbl(node);
- value = g_variant_new_double(tmp);
- } else if (type == VCONF_TYPE_BOOL) {
- gboolean tmp = FALSE;
- tmp = vconf_keynode_get_bool(node);
- value = g_variant_new_boolean(tmp);
- }
-
-
- if (callback_dispatch != NULL)
- callback_dispatch(strg, s_key, value);
-
- if (value)
- g_variant_unref(value);
-
- return;
-}
-
-static gboolean set_key_callback(Storage *strg, enum tcore_storage_key key, TcoreStorageDispatchCallback cb)
-{
- const gchar *s_key = NULL;
-
- if (!strg)
- return FALSE;
-
- s_key = convert_strgkey_to_vconf(key);
- dbg("s_key (%s)", s_key);
-
- if (s_key == NULL)
- return FALSE;
-
- if (callback_dispatch == NULL)
- callback_dispatch = cb;
-
- vconf_notify_key_changed(s_key, __vconfkey_callback, strg);
- return TRUE;
-}
-
-static gboolean remove_key_callback(Storage *strg, enum tcore_storage_key key)
-{
- const gchar *s_key = NULL;
-
- if (!strg)
- return FALSE;
-
- s_key = convert_strgkey_to_vconf(key);
- dbg("s_key (%s)", s_key);
-
- if (s_key == NULL)
- return FALSE;
-
- vconf_ignore_key_changed(s_key, __vconfkey_callback);
- return TRUE;
-}
-
-struct storage_operations ops = {
- .create_handle = create_handle,
- .remove_handle = remove_handle,
- .set_int = set_int,
- .set_string = set_string,
- .set_bool = set_bool,
- .get_int = get_int,
- .get_string = get_string,
- .get_bool = get_bool,
- .set_key_callback = set_key_callback,
- .remove_key_callback = remove_key_callback,
-};
-
-static void _update_vconf_network_name(CoreObject *o)
-{
- char *nwname = NULL;
- char *spnname = NULL;
- enum telephony_network_service_type svc_type;
- enum telephony_network_access_technology svc_act;
- enum tcore_network_name_priority network_name_priority;
-
- tcore_network_get_service_type(o, &svc_type);
- if (svc_type != NETWORK_SERVICE_TYPE_3G) {
- int current = 0;
-
- vconf_get_int(VCONFKEY_TELEPHONY_PSTYPE, ¤t);
- if (current != 0) {
- dbg("force hsdpa state off");
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_NONE);
- }
- }
-
- tcore_network_get_access_technology(o, &svc_act);
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVC_ACT, svc_act);
-
- tcore_network_get_network_name_priority(o, &network_name_priority);
- switch (network_name_priority) {
- case TCORE_NETWORK_NAME_PRIORITY_SPN:
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_SPN);
- break;
-
- case TCORE_NETWORK_NAME_PRIORITY_NETWORK:
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_PLMN);
- break;
-
- case TCORE_NETWORK_NAME_PRIORITY_ANY:
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_SPN_PLMN);
- break;
-
- default:
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_INVALID);
- break;
- }
-
- switch (svc_type) {
- case NETWORK_SERVICE_TYPE_UNKNOWN:
- case NETWORK_SERVICE_TYPE_NO_SERVICE:
- case NETWORK_SERVICE_TYPE_EMERGENCY:
- case NETWORK_SERVICE_TYPE_SEARCH:
- break;
-
- default:
- /* spn */
- spnname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_SPN);
- if (spnname)
- __vconf_check_and_set_str(VCONFKEY_TELEPHONY_SPN_NAME, spnname);
-
- /* nitz */
- nwname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_FULL);
- if (nwname && strlen(nwname) > 0) {
- dbg("SPN:[%s] FULL:[%s] prio:[%d] act:[%d] svc_type:[%d]",
- spnname ? spnname : "", nwname, network_name_priority, svc_act, svc_type);
- __vconf_check_and_set_str(VCONFKEY_TELEPHONY_NWNAME, nwname);
- break;
- } else {
- if (nwname)
- free(nwname);
- nwname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_SHORT);
- if (nwname) {
- dbg("SPN:[%s] SHORT:[%s] prio:[%d] act:[%d] svc_type:[%d]",
- spnname ? spnname : "", nwname, network_name_priority, svc_act, svc_type);
- __vconf_check_and_set_str(VCONFKEY_TELEPHONY_NWNAME, nwname);
- break;
- }
- }
- dbg("name is not fixed yet. SPN:[%s] prio:[%d] act:[%d] svc_type:[%d]",
- spnname ? spnname : "", network_name_priority, svc_act, svc_type);
-
- break;
- }
-
- if (spnname)
- free(spnname);
-
- if (nwname)
- free(nwname);
-}
-
-static enum tcore_hook_return on_hook_network_location_cellinfo(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_network_location_cellinfo *info = data;
-
- /*
- * Backward compatibility for Single SIM (Primary Subscription ONLY)
- *
- * In case of Dual SIM, ONLY Primary Subscription's notifications would be
- * processed
- */
- if (__vconf_check_process_hook_callback(source) == FALSE) {
- dbg("Notification NOT intended for Primary Subscription");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_CELLID, info->cell_id);
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_LAC, info->lac);
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_network_icon_info(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_network_icon_info *info = data;
-
- /*
- * Backward compatibility for Single SIM (Primary Subscription ONLY)
- *
- * In case of Dual SIM, ONLY Primary Subscription's notifications would be
- * processed
- */
- if (__vconf_check_process_hook_callback(source) == FALSE) {
- dbg("Notification NOT intended for Primary Subscription");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-#ifdef TIZEN_FEATURE_CDMA
- if (info->type & NETWORK_ICON_INFO_ROAM_ICON_MODE)
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_ROAM_ICON_MODE, info->roam_icon_mode);
-#endif
- if (info->type & NETWORK_ICON_INFO_RSSI)
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_RSSI, info->rssi);
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_network_registration_status(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_network_registration_status *info = data;
- int status;
- gboolean roaming_allowed;
-
- warn("vconf set (cs:[%d] ps:[%d] svctype:[%d] roam:[%d])",
- info->cs_domain_status, info->ps_domain_status, info->service_type, info->roaming_status);
-
- /*
- * Backward compatibility for Single SIM (Primary Subscription ONLY)
- *
- * In case of Dual SIM, ONLY Primary Subscription's notifications would be
- * processed
- */
- if (__vconf_check_process_hook_callback(source) == FALSE) {
- dbg("Notification NOT intended for Primary Subscription");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- /* CS */
- if (info->cs_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL)
- status = 2;
- else
- status = 1;
-
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVC_CS, status);
-
- /* PS */
- if (info->ps_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL)
- status = 2;
- else
- status = 1;
-
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVC_PS, status);
-
- /* Service type */
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVCTYPE, info->service_type);
-
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVC_ROAM, info->roaming_status);
-
- _update_vconf_network_name(source);
-
- vconf_get_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, &roaming_allowed);
- if (info->service_type > NETWORK_SERVICE_TYPE_SEARCH && !roaming_allowed && info->roaming_status) {
- int pkg_state;
- vconf_get_int(VCONFKEY_DNET_STATE, &pkg_state);
- if (pkg_state > 0) {
- dbg("Mismatch: hide PS icon.");
- __vconf_check_and_set_int(VCONFKEY_DNET_STATE, VCONFKEY_DNET_OFF);
- }
- }
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_network_change(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_network_change *info = data;
-
- msg("vconf set (plmn:[%s] lac:[%d])", info->plmn, info->gsm.lac);
-
- /*
- * Backward compatibility for Single SIM (Primary Subscription ONLY)
- *
- * In case of Dual SIM, ONLY Primary Subscription's notifications would be
- * processed
- */
- if (__vconf_check_process_hook_callback(source) == FALSE) {
- dbg("Notification NOT intended for Primary Subscription");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PLMN, atoi(info->plmn));
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_LAC, info->gsm.lac);
-
- _update_vconf_network_name(source);
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_network_identity(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_network_identity *info = data;
-
- msg("vconf set (plmn:[%s])", info->plmn);
-
- /*
- * Backward compatibility for Single SIM (Primary Subscription ONLY)
- *
- * In case of Dual SIM, ONLY Primary Subscription's notifications would be
- * processed
- */
- if (__vconf_check_process_hook_callback(source) == FALSE) {
- dbg("Notification NOT intended for Primary Subscription");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PLMN, atoi(info->plmn));
-
- _update_vconf_network_name(source);
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_network_default_data_subs(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_network_default_data_subs *info = data;
-
- msg("vconf set (default data subs:[%d])", info->default_subs);
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_DB_DEFAULT_DATA_SUBS, info->default_subs);
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_sim_init(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_sim_status *sim = data;
- const char *cp_name;
- guint slot = 0;
-
- cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source));
- dbg("CP name: [%s]", cp_name);
-
- if (cp_name != NULL) {
- if (g_str_has_suffix(cp_name, "0")) {
- slot = 0;
- } else if (g_str_has_suffix(cp_name, "1")) {
- slot = 1;
- } else {
- err("Vconf keys are not supported for this CP name");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
- } else {
- err("CP Name is NULL");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- warn("vconf set (sim_status = %d), slot - (%d)", sim->sim_status, slot);
-
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SIM_STATUS, sim->sim_status);
-
- switch (sim->sim_status) {
- case SIM_STATUS_CARD_ERROR:
- case SIM_STATUS_CARD_CRASHED:
- if (slot == 0)
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_CARD_ERROR);
- else
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_CARD_ERROR);
- __vconf_check_and_set_str(VCONFKEY_TELEPHONY_NWNAME, "SIM Error");
- break;
-
- case SIM_STATUS_CARD_NOT_PRESENT:
- case SIM_STATUS_CARD_REMOVED:
- if (slot == 0)
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_NOT_PRESENT);
- else
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_NOT_PRESENT);
- __vconf_check_and_set_str(VCONFKEY_TELEPHONY_NWNAME, "NO SIM");
- break;
-
- 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:
- if (slot == 0)
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_INSERTED);
- else
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_INSERTED);
- break;
-
- case SIM_STATUS_UNKNOWN:
- default:
- if (slot == 0)
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_UNKNOWN);
- else
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_UNKNOWN);
- break;
- }
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_pb_init(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_phonebook_status *pb = data;
-
- dbg("vconf set (pb->b_init = %d)", pb->b_init);
-
- /*
- * Backward compatibility for Single SIM (Primary Subscription ONLY)
- *
- * In case of Dual SIM, ONLY Primary Subscription's notifications would be
- * processed
- */
- if (__vconf_check_process_hook_callback(source) == FALSE) {
- dbg("Notification NOT intended for Primary Subscription");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- if (vconf_set_int(VCONFKEY_TELEPHONY_SIM_PB_INIT, pb->b_init) != 0)
- dbg("[FAIL] UPDATE VCONFKEY_TELEPHONY_SIM_PB_INIT");
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-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)
-{
- enum telephony_network_service_type svc_type;
- const struct tnoti_ps_protocol_status *noti = data;
-
- dbg("vconf set (ps status = %d)", noti->status);
-
- /*
- * Backward compatibility for Single SIM (Primary Subscription ONLY)
- *
- * In case of Dual SIM, ONLY Primary Subscription's notifications would be
- * processed
- */
- if (__vconf_check_process_hook_callback(source) == FALSE) {
- dbg("Notification NOT intended for Primary Subscription");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, (int *)&svc_type);
- if (svc_type < (enum telephony_network_service_type)VCONFKEY_TELEPHONY_SVCTYPE_2G) {
- dbg("service state is not available");
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_NONE);
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- switch (noti->status) {
- case TELEPHONY_HSDPA_OFF:
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_NONE);
- break;
-
- case TELEPHONY_HSDPA_ON:
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_HSDPA);
- break;
-
- case TELEPHONY_HSUPA_ON:
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_HSUPA);
- break;
-
- case TELEPHONY_HSPA_ON:
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_HSPA);
- break;
-
- case TELEPHONY_HSPAP_ON:
- __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_HSPAP);
- break;
-
- default:
- warn("invalid ps status");
- break;
- }
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_modem_flight_mode(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_modem_flight_mode *flight_mode = data;
- struct vconf_plugin_user_data *ud = user_data;
-
- /*
- * Backward compatibility for Single SIM (Primary Subscription ONLY)
- *
- * In case of Dual SIM, ONLY Primary Subscription's notifications would be
- * processed
- */
- if (__vconf_check_process_hook_callback(source) == FALSE) {
- dbg("Notification NOT intended for Primary Subscription");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- warn("vconf set (flight_mode = %d)", flight_mode->enable);
-
- vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, flight_mode->enable);
-
- if (flight_mode->enable == 1) {
- if (ud->last_modem_power_state == MODEM_STATE_ONLINE && ud->last_flight_mode_state == FALSE) {
- __vconf_write_power_status_log(ud, MODEM_STATE_LOW);
- ud->last_flight_mode_state = TRUE;
- }
- } else {
- if (ud->last_modem_power_state == MODEM_STATE_LOW && ud->last_flight_mode_state == TRUE) {
- __vconf_write_power_status_log(ud, MODEM_STATE_ONLINE);
- ud->last_flight_mode_state = FALSE;
- }
- }
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_modem_power(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- const struct tnoti_modem_power *power = data;
- struct vconf_plugin_user_data *ud = user_data;
-
- /*
- * Backward compatibility for Single SIM (Primary Subscription ONLY)
- *
- * In case of Dual SIM, ONLY Primary Subscription's notifications would be
- * processed
- */
- if (__vconf_check_process_hook_callback(source) == FALSE) {
- dbg("Notification NOT intended for Primary Subscription");
- return TCORE_HOOK_RETURN_CONTINUE;
- }
-
- /* TODO: check if tapi ready needs to be reset in case of cp reset
- Keeping current behavior
- */
- info("modem state : %d", power->state);
-
- if (power->state == MODEM_STATE_RESUME) {
- info("tapi ready");
- vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_READY);
- } else if (power->state == MODEM_STATE_ERROR) {
- info("cp crash : all network setting will be reset");
- reset_vconf();
- } else if (power->state == MODEM_STATE_LOW) {
- vconf_set_bool(VCONFKEY_TELEPHONY_PRIVATE_MODEM_STATE, FALSE);
- __vconf_write_power_status_log(ud, MODEM_STATE_LOW);
- } else if (power->state == MODEM_STATE_ONLINE) {
- vconf_set_bool(VCONFKEY_TELEPHONY_PRIVATE_MODEM_STATE, TRUE);
- __vconf_write_power_status_log(ud, MODEM_STATE_ONLINE);
- }
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_bootup_complete(Server *s, CoreObject *source,
- enum tcore_notification_command command, unsigned int data_len, void *data, void *user_data)
-{
- info("tapi ready");
- vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_READY);
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static enum tcore_hook_return on_hook_modem_plugin_removed(Server *s,
- CoreObject *source, enum tcore_notification_command command,
- unsigned int data_len, void *data, void *user_data)
-{
- dbg("vconf (Modem Plugin Removed!!!)");
-
- reset_vconf();
-
- return TCORE_HOOK_RETURN_CONTINUE;
-}
-
-static void reset_vconf()
-{
- vconf_set_str(VCONFKEY_TELEPHONY_NWNAME, "");
- vconf_set_int(VCONFKEY_TELEPHONY_PLMN, 0);
- vconf_set_int(VCONFKEY_TELEPHONY_LAC, 0);
- vconf_set_int(VCONFKEY_TELEPHONY_CELLID, 0);
- vconf_set_int(VCONFKEY_TELEPHONY_SVCTYPE, VCONFKEY_TELEPHONY_SVCTYPE_NONE);
- vconf_set_int(VCONFKEY_TELEPHONY_SVC_CS, VCONFKEY_TELEPHONY_SVC_CS_UNKNOWN);
- vconf_set_int(VCONFKEY_TELEPHONY_SVC_PS, VCONFKEY_TELEPHONY_SVC_PS_UNKNOWN);
- vconf_set_int(VCONFKEY_TELEPHONY_SVC_ROAM, VCONFKEY_TELEPHONY_SVC_ROAM_OFF);
-#ifdef TIZEN_FEATURE_CDMA
- vconf_set_int(VCONFKEY_TELEPHONY_ROAM_ICON_MODE, VCONFKEY_TELEPHONY_ROAM_ICON_OFF);
-#endif
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_UNKNOWN);
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_PB_INIT, VCONFKEY_TELEPHONY_SIM_PB_INIT_NONE);
- vconf_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_INVALID);
- vconf_set_str(VCONFKEY_TELEPHONY_SPN_NAME, "");
- vconf_set_int(VCONFKEY_TELEPHONY_RSSI, VCONFKEY_TELEPHONY_RSSI_0);
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_PB_INIT, VCONFKEY_TELEPHONY_SIM_PB_INIT_NONE);
- vconf_set_int(VCONFKEY_TELEPHONY_NITZ_GMT, 0);
- vconf_set_int(VCONFKEY_TELEPHONY_NITZ_EVENT_GMT, 0);
- vconf_set_str(VCONFKEY_TELEPHONY_NITZ_ZONE, "");
-
- vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_UNKNOWN);
-}
-
static gboolean on_load()
{
dbg("i'm load!");
return TRUE;
}
-static void __telephony_ready_change_cb(keynode_t *node, void *data)
-{
- gboolean enable;
-
- enable = vconf_keynode_get_bool(node);
-
- if (enable)
- vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_READY);
- else
- vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_NONE);
-}
-
static gboolean on_init(TcorePlugin *p)
{
- Storage *strg;
- Server *s;
- struct vconf_plugin_user_data *ud;
+ gboolean ret;
if (!p)
return FALSE;
dbg("i'm init!");
- strg = tcore_storage_new(p, "vconf", &ops);
- ud = calloc(sizeof(struct vconf_plugin_user_data), 1);
- if (tcore_plugin_link_user_data(p, ud) != TCORE_RETURN_SUCCESS)
- return FALSE;
-
- reset_vconf();
+ ret = vconf_main_init(p);
+ dbg("on_init: [%s]", ret ? "Success" : "Fail");
- vconf_set_int(VCONFKEY_TELEPHONY_SVC_ROAM, VCONFKEY_TELEPHONY_SVC_ROAM_OFF);
- vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_NONE);
- vconf_set_bool(VCONFKEY_TELEPHONY_READY, FALSE);
-
- s = tcore_plugin_ref_server(p);
- tcore_server_add_notification_hook(s, TNOTI_NETWORK_LOCATION_CELLINFO, on_hook_network_location_cellinfo, strg);
- tcore_server_add_notification_hook(s, TNOTI_NETWORK_ICON_INFO, on_hook_network_icon_info, strg);
- tcore_server_add_notification_hook(s, TNOTI_NETWORK_REGISTRATION_STATUS, on_hook_network_registration_status, strg);
- tcore_server_add_notification_hook(s, TNOTI_NETWORK_CHANGE, on_hook_network_change, strg);
- tcore_server_add_notification_hook(s, TNOTI_NETWORK_IDENTITY, on_hook_network_identity, strg);
- tcore_server_add_notification_hook(s, TNOTI_SIM_STATUS, on_hook_sim_init, strg);
- tcore_server_add_notification_hook(s, TNOTI_PHONEBOOK_STATUS, on_hook_pb_init, strg);
- tcore_server_add_notification_hook(s, TNOTI_PS_PROTOCOL_STATUS, on_hook_ps_protocol_status, strg);
- tcore_server_add_notification_hook(s, TNOTI_MODEM_POWER, on_hook_modem_power, ud);
- tcore_server_add_notification_hook(s, TNOTI_MODEM_BOOTUP, on_hook_bootup_complete, ud);
- tcore_server_add_notification_hook(s, TNOTI_MODEM_FLIGHT_MODE, on_hook_modem_flight_mode, ud);
- tcore_server_add_notification_hook(s, TNOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION, on_hook_network_default_data_subs, strg);
- tcore_server_add_notification_hook(s, TNOTI_SERVER_REMOVED_MODEM_PLUGIN, on_hook_modem_plugin_removed, strg);
- vconf_notify_key_changed(VCONFKEY_TELEPHONY_READY, __telephony_ready_change_cb, NULL);
-
- return TRUE;
+ return ret;
}
static void on_unload(TcorePlugin *p)
{
- Storage *strg;
- struct vconf_plugin_user_data *ud;
-
if (!p)
return;
dbg("i'm unload");
- ud = tcore_plugin_ref_user_data(p);
- if (ud)
- free(ud);
-
- strg = tcore_server_find_storage(tcore_plugin_ref_server(p), "vconf");
- if (!strg)
- return;
-
- tcore_storage_free(strg);
+ vconf_main_deinit(p);
}
+/* Plug-in descriptor */
EXPORT_API struct tcore_plugin_define_desc plugin_define_desc = {
.name = "VCONF_STORAGE",
.priority = TCORE_PLUGIN_PRIORITY_HIGH - 1,
.init = on_init,
.unload = on_unload
};
-
--- /dev/null
+/*
+ * tel-plugin-vconf
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <glib.h>
+#include <vconf.h>
+
+#include <tcore.h>
+#include <server.h>
+#include <plugin.h>
+#include <storage.h>
+
+#include "vconf_main.h"
+#include "vconf_core.h"
+
+static TcoreStorageDispatchCallback callback_dispatch;
+
+static const char *__vconf_convert_strgkey_to_vconf(enum tcore_storage_key key)
+{
+ switch (key) {
+ case STORAGE_KEY_TELEPHONY_PLMN:
+ return VCONFKEY_TELEPHONY_PLMN;
+ case STORAGE_KEY_TELEPHONY_LAC:
+ return VCONFKEY_TELEPHONY_LAC;
+ case STORAGE_KEY_TELEPHONY_CELLID:
+ return VCONFKEY_TELEPHONY_CELLID;
+ case STORAGE_KEY_TELEPHONY_SVCTYPE:
+ return VCONFKEY_TELEPHONY_SVCTYPE;
+ case STORAGE_KEY_TELEPHONY_SVC_CS:
+ return VCONFKEY_TELEPHONY_SVC_CS;
+ case STORAGE_KEY_TELEPHONY_SVC_PS:
+ return VCONFKEY_TELEPHONY_SVC_PS;
+ case STORAGE_KEY_TELEPHONY_SVC_ROAM:
+ return VCONFKEY_TELEPHONY_SVC_ROAM;
+ case STORAGE_KEY_TELEPHONY_SIM_PB_INIT:
+ return VCONFKEY_TELEPHONY_SIM_PB_INIT;
+ case STORAGE_KEY_TELEPHONY_CALL_FORWARD_STATE:
+ return VCONFKEY_TELEPHONY_CALL_FORWARD_STATE;
+ case STORAGE_KEY_TELEPHONY_TAPI_STATE:
+ return VCONFKEY_TELEPHONY_TAPI_STATE;
+ case STORAGE_KEY_TELEPHONY_SPN_DISP_CONDITION:
+ return VCONFKEY_TELEPHONY_SPN_DISP_CONDITION;
+ case STORAGE_KEY_TELEPHONY_RSSI:
+ return VCONFKEY_TELEPHONY_RSSI;
+ case STORAGE_KEY_TELEPHONY_READY:
+ return VCONFKEY_TELEPHONY_READY;
+ case STORAGE_KEY_TELEPHONY_SIM_SLOT:
+ return VCONFKEY_TELEPHONY_SIM_SLOT;
+ case STORAGE_KEY_TELEPHONY_SIM_SLOT2:
+ return VCONFKEY_TELEPHONY_SIM_SLOT2;
+ case STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT:
+ return VCONFKEY_TELEPHONY_SIM_SLOT_COUNT;
+ case STORAGE_KEY_PM_STATE:
+ return VCONFKEY_PM_STATE;
+ case STORAGE_KEY_PACKET_SERVICE_STATE:
+ return VCONFKEY_DNET_STATE;
+ case STORAGE_KEY_PACKET_SERVICE_STATE2:
+ return VCONFKEY_DNET_STATE2;
+ case STORAGE_KEY_PACKET_INDICATOR_STATE:
+ return VCONFKEY_PACKET_STATE;
+ case STORAGE_KEY_3G_ENABLE:
+ return VCONFKEY_3G_ENABLE;
+ case STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT:
+ return VCONFKEY_TELEPHONY_DB_DEFAULT_DATA_SUBS;
+ case STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL:
+ return VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL;
+ case STORAGE_KEY_TELEPHONY_NWNAME:
+ return VCONFKEY_TELEPHONY_NWNAME;
+ case STORAGE_KEY_TELEPHONY_SPN_NAME:
+ return VCONFKEY_TELEPHONY_SPN_NAME;
+ case STORAGE_KEY_CELLULAR_STATE:
+ return VCONFKEY_NETWORK_CELLULAR_STATE;
+ case STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV:
+ return VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV;
+ case STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV2:
+ return VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2;
+ case STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT:
+ return VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT;
+ case STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT2:
+ return VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2;
+ case STORAGE_KEY_CELLULAR_PKT_LAST_RCV:
+ return VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV;
+ case STORAGE_KEY_CELLULAR_PKT_LAST_RCV2:
+ return VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2;
+ case STORAGE_KEY_CELLULAR_PKT_LAST_SNT:
+ return VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT;
+ case STORAGE_KEY_CELLULAR_PKT_LAST_SNT2:
+ return VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2;
+ case STORAGE_KEY_LANGUAGE_SET:
+ return VCONFKEY_LANGSET;
+ case STORAGE_KEY_FLIGHT_MODE_BOOL:
+ return VCONFKEY_TELEPHONY_FLIGHT_MODE;
+ case STORAGE_KEY_POWER_SAVING_MODE:
+ return VCONFKEY_SETAPPL_PSMODE;
+ case STORAGE_KEY_SETAPPL_NETWORK_RESTRICT_MODE:
+ return VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE;
+ case STORAGE_KEY_MSG_SERVER_READY_BOOL:
+ return VCONFKEY_MSG_SERVER_READY;
+ case STORAGE_KEY_TELEPHONY_PREFERRED_VOICE_SUBSCRIPTION:
+ return VCONFKEY_TELEPHONY_PREFERRED_VOICE_SUBSCRIPTION;
+ case STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_SERVICE_INT:
+ return VCONFKEY_TELEPHONY_DB_DEFAULT_SUBS;
+ case STORAGE_KEY_WIFI_STATE_INT:
+ return VCONFKEY_WIFI_STATE;
+ case STORAGE_KEY_WECONN_ALL_CONNECTED:
+ return VCONFKEY_WECONN_ALL_CONNECTED;
+ case STORAGE_KEY_SAP_CONNECTION_TYPE:
+ return VCONFKEY_SAP_CONNECTION_TYPE;
+#ifdef PREPAID_SIM_APN_SUPPORT
+ case STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL:
+ return VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT;
+ case STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID:
+ return VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID;
+ case STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN:
+ return VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT_PLMN;
+#endif
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
+static enum tcore_storage_key __vconf_convert_vconf_to_strgkey(const char *key)
+{
+ if (g_str_equal(key, VCONFKEY_TELEPHONY_PLMN) == TRUE)
+ return STORAGE_KEY_TELEPHONY_PLMN;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_LAC) == TRUE)
+ return STORAGE_KEY_TELEPHONY_LAC;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_CELLID) == TRUE)
+ return STORAGE_KEY_TELEPHONY_CELLID;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SVCTYPE) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SVCTYPE;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SVC_CS) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SVC_CS;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SVC_PS) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SVC_PS;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SVC_ROAM) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SVC_ROAM;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SIM_PB_INIT) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SIM_PB_INIT;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_CALL_FORWARD_STATE) == TRUE)
+ return STORAGE_KEY_TELEPHONY_CALL_FORWARD_STATE;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_TAPI_STATE) == TRUE)
+ return STORAGE_KEY_TELEPHONY_TAPI_STATE;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SPN_DISP_CONDITION) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SPN_DISP_CONDITION;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_RSSI) == TRUE)
+ return STORAGE_KEY_TELEPHONY_RSSI;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_READY) == TRUE)
+ return STORAGE_KEY_TELEPHONY_READY;
+ else if (g_str_equal(key, VCONFKEY_3G_ENABLE) == TRUE)
+ return STORAGE_KEY_3G_ENABLE;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_DB_DEFAULT_DATA_SUBS) == TRUE)
+ return STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_DATA_SERVICE_INT;
+ else if (g_str_equal(key, VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL) == TRUE)
+ return STORAGE_KEY_SETAPPL_STATE_DATA_ROAMING_BOOL;
+ else if (g_str_equal(key, VCONFKEY_PM_STATE) == TRUE)
+ return STORAGE_KEY_PM_STATE;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SIM_SLOT) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SIM_SLOT;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SIM_SLOT2) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SIM_SLOT2;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SIM_SLOT_COUNT) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SIM_SLOT_COUNT;
+ else if (g_str_equal(key, VCONFKEY_DNET_STATE) == TRUE)
+ return STORAGE_KEY_PACKET_SERVICE_STATE;
+ else if (g_str_equal(key, VCONFKEY_DNET_STATE2) == TRUE)
+ return STORAGE_KEY_PACKET_SERVICE_STATE2;
+ else if (g_str_equal(key, VCONFKEY_PACKET_STATE) == TRUE)
+ return STORAGE_KEY_PACKET_INDICATOR_STATE;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_NWNAME) == TRUE)
+ return STORAGE_KEY_TELEPHONY_NWNAME;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_SPN_NAME) == TRUE)
+ return STORAGE_KEY_TELEPHONY_SPN_NAME;
+ else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_STATE) == TRUE)
+ return STORAGE_KEY_CELLULAR_STATE;
+ else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV) == TRUE)
+ return STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV;
+ else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2) == TRUE)
+ return STORAGE_KEY_CELLULAR_PKT_TOTAL_RCV2;
+ else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT) == TRUE)
+ return STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT;
+ else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2) == TRUE)
+ return STORAGE_KEY_CELLULAR_PKT_TOTAL_SNT2;
+ else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV) == TRUE)
+ return STORAGE_KEY_CELLULAR_PKT_LAST_RCV;
+ else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2) == TRUE)
+ return STORAGE_KEY_CELLULAR_PKT_LAST_RCV2;
+ else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT) == TRUE)
+ return STORAGE_KEY_CELLULAR_PKT_LAST_SNT;
+ else if (g_str_equal(key, VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2) == TRUE)
+ return STORAGE_KEY_CELLULAR_PKT_LAST_SNT2;
+ else if (g_str_equal(key, VCONFKEY_LANGSET) == TRUE)
+ return STORAGE_KEY_LANGUAGE_SET;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_FLIGHT_MODE) == TRUE)
+ return STORAGE_KEY_FLIGHT_MODE_BOOL;
+ else if (g_str_equal(key, VCONFKEY_SETAPPL_PSMODE) == TRUE)
+ return STORAGE_KEY_POWER_SAVING_MODE;
+ else if (g_str_equal(key, VCONFKEY_SETAPPL_NETWORK_RESTRICT_MODE) == TRUE)
+ return STORAGE_KEY_SETAPPL_NETWORK_RESTRICT_MODE;
+ else if (g_str_equal(key, VCONFKEY_MSG_SERVER_READY) == TRUE)
+ return STORAGE_KEY_MSG_SERVER_READY_BOOL;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_PREFERRED_VOICE_SUBSCRIPTION) == TRUE)
+ return STORAGE_KEY_TELEPHONY_PREFERRED_VOICE_SUBSCRIPTION;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_DB_DEFAULT_SUBS) == TRUE)
+ return STORAGE_KEY_TELEPHONY_DUALSIM_DEFAULT_SERVICE_INT;
+ else if (g_str_equal(key, VCONFKEY_WIFI_STATE) == TRUE)
+ return STORAGE_KEY_WIFI_STATE_INT;
+ else if (g_str_equal(key, VCONFKEY_WECONN_ALL_CONNECTED) == TRUE)
+ return STORAGE_KEY_WECONN_ALL_CONNECTED;
+ else if (g_str_equal(key, VCONFKEY_SAP_CONNECTION_TYPE) == TRUE)
+ return STORAGE_KEY_SAP_CONNECTION_TYPE;
+#ifdef PREPAID_SIM_APN_SUPPORT
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT) == TRUE)
+ return STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_BOOL;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID) == TRUE)
+ return STORAGE_KEY_PDP_LAST_CONNECTED_CONTEXT_PROFILE_ID;
+ else if (g_str_equal(key, VCONFKEY_TELEPHONY_PRIVATE_PDP_LAST_CONNECTED_CONTEXT_PLMN) == TRUE)
+ return STORAGE_KEY_TELEPHONY_LAST_CONNECTED_CONTEXT_PLMN;
+#endif
+
+ return 0;
+}
+
+static void __vconf_key_change_callback(keynode_t *node, void *data)
+{
+ int type = 0;
+ char *vkey = NULL;
+ GVariant *value = NULL;
+ enum tcore_storage_key s_key = 0;
+ Storage *strg = NULL;
+
+ strg = (Storage *)data;
+ vkey = vconf_keynode_get_name(node);
+ type = vconf_keynode_get_type(node);
+ if (vkey != NULL)
+ s_key = __vconf_convert_vconf_to_strgkey(vkey);
+
+ if (type == VCONF_TYPE_STRING) {
+ gchar *tmp;
+ tmp = (char *)vconf_keynode_get_str(node);
+ value = g_variant_new_string(tmp);
+ } else if (type == VCONF_TYPE_INT) {
+ gint32 tmp = 0;
+ tmp = vconf_keynode_get_int(node);
+ value = g_variant_new_int32(tmp);
+ } else if (type == VCONF_TYPE_DOUBLE) {
+ gdouble tmp = 0;
+ tmp = vconf_keynode_get_dbl(node);
+ value = g_variant_new_double(tmp);
+ } else if (type == VCONF_TYPE_BOOL) {
+ gboolean tmp = FALSE;
+ tmp = vconf_keynode_get_bool(node);
+ value = g_variant_new_boolean(tmp);
+ }
+
+
+ if (callback_dispatch != NULL)
+ callback_dispatch(strg, s_key, value);
+
+ if (value)
+ g_variant_unref(value);
+
+ return;
+}
+
+static void *create_handle(Storage *strg, const char *path)
+{
+ void *tmp = NULL;
+ if (!strg)
+ return NULL;
+
+ tmp = malloc(sizeof(char));
+ return tmp;
+}
+
+static gboolean remove_handle(Storage *strg, void *handle)
+{
+ if (!strg || !handle)
+ return FALSE;
+
+ free(handle);
+ return TRUE;
+}
+
+static gboolean set_int(Storage *strg, enum tcore_storage_key key, int value)
+{
+ const gchar *s_key = NULL;
+
+ if (!strg)
+ return FALSE;
+
+ if (key & STORAGE_KEY_INT)
+ s_key = __vconf_convert_strgkey_to_vconf(key);
+
+ if (!s_key)
+ return FALSE;
+
+ if (vconf_set_int(s_key, value) == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean set_bool(Storage *strg, enum tcore_storage_key key, gboolean value)
+{
+ const gchar *s_key = NULL;
+
+ if (!strg)
+ return FALSE;
+
+ if (key & STORAGE_KEY_BOOL)
+ s_key = __vconf_convert_strgkey_to_vconf(key);
+
+ if (!s_key)
+ return FALSE;
+
+ vconf_set_bool(s_key, value);
+ return TRUE;
+}
+
+static gboolean set_string(Storage *strg, enum tcore_storage_key key, const char *value)
+{
+ const gchar *s_key = NULL;
+
+ if (!strg)
+ return FALSE;
+
+ if (key & STORAGE_KEY_STRING)
+ s_key = __vconf_convert_strgkey_to_vconf(key);
+
+ if (!s_key)
+ return FALSE;
+
+ vconf_set_str(s_key, value);
+ return TRUE;
+}
+
+static int get_int(Storage *strg, enum tcore_storage_key key)
+{
+ int value = -1;
+ const gchar *s_key = NULL;
+
+ if (!strg)
+ return value;
+
+ if (key & STORAGE_KEY_INT)
+ s_key = __vconf_convert_strgkey_to_vconf(key);
+
+ if (s_key != NULL)
+ vconf_get_int(s_key, &value);
+
+ return value;
+}
+
+static gboolean get_bool(Storage *strg, enum tcore_storage_key key)
+{
+ gboolean value = FALSE;
+ const gchar *s_key = NULL;
+
+ if (!strg)
+ return value;
+
+ if (key & STORAGE_KEY_BOOL)
+ s_key = __vconf_convert_strgkey_to_vconf(key);
+
+ if (s_key != NULL)
+ vconf_get_bool(s_key, &value);
+
+ return value;
+}
+
+static char *get_string(Storage *strg, enum tcore_storage_key key)
+{
+ const gchar *s_key = NULL;
+
+ if (!strg)
+ return NULL;
+
+ if (key & STORAGE_KEY_STRING)
+ s_key = __vconf_convert_strgkey_to_vconf(key);
+
+ if (s_key != NULL)
+ return vconf_get_str(s_key);
+
+ return NULL;
+}
+
+static gboolean set_key_callback(Storage *strg,
+ enum tcore_storage_key key, TcoreStorageDispatchCallback cb)
+{
+ const gchar *s_key = NULL;
+
+ if (!strg)
+ return FALSE;
+
+ s_key = __vconf_convert_strgkey_to_vconf(key);
+ dbg("s_key (%s)", s_key);
+
+ if (s_key == NULL)
+ return FALSE;
+
+ if (callback_dispatch == NULL)
+ callback_dispatch = cb;
+
+ vconf_notify_key_changed(s_key,
+ __vconf_key_change_callback, strg);
+
+ return TRUE;
+}
+
+static gboolean remove_key_callback(Storage *strg,
+ enum tcore_storage_key key)
+{
+ const gchar *s_key = NULL;
+
+ if (!strg)
+ return FALSE;
+
+ s_key = __vconf_convert_strgkey_to_vconf(key);
+ dbg("s_key (%s)", s_key);
+
+ if (s_key == NULL)
+ return FALSE;
+
+ vconf_ignore_key_changed(s_key,
+ __vconf_key_change_callback);
+
+ return TRUE;
+}
+
+/*
+ * VCONF operations
+ */
+static struct storage_operations vconf_ops = {
+ .create_handle = create_handle,
+ .remove_handle = remove_handle,
+ .set_int = set_int,
+ .set_string = set_string,
+ .set_bool = set_bool,
+ .get_int = get_int,
+ .get_string = get_string,
+ .get_bool = get_bool,
+ .set_key_callback = set_key_callback,
+ .remove_key_callback = remove_key_callback,
+};
+
+/*
+ * VCONF Initialization function
+ */
+gboolean vconf_core_init(TcorePlugin *p)
+{
+ Storage *strg;
+
+ if (!p)
+ return FALSE;
+
+ strg = tcore_storage_new(p, "vconf", &vconf_ops);
+ if (strg == NULL) {
+ err("Storage creation failed!");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+ * VCONF Core De-initialization function
+ */
+void vconf_core_deinit(TcorePlugin *p)
+{
+ Storage *strg;
+
+ if (!p)
+ return;
+
+ dbg("Enter");
+
+ strg = tcore_server_find_storage(tcore_plugin_ref_server(p), "vconf");
+ if (!strg)
+ return;
+
+ tcore_storage_free(strg);
+}
--- /dev/null
+/*
+ * tel-plugin-vconf
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/sysinfo.h>
+
+#include <glib.h>
+#include <vconf.h>
+
+#include <tcore.h>
+#include <server.h>
+#include <plugin.h>
+#include <storage.h>
+#include <co_network.h>
+
+#include "vconf_main.h"
+#include "vconf_handler.h"
+
+/*
+ * Private data
+ */
+typedef struct {
+ gboolean b_get_nck_retry_count;
+
+ enum modem_state last_modem_power_state;
+ gboolean last_flight_mode_state;
+ long last_modem_state_timestamp;
+} VconfPrivData;
+
+static gboolean __vconf_check_process_hook_callback(CoreObject *co)
+{
+ const char *cp_name;
+
+ cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(co));
+ dbg("CP name: [%s]", cp_name);
+
+ if (cp_name == NULL)
+ return FALSE;
+
+ return g_str_has_suffix(cp_name, "0");
+}
+
+static void __vconf_check_and_set_int(const char *in_key, const int intval)
+{
+ int current;
+ vconf_get_int(in_key, ¤t);
+ if (current != intval)
+ vconf_set_int(in_key, intval);
+}
+
+static void __vconf_check_and_set_str(const char *in_key, const char *strval)
+{
+ char *current = vconf_get_str(in_key);
+
+ if (current) {
+ if (strval && strcmp(current, strval))
+ vconf_set_str(in_key, strval);
+
+ free(current);
+ } else {
+ vconf_set_str(in_key, strval);
+ }
+}
+
+static void __vconf_write_power_status_log(VconfPrivData *ud, enum modem_state state)
+{
+ struct sysinfo sys_info;
+
+ if (ud == NULL)
+ return;
+
+ if (0 != sysinfo(&sys_info))
+ err("sysinfo failed.");
+
+ if (state == MODEM_STATE_ONLINE) {
+ if (ud->last_modem_power_state == MODEM_STATE_LOW) {
+ int count = 0;
+ if (0 == vconf_get_int(VCONFKEY_TELEPHONY_PRIVATE_MODEM_ON_COUNT, &count)) {
+ count++;
+ if (0 != vconf_set_int(VCONFKEY_TELEPHONY_PRIVATE_MODEM_ON_COUNT, count))
+ err("vconf_set_int failed.");
+ } else {
+ err("vconf_get_int failed.");
+ }
+ msg("[MODEM ON/OFF] MODEM LOW => ON in %d secs. (modem_on_count[%d] after boot-up. (uptime %ld secs))",
+ sys_info.uptime - ud->last_modem_state_timestamp, count, sys_info.uptime);
+ ud->last_modem_power_state = state;
+ ud->last_modem_state_timestamp = sys_info.uptime;
+ }
+ } else if (state == MODEM_STATE_LOW) {
+ if (ud->last_modem_power_state == MODEM_STATE_ONLINE) {
+ int count = 0;
+ if (0 != vconf_get_int(VCONFKEY_TELEPHONY_PRIVATE_MODEM_ON_COUNT, &count))
+ err("vconf_get_int failed.");
+
+ msg("[MODEM ON/OFF] MODEM ON => LOW in %d secs. (modem_on_count=[%d] after boot-up(uptime %ld secs))",
+ sys_info.uptime - ud->last_modem_state_timestamp, count, sys_info.uptime);
+ ud->last_modem_power_state = state;
+ ud->last_modem_state_timestamp = sys_info.uptime;
+ }
+ }
+}
+
+static void __vconf_update_network_name(CoreObject *o)
+{
+ char *nwname = NULL;
+ char *spnname = NULL;
+ enum telephony_network_service_type svc_type;
+ enum telephony_network_access_technology svc_act;
+ enum tcore_network_name_priority network_name_priority;
+
+ tcore_network_get_service_type(o, &svc_type);
+ if (svc_type != NETWORK_SERVICE_TYPE_3G) {
+ int current = 0;
+
+ vconf_get_int(VCONFKEY_TELEPHONY_PSTYPE, ¤t);
+ if (current != 0) {
+ dbg("force hsdpa state off");
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_NONE);
+ }
+ }
+
+ tcore_network_get_access_technology(o, &svc_act);
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVC_ACT, svc_act);
+
+ tcore_network_get_network_name_priority(o, &network_name_priority);
+ switch (network_name_priority) {
+ case TCORE_NETWORK_NAME_PRIORITY_SPN:
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_SPN);
+ break;
+
+ case TCORE_NETWORK_NAME_PRIORITY_NETWORK:
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_PLMN);
+ break;
+
+ case TCORE_NETWORK_NAME_PRIORITY_ANY:
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_SPN_PLMN);
+ break;
+
+ default:
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_INVALID);
+ break;
+ }
+
+ switch (svc_type) {
+ case NETWORK_SERVICE_TYPE_UNKNOWN:
+ case NETWORK_SERVICE_TYPE_NO_SERVICE:
+ case NETWORK_SERVICE_TYPE_EMERGENCY:
+ case NETWORK_SERVICE_TYPE_SEARCH:
+ break;
+
+ default:
+ /* spn */
+ spnname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_SPN);
+ if (spnname)
+ __vconf_check_and_set_str(VCONFKEY_TELEPHONY_SPN_NAME, spnname);
+
+ /* nitz */
+ nwname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_FULL);
+ if (nwname && strlen(nwname) > 0) {
+ dbg("SPN:[%s] FULL:[%s] prio:[%d] act:[%d] svc_type:[%d]",
+ spnname ? spnname : "", nwname, network_name_priority, svc_act, svc_type);
+ __vconf_check_and_set_str(VCONFKEY_TELEPHONY_NWNAME, nwname);
+ break;
+ } else {
+ if (nwname)
+ free(nwname);
+ nwname = tcore_network_get_network_name(o, TCORE_NETWORK_NAME_TYPE_SHORT);
+ if (nwname) {
+ dbg("SPN:[%s] SHORT:[%s] prio:[%d] act:[%d] svc_type:[%d]",
+ spnname ? spnname : "", nwname, network_name_priority, svc_act, svc_type);
+ __vconf_check_and_set_str(VCONFKEY_TELEPHONY_NWNAME, nwname);
+ break;
+ }
+ }
+ dbg("name is not fixed yet. SPN:[%s] prio:[%d] act:[%d] svc_type:[%d]",
+ spnname ? spnname : "", network_name_priority, svc_act, svc_type);
+
+ break;
+ }
+
+ if (spnname)
+ free(spnname);
+
+ if (nwname)
+ free(nwname);
+}
+
+static void __vconf_reset_vconfkeys()
+{
+ vconf_set_str(VCONFKEY_TELEPHONY_NWNAME, "");
+ vconf_set_int(VCONFKEY_TELEPHONY_PLMN, 0);
+ vconf_set_int(VCONFKEY_TELEPHONY_LAC, 0);
+ vconf_set_int(VCONFKEY_TELEPHONY_CELLID, 0);
+ vconf_set_int(VCONFKEY_TELEPHONY_SVCTYPE, VCONFKEY_TELEPHONY_SVCTYPE_NONE);
+ vconf_set_int(VCONFKEY_TELEPHONY_SVC_CS, VCONFKEY_TELEPHONY_SVC_CS_UNKNOWN);
+ vconf_set_int(VCONFKEY_TELEPHONY_SVC_PS, VCONFKEY_TELEPHONY_SVC_PS_UNKNOWN);
+ vconf_set_int(VCONFKEY_TELEPHONY_SVC_ROAM, VCONFKEY_TELEPHONY_SVC_ROAM_OFF);
+#ifdef TIZEN_FEATURE_CDMA
+ vconf_set_int(VCONFKEY_TELEPHONY_ROAM_ICON_MODE, VCONFKEY_TELEPHONY_ROAM_ICON_OFF);
+#endif
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_UNKNOWN);
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_PB_INIT, VCONFKEY_TELEPHONY_SIM_PB_INIT_NONE);
+ vconf_set_int(VCONFKEY_TELEPHONY_SPN_DISP_CONDITION, VCONFKEY_TELEPHONY_DISP_INVALID);
+ vconf_set_str(VCONFKEY_TELEPHONY_SPN_NAME, "");
+ vconf_set_int(VCONFKEY_TELEPHONY_RSSI, VCONFKEY_TELEPHONY_RSSI_0);
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_PB_INIT, VCONFKEY_TELEPHONY_SIM_PB_INIT_NONE);
+ vconf_set_int(VCONFKEY_TELEPHONY_NITZ_GMT, 0);
+ vconf_set_int(VCONFKEY_TELEPHONY_NITZ_EVENT_GMT, 0);
+ vconf_set_str(VCONFKEY_TELEPHONY_NITZ_ZONE, "");
+
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_UNKNOWN);
+}
+
+static void __vconf_telephony_ready_change_cb(keynode_t *node, void *data)
+{
+ gboolean enable;
+
+ enable = vconf_keynode_get_bool(node);
+ dbg("Telephony State: [%s]", enable ? "Ready" : "NOT ready");
+
+ if (enable)
+ vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_READY);
+ else
+ vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_NONE);
+}
+
+static enum tcore_hook_return vconf_on_hook_network_location_cellinfo(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_network_location_cellinfo *info = data;
+
+ /*
+ * Backward compatibility for Single SIM (Primary Subscription ONLY)
+ *
+ * In case of Dual SIM, ONLY Primary Subscription's notifications would be
+ * processed
+ */
+ if (__vconf_check_process_hook_callback(source) == FALSE) {
+ dbg("Notification NOT intended for Primary Subscription");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_CELLID, info->cell_id);
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_LAC, info->lac);
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_network_icon_info(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_network_icon_info *info = data;
+
+ /*
+ * Backward compatibility for Single SIM (Primary Subscription ONLY)
+ *
+ * In case of Dual SIM, ONLY Primary Subscription's notifications would be
+ * processed
+ */
+ if (__vconf_check_process_hook_callback(source) == FALSE) {
+ dbg("Notification NOT intended for Primary Subscription");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+#ifdef TIZEN_FEATURE_CDMA
+ if (info->type & NETWORK_ICON_INFO_ROAM_ICON_MODE)
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_ROAM_ICON_MODE, info->roam_icon_mode);
+#endif
+ if (info->type & NETWORK_ICON_INFO_RSSI)
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_RSSI, info->rssi);
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_network_registration_status(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_network_registration_status *info = data;
+ int status;
+ gboolean roaming_allowed;
+
+ warn("vconf set (cs:[%d] ps:[%d] svctype:[%d] roam:[%d])",
+ info->cs_domain_status, info->ps_domain_status, info->service_type, info->roaming_status);
+
+ /*
+ * Backward compatibility for Single SIM (Primary Subscription ONLY)
+ *
+ * In case of Dual SIM, ONLY Primary Subscription's notifications would be
+ * processed
+ */
+ if (__vconf_check_process_hook_callback(source) == FALSE) {
+ dbg("Notification NOT intended for Primary Subscription");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ /* CS */
+ if (info->cs_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL)
+ status = 2;
+ else
+ status = 1;
+
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVC_CS, status);
+
+ /* PS */
+ if (info->ps_domain_status == NETWORK_SERVICE_DOMAIN_STATUS_FULL)
+ status = 2;
+ else
+ status = 1;
+
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVC_PS, status);
+
+ /* Service type */
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVCTYPE, info->service_type);
+
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SVC_ROAM, info->roaming_status);
+
+ __vconf_update_network_name(source);
+
+ vconf_get_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, &roaming_allowed);
+ if (info->service_type > NETWORK_SERVICE_TYPE_SEARCH && !roaming_allowed && info->roaming_status) {
+ int pkg_state;
+ vconf_get_int(VCONFKEY_DNET_STATE, &pkg_state);
+ if (pkg_state > 0) {
+ dbg("Mismatch: hide PS icon.");
+ __vconf_check_and_set_int(VCONFKEY_DNET_STATE, VCONFKEY_DNET_OFF);
+ }
+ }
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_network_change(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_network_change *info = data;
+
+ msg("vconf set (plmn:[%s] lac:[%d])", info->plmn, info->gsm.lac);
+
+ /*
+ * Backward compatibility for Single SIM (Primary Subscription ONLY)
+ *
+ * In case of Dual SIM, ONLY Primary Subscription's notifications would be
+ * processed
+ */
+ if (__vconf_check_process_hook_callback(source) == FALSE) {
+ dbg("Notification NOT intended for Primary Subscription");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PLMN, atoi(info->plmn));
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_LAC, info->gsm.lac);
+
+ __vconf_update_network_name(source);
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_network_identity(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_network_identity *info = data;
+
+ msg("vconf set (plmn:[%s])", info->plmn);
+
+ /*
+ * Backward compatibility for Single SIM (Primary Subscription ONLY)
+ *
+ * In case of Dual SIM, ONLY Primary Subscription's notifications would be
+ * processed
+ */
+ if (__vconf_check_process_hook_callback(source) == FALSE) {
+ dbg("Notification NOT intended for Primary Subscription");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PLMN, atoi(info->plmn));
+
+ __vconf_update_network_name(source);
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_network_default_data_subs(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_network_default_data_subs *info = data;
+
+ msg("vconf set (default data subs:[%d])", info->default_subs);
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_DB_DEFAULT_DATA_SUBS, info->default_subs);
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_sim_init(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_sim_status *sim = data;
+ const char *cp_name;
+ guint slot = 0;
+
+ cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source));
+ dbg("CP name: [%s]", cp_name);
+
+ if (cp_name != NULL) {
+ if (g_str_has_suffix(cp_name, "0")) {
+ slot = 0;
+ } else if (g_str_has_suffix(cp_name, "1")) {
+ slot = 1;
+ } else {
+ err("Vconf keys are not supported for this CP name");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+ } else {
+ err("CP Name is NULL");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ warn("vconf set (sim_status = %d), slot - (%d)", sim->sim_status, slot);
+
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_SIM_STATUS, sim->sim_status);
+
+ switch (sim->sim_status) {
+ case SIM_STATUS_CARD_ERROR:
+ case SIM_STATUS_CARD_CRASHED:
+ if (slot == 0)
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_CARD_ERROR);
+ else
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_CARD_ERROR);
+ __vconf_check_and_set_str(VCONFKEY_TELEPHONY_NWNAME, "SIM Error");
+ break;
+
+ case SIM_STATUS_CARD_NOT_PRESENT:
+ case SIM_STATUS_CARD_REMOVED:
+ if (slot == 0)
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_NOT_PRESENT);
+ else
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_NOT_PRESENT);
+ __vconf_check_and_set_str(VCONFKEY_TELEPHONY_NWNAME, "NO SIM");
+ break;
+
+ 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:
+ if (slot == 0)
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_INSERTED);
+ else
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_INSERTED);
+ break;
+
+ case SIM_STATUS_UNKNOWN:
+ default:
+ if (slot == 0)
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT, VCONFKEY_TELEPHONY_SIM_UNKNOWN);
+ else
+ vconf_set_int(VCONFKEY_TELEPHONY_SIM_SLOT2, VCONFKEY_TELEPHONY_SIM_UNKNOWN);
+ break;
+ }
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_pb_init(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_phonebook_status *pb = data;
+
+ dbg("vconf set (pb->b_init = %d)", pb->b_init);
+
+ /*
+ * Backward compatibility for Single SIM (Primary Subscription ONLY)
+ *
+ * In case of Dual SIM, ONLY Primary Subscription's notifications would be
+ * processed
+ */
+ if (__vconf_check_process_hook_callback(source) == FALSE) {
+ dbg("Notification NOT intended for Primary Subscription");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ if (vconf_set_int(VCONFKEY_TELEPHONY_SIM_PB_INIT, pb->b_init) != 0)
+ dbg("[FAIL] UPDATE VCONFKEY_TELEPHONY_SIM_PB_INIT");
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_ps_protocol_status(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ enum telephony_network_service_type svc_type;
+ const struct tnoti_ps_protocol_status *noti = data;
+
+ dbg("vconf set (ps status = %d)", noti->status);
+
+ /*
+ * Backward compatibility for Single SIM (Primary Subscription ONLY)
+ *
+ * In case of Dual SIM, ONLY Primary Subscription's notifications would be
+ * processed
+ */
+ if (__vconf_check_process_hook_callback(source) == FALSE) {
+ dbg("Notification NOT intended for Primary Subscription");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, (int *)&svc_type);
+ if (svc_type < (enum telephony_network_service_type)VCONFKEY_TELEPHONY_SVCTYPE_2G) {
+ dbg("service state is not available");
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_NONE);
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ switch (noti->status) {
+ case TELEPHONY_HSDPA_OFF:
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_NONE);
+ break;
+
+ case TELEPHONY_HSDPA_ON:
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_HSDPA);
+ break;
+
+ case TELEPHONY_HSUPA_ON:
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_HSUPA);
+ break;
+
+ case TELEPHONY_HSPA_ON:
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_HSPA);
+ break;
+
+ case TELEPHONY_HSPAP_ON:
+ __vconf_check_and_set_int(VCONFKEY_TELEPHONY_PSTYPE, VCONFKEY_TELEPHONY_PSTYPE_HSPAP);
+ break;
+
+ default:
+ warn("invalid ps status");
+ break;
+ }
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_modem_flight_mode(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_modem_flight_mode *flight_mode = data;
+ VconfPrivData *ud = user_data;
+
+ /*
+ * Backward compatibility for Single SIM (Primary Subscription ONLY)
+ *
+ * In case of Dual SIM, ONLY Primary Subscription's notifications would be
+ * processed
+ */
+ if (__vconf_check_process_hook_callback(source) == FALSE) {
+ dbg("Notification NOT intended for Primary Subscription");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ warn("vconf set (flight_mode = %d)", flight_mode->enable);
+
+ vconf_set_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, flight_mode->enable);
+
+ if (flight_mode->enable == 1) {
+ if (ud->last_modem_power_state == MODEM_STATE_ONLINE && ud->last_flight_mode_state == FALSE) {
+ __vconf_write_power_status_log(ud, MODEM_STATE_LOW);
+ ud->last_flight_mode_state = TRUE;
+ }
+ } else {
+ if (ud->last_modem_power_state == MODEM_STATE_LOW && ud->last_flight_mode_state == TRUE) {
+ __vconf_write_power_status_log(ud, MODEM_STATE_ONLINE);
+ ud->last_flight_mode_state = FALSE;
+ }
+ }
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_modem_power(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ const struct tnoti_modem_power *power = data;
+ VconfPrivData *ud = user_data;
+
+ /*
+ * Backward compatibility for Single SIM (Primary Subscription ONLY)
+ *
+ * In case of Dual SIM, ONLY Primary Subscription's notifications would be
+ * processed
+ */
+ if (__vconf_check_process_hook_callback(source) == FALSE) {
+ dbg("Notification NOT intended for Primary Subscription");
+ return TCORE_HOOK_RETURN_CONTINUE;
+ }
+
+ /* TODO: check if tapi ready needs to be reset in case of cp reset
+ Keeping current behavior
+ */
+ info("modem state : %d", power->state);
+
+ if (power->state == MODEM_STATE_RESUME) {
+ info("tapi ready");
+ vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_READY);
+ } else if (power->state == MODEM_STATE_ERROR) {
+ info("cp crash : all network setting will be reset");
+
+ /*
+ * Reset Telephony VCONF keys
+ */
+ __vconf_reset_vconfkeys();
+ } else if (power->state == MODEM_STATE_LOW) {
+ vconf_set_bool(VCONFKEY_TELEPHONY_PRIVATE_MODEM_STATE, FALSE);
+ __vconf_write_power_status_log(ud, MODEM_STATE_LOW);
+ } else if (power->state == MODEM_STATE_ONLINE) {
+ vconf_set_bool(VCONFKEY_TELEPHONY_PRIVATE_MODEM_STATE, TRUE);
+ __vconf_write_power_status_log(ud, MODEM_STATE_ONLINE);
+ }
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_bootup_complete(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ info("tapi ready");
+ vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_READY);
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+static enum tcore_hook_return vconf_on_hook_modem_plugin_removed(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
+{
+ dbg("vconf (Modem Plugin Removed!!!)");
+
+ /*
+ * Reset Telephony VCONF keys
+ */
+ __vconf_reset_vconfkeys();
+
+ return TCORE_HOOK_RETURN_CONTINUE;
+}
+
+/*
+ * Add notification hooks
+ */
+static void __vconf_register_hooks(Server *s,
+ Storage *strg, VconfPrivData *ud)
+{
+ /* Network related */
+ tcore_server_add_notification_hook(s, TNOTI_NETWORK_LOCATION_CELLINFO,
+ vconf_on_hook_network_location_cellinfo, strg);
+ tcore_server_add_notification_hook(s, TNOTI_NETWORK_ICON_INFO,
+ vconf_on_hook_network_icon_info, strg);
+ tcore_server_add_notification_hook(s, TNOTI_NETWORK_REGISTRATION_STATUS,
+ vconf_on_hook_network_registration_status, strg);
+ tcore_server_add_notification_hook(s, TNOTI_NETWORK_CHANGE,
+ vconf_on_hook_network_change, strg);
+ tcore_server_add_notification_hook(s, TNOTI_NETWORK_IDENTITY,
+ vconf_on_hook_network_identity, strg);
+ tcore_server_add_notification_hook(s, TNOTI_NETWORK_DEFAULT_DATA_SUBSCRIPTION,
+ vconf_on_hook_network_default_data_subs, strg);
+
+ /* SIM related */
+ tcore_server_add_notification_hook(s, TNOTI_SIM_STATUS,
+ vconf_on_hook_sim_init, strg);
+
+ /* Phonebook related */
+ tcore_server_add_notification_hook(s, TNOTI_PHONEBOOK_STATUS,
+ vconf_on_hook_pb_init, strg);
+
+ /* PS related */
+ tcore_server_add_notification_hook(s, TNOTI_PS_PROTOCOL_STATUS,
+ vconf_on_hook_ps_protocol_status, strg);
+
+ /* Modem related */
+ tcore_server_add_notification_hook(s, TNOTI_MODEM_POWER,
+ vconf_on_hook_modem_power, ud);
+ tcore_server_add_notification_hook(s, TNOTI_MODEM_BOOTUP,
+ vconf_on_hook_bootup_complete, ud);
+ tcore_server_add_notification_hook(s, TNOTI_MODEM_FLIGHT_MODE,
+ vconf_on_hook_modem_flight_mode, ud);
+
+ /* Plug-in related */
+ tcore_server_add_notification_hook(s, TNOTI_SERVER_REMOVED_MODEM_PLUGIN,
+ vconf_on_hook_modem_plugin_removed, strg);
+
+ /*
+ * Track Telephony state change
+ *
+ * Need to update VCONFKEY_TELEPHONY_TAPI_STATE,
+ * key based on Telephony state change
+ */
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_READY,
+ __vconf_telephony_ready_change_cb, NULL);
+}
+
+/*
+ * Remove notification hooks
+ */
+static void __vconf_deregister_hooks(Server *s)
+{
+ /* Network related */
+ tcore_server_remove_notification_hook(s, vconf_on_hook_network_location_cellinfo);
+ tcore_server_remove_notification_hook(s, vconf_on_hook_network_icon_info);
+ tcore_server_remove_notification_hook(s, vconf_on_hook_network_registration_status);
+ tcore_server_remove_notification_hook(s, vconf_on_hook_network_change);
+ tcore_server_remove_notification_hook(s, vconf_on_hook_network_identity);
+ tcore_server_remove_notification_hook(s, vconf_on_hook_network_default_data_subs);
+
+ /* SIM related */
+ tcore_server_remove_notification_hook(s, vconf_on_hook_sim_init);
+
+ /* Phonebook related */
+ tcore_server_remove_notification_hook(s, vconf_on_hook_pb_init);
+
+ /* PS related */
+ tcore_server_remove_notification_hook(s, vconf_on_hook_ps_protocol_status);
+
+ /* Modem related */
+ tcore_server_remove_notification_hook(s, vconf_on_hook_modem_power);
+ tcore_server_remove_notification_hook(s, vconf_on_hook_bootup_complete);
+ tcore_server_remove_notification_hook(s, vconf_on_hook_modem_flight_mode);
+
+ /* Plug-in related */
+ tcore_server_remove_notification_hook(s, vconf_on_hook_modem_plugin_removed);
+
+ /*
+ * Track Telephony state change
+ *
+ * Need to update VCONFKEY_TELEPHONY_TAPI_STATE,
+ * key based on Telephony state change
+ */
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_READY,
+ __vconf_telephony_ready_change_cb);
+
+}
+
+/*
+ * VCONF Handler Initialization function
+ */
+gboolean vconf_handler_init(TcorePlugin *p)
+{
+ Storage *strg;
+ Server *s;
+ VconfPrivData *ud;
+
+ if (!p)
+ return FALSE;
+
+ dbg("Enter");
+
+ s = tcore_plugin_ref_server(p);
+ strg = tcore_server_find_storage(s, "vconf");
+ if (!strg)
+ return FALSE;
+
+ ud = calloc(sizeof(VconfPrivData), 1);
+ if (ud == NULL) {
+ err("Failed to allocate memory for user_data");
+ tcore_storage_free(strg);
+ return FALSE;
+ }
+
+ if (tcore_plugin_link_user_data(p, ud) != TCORE_RETURN_SUCCESS) {
+ err("Failed to link user_data");
+ tcore_storage_free(strg);
+ free(ud);
+ return FALSE;
+ }
+
+ /*
+ * Reset Telephony VCONF keys
+ */
+ __vconf_reset_vconfkeys();
+
+ /* Reset Telephony states */
+ vconf_set_int(VCONFKEY_TELEPHONY_TAPI_STATE, VCONFKEY_TELEPHONY_TAPI_STATE_NONE);
+ vconf_set_bool(VCONFKEY_TELEPHONY_READY, FALSE);
+
+ /*
+ * Register for all hook callbacks
+ */
+ __vconf_register_hooks(s, strg, ud);
+
+ return TRUE;
+}
+
+/*
+ * VCONF Handler De-initialization function
+ */
+void vconf_handler_deinit(TcorePlugin *p)
+{
+ Server *s;
+ VconfPrivData *ud;
+
+ if (!p)
+ return;
+
+ dbg("Enter");
+
+ s = tcore_plugin_ref_server(p);
+
+ /*
+ * De-register for all hook callbacks
+ */
+ __vconf_deregister_hooks(s);
+
+ ud = tcore_plugin_ref_user_data(p);
+ if (ud)
+ free(ud);
+}
--- /dev/null
+/*
+ * tel-plugin-vconf
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Ja-young Gu <jygu@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <glib.h>
+
+#include <tcore.h>
+
+#include "vconf_main.h"
+#include "vconf_core.h"
+#include "vconf_handler.h"
+
+/*
+ * VCONF Initialization function
+ */
+gboolean vconf_main_init(TcorePlugin *p)
+{
+ gboolean ret;
+
+ if (!p)
+ return FALSE;
+
+ dbg("Enter");
+
+ /*
+ * Initialize VCONF 'Core'
+ */
+ ret = vconf_core_init(p);
+ if (ret == FALSE) {
+ err("VCONF Core init failed!");
+ return FALSE;
+ }
+
+ /*
+ * Initialize VCONF 'Handler'
+ */
+ ret = vconf_handler_init(p);
+ if (ret == FALSE) {
+ err("VCONF Handler init failed!");
+
+ vconf_core_deinit(p);
+ return FALSE;
+ }
+
+
+ return TRUE;
+}
+
+/*
+ * VCONF De-initialization function
+ */
+void vconf_main_deinit(TcorePlugin *p)
+{
+ if (!p)
+ return;
+
+ dbg("Enter");
+
+ /*
+ * De-initialize VCONF 'Handler'
+ */
+ vconf_handler_deinit(p);
+
+ /*
+ * De-initialize VCONF 'Core'
+ */
+ vconf_core_deinit(p);
+}