~ubuntu-branches/ubuntu/maverick/telepathy-salut/maverick

« back to all changes in this revision

Viewing changes to lib/gibber/gibber-xmpp-connection.c

  • Committer: Bazaar Package Importer
  • Author(s): Sjoerd Simons
  • Date: 2007-06-13 10:54:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070613105425-mwwsplxbk8n6z5t6
Tags: 0.1.3-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
static guint signals[LAST_SIGNAL] = {0};
54
54
 
55
 
/* properties */
56
 
enum 
57
 
58
 
  PROP_STREAMING = 1,
59
 
  LAST_PROPERTY
60
 
};
61
 
 
62
55
static void 
63
56
_reader_stream_opened_cb(GibberXmppReader *reader, 
64
57
                         const gchar *to, const gchar *from,
79
72
{
80
73
  GibberXmppReader *reader;
81
74
  GibberXmppWriter *writer;
82
 
  gboolean streaming; 
83
75
  gboolean dispose_has_run;
84
76
  gboolean stream_opened;
85
77
};
99
91
 
100
92
  priv = GIBBER_XMPP_CONNECTION_GET_PRIVATE (obj);
101
93
 
102
 
  if (priv->streaming) { 
103
 
    priv->writer = gibber_xmpp_writer_new();
104
 
    priv->reader = gibber_xmpp_reader_new();
105
 
    priv->stream_opened = FALSE;
106
 
 
107
 
    g_signal_connect(priv->reader, "stream-opened", 
108
 
                      G_CALLBACK(_reader_stream_opened_cb), obj);
109
 
    g_signal_connect(priv->reader, "stream-closed", 
110
 
                      G_CALLBACK(_reader_stream_closed_cb), obj);
111
 
  } else {
112
 
    priv->writer = gibber_xmpp_writer_new_no_stream();
113
 
    priv->reader = gibber_xmpp_reader_new_no_stream();
114
 
    priv->stream_opened = TRUE;
115
 
  }  
116
 
 
 
94
  priv->writer = gibber_xmpp_writer_new();
 
95
  priv->reader = gibber_xmpp_reader_new();
 
96
  priv->stream_opened = FALSE;
 
97
 
 
98
  g_signal_connect(priv->reader, "stream-opened", 
 
99
                   G_CALLBACK(_reader_stream_opened_cb), obj);
 
100
  g_signal_connect(priv->reader, "stream-closed", 
 
101
                   G_CALLBACK(_reader_stream_closed_cb), obj);
117
102
  g_signal_connect(priv->reader, "received-stanza", 
118
103
                    G_CALLBACK(_reader_received_stanza_cb), obj);
119
104
 
121
106
}
122
107
 
123
108
static void
124
 
gibber_xmpp_connection_set_property (GObject     *object,
125
 
                                     guint        property_id,
126
 
                                     const GValue *value,
127
 
                                     GParamSpec   *pspec)
128
 
{
129
 
  GibberXmppConnection *conn = GIBBER_XMPP_CONNECTION(object);
130
 
  GibberXmppConnectionPrivate *priv = GIBBER_XMPP_CONNECTION_GET_PRIVATE(conn);
131
 
 
132
 
  switch (property_id) {
133
 
    case PROP_STREAMING:
134
 
      priv->streaming = g_value_get_boolean(value);
135
 
      break;
136
 
    default:
137
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
138
 
      break;
139
 
  }
140
 
}
141
 
 
142
 
static void
143
 
gibber_xmpp_connection_get_property (GObject     *object,
144
 
                                     guint        property_id,
145
 
                                     GValue *value,
146
 
                                     GParamSpec   *pspec) {
147
 
  GibberXmppConnection *conn = GIBBER_XMPP_CONNECTION(object);
148
 
  GibberXmppConnectionPrivate *priv = GIBBER_XMPP_CONNECTION_GET_PRIVATE(conn);
149
 
 
150
 
  switch (property_id) {
151
 
    case PROP_STREAMING:
152
 
      g_value_set_boolean(value, priv->streaming);
153
 
      break;
154
 
    default:
155
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
156
 
      break;
157
 
  }
158
 
}
159
 
 
160
 
static void
161
109
gibber_xmpp_connection_init (GibberXmppConnection *obj) {
162
110
  obj->transport = NULL;
163
111
}
169
117
gibber_xmpp_connection_class_init (GibberXmppConnectionClass *gibber_xmpp_connection_class)
170
118
{
171
119
  GObjectClass *object_class = G_OBJECT_CLASS (gibber_xmpp_connection_class);
172
 
  GParamSpec *param_spec;
173
120
 
174
121
  g_type_class_add_private (gibber_xmpp_connection_class, sizeof (GibberXmppConnectionPrivate));
175
122
 
177
124
  object_class->finalize = gibber_xmpp_connection_finalize;
178
125
 
179
126
  object_class->constructor = gibber_xmpp_connection_constructor;
180
 
  object_class->get_property = gibber_xmpp_connection_get_property;
181
 
  object_class->set_property = gibber_xmpp_connection_set_property;
182
 
 
183
127
 
184
128
  signals[STREAM_OPENED] = 
185
129
    g_signal_new("stream-opened", 
213
157
                 NULL, NULL,
214
158
                 g_cclosure_marshal_VOID__VOID,
215
159
                 G_TYPE_NONE, 0);
216
 
 
217
 
  param_spec = g_param_spec_boolean ("streaming",
218
 
                                     "streaming",
219
 
                                     "Whether this is an streaming" 
220
 
                                     "xmpp connection",
221
 
                                     TRUE,
222
 
                                     G_PARAM_CONSTRUCT_ONLY |
223
 
                                     G_PARAM_READWRITE      |
224
 
                                     G_PARAM_STATIC_NAME    |
225
 
                                     G_PARAM_STATIC_BLURB);
226
 
  g_object_class_install_property(object_class, PROP_STREAMING, param_spec);
227
 
 
228
 
   
229
160
}
230
161
 
231
162
void
270
201
new_connection(GibberTransport *transport, gboolean stream)  {
271
202
  GibberXmppConnection * result;
272
203
 
273
 
  result = g_object_new(GIBBER_TYPE_XMPP_CONNECTION, "streaming", stream, NULL);
 
204
  result = g_object_new(GIBBER_TYPE_XMPP_CONNECTION, NULL);
274
205
 
275
206
  if (transport != NULL) {
276
207
    gibber_xmpp_connection_engage(result, transport);