test_contents.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)yahoo.fr>
  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 _TEST_CONTENTS_H_
  23. #define _TEST_CONTENTS_H_
  24. static void test_content_dummy();
  25. static void test_content_text_plain();
  26. static void test_content_cpim();
  27. static void test_contents()
  28. {
  29. test_content_dummy();
  30. test_content_text_plain();
  31. test_content_cpim();
  32. }
  33. static void test_content_dummy()
  34. {
  35. #define CONTENT_DUMMY_DATA "salut"
  36. #define CONTENT_DUMMY_TYPE "cool/ok"
  37. tmedia_content_t* content = tmedia_content_parse(CONTENT_DUMMY_DATA, tsk_strlen(CONTENT_DUMMY_DATA), CONTENT_DUMMY_TYPE);
  38. if(content) {
  39. tsk_buffer_t* data = tmedia_content_get_data(content);
  40. TSK_DEBUG_INFO("content-type=%s\n\ncontent=%s", TMEDIA_CONTENT(content)->type, TSK_BUFFER_DATA(data));
  41. tsk_object_unref(data);
  42. }
  43. TSK_OBJECT_SAFE_FREE(content);
  44. }
  45. static void test_content_text_plain()
  46. {
  47. #define CONTENT_TEXT_PLAIN_DATA "salut comment tu vas?"
  48. #define CONTENT_TEXT_PLAIN_TYPE "text/plain"
  49. tmedia_content_t* content = tmedia_content_parse(CONTENT_TEXT_PLAIN_DATA, tsk_strlen(CONTENT_TEXT_PLAIN_DATA), CONTENT_TEXT_PLAIN_TYPE);
  50. if(content) {
  51. tsk_buffer_t* data = tmedia_content_get_data(content);
  52. TSK_DEBUG_INFO("content-type=%s\n\ncontent=%s", TMEDIA_CONTENT(content)->type, TSK_BUFFER_DATA(data));
  53. tsk_object_unref(data);
  54. }
  55. TSK_OBJECT_SAFE_FREE(content);
  56. }
  57. static void test_content_cpim()
  58. {
  59. #define CONTENT_CPIM_DATA "To: <sip:test@doubango.org>\r\n" \
  60. "From: <sip:test@doubango.org>\r\n" \
  61. "DateTime: 2010-12-17T09:57:32.562Z\r\n" \
  62. "Content-Disposition: attachment; filename=\"history.xml\"; creation-date=\"2010-12-17T09:19:56.978Z\"; size=3714\r\n" \
  63. "\r\n" \
  64. "Content-Type: application/octet-stream\r\n" \
  65. "Content-ID: <1234567890@doubango.org>\r\n" \
  66. "\r\n" \
  67. "salut comment tu vas?\r\n"
  68. #define CONTENT_CPIM_TYPE "message/CPIM"
  69. tmedia_content_t* content = tmedia_content_parse(CONTENT_CPIM_DATA, tsk_strlen(CONTENT_CPIM_DATA), CONTENT_CPIM_TYPE);
  70. if(content) {
  71. tsk_buffer_t* data = tmedia_content_get_data(content);
  72. TSK_DEBUG_INFO("content-type=%s\n\ncontent=%s", TMEDIA_CONTENT(content)->type, TSK_BUFFER_DATA(data));
  73. tsk_object_unref(data);
  74. }
  75. TSK_OBJECT_SAFE_FREE(content);
  76. }
  77. #endif /* _TEST_CONTENTS_H_ */