stropheruby 0.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/strophe.h CHANGED
@@ -1,7 +1,7 @@
1
1
  /* strophe.h
2
2
  ** strophe XMPP client library C API
3
3
  **
4
- ** Copyright (C) 2005-2009 Collecta, Inc.
4
+ ** Copyright (C) 2005-2008 OGG, LLC.
5
5
  **
6
6
  ** This software is provided AS-IS with no warranty, either express or
7
7
  ** implied.
@@ -14,7 +14,7 @@
14
14
 
15
15
  /** @file
16
16
  * Strophe public C API definitions.
17
- */
17
+ */
18
18
 
19
19
  #ifndef __LIBSTROPHE_STROPHE_H__
20
20
  #define __LIBSTROPHE_STROPHE_H__
@@ -212,19 +212,16 @@ xmpp_conn_t * xmpp_conn_clone(xmpp_conn_t * const conn);
212
212
  int xmpp_conn_release(xmpp_conn_t * const conn);
213
213
 
214
214
  const char *xmpp_conn_get_jid(const xmpp_conn_t * const conn);
215
- const char *xmpp_conn_get_bound_jid(const xmpp_conn_t * const conn);
216
215
  void xmpp_conn_set_jid(xmpp_conn_t * const conn, const char * const jid);
217
216
  const char *xmpp_conn_get_pass(const xmpp_conn_t * const conn);
218
217
  void xmpp_conn_set_pass(xmpp_conn_t * const conn, const char * const pass);
219
- unsigned int xmpp_conn_get_connect_timeout(const xmpp_conn_t * const conn);
220
- void xmpp_conn_set_connect_timeout(xmpp_conn_t * const conn, const unsigned int timeout);
221
218
  xmpp_ctx_t* xmpp_conn_get_context(xmpp_conn_t * const conn);
222
219
 
223
- int xmpp_connect_client(xmpp_conn_t * const conn,
220
+ int xmpp_connect_client(xmpp_conn_t * const conn,
224
221
  const char * const altdomain,
225
222
  unsigned short altport,
226
- xmpp_conn_handler callback,
227
- void * const userdata);
223
+ xmpp_conn_handler callback,
224
+ void * const userdata);
228
225
 
229
226
  /*
230
227
  int xmpp_connect_component(conn, name)
data/ext/thread.c CHANGED
@@ -1,7 +1,7 @@
1
1
  /* thread.c
2
2
  ** strophe XMPP client library -- thread abstraction
3
3
  **
4
- ** Copyright (C) 2005-2009 Collecta, Inc.
4
+ ** Copyright (C) 2005-2008 OGG, LLC. All rights reserved.
5
5
  **
6
6
  ** This software is provided AS-IS with no warranty, either express
7
7
  ** or implied.
@@ -14,7 +14,7 @@
14
14
 
15
15
  /** @file
16
16
  * Thread absraction.
17
- */
17
+ */
18
18
 
19
19
  #include <stdio.h>
20
20
  #include <stdlib.h>
data/ext/thread.h CHANGED
@@ -1,7 +1,7 @@
1
1
  /* thread.h
2
2
  ** strophe XMPP client library -- thread abstraction header
3
3
  **
4
- ** Copyright (C) 2005-2009 Collecta, Inc.
4
+ ** Copyright (C) 2005-2008 OGG, LLC. All rights reserved.
5
5
  **
6
6
  ** This software is provided AS-IS with no warranty, either express
7
7
  ** or implied.
@@ -14,7 +14,7 @@
14
14
 
15
15
  /** @file
16
16
  * Threading abstraction API.
17
- */
17
+ */
18
18
 
19
19
  #ifndef __LIBSTROPHE_THREAD_H__
20
20
  #define __LIBSTROPHE_THREAD_H__
data/ext/tls.h CHANGED
@@ -1,7 +1,7 @@
1
1
  /* tls.h
2
2
  ** strophe XMPP client library -- TLS abstraction header
3
3
  **
4
- ** Copyright (C) 2005-2009 Collecta, Inc.
4
+ ** Copyright (C) 2005-2008 OGG, LLC. All rights reserved.
5
5
  **
6
6
  ** This software is provided AS-IS with no warranty, either express
7
7
  ** or implied.
data/ext/tls_dummy.c CHANGED
@@ -1,7 +1,7 @@
1
1
  /* tls_dummy.c
2
2
  ** strophe XMPP client library -- TLS abstraction dummy impl.
3
3
  **
4
- ** Copyright (C) 2005-2009 Collecta, Inc.
4
+ ** Copyright (C) 2005-2008 OGG, LLC. All rights reserved.
5
5
  **
6
6
  ** This software is provided AS-IS with no warranty, either express
7
7
  ** or implied.
@@ -14,7 +14,7 @@
14
14
 
15
15
  /** @file
16
16
  * TLS dummy implementation.
17
- */
17
+ */
18
18
 
19
19
  #include "common.h"
20
20
  #include "tls.h"
data/ext/util.c CHANGED
@@ -1,7 +1,7 @@
1
1
  /* util.c
2
2
  ** strophe XMPP client library -- various utility functions
3
3
  **
4
- ** Copyright (C) 2005-2009 Collecta, Inc.
4
+ ** Copyright (C) 2005-2008 OGG, LLC. All rights reserved.
5
5
  **
6
6
  ** This software is provided AS-IS with no warranty, either express
7
7
  ** or implied.
@@ -14,7 +14,7 @@
14
14
 
15
15
  /** @file
16
16
  * Utility functions.
17
- */
17
+ */
18
18
 
19
19
  #include <stdio.h>
20
20
  #include <string.h>
data/ext/util.h CHANGED
@@ -1,7 +1,7 @@
1
1
  /* util.h
2
2
  ** strophe XMPP client library -- various utility functions
3
3
  **
4
- ** Copyright (C) 2005-2009 Collecta, Inc.
4
+ ** Copyright (C) 2005-2008 OGG, LLC. All rights reserved.
5
5
  **
6
6
  ** This software is provided AS-IS with no warranty, either express
7
7
  ** or implied.
@@ -14,7 +14,7 @@
14
14
 
15
15
  /** @file
16
16
  * Internally used utility functions.
17
- */
17
+ */
18
18
 
19
19
  #ifndef __LIBSTROPHE_UTIL_H__
20
20
  #define __LIBSTROPHE_UTIL_H__
metadata CHANGED
@@ -1,30 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stropheruby
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 21
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- version: "0.2"
9
+ - 1
10
+ version: 0.2.1
9
11
  platform: ruby
10
12
  authors:
11
- - Dingding Ye
12
- - Xue Yong Zhi
13
13
  - "Fran\xC3\xA7ois Lamontagne"
14
+ - Yongzhi Xue
15
+ - Dingding Ye
14
16
  autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2010-02-26 00:00:00 +08:00
20
+ date: 2010-09-19 00:00:00 +08:00
19
21
  default_executable:
20
22
  dependencies:
21
23
  - !ruby/object:Gem::Dependency
22
24
  name: hoe
23
25
  prerelease: false
24
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
25
28
  requirements:
26
29
  - - ">="
27
30
  - !ruby/object:Gem::Version
31
+ hash: 49
28
32
  segments:
29
33
  - 1
30
34
  - 8
@@ -32,11 +36,11 @@ dependencies:
32
36
  version: 1.8.3
33
37
  type: :development
34
38
  version_requirements: *id001
35
- description:
39
+ description: Stropheruby is a ruby bindings for Strophe, a C library for writing XMPP clients.
36
40
  email:
37
- - yedingding@gmail.com
38
- - xue.yong.zhi@gmail.com
39
41
  - flamontagne@gmail.com
42
+ - xue.yong.zhi@gmail.com
43
+ - yedingding@gmail.com
40
44
  executables: []
41
45
 
42
46
  extensions:
@@ -53,8 +57,7 @@ files:
53
57
  - README.txt
54
58
  - Rakefile
55
59
  - ext/md5.c
56
- - ext/parser.h
57
- - ext/parser_expat.c
60
+ - ext/parser.c
58
61
  - ext/util.c
59
62
  - ext/strophe_ruby.c
60
63
  - ext/conn.c
@@ -89,7 +92,7 @@ files:
89
92
  - ext/extconf.rb
90
93
  - examples/xmpp_client.rb
91
94
  has_rdoc: true
92
- homepage:
95
+ homepage: http://github.com/yong/stropheruby
93
96
  licenses: []
94
97
 
95
98
  post_install_message:
@@ -100,23 +103,27 @@ require_paths:
100
103
  - lib
101
104
  - ext
102
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
103
107
  requirements:
104
108
  - - ">="
105
109
  - !ruby/object:Gem::Version
110
+ hash: 3
106
111
  segments:
107
112
  - 0
108
113
  version: "0"
109
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
110
116
  requirements:
111
117
  - - ">="
112
118
  - !ruby/object:Gem::Version
119
+ hash: 3
113
120
  segments:
114
121
  - 0
115
122
  version: "0"
116
123
  requirements: []
117
124
 
118
125
  rubyforge_project: strophe_ruby
119
- rubygems_version: 1.3.6
126
+ rubygems_version: 1.3.7
120
127
  signing_key:
121
128
  specification_version: 2
122
129
  summary: strophe_ruby
data/ext/parser.h DELETED
@@ -1,43 +0,0 @@
1
- /* parser.h
2
- ** strophe XMPP client library -- parser structures and functions
3
- **
4
- ** Copyright (C) 2005-2009 Collecta, Inc.
5
- **
6
- ** This software is provided AS-IS with no warranty, either express or
7
- ** implied.
8
- **
9
- ** This software is distributed under license and may not be copied,
10
- ** modified or distributed except as expressly authorized under the
11
- ** terms of the license contained in the file LICENSE.txt in this
12
- ** distribution.
13
- */
14
-
15
- /** @file
16
- * Internally used functions and structures.
17
- */
18
-
19
- #ifndef __LIBSTROPHE_PARSER_H__
20
- #define __LIBSTROPHE_PARSER_H__
21
-
22
- #include "strophe.h"
23
-
24
- typedef struct _parser_t parser_t;
25
-
26
- typedef void (*parser_start_callback)(char *name,
27
- char **attrs,
28
- void * const userdata);
29
- typedef void (*parser_end_callback)(char *name, void * const userdata);
30
- typedef void (*parser_stanza_callback)(xmpp_stanza_t *stanza,
31
- void * const userdata);
32
-
33
-
34
- parser_t *parser_new(xmpp_ctx_t *ctx,
35
- parser_start_callback startcb,
36
- parser_end_callback endcb,
37
- parser_stanza_callback stanzacb,
38
- void *userdata);
39
- void parser_free(parser_t * const parser);
40
- int parser_reset(parser_t *parser);
41
- int parser_feed(parser_t *parser, char *chunk, int len);
42
-
43
- #endif /* __LIBSTROPHE_PARSER_H__ */
data/ext/parser_expat.c DELETED
@@ -1,202 +0,0 @@
1
- /* parser.c
2
- ** strophe XMPP client library -- xml parser handlers and utility functions
3
- **
4
- ** Copyright (C) 2005-2009 Collecta, Inc.
5
- **
6
- ** This software is provided AS-IS with no warranty, either express
7
- ** or implied.
8
- **
9
- ** This software is distributed under license and may not be copied,
10
- ** modified or distributed except as expressly authorized under the
11
- ** terms of the license contained in the file LICENSE.txt in this
12
- ** distribution.
13
- */
14
-
15
- /** @file
16
- * XML parser handlers.
17
- */
18
-
19
- #include <stdio.h>
20
- #include <stdlib.h>
21
- #include <string.h>
22
-
23
- #include <expat.h>
24
-
25
- #include <strophe.h>
26
- #include "common.h"
27
- #include "parser.h"
28
-
29
- struct _parser_t {
30
- xmpp_ctx_t *ctx;
31
- XML_Parser expat;
32
- parser_start_callback startcb;
33
- parser_end_callback endcb;
34
- parser_stanza_callback stanzacb;
35
- void *userdata;
36
- int depth;
37
- xmpp_stanza_t *stanza;
38
- };
39
-
40
- static void _set_attributes(xmpp_stanza_t *stanza, const XML_Char **attrs)
41
- {
42
- int i;
43
-
44
- if (!attrs) return;
45
-
46
- for (i = 0; attrs[i]; i += 2) {
47
- xmpp_stanza_set_attribute(stanza, attrs[i], attrs[i+1]);
48
- }
49
- }
50
-
51
- static void _start_element(void *userdata,
52
- const XML_Char *name,
53
- const XML_Char **attrs)
54
- {
55
- parser_t *parser = (parser_t *)userdata;
56
- xmpp_stanza_t *child;
57
-
58
- if (parser->depth == 0) {
59
- /* notify the owner */
60
- if (parser->startcb)
61
- parser->startcb((char *)name, (char **)attrs,
62
- parser->userdata);
63
- } else {
64
- /* build stanzas at depth 1 */
65
- if (!parser->stanza && parser->depth != 1) {
66
- /* something terrible happened */
67
- /* FIXME: shutdown disconnect */
68
- xmpp_error(parser->ctx, "parser", "oops, where did our stanza go?");
69
- } else if (!parser->stanza) {
70
- /* starting a new toplevel stanza */
71
- parser->stanza = xmpp_stanza_new(parser->ctx);
72
- if (!parser->stanza) {
73
- /* FIXME: can't allocate, disconnect */
74
- }
75
- xmpp_stanza_set_name(parser->stanza, name);
76
- _set_attributes(parser->stanza, attrs);
77
- } else {
78
- /* starting a child of parser->stanza */
79
- child = xmpp_stanza_new(parser->ctx);
80
- if (!child) {
81
- /* FIXME: can't allocate, disconnect */
82
- }
83
- xmpp_stanza_set_name(child, name);
84
- _set_attributes(child, attrs);
85
-
86
- /* add child to parent */
87
- xmpp_stanza_add_child(parser->stanza, child);
88
-
89
- /* the child is owned by the toplevel stanza now */
90
- xmpp_stanza_release(child);
91
-
92
- /* make child the current stanza */
93
- parser->stanza = child;
94
- }
95
- }
96
-
97
- parser->depth++;
98
- }
99
-
100
- static void _end_element(void *userdata, const XML_Char *name)
101
- {
102
- parser_t *parser = (parser_t *)userdata;
103
-
104
- parser->depth--;
105
-
106
- if (parser->depth == 0) {
107
- /* notify the owner */
108
- if (parser->endcb)
109
- parser->endcb((char *)name, parser->userdata);
110
- } else {
111
- if (parser->stanza->parent) {
112
- /* we're finishing a child stanza, so set current to the parent */
113
- parser->stanza = parser->stanza->parent;
114
- } else {
115
- if (parser->stanzacb)
116
- parser->stanzacb(parser->stanza,
117
- parser->userdata);
118
- xmpp_stanza_release(parser->stanza);
119
- parser->stanza = NULL;
120
- }
121
- }
122
- }
123
-
124
- static void _characters(void *userdata, const XML_Char *s, int len)
125
- {
126
- parser_t *parser = (parser_t *)userdata;
127
- xmpp_stanza_t *stanza;
128
-
129
- if (parser->depth < 2) return;
130
-
131
- /* create and populate stanza */
132
- stanza = xmpp_stanza_new(parser->ctx);
133
- if (!stanza) {
134
- /* FIXME: allocation error, disconnect */
135
- return;
136
- }
137
- xmpp_stanza_set_text_with_size(stanza, s, len);
138
-
139
- xmpp_stanza_add_child(parser->stanza, stanza);
140
- xmpp_stanza_release(stanza);
141
- }
142
-
143
- parser_t *parser_new(xmpp_ctx_t *ctx,
144
- parser_start_callback startcb,
145
- parser_end_callback endcb,
146
- parser_stanza_callback stanzacb,
147
- void *userdata)
148
- {
149
- parser_t *parser;
150
-
151
- parser = xmpp_alloc(ctx, sizeof(parser_t));
152
- if (parser != NULL) {
153
- parser->ctx = ctx;
154
- parser->expat = NULL;
155
- parser->startcb = startcb;
156
- parser->endcb = endcb;
157
- parser->stanzacb = stanzacb;
158
- parser->userdata = userdata;
159
- parser->depth = 0;
160
- parser->stanza = NULL;
161
-
162
- parser_reset(parser);
163
- }
164
-
165
- return parser;
166
- }
167
-
168
- /* free a parser */
169
- void parser_free(parser_t *parser)
170
- {
171
- if (parser->expat)
172
- XML_ParserFree(parser->expat);
173
-
174
- xmpp_free(parser->ctx, parser);
175
- }
176
-
177
- /* shuts down and restarts XML parser. true on success */
178
- int parser_reset(parser_t *parser)
179
- {
180
- if (parser->expat)
181
- XML_ParserFree(parser->expat);
182
-
183
- if (parser->stanza)
184
- xmpp_stanza_release(parser->stanza);
185
-
186
- parser->expat = XML_ParserCreate(NULL);
187
- if (!parser->expat) return 0;
188
-
189
- parser->depth = 0;
190
- parser->stanza = NULL;
191
-
192
- XML_SetUserData(parser->expat, parser);
193
- XML_SetElementHandler(parser->expat, _start_element, _end_element);
194
- XML_SetCharacterDataHandler(parser->expat, _characters);
195
-
196
- return 1;
197
- }
198
-
199
- int parser_feed(parser_t *parser, char *chunk, int len)
200
- {
201
- return XML_Parse(parser->expat, chunk, len, 0);
202
- }