(Circle) Dialer / src /

data.c

  1. /*
  2. * Copyright (c) 2015 Samsung Electronics Co., Ltd
  3. *
  4. * Licensed under the Flora License, Version 1.1 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://floralicense.org/license/
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16.  
  17. #include <tizen.h>
  18. #include <app.h>
  19. #include <efl_extension.h>
  20. #include <dlog.h>
  21. #include "$(appName).h"
  22. #include "data.h"
  23.  
  24. /*
  25. * @brief Initialization function for data module
  26. */
  27. void data_initialize(void)
  28. {
  29. /*
  30. * If you need to initialize managing data,
  31. * please use this function.
  32. */
  33. }
  34.  
  35. /*
  36. * @brief Finalization function for data module
  37. */
  38. void data_finalize(void)
  39. {
  40. /*
  41. * If you need to finalize managing data,
  42. * please use this function.
  43. */
  44. }
  45.  
  46. /*
  47. * @brief Get full path of resource
  48. * @param[in] file_path File path of target file
  49. * @param[out] full_path Full file path concatenated with resource path
  50. * @param[in] path_max Max length of full file path
  51. */
  52. void data_get_full_path(const char *file_path, char *full_path, int path_max)
  53. {
  54. char *res_path = app_get_resource_path();
  55. if (res_path) {
  56. snprintf(full_path, path_max, "%s%s", res_path, file_path);
  57. free(res_path);
  58. }
  59. }
  60.  
  61. /*
  62. * @brief Get path of image file for part
  63. * @param[in] part_name Part name of the target image path
  64. */
  65. char *data_get_image_path(const char *part_name)
  66. {
  67. /*
  68. * You can use this function to retrieve data.
  69. */
  70. char *ret = NULL;
  71. char full_path[PATH_MAX] = { 0, };
  72. char *res_path = app_get_resource_path();
  73.  
  74. if (res_path) {
  75. if (!strcmp("sw.button.bg", part_name))
  76. snprintf(full_path, sizeof(full_path) - 1, "%s%s", res_path, "images/dialer_button_bg.png");
  77. else if (!strcmp("sw.button.call", part_name))
  78. snprintf(full_path, sizeof(full_path) - 1, "%s%s", res_path, "images/dialer_btn_call_icon.png");
  79. else if (!strcmp("sw.button.call.ef", part_name))
  80. snprintf(full_path, sizeof(full_path) - 1, "%s%s", res_path, "images/dialer_btn_call_icon_ef.png");
  81. else if (!strcmp("sw.button.delete", part_name))
  82. snprintf(full_path, sizeof(full_path) - 1, "%s%s", res_path, "images/dialer_btn_back.png");
  83. else if (!strcmp("sw.image.effect", part_name))
  84. snprintf(full_path, sizeof(full_path) - 1, "%s%s", res_path, "images/dialer_fadeout.#.png");
  85. else {
  86. dlog_print(DLOG_ERROR, LOG_TAG, "failed to get image.");
  87. free(res_path);
  88. return NULL;
  89. }
  90.  
  91. ret = strdup(full_path);
  92. free(res_path);
  93. }
  94.  
  95. return ret;
  96. }