netreg.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. *
  3. * oFono - Open Source Telephony
  4. *
  5. * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #ifndef __OFONO_NETREG_H
  22. #define __OFONO_NETREG_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #include <ofono/types.h>
  27. struct ofono_netreg;
  28. /* Theoretical limit is 16, but each GSM char can be encoded into
  29. * * 3 UTF8 characters resulting in 16*3=48 chars
  30. * */
  31. #define OFONO_MAX_OPERATOR_NAME_LENGTH 63
  32. struct ofono_network_operator {
  33. char name[OFONO_MAX_OPERATOR_NAME_LENGTH + 1];
  34. char mcc[OFONO_MAX_MCC_LENGTH + 1];
  35. char mnc[OFONO_MAX_MNC_LENGTH + 1];
  36. int status;
  37. int tech;
  38. };
  39. typedef void (*ofono_netreg_operator_cb_t)(const struct ofono_error *error,
  40. const struct ofono_network_operator *op,
  41. void *data);
  42. typedef void (*ofono_netreg_register_cb_t)(const struct ofono_error *error,
  43. void *data);
  44. typedef void (*ofono_netreg_operator_list_cb_t)(const struct ofono_error *error,
  45. int total,
  46. const struct ofono_network_operator *list,
  47. void *data);
  48. typedef void (*ofono_netreg_status_cb_t)(const struct ofono_error *error,
  49. int status, int lac, int ci, int tech,
  50. void *data);
  51. typedef void (*ofono_netreg_strength_cb_t)(const struct ofono_error *error,
  52. int strength, void *data);
  53. /* Network related functions, including registration status, operator selection
  54. * and signal strength indicators.
  55. *
  56. * It is up to the plugin to implement CSQ polling if the modem does not support
  57. * vendor extensions for signal strength notification.
  58. */
  59. struct ofono_netreg_driver {
  60. const char *name;
  61. int (*probe)(struct ofono_netreg *netreg, unsigned int vendor,
  62. void *data);
  63. void (*remove)(struct ofono_netreg *netreg);
  64. void (*registration_status)(struct ofono_netreg *netreg,
  65. ofono_netreg_status_cb_t cb, void *data);
  66. void (*current_operator)(struct ofono_netreg *netreg,
  67. ofono_netreg_operator_cb_t cb, void *data);
  68. void (*list_operators)(struct ofono_netreg *netreg,
  69. ofono_netreg_operator_list_cb_t cb, void *data);
  70. void (*register_auto)(struct ofono_netreg *netreg,
  71. ofono_netreg_register_cb_t cb, void *data);
  72. void (*register_manual)(struct ofono_netreg *netreg,
  73. const char *mcc, const char *mnc,
  74. ofono_netreg_register_cb_t cb, void *data);
  75. void (*strength)(struct ofono_netreg *netreg,
  76. ofono_netreg_strength_cb_t, void *data);
  77. };
  78. void ofono_netreg_strength_notify(struct ofono_netreg *netreg, int strength);
  79. void ofono_netreg_status_notify(struct ofono_netreg *netreg, int status,
  80. int lac, int ci, int tech);
  81. void ofono_netreg_time_notify(struct ofono_netreg *netreg,
  82. struct ofono_network_time *info);
  83. int ofono_netreg_driver_register(const struct ofono_netreg_driver *d);
  84. void ofono_netreg_driver_unregister(const struct ofono_netreg_driver *d);
  85. struct ofono_netreg *ofono_netreg_create(struct ofono_modem *modem,
  86. unsigned int vendor,
  87. const char *driver,
  88. void *data);
  89. void ofono_netreg_register(struct ofono_netreg *netreg);
  90. void ofono_netreg_remove(struct ofono_netreg *netreg);
  91. void ofono_netreg_set_data(struct ofono_netreg *netreg, void *data);
  92. void *ofono_netreg_get_data(struct ofono_netreg *netreg);
  93. int ofono_netreg_get_location(struct ofono_netreg *netreg);
  94. int ofono_netreg_get_cellid(struct ofono_netreg *netreg);
  95. int ofono_netreg_get_status(struct ofono_netreg *netreg);
  96. int ofono_netreg_get_technology(struct ofono_netreg *netreg);
  97. const char *ofono_netreg_get_mcc(struct ofono_netreg *netreg);
  98. const char *ofono_netreg_get_mnc(struct ofono_netreg *netreg);
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. #endif /* __OFONO_NETREG_H */