paulo@0: /* paulo@0: * $Id: gt_share_state.h,v 1.2 2004/03/31 08:58:24 hipnod Exp $ paulo@0: * paulo@0: * Copyright (C) 2004 giFT project (gift.sourceforge.net) paulo@0: * paulo@0: * This program is free software; you can redistribute it and/or modify it paulo@0: * under the terms of the GNU General Public License as published by the paulo@0: * Free Software Foundation; either version 2, or (at your option) any paulo@0: * later version. paulo@0: * paulo@0: * This program is distributed in the hope that it will be useful, but paulo@0: * WITHOUT ANY WARRANTY; without even the implied warranty of paulo@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU paulo@0: * General Public License for more details. paulo@0: */ paulo@0: paulo@0: #ifndef GIFT_GT_SHARE_STATE_H_ paulo@0: #define GIFT_GT_SHARE_STATE_H_ paulo@0: paulo@0: /******************************************************************************/ paulo@0: paulo@0: /* paulo@0: * Keep track of the "hidden" share status on the remote node. To paulo@0: * disable sharing, the node is sent a HopsFlow message with a payload of 0, paulo@0: * telling it not to send us any queries. If the HopsFlow message isn't paulo@0: * supported, the query handling code can simply drop the queries paulo@0: * (alternatively, the QRT could be manipulated, but that's more complicated). paulo@0: * paulo@0: * There are two variables to deal with: giftd may have disabled sharing, and paulo@0: * the plugin may have flow-controlled the remote node. When either of these paulo@0: * conditions becomes true, the node is sent the HopsFlow message to disable paulo@0: * receipt of queries. Only when both these conditions become false does the paulo@0: * node receive another HopsFlow with a payload of 8, allowing the node to send paulo@0: * us queries again. paulo@0: * paulo@0: * giftd's hidden state is tracked by gt_share_state.c. Here, each node's paulo@0: * hidden state is tracked: paulo@0: */ paulo@0: struct gt_share_state paulo@0: { paulo@0: BOOL hidden; /* sharing is disabled for this node */ paulo@0: BOOL plugin_hidden; /* plugin disabled it (flow control) */ paulo@0: }; paulo@0: paulo@0: /*****************************************************************************/ paulo@0: paulo@0: struct gt_share_state *gt_share_state_new (void); paulo@0: void gt_share_state_free (struct gt_share_state *state); paulo@0: paulo@0: /*****************************************************************************/ paulo@0: paulo@0: /* update the node about our sharing status, possibly by sending it a HopsFlow paulo@0: * message */ paulo@0: void gt_share_state_update (struct gt_node *node); paulo@0: paulo@0: /* control share disabling on each individual node (as opposed to locally) */ paulo@0: void gt_share_state_hide (struct gt_node *node); paulo@0: void gt_share_state_show (struct gt_node *node); paulo@0: paulo@0: /*****************************************************************************/ paulo@0: paulo@0: void gt_share_state_local_init (void); paulo@0: void gt_share_state_local_cleanup (void); paulo@0: paulo@0: /*****************************************************************************/ paulo@0: paulo@0: void gnutella_share_hide (Protocol *p); paulo@0: void gnutella_share_show (Protocol *p); paulo@0: paulo@0: /******************************************************************************/ paulo@0: paulo@0: #endif /* GIFT_GT_SHARE_STATE_H_ */