SMSEncoder.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou@doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. #ifndef TINYWRAP_SMSENCODER_H
  23. #define TINYWRAP_SMSENCODER_H
  24. #include "tinyWRAP_config.h"
  25. #include "tinysip.h" /* SIP/IMS */
  26. #include "tinysms.h" /* Binary SMS API*/
  27. typedef enum twrap_rpmessage_type_e {
  28. twrap_rpmessage_type_sms_none,
  29. twrap_rpmessage_type_sms_submit,
  30. twrap_rpmessage_type_sms_deliver,
  31. twrap_rpmessage_type_sms_ack,
  32. twrap_rpmessage_type_sms_error,
  33. }
  34. twrap_rpmessage_type_t;
  35. typedef enum twrap_sms_type_e {
  36. twrap_sms_type_none,
  37. twrap_sms_type_rpdata,
  38. twrap_sms_type_smma,
  39. twrap_sms_type_ack,
  40. twrap_sms_type_error,
  41. }
  42. twrap_sms_type_t;
  43. class RPMessage
  44. {
  45. public:
  46. #if !defined(SWIG)
  47. RPMessage(twrap_rpmessage_type_t type, tsms_rpdu_message_t* rp_message);
  48. #endif
  49. RPMessage();
  50. virtual ~RPMessage();
  51. public:
  52. /* Public API functions */
  53. twrap_rpmessage_type_t getType();
  54. unsigned getPayloadLength();
  55. unsigned getPayload(void* output, unsigned maxsize);
  56. private:
  57. twrap_rpmessage_type_t type;
  58. tsms_rpdu_message_t* rp_message;
  59. tsk_buffer_t* tmpBuffer;
  60. };
  61. class SMSData
  62. {
  63. public:
  64. #if !defined(SWIG)
  65. SMSData(twrap_sms_type_t type, int mr, const void* ascii, tsk_size_t size);
  66. #endif
  67. SMSData();
  68. virtual ~SMSData();
  69. public:
  70. /* Public API functions */
  71. twrap_sms_type_t getType();
  72. int getMR();
  73. unsigned getPayloadLength();
  74. unsigned getPayload(void* output, unsigned maxsize);
  75. const char* getOA();
  76. const char* getDA();
  77. #if !defined(SWIG)
  78. void setOA(const char* oa);
  79. void setDA(const char* da);
  80. #endif
  81. private:
  82. twrap_sms_type_t type;
  83. int mr;
  84. void* ascii;
  85. char* oa;
  86. char* da;
  87. tsk_size_t size;
  88. };
  89. class SMSEncoder
  90. {
  91. public:
  92. static RPMessage* encodeSubmit(int mr, const char* smsc, const char* destination, const char* ascii);
  93. static RPMessage* encodeDeliver(int mr, const char* smsc, const char* originator, const char* ascii);
  94. static RPMessage* encodeACK(int mr, const char* smsc, const char* destination, bool forSUBMIT);
  95. static RPMessage* encodeError(int mr, const char* smsc, const char* destination, bool forSUBMIT);
  96. static SMSData* decode(const void* data, unsigned size, bool MobOrig);
  97. };
  98. #endif /* TINYWRAP_SMSENCODER_H */