/* Jungle Monkey
* Copyright (C) 1999-2001 The Regents of the University of Michigan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
Jungle Monkey Multicast Search Protocol client
The client creates or joins a JMMSP group. Call jmmsp_query and
jmmsp_reply to send packets to the group. You can set handlers to
process query and reply packets sent to the group.
*/
#ifndef _JMMSP_H
#define _JMMSP_H
#include <glib.h>
#include "btp/btp.h"
typedef struct _JMMSP JMMSP;
typedef struct _JMMSPHandler JMMSPHandler;
typedef struct _JMMSPReply JMMSPReply;
typedef void (*JMMSPQueryFunc)(JMMSPHandler* handler, JMMSP* jmmsp,
const gchar* keyword);
typedef void (*JMMSPReplyFunc)(JMMSPHandler* handler, JMMSP* jmmsp,
const gchar* keyword, const JMMSPReply* reply);
typedef void (*JMMSPDestroyFunc)(JMMSPHandler* handler, JMMSP* jmmsp);
typedef void (*JMMSPErrorFunc)(JMMSPHandler* handler, JMMSP* jmmsp);
typedef void (*JMMSPErrorUpFunc)(JMMSP* jmmsp, gpointer user_data);
typedef struct _JMMSPHandlerFuncs
{
JMMSPQueryFunc query;
JMMSPReplyFunc reply;
JMMSPDestroyFunc destroy;
JMMSPErrorFunc error;
} JMMSPHandlerFuncs;
struct _JMMSPHandler
{
JMMSPHandlerFuncs* funcs;
gboolean is_enabled;
GSList* jmmsps;
gboolean loopback;
};
struct _JMMSPReply
{
gchar* name;
GURL* url;
gint length;
};
struct _JMMSP
{
BPeer* peer;
GURL* url;
Btp* btp;
gboolean is_local;
gboolean is_down;
GSList* handlers;
JMMSPErrorUpFunc error_func; /* 'NULL' handler error func */
gpointer user_data;
};
/* ******************** */
JMMSP* jmmsp_create (BPeer* bpeer, const gchar* name);
JMMSP* jmmsp_join (BPeer* bpeer, const GURL* url);
JMMSP* jmmsp_setup (BPeer* bpeer, const GURL* url);
gboolean jmmsp_rejoin (JMMSP* jmmsp); /* FALSE = success */
void jmmsp_leave (JMMSP* jmmsp);
void jmmsp_delete (JMMSP* jmmsp);
#define jmmsp_is_up(J) ((J)->btp != NULL)
#define jmmsp_is_down(J) ((J)->is_down)
void jmmsp_send_query (JMMSP* jmmsp, const gchar* keyword, gint ttl);
void jmmsp_send_reply (JMMSP* jmmsp, const gchar* keyword,
JMMSPReply* reply, gint ttl);
void jmmsp_add_handler (JMMSP* jmmsp, JMMSPHandler* handler);
void jmmsp_remove_handler (JMMSP* jmmsp, JMMSPHandler* handler);
/* ******************** */
void jmmsp_handler_init (JMMSPHandler* handler, JMMSPHandlerFuncs* funcs);
void jmmsp_handler_uninit (JMMSPHandler* handler);
void jmmsp_handler_set_enabled (JMMSPHandler* handler, gboolean is_enabled);
gboolean jmmsp_handler_is_enabled (JMMSPHandler* handler);
/* ******************** */
void jmmsp_reply_delete (JMMSPReply* reply);
JMMSPReply* jmmsp_reply_clone (const JMMSPReply* reply);
gint jmmsp_reply_equal (gconstpointer a, gconstpointer b);
guint jmmsp_reply_hash (gconstpointer p);
guint jmmsp_reply_size (const JMMSPReply* reply);
gboolean jmmsp_reply_matches (const JMMSPReply* reply, const gchar* query);
#endif /* _JMMSP_H */
syntax highlighted by Code2HTML, v. 0.9.1