Browse code

py_sems: updated to new API, wip, still doesn't compile

Stefan Sayer authored on 01/04/2014 10:22:09
Showing 7 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,133 @@
1
+
2
+
3
+
4
+struct AmContentType
5
+{
6
+
7
+%TypeHeaderCode
8
+#include "../../../core/AmMimeBody.h"
9
+%End
10
+
11
+  struct Param
12
+  {
13
+
14
+    enum Type {
15
+      UNPARSED=0,
16
+      BOUNDARY,
17
+      OTHER
18
+    };
19
+
20
+    Type   type;
21
+    string name;
22
+    string value;
23
+
24
+    int parseType();
25
+  };
26
+
27
+  typedef list<Param*> Params;
28
+
29
+  int  parse(const string& ct);
30
+  int  parseParams(const char* c, const char* end);
31
+
32
+  void setType(const string& t);
33
+  void setSubType(const string& st);
34
+
35
+  bool isType(const string& t) const;
36
+  bool isSubType(const string& st) const;
37
+  bool hasContentType(const string& content_type) const;
38
+
39
+  /** get content-type without any parameters */
40
+  string getStr() const;
41
+
42
+  /** get content-type with parameters */
43
+  string getHdr() const;
44
+
45
+  /** Clear and free param list */
46
+  void clearParams();
47
+};
48
+
49
+
50
+class AmMimeBody
51
+{
52
+
53
+%TypeHeaderCode
54
+#include "../../../core/AmMimeBody.h"
55
+%End
56
+
57
+public:
58
+
59
+  typedef list<AmMimeBody*>  Parts;
60
+
61
+  /** Parse a body (single & multi-part) */
62
+  int  parse(const string& content_type, 
63
+	     const unsigned char* buf, 
64
+	     unsigned int len);
65
+
66
+  /** Set the payload of this body */
67
+  void setPayload(const unsigned char* buf, unsigned int len);
68
+
69
+  /** Set part headers (intended for sub-parts)*/
70
+  void setHeaders(const string& hdrs);
71
+
72
+  /** 
73
+   * Add a new part to this body, possibly
74
+   * converting to multi-part if necessary.
75
+   * @return a pointer to the new empty part.
76
+   */
77
+  AmMimeBody* addPart(const string& content_type);
78
+
79
+  /** Get content-type without any parameters */
80
+  string getCTStr() const;
81
+
82
+  /** Get content-type with parameters */
83
+  string getCTHdr() const;
84
+  
85
+  /** @return the list of sub-parts */
86
+  const Parts& getParts() const;
87
+
88
+  /** @return the sub-part headers */
89
+  const string& getHeaders();
90
+
91
+  /**
92
+   * @return a pointer to the payload of this part.
93
+   *         in case of multi-part, NULL is returned.
94
+   */
95
+  const unsigned char* getPayload();
96
+
97
+  /**
98
+   * @return the payload length of this part.
99
+   *         in case of multi-part, 0 is returned.
100
+   */
101
+  unsigned int   getLen();
102
+
103
+  /** @return true if no payload assigned and no sub-parts available */
104
+  bool empty() const;
105
+
106
+  /** @return true if this part has the provided content-type */
107
+  bool isContentType(const string& /* content_type */) const;
108
+
109
+  /** 
110
+   * @return a pointer to a part of the coresponding 
111
+   *         content-type (if available).
112
+   *         This could be a pointer to this body.
113
+   */
114
+  AmMimeBody* hasContentType(const string& /*content_type*/);
115
+
116
+  /** 
117
+   * @return a const pointer to a part of the coresponding 
118
+   *         content-type (if available).
119
+   *         This could be a pointer to this body.
120
+   */
121
+  const AmMimeBody* hasContentType(const string& /* content_type*/ ) const;
122
+
123
+  /**
124
+   * Print the body including sub-parts suitable for sending
125
+   * within the body of a SIP message.
126
+   */
127
+  void print(string& /* buf */) const;
128
+
129
+  const AmContentType &getContentType();
130
+  void setContentType(const AmContentType & /*_ct*/);
131
+  void addPart(const AmMimeBody & /*part*/);
132
+
133
+};
... ...
@@ -26,12 +26,12 @@ public:
26 26
 
27 27
     string contact_uri;  // pre-calculated contact uri
28 28
 
29
-    string callid;
30
-    string remote_tag;
31
-    string local_tag;
29
+    string getCallid();
30
+    string getRemoteTag();
31
+    string getLocalTag();
32 32
 
33
-    string remote_party; // To/From
34
-    string local_party;  // To/From
33
+    string getRemoteParty(); // To/From
34
+    string getLocalParty();  // To/From
35 35
 
36 36
     int cseq;            // CSeq for next request
37 37
     int r_cseq;
... ...
@@ -49,23 +49,21 @@ public:
49 49
  	      unsigned int  /* code */, 
50 50
  	      const string& /* reason */,
51 51
  	      const string& /* content_type */,
52
- 	      const string& /* body */,
52
+ 	      const AmMimeBody* /* body */,
53 53
  	      const string& /* hdrs */);
54 54
 
55 55
     int sendRequest(const string& /* method */, 
56 56
 		    const string& /* content_type */,
57
-		    const string& /* body */,
57
+		    const AmMimeBody* /* body */,
58 58
 		    const string& /* hdrs */);
59 59
     
60 60
     int bye();
61 61
 
62 62
     int cancel();
63 63
 
64
-    int update(const string& /* content_type */,
65
-	       const string& /* body */,
64
+    int update(const AmMimeBody* /* body */,
66 65
 	       const string& /* hdrs */);
67 66
 
68
-    int reinvite(const string& /* hdrs */,
69
-		 const string& /* content_type */,
70
-		 const string& /* body */);
67
+    int reinvite(const AmMimeBody* /* body */,
68
+    	         const string& /* hdrs */);
71 69
 };
... ...
@@ -27,7 +27,7 @@ class PySemsB2ABDialog
27 27
 
28 28
 public:
29 29
 
30
-    AmSipDialog dlg;
30
+    AmSipDialog* dlg;
31 31
 
32 32
     PySemsB2ABDialog();
33 33
 
... ...
@@ -8,7 +8,7 @@ class PySemsB2BDialog
8 8
 
9 9
 public:
10 10
 
11
-    AmSipDialog dlg;
11
+    AmSipDialog* dlg;
12 12
 
13 13
     PySemsB2BDialog();
14 14
 
... ...
@@ -8,7 +8,7 @@ class PySemsDialog
8 8
 
9 9
 public:
10 10
 
11
-    AmSipDialog dlg;
11
+    AmSipDialog* dlg;
12 12
 
13 13
     PySemsDialog();
14 14
 
15 15
deleted file mode 100644
... ...
@@ -1,3 +0,0 @@
1
-target = py_sems_lib
2
-sources = sippy_sems_libcmodule.cpp sippy_sems_libPySemsB2ABEvent.cpp sippy_sems_libPySemsB2ABCalleeDialog.cpp sippy_sems_libAmB2ABCalleeSession.cpp sippy_sems_libPySemsB2ABDialog.cpp sippy_sems_libAmSessionAudioConnector.cpp sippy_sems_libPySemsB2BDialog.cpp sippy_sems_libPySemsDialog.cpp sippy_sems_libAmAudioFile.cpp sippy_sems_libAmAudioEvent.cpp sippy_sems_libAmEvent.cpp sippy_sems_libAmSipDialog.cpp sippy_sems_libAmSipReply.cpp sippy_sems_libAmSipRequest.cpp sippy_sems_libstring.cpp
3
-headers = sipAPIpy_sems_lib.h
... ...
@@ -9,3 +9,4 @@
9 9
 %Include PySemsB2BDialog.sip
10 10
 %Include PySemsB2ABDialog.sip
11 11
 %Include AmUtils.sip
12
+%Include AmMimeBody.sip