예제 #1
0
/*------------------------------------------------------------------------
 * User as closed the chat window, and the chatroom is not marked as persistent.
 *
 *  @param gc			The connection object
 *  @param id			The chat room ID
 */
void mxit_chat_leave(PurpleConnection *gc, int id)
{
	struct MXitSession* session = (struct MXitSession*) gc->proto_data;
	struct multimx* multimx = NULL;

	purple_debug_info(MXIT_PLUGIN_ID, "Groupchat %i leave\n", id);

	/* Find matching multimx group */
	multimx = find_room_by_id(session, id);
	if (multimx == NULL) {
		purple_debug_error(MXIT_PLUGIN_ID, "Could not find groupchat %i\n", id);
		return;
	}

	/* Send Remove Groupchat to MXit */
	mxit_send_remove(session, multimx->roomid);

	/* Remove from our list of rooms */
	room_remove(session, multimx);
}
예제 #2
0
/*------------------------------------------------------------------------
 * User has rejected an invite to join a MultiMX room.
 *
 *  @param gc			The connection object
 *  @param components	The list of chat configuration values
 */
void mxit_chat_reject(PurpleConnection *gc, GHashTable* components)
{
	struct MXitSession* session = (struct MXitSession*) gc->proto_data;
	const char* roomname = NULL;
	struct multimx* multimx = NULL;

	purple_debug_info(MXIT_PLUGIN_ID, "mxit_chat_reject\n");

	roomname = g_hash_table_lookup(components, "room");
	multimx = find_room_by_alias(session, roomname);
	if (multimx == NULL) {
		purple_debug_error(MXIT_PLUGIN_ID, "Groupchat '%s' not found\n", roomname);
		return;
	}

	/* Send Subscription Reject to MXit */
	mxit_send_deny_sub(session, multimx->roomid);

	/* Remove from our list of rooms */
	room_remove(session, multimx);
}
예제 #3
0
static void automap_calc_exits(loc_node *location, int depth)
{
  unsigned i, n;
  loc_node *proposed[NUM_DIRS];         /* Store proposed edges here */
  BOOL is_oneway[NUM_DIRS];
  
  /* Remove fake locations */
  for(i = 0; i < NUM_DIRS; i++) {
    loc_node *curdest = automap_edge_follow(location, i);
    if(curdest && !curdest->real)
      room_remove(curdest);
  }

  /* Default to things going the way they actually do */
  for(i = 0; i < NUM_DIRS; i++) {
    proposed[i] = location->exits[i];
    is_oneway[i] = FALSE;
  }
  
  /* Get rid of superfluous exits */
  for(i = 0; i < NUM_DIRS; i++) {
    if(proposed[i]) {
      for(n = i+1; n < NUM_DIRS; n++) {
	if(proposed[n] == proposed[i]) {
	  if(proposed[i]->exits[REVERSE_DIR(n)] == location) {
	    proposed[i] = NULL;
	    break;
	  }
	  if(proposed[i]->exits[REVERSE_DIR(i)] == location)
	    proposed[n] = NULL;
	}
      }
    }
  }

  /* Handle forced movement */
  for(i = 0; i < NUM_DIRS; i++) {
    if(proposed[i] && proposed[i] == location->exits[DIR_WAIT]) {
      if(proposed[i]->exits[REVERSE_DIR(i)] != location)
	proposed[i] = NULL;
    }
  }
  
  /* Check for one way and bent passages */
  for(i = 0; i < NUM_DIRS; i++) {
    if(proposed[i] && proposed[i]->found
       && proposed[i]->exits[REVERSE_DIR(i)] != location) {
      is_oneway[i] = TRUE;
      for(n = 0; n < NUM_DIRS; n++) {
	if(n != i && proposed[i]->exits[n] == location) {
	  loc_node *newnode = room_find_or_create(automap_get_cookie(), FALSE);
	    
	  is_oneway[i] = FALSE;
	  newnode->found = TRUE;
	    
	  automap_set_virtual_connection(proposed[i], n, newnode, FALSE);
	  proposed[i] = newnode;
	}
      }
    }
  }

  /* If it's a one way passage, but there are up/down exits connecting the two,
     ignore the passage */
  for(i = 0; i < NUM_DIRS; i++) {
    if(is_oneway[i] && proposed[i]
	 && ((location->exits[DIR_UP] == proposed[i]
	      && proposed[i]->exits[DIR_DOWN] == location)
	     || (location->exits[DIR_DOWN] == proposed[i]
		 && proposed[i]->exits[DIR_UP] == location))) {
      proposed[i] = 0;
      is_oneway[i] = FALSE;
    }
  }

  /* Create the proposed passages */
  for(i = 0; i < NUM_DIRS; i++)
    automap_set_virtual_connection(location, i, proposed[i], is_oneway[i]);
  
  /* Explore neighbors */
  if(depth) {
    for(i = 0; i < NUM_DIRS; i++)
      automap_calc_exits(location->exits[i], depth-1);
  }
}