void rc_pop_contacts(PurpleGroup * grp)
{
  if (!grp) return;

  PurpleBlistNode * gnode = PURPLE_BLIST_NODE(grp);
  PurpleBlistNode * n = NULL;
  PurpleBuddy * b = NULL;
  int total;
  gboolean offline;

  //XXX group->totalsize is unreliable!!!

  for (n=gnode->child, total=0; n!=NULL; total++, n=n->next);
  trace("Total Group Count %d", total);

  while (total > g_size) {

    n = gnode->child;

    if (PURPLE_BLIST_NODE_IS_CONTACT(n)) {
      trace("Child Contact : %s", (PURPLE_CONTACT(n)->priority->name));
      b = PURPLE_CONTACT(n)->priority;
    } else if (PURPLE_BLIST_NODE_IS_BUDDY(n)) {
      trace("Child Buddy : %s", (PURPLE_BUDDY(n)->name));
      b = PURPLE_BUDDY(n);
    }

    n = PURPLE_BLIST_NODE(b);
    const char *name = purple_blist_node_get_string(n, NODE_GROUP_KEY);
    if (!name) {  // if cannot find orig group name, put back to Buddies
      trace("ERROR!!! cannot find original group name"); 
      name = "Buddies"; 
    }
    PurpleGroup * g = purple_find_group(name);
    if (!g) {
      trace("Group %s Not Found. Create one.", name);
      g = purple_group_new(name);
    }
    trace("<<<<<<< Remove %s", b->name);

    offline = purple_blist_node_get_bool(n, NODE_ORIG_OFFLINE_KEY);
    purple_blist_node_set_bool(n, NODE_OFFLINE_KEY, offline);
    purple_blist_add_buddy(b, NULL, g, NULL);

    total--;
  }
  
}
Exemple #2
0
BuddyListContact::BuddyListContact(PurpleBlistNode *node_)
: BuddyListNode(node_)
{
  setColorScheme("buddylistcontact");

  contact = PURPLE_CONTACT(blist_node);
}
static gpointer meebo_find_parent(PurpleBlistNode *node)
{
	if (PURPLE_IS_CONTACT(node)) {
		PurpleBuddy *buddy = purple_contact_get_priority_buddy(PURPLE_CONTACT(node));
		if (buddy && !PURPLE_BUDDY_IS_ONLINE(buddy)) {
			return &meebo;
		}
	}
	return default_manager->find_parent(node);
}
static gpointer on_offline_find_parent(PurpleBlistNode *node)
{
	gpointer ret = NULL;

	if (PURPLE_IS_CONTACT(node)) {
		node = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node)));
		ret = PURPLE_BUDDY_IS_ONLINE(PURPLE_BUDDY(node)) ? online : offline;
	} else if (PURPLE_IS_BUDDY(node)) {
		ret = purple_blist_node_get_parent(node);
		finch_blist_manager_add_node(ret);
	} else if (PURPLE_IS_CHAT(node)) {
		ret = online;
	}

	return ret;
}
static gboolean on_offline_can_add_node(PurpleBlistNode *node)
{
	if (PURPLE_IS_CONTACT(node)) {
		PurpleContact *contact = PURPLE_CONTACT(node);
		if (purple_counting_node_get_current_size(PURPLE_COUNTING_NODE(contact)) > 0)
			return TRUE;
		return FALSE;
	} else if (PURPLE_IS_BUDDY(node)) {
		PurpleBuddy *buddy = PURPLE_BUDDY(node);
		if (PURPLE_BUDDY_IS_ONLINE(buddy))
			return TRUE;
		if (purple_prefs_get_bool("/finch/blist/showoffline") &&
				purple_account_is_connected(purple_buddy_get_account(buddy)))
			return TRUE;
		return FALSE;
	} else if (PURPLE_IS_CHAT(node)) {
		PurpleChat *chat = PURPLE_CHAT(node);
		return purple_account_is_connected(purple_chat_get_account(chat));
	}

	return FALSE;
}
Exemple #6
0
void
purple_events_ui_menu_add(PurpleBlistNode *node, GList **menu, PurpleEventsContext *context)
{
    PurpleBlistNode *group = NULL;

    node = _purple_events_ui_get_good_node(node);
    if ( ( node == NULL ) || ( ( purple_blist_node_get_flags(node) & PURPLE_BLIST_NODE_FLAG_NO_SAVE ) > 0 ) )
        return;

    if ( PURPLE_BLIST_NODE_IS_CONTACT(node) )
        group = PURPLE_BLIST_NODE(purple_buddy_get_group(purple_contact_get_priority_buddy(PURPLE_CONTACT(node))));


    gint current = purple_blist_node_get_int(node, "events");
    GList *actions = NULL;
    PurpleMenuAction *action = NULL;

    const gchar *label = "";
    if ( current != 0 )
    {
        if ( PURPLE_BLIST_NODE_IS_GROUP(node) || ( purple_blist_node_get_int(group, "events") == 0 ) )
            label = _("Use global settings");
        else
            label = _("Use group settings");
        action = purple_menu_action_new(label, (PurpleCallback)_purple_events_ui_reset_setting, NULL, NULL);
        actions = g_list_prepend(actions, action);
    }
    if ( current >= 0 )
    {
        action = purple_menu_action_new(_("Disable all events"), (PurpleCallback)_purple_events_ui_disable_all_events, NULL, NULL);
        actions = g_list_prepend(actions, action);
    }

    action = purple_menu_action_new(_("Select events"), (PurpleCallback)_purple_events_ui_events_selection_dialog, context, NULL);
    actions = g_list_prepend(actions, action);

    switch ( current )
    {
    case -1:
        label = _("Current events: all disabled");
    break;
    case 0:
        if ( PURPLE_BLIST_NODE_IS_GROUP(node) || ( purple_blist_node_get_int(group, "events") == 0 ) )
            label = _("Current events: global settings");
        else
            label = _("Current events: group settings");
    break;
    case 1:
        label = _("Current events: selection");
    break;
    }
    actions = g_list_prepend(actions, NULL);
    action = purple_menu_action_new(label, NULL, NULL, NULL);
    actions = g_list_prepend(actions, action);

    *menu = g_list_append(*menu, NULL);
    action = purple_menu_action_new(_("Events"), NULL, NULL, actions);
    *menu = g_list_append(*menu, action);
}
Exemple #7
0
static void
_purple_events_ui_events_selection_dialog(PurpleBlistNode *node, PurpleEventsContext *context)
{
    node = _purple_events_ui_get_good_node(node);
    if ( node == NULL )
        return;

    PurpleRequestFields *request;
    PurpleRequestFieldGroup *group;
    PurpleRequestField *field;

    group = purple_request_field_group_new(NULL);

    gint current;
    guint i;
    gboolean v;
    for ( i = 0 ; _purple_events_ui_events[i] != NULL ; ++i )
    {
        current = purple_blist_node_get_int(node, _purple_events_ui_events[i]);
        if ( current != 0 )
            v = ( current > 0 );
        else
        {
            gchar *pref_name;

            pref_name = g_strconcat("/plugins/core/events/", _purple_events_ui_events[i], NULL);
            v = purple_prefs_get_bool(pref_name);
            g_free(pref_name);
        }

        field = purple_request_field_bool_new(_purple_events_ui_events[i], _(_purple_events_ui_events_labels[i]), v);
        purple_request_field_group_add_field(group, field);
    }

    request = purple_request_fields_new();
    purple_request_fields_add_group(request, group);

    purple_request_fields(context->plugin,
        _("Events selection"),
        PURPLE_BLIST_NODE_IS_CONTACT(node) ? _("Select events for contact") : _("Select events for group"),
        NULL,
        request,
        PURPLE_BLIST_NODE_IS_CONTACT(node) ? _("_Set events for contact") : _("_Set events for group"),
        G_CALLBACK(_purple_events_ui_events_selection),
        _("_Cancel"),
        NULL,
        NULL,
        PURPLE_BLIST_NODE_IS_CONTACT(node) ? purple_buddy_get_name(purple_contact_get_priority_buddy(PURPLE_CONTACT(node))) : NULL,
        NULL,
        node);

}