1 /* gdict-server-context.h - Implementation of a dictionary protocol client context 2 * 3 * Copyright (C) 2005 Emmanuele Bassi <ebassi@gmail.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with this library. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef __GDICT_CLIENT_CONTEXT_H__ 20 #define __GDICT_CLIENT_CONTEXT_H__ 21 22 #include "gdict-context.h" 23 24 #define GDICT_TYPE_CLIENT_CONTEXT (gdict_client_context_get_type ()) 25 #define GDICT_CLIENT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDICT_TYPE_CLIENT_CONTEXT, GdictClientContext)) 26 #define GDICT_IS_CLIENT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDICT_TYPE_CLIENT_CONTEXT)) 27 #define GDICT_CLIENT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDICT_TYPE_CLIENT_CONTEXT, GdictClientContextClass)) 28 #define GDICT_CLIENT_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDICT_TYPE_CLIENT_CONTEXT, GdictClientContextClass)) 29 30 typedef struct _GdictClientContext GdictClientContext; 31 typedef struct _GdictClientContextClass GdictClientContextClass; 32 typedef struct _GdictClientContextPrivate GdictClientContextPrivate; 33 34 #define GDICT_CLIENT_CONTEXT_ERROR (gdict_client_context_error_quark ()) 35 36 /** 37 * GdictClientContextError: 38 * @GDICT_CLIENT_CONTEXT_ERROR_SOCKET: 39 * @GDICT_CLIENT_CONTEXT_ERROR_LOOKUP: 40 * @GDICT_CLIENT_CONTEXT_ERROR_NO_CONNECTION: 41 * @GDICT_CLIENT_CONTEXT_ERROR_SERVER_DOWN: 42 * 43 * #GdictClientContext error enumeration 44 */ 45 typedef enum { 46 GDICT_CLIENT_CONTEXT_ERROR_SOCKET, 47 GDICT_CLIENT_CONTEXT_ERROR_LOOKUP, 48 GDICT_CLIENT_CONTEXT_ERROR_NO_CONNECTION, 49 GDICT_CLIENT_CONTEXT_ERROR_SERVER_DOWN 50 } GdictClientContextError; 51 52 GQuark gdict_client_context_error_quark (void); 53 54 struct _GdictClientContext 55 { 56 /*< private >*/ 57 GObject parent_instance; 58 59 GdictClientContextPrivate *priv; 60 }; 61 62 struct _GdictClientContextClass 63 { 64 /*< private >*/ 65 GObjectClass parent_class; 66 67 /*< public >*/ 68 /* signals monitoring the lifetime of the connection with 69 * the dictionary server 70 */ 71 void (*connected) (GdictClientContext *context); 72 void (*disconnected) (GdictClientContext *context); 73 74 /*< private >*/ 75 /* padding for future expansion */ 76 void (*_gdict_client_1) (void); 77 void (*_gdict_client_2) (void); 78 void (*_gdict_client_3) (void); 79 void (*_gdict_client_4) (void); 80 }; 81 82 GType gdict_client_context_get_type (void) G_GNUC_CONST; 83 84 GdictContext * gdict_client_context_new (const gchar *hostname, 85 gint port); 86 87 void gdict_client_context_set_hostname (GdictClientContext *context, 88 const gchar *hostname); 89 const gchar * gdict_client_context_get_hostname (GdictClientContext *context); 90 void gdict_client_context_set_port (GdictClientContext *context, 91 gint port); 92 guint gdict_client_context_get_port (GdictClientContext *context); 93 void gdict_client_context_set_client (GdictClientContext *context, 94 const gchar *client); 95 const gchar * gdict_client_context_get_client (GdictClientContext *context); 96 97 #endif /* __GDICT_CLIENT_CONTEXT_H__ */ 98