You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
4.7KB

  1. /*
  2. Implementation of special data used by Garmin products.
  3. Copyright (C) 2006 Olaf Klein, o.b.klein@gpsbabel.org
  4. Copyright (C) 2006-2014 Robert Lipe, robertlipe@gpsbabel.org
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
  16. */
  17. #ifndef GARMIN_FS_H
  18. #define GARMIN_FS_H
  19. #include "defs.h"
  20. #include "jeeps/gps.h"
  21. /* this order is used by most devices */
  22. /* typedef enum {
  23. garmin_display_symbol_and_name = 0,
  24. garmin_display_symbol_only = 1,
  25. garmin_display_symbol_and_description = 2
  26. } garmin_display_t;
  27. */
  28. /* macros */
  29. #define GMSD_FIND(a) (garmin_fs_t *) fs_chain_find((a)->fs, FS_GMSD)
  30. #define GMSD_HAS(a) (gmsd && gmsd->flags.a)
  31. /* GMSD_GET(a,b): a = any gmsd field, b = default value */
  32. #define GMSD_GET(a,b) ((gmsd) && (gmsd->flags.a)) ? (gmsd->a) : (b)
  33. /* GMSD_SET(a,b): a = numeric gmsd field, b = numeric source */
  34. #define GMSD_SET(a,b) if (gmsd) {gmsd->a = (b); gmsd->flags.a = 1; }
  35. /* GMSD_UNSET(a): a = gmsd field */
  36. #define GMSD_UNSET(a) if (gmsd) { gmsd->flags.a = 0; }
  37. /* GMSD_SETSTR(a,b): a = gmsd field, b = null terminated source */
  38. #define GMSD_SETSTR(a,b) if (gmsd && (b) && (b)[0]) { gmsd->a = xstrdup((b)); gmsd->flags.a = 1; }
  39. #define GMSD_SETQSTR(a,b) if (gmsd) { gmsd->a = xstrdup((b)); gmsd->flags.a = 1; }
  40. #define GMSD_SETSTRQ(a,b) if (gmsd && !b.isEmpty()) { gmsd->a = xstrdup((b)); gmsd->flags.a = 1; }
  41. /* GMSD_SETNSTR(a,b,c): a = gmsd field, b = source, c = sizeof(source) */
  42. #define GMSD_SETNSTR(a,b,c) if (gmsd && (b) && (b)[0]) { gmsd->a = xstrndup((b),(c)); gmsd->flags.a = 1; }
  43. /* GMSD_GETNSTR(a,b,c): a = gmsd field, b = target, c = sizeof(target) */
  44. #define GMSD_GETNSTR(a,b,c) if (gmsd && gmsd->flags.a) strncpy((b),gmsd->a,(c))
  45. typedef struct garmin_ilink_s {
  46. int ref_count;
  47. double lat, lon, alt;
  48. struct garmin_ilink_s* next;
  49. } garmin_ilink_t;
  50. typedef struct {
  51. unsigned int icon:1;
  52. unsigned int wpt_class:1;
  53. unsigned int display:1;
  54. unsigned int category:1;
  55. unsigned int city:1;
  56. unsigned int state:1;
  57. unsigned int facility:1;
  58. unsigned int cc:1;
  59. unsigned int cross_road:1;
  60. unsigned int addr:1;
  61. unsigned int country:1;
  62. unsigned int phone_nr:1;
  63. unsigned int phone_nr2:1;
  64. unsigned int fax_nr:1;
  65. unsigned int postal_code:1;
  66. unsigned int email:1;
  67. #ifdef GMSD_EXPERIMENTAL
  68. unsigned int subclass:1;
  69. #endif
  70. } garmin_fs_flags_t;
  71. typedef struct garmin_fs_s {
  72. format_specific_data fs;
  73. garmin_fs_flags_t flags;
  74. int protocol; /* ... used by device (-1 is MapSource) */
  75. int32_t icon;
  76. int wpt_class;
  77. int32_t display;
  78. int16_t category;
  79. char* city; /* city name */
  80. char* facility; /* facility name */
  81. char* state; /* state */
  82. char* cc; /* country code */
  83. char* cross_road; /* Intersection road label */
  84. char* addr; /* address + number */
  85. char* country; /* country */
  86. char* phone_nr; /* phone number */
  87. char* phone_nr2; /* phone number (2) */
  88. char* fax_nr; /* fax number */
  89. char* postal_code; /* postal code */
  90. char* email; /* email address */
  91. garmin_ilink_t* ilinks;
  92. #ifdef GMSD_EXPERIMENTAL
  93. char subclass[22];
  94. #endif
  95. } garmin_fs_t, *garmin_fs_p;
  96. garmin_fs_t* garmin_fs_alloc(const int protocol);
  97. void garmin_fs_destroy(void* fs);
  98. void garmin_fs_copy(garmin_fs_t** dest, garmin_fs_t* src);
  99. void garmin_fs_convert(void* fs);
  100. char* garmin_fs_xstrdup(const char* src, size_t size);
  101. /* for GPX */
  102. void garmin_fs_xml_convert(const int base_tag, int tag, const QString& cdatastr, Waypoint* waypt);
  103. class QXmlStreamWriter;
  104. void garmin_fs_xml_fprint(const Waypoint* waypt, QXmlStreamWriter*);
  105. /* common garmin_fs utilities */
  106. /* ..convert_category: returns 1=OK; 0=Unable to convert category */
  107. unsigned char garmin_fs_convert_category(const char* category_name, uint16_t* category);
  108. /* ..merge_category: returns 1=OK; 0=Unable to convert category */
  109. unsigned char garmin_fs_merge_category(const char* category_name, Waypoint* waypt);
  110. #define GMSD_SECTION_CATEGORIES "Garmin Categories"
  111. void garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid);
  112. void garmin_fs_garmin_before_write(const Waypoint* wpt, GPS_PWay way, const int protoid);
  113. #endif