telepathygabble/inc/disco.h
changeset 10 59927b2d3b75
parent 0 d0f3a028347a
equal deleted inserted replaced
0:d0f3a028347a 10:59927b2d3b75
     1 /*
       
     2  * disco.h - Headers for Gabble service discovery
       
     3  *
       
     4  * Copyright (C) 2006 Collabora Ltd.
       
     5  * 
       
     6  *
       
     7  * This library is free software; you can redistribute it and/or
       
     8  * modify it under the terms of the GNU Lesser General Public
       
     9  * License as published by the Free Software Foundation; either
       
    10  * version 2.1 of the License, or (at your option) any later version.
       
    11  *
       
    12  * This library is distributed in the hope that it will be useful,
       
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    15  * Lesser General Public License for more details.
       
    16  *
       
    17  * You should have received a copy of the GNU Lesser General Public
       
    18  * License along with this library; if not, write to the Free Software
       
    19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
       
    20  *
       
    21  * -- LET'S DISCO!!!  \o/ \o_ _o/ /\o/\ _/o/- -\o\_ --
       
    22  */
       
    23 
       
    24 #ifndef __GABBLE_DISCO_H__
       
    25 #define __GABBLE_DISCO_H__
       
    26 
       
    27 #include <glib-object.h>
       
    28 #include "loudmouth/loudmouth.h"
       
    29 
       
    30 #include "gabble-types.h"
       
    31 
       
    32 G_BEGIN_DECLS
       
    33 
       
    34 typedef enum
       
    35 {
       
    36   GABBLE_DISCO_TYPE_INFO,
       
    37   GABBLE_DISCO_TYPE_ITEMS
       
    38 } GabbleDiscoType;
       
    39 
       
    40 typedef struct _GabbleDiscoClass GabbleDiscoClass;
       
    41 typedef struct _GabbleDiscoRequest GabbleDiscoRequest;
       
    42 
       
    43 /**
       
    44  * GabbleDiscoError:
       
    45  * @GABBLE_DISCO_ERROR_CANCELLED: The DISCO request was cancelled
       
    46  * @GABBLE_DISCO_ERROR_TIMEOUT: The DISCO request timed out
       
    47  * @GABBLE_DISCO_ERROR_UNKNOWN: An unknown error occured
       
    48  */
       
    49 typedef enum
       
    50 {
       
    51   GABBLE_DISCO_ERROR_CANCELLED,
       
    52   GABBLE_DISCO_ERROR_TIMEOUT,
       
    53   GABBLE_DISCO_ERROR_UNKNOWN
       
    54 } GabbleDiscoError;
       
    55 
       
    56 GQuark gabble_disco_error_quark (void);
       
    57 #define GABBLE_DISCO_ERROR gabble_disco_error_quark ()
       
    58 
       
    59 IMPORT_C GType gabble_disco_get_type(void);
       
    60 
       
    61 /* TYPE MACROS */
       
    62 #define GABBLE_TYPE_DISCO \
       
    63   (gabble_disco_get_type())
       
    64 #define GABBLE_DISCO(obj) \
       
    65   (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_DISCO, GabbleDisco))
       
    66 #define GABBLE_DISCO_CLASS(klass) \
       
    67   (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_DISCO, GabbleDiscoClass))
       
    68 #define GABBLE_IS_DISCO(obj) \
       
    69   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_DISCO))
       
    70 #define GABBLE_IS_DISCO_CLASS(klass) \
       
    71   (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_DISCO))
       
    72 #define GABBLE_DISCO_GET_CLASS(obj) \
       
    73   (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_DISCO, GabbleDiscoClass))
       
    74 
       
    75 struct _GabbleDiscoClass {
       
    76     GObjectClass parent_class;
       
    77 };
       
    78 
       
    79 struct _GabbleDisco {
       
    80     GObject parent;
       
    81     gpointer priv;
       
    82 };
       
    83 
       
    84 typedef void (*GabbleDiscoCb)(GabbleDisco *self, GabbleDiscoRequest *request, const gchar *jid, const gchar *node, LmMessageNode *query_result, GError* error, gpointer user_data);
       
    85 
       
    86 GabbleDisco *gabble_disco_new (GabbleConnection *);
       
    87 
       
    88 GabbleDiscoRequest *gabble_disco_request (GabbleDisco *self,
       
    89     GabbleDiscoType type, const gchar *jid, const char *node,
       
    90     GabbleDiscoCb callback, gpointer user_data, GObject *object,
       
    91     GError **error);
       
    92 GabbleDiscoRequest *gabble_disco_request_with_timeout (GabbleDisco *self,
       
    93     GabbleDiscoType type, const gchar *jid, const char *node,
       
    94     guint timeout, GabbleDiscoCb callback, gpointer user_data,
       
    95     GObject *object, GError **error);
       
    96 
       
    97 void gabble_disco_cancel_request (GabbleDisco *, GabbleDiscoRequest *);
       
    98 
       
    99 /* Pipelines */
       
   100 
       
   101 typedef struct _GabbleDiscoItem GabbleDiscoItem;
       
   102 
       
   103 struct _GabbleDiscoItem {
       
   104     const gchar *jid;
       
   105     const char *name;
       
   106     const char *type;
       
   107     const char *category;
       
   108     GHashTable *features;
       
   109 };
       
   110 
       
   111 typedef void (*GabbleDiscoPipelineCb)(gpointer pipeline,
       
   112                                       GabbleDiscoItem *item,
       
   113                                       gpointer user_data);
       
   114 
       
   115 typedef void (*GabbleDiscoEndCb)(gpointer pipeline,
       
   116                                  gpointer user_data);
       
   117 
       
   118 gpointer gabble_disco_pipeline_init (GabbleDisco *disco,
       
   119                                      GabbleDiscoPipelineCb callback,
       
   120                                      GabbleDiscoEndCb end_callback,
       
   121                                      gpointer user_data);
       
   122 
       
   123 void gabble_disco_pipeline_run (gpointer self, const char *server);
       
   124 void gabble_disco_pipeline_destroy (gpointer self);
       
   125 
       
   126 /* Service discovery */
       
   127 
       
   128 void gabble_disco_service_discovery (GabbleDisco *disco, const char *server);
       
   129 const GabbleDiscoItem *
       
   130 gabble_disco_service_find (GabbleDisco *disco,
       
   131                            const char *type,
       
   132                            const char *category,
       
   133                            const char *feature);
       
   134 
       
   135 G_END_DECLS
       
   136 
       
   137 #endif