author | hallski <hallski> |
Fri, 11 Jul 2003 23:56:22 +0000 | |
changeset 15 | 1ff2f81867e1 |
parent 7 | d8eae83450ac |
child 57 | 6b168a8917f7 |
permissions | -rw-r--r-- |
1 | 1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
2 |
/* |
|
7
d8eae83450ac
2003-06-13 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
4
diff
changeset
|
3 |
* Copyright (C) 2003 Mikael Hallendal <micke@imendio.com> |
1 | 4 |
* Copyright (C) 2003 CodeFactory AB. |
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU Lesser General Public License as |
|
8 |
* published by the Free Software Foundation; either version 2 of the |
|
9 |
* License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 |
* Lesser General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU Lesser General Public |
|
17 |
* License along with this program; if not, write to the |
|
18 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
19 |
* Boston, MA 02111-1307, USA. |
|
20 |
*/ |
|
21 |
||
22 |
#ifndef __LM_CONNECTION_H__ |
|
23 |
#define __LM_CONNECTION_H__ |
|
24 |
||
25 |
#if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION) |
|
26 |
#error "Only <loudmouth/loudmouth.h> can be included directly, this file may di\sappear or change contents." |
|
27 |
#endif |
|
28 |
||
29 |
#include <loudmouth/lm-message.h> |
|
30 |
||
31 |
#define LM_CONNECTION(o) (LmConnection *) o; |
|
32 |
||
33 |
#define LM_CONNECTION_DEFAULT_PORT 5222 |
|
34 |
#define LM_CONNECTION_DEFAULT_PORT_SSL 5223 |
|
35 |
||
36 |
typedef struct _LmConnection LmConnection; |
|
37 |
||
38 |
typedef struct LmMessageHandler LmMessageHandler; |
|
39 |
||
40 |
typedef enum { |
|
41 |
LM_HANDLER_RESULT_REMOVE_MESSAGE, |
|
42 |
LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS |
|
43 |
} LmHandlerResult; |
|
44 |
||
45 |
typedef enum { |
|
46 |
LM_HANDLER_PRIORITY_LAST = 1, |
|
47 |
LM_HANDLER_PRIORITY_NORMAL = 2, |
|
48 |
LM_HANDLER_PRIORITY_FIRST = 3 |
|
49 |
} LmHandlerPriority; |
|
50 |
||
51 |
typedef enum { |
|
52 |
LM_DISCONNECT_REASON_OK, |
|
53 |
LM_DISCONNECT_REASON_PING_TIME_OUT, |
|
54 |
LM_DISCONNECT_REASON_HUP, |
|
55 |
LM_DISCONNECT_REASON_ERROR, |
|
56 |
LM_DISCONNECT_REASON_UNKNOWN |
|
57 |
} LmDisconnectReason; |
|
58 |
||
59 |
typedef void (* LmResultFunction) (LmConnection *connection, |
|
60 |
gboolean success, |
|
61 |
gpointer user_data); |
|
62 |
||
63 |
typedef void (* LmDisconnectFunction) (LmConnection *connection, |
|
64 |
LmDisconnectReason reason, |
|
65 |
gpointer user_data); |
|
66 |
||
67 |
||
68 |
LmConnection *lm_connection_new (const gchar *server); |
|
69 |
gboolean lm_connection_open (LmConnection *connection, |
|
70 |
LmResultFunction function, |
|
71 |
gpointer user_data, |
|
72 |
GDestroyNotify notify, |
|
73 |
GError **error); |
|
74 |
gboolean lm_connection_open_and_block (LmConnection *connection, |
|
75 |
GError **error); |
|
76 |
||
77 |
gboolean lm_connection_close (LmConnection *connection, |
|
78 |
GError **error); |
|
79 |
gboolean lm_connection_authenticate (LmConnection *connection, |
|
80 |
const gchar *username, |
|
81 |
const gchar *password, |
|
82 |
const gchar *resource, |
|
83 |
LmResultFunction function, |
|
84 |
gpointer user_data, |
|
85 |
GDestroyNotify notify, |
|
86 |
GError **error); |
|
87 |
gboolean |
|
88 |
lm_connection_authenticate_and_block (LmConnection *connection, |
|
89 |
const gchar *username, |
|
90 |
const gchar *password, |
|
91 |
const gchar *resource, |
|
92 |
GError **error); |
|
93 |
gboolean lm_connection_is_open (LmConnection *connection); |
|
94 |
gboolean lm_connection_is_authenticated (LmConnection *connection); |
|
95 |
||
96 |
const gchar * lm_connection_get_server (LmConnection *connection); |
|
97 |
void lm_connection_set_server (LmConnection *connection, |
|
98 |
const gchar *server); |
|
99 |
||
100 |
guint lm_connection_get_port (LmConnection *connection); |
|
101 |
void lm_connection_set_port (LmConnection *connection, |
|
102 |
guint port); |
|
15
1ff2f81867e1
2003-07-12 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
7
diff
changeset
|
103 |
gboolean lm_connection_supports_ssl (void); |
1 | 104 |
gboolean lm_connection_get_use_ssl (LmConnection *connection); |
105 |
void lm_connection_set_use_ssl (LmConnection *connection, |
|
106 |
gboolean use_ssl); |
|
107 |
||
108 |
gboolean lm_connection_send (LmConnection *connection, |
|
109 |
LmMessage *message, |
|
110 |
GError **error); |
|
111 |
gboolean lm_connection_send_with_reply (LmConnection *connection, |
|
112 |
LmMessage *message, |
|
113 |
LmMessageHandler *handler, |
|
114 |
GError **error); |
|
115 |
LmMessage * |
|
116 |
lm_connection_send_with_reply_and_block (LmConnection *connection, |
|
117 |
LmMessage *message, |
|
118 |
GError **error); |
|
119 |
void |
|
120 |
lm_connection_register_message_handler (LmConnection *connection, |
|
121 |
LmMessageHandler *handler, |
|
122 |
LmMessageType type, |
|
123 |
LmHandlerPriority priority); |
|
124 |
void |
|
125 |
lm_connection_unregister_message_handler (LmConnection *connection, |
|
126 |
LmMessageHandler *handler, |
|
127 |
LmMessageType type); |
|
128 |
void |
|
129 |
lm_connection_set_disconnect_function (LmConnection *connection, |
|
130 |
LmDisconnectFunction function, |
|
131 |
gpointer user_data, |
|
132 |
GDestroyNotify notify); |
|
133 |
||
134 |
gboolean lm_connection_send_raw (LmConnection *connection, |
|
135 |
const gchar *str, |
|
136 |
GError **error); |
|
137 |
LmConnection* lm_connection_ref (LmConnection *connection); |
|
138 |
void lm_connection_unref (LmConnection *connection); |
|
139 |
||
140 |
#endif /* __LM_CONNECTION_H__ */ |