Exemplo n.º 1
0
void GeneralMenu::openRequestFieldsTest(CppConsUI::Button& /*activator*/)
{
  PurpleRequestFields *fields = purple_request_fields_new();
  PurpleRequestFieldGroup *g = purple_request_field_group_new("Group 0");

  purple_request_fields_add_group(fields, g);

  PurpleRequestField *f;
  f = purple_request_field_string_new("text0", "String field 0", "def0",
      FALSE);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("text1", "String field 1", NULL,
      FALSE);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_int_new("int0", "Int field 0", INT_MAX);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_bool_new("bool0", "Bool field 0", FALSE);
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_choice_new("choice0", "Choice field 0", 2);
  purple_request_field_choice_add(f, "One");
  purple_request_field_choice_add(f, "Two");
  purple_request_field_choice_add(f, "Three");
  purple_request_field_choice_add(f, "Four");
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_list_new("list0", "List field 0, multiple");
  purple_request_field_list_set_multi_select(f, TRUE);
  purple_request_field_list_add(f, "One", this);
  purple_request_field_list_add(f, "Two", this);
  purple_request_field_list_add(f, "Three", this);
  purple_request_field_list_add(f, "Four", this);
  purple_request_field_list_add_selected(f, "Three");
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_list_new("list1", "List field 1, single");
  purple_request_field_list_set_multi_select(f, FALSE);
  purple_request_field_list_add(f, "One", this);
  purple_request_field_list_add(f, "Two", this);
  purple_request_field_list_add(f, "Three", this);
  purple_request_field_list_add(f, "Four", this);
  purple_request_field_list_add_selected(f, "Three");
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_account_new("account0", "Account field 0", NULL);
  purple_request_field_account_set_show_all(f, TRUE);
  purple_request_field_group_add_field(g, f);

  purple_request_fields(NULL, "Title", "Primary", "Secondary", fields,
      "Ok", G_CALLBACK(fields_ok_cb_),
      "Cancel", NULL,
      NULL, NULL, NULL, this);

  close();
}
Exemplo n.º 2
0
void BuddyList::request_add_buddy(PurpleAccount *account,
    const char *username, const char *group, const char *alias)
{
  if (!CheckAnyAccountConnected())
    return;

  PurpleRequestFields *fields = purple_request_fields_new();
  PurpleRequestFieldGroup *g = purple_request_field_group_new(NULL);

  purple_request_fields_add_group(fields, g);

  PurpleRequestField *f;
  f = purple_request_field_account_new("account", _("Account"), account);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("name", _("Buddy name"), username,
      FALSE);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("alias", _("Alias"), alias, FALSE);
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_choice_new("group", _("Group"), 0);
  bool add_default_group = true;
  int dval = 0;
  bool dval_set = false;
  for (PurpleBlistNode *i = purple_blist_get_root(); i; i = i->next)
    if (PURPLE_BLIST_NODE_IS_GROUP(i)) {
      const char *cur_name = purple_group_get_name(
          reinterpret_cast<PurpleGroup*>(i));
      purple_request_field_choice_add(f, cur_name);
      if (!dval_set) {
        if (group && !strcmp(group, cur_name)) {
          purple_request_field_choice_set_default_value(f, dval);
          dval_set = true;
        }
        dval++;
      }
      add_default_group = false;
    }
  if (add_default_group)
      purple_request_field_choice_add(f, _("Buddies"));
  purple_request_field_group_add_field(g, f);

  purple_request_fields(NULL, _("Add buddy"), NULL, NULL, fields, _("Add"),
      G_CALLBACK(add_buddy_ok_cb_), CANCEL_BUTTON_TEXT, NULL, NULL, NULL,
      NULL, this);
}
Exemplo n.º 3
0
static void
lh_migrate_source_request_cb(void *ignored, PurpleRequestFields *fields)
{
    PurpleRequestFields *request;
    PurpleRequestFieldGroup *group;
    PurpleRequestField *field;

    source_account = purple_request_fields_get_account(fields,
                     "migrate_source_acct");
    valid_target_prpl_id = purple_account_get_protocol_id(source_account);

    /* It seems Purple is super-picky about the order of these first three calls */
    /* create a request */
    request = purple_request_fields_new();

    /* now create a field group */
    group = purple_request_field_group_new(NULL);
    /* and add that group to the request created above */
    purple_request_fields_add_group(request, group);

    /* create a field */
    field = purple_request_field_account_new("migrate_target_acct",
            _("Account"), NULL);

    /* mark the field as required */
    purple_request_field_set_required(field, TRUE);

    /* filter this list so that only accounts with the same prpl as the
     * source account can be chosen as a destination */
    purple_request_field_account_set_filter(field, lh_migrate_filter);

    /* add the field to the group created above */
    purple_request_field_group_add_field(group, field);

    /* and finally we can create the request */
    purple_request_fields(purple_get_blist(), _("Listhandler - Copying"),
                          _("Choose the account to add buddies to:"), NULL,
                          request, _("_Add"),
                          G_CALLBACK(lh_migrate_target_request_cb), _("_Cancel"),
                          NULL, NULL, NULL, NULL, NULL);

    return;
}
Exemplo n.º 4
0
void
lh_migrate_action_cb(PurplePluginAction *action)
{
    PurpleRequestFields *request;
    PurpleRequestFieldGroup *group;
    PurpleRequestField *field;

    /* It seems Purple is super-picky about the order of these first three calls */
    /* create a request */
    request = purple_request_fields_new();

    /* now create a field group */
    group = purple_request_field_group_new(NULL);
    /* and add that group to the request created above */
    purple_request_fields_add_group(request, group);

    /* create a field */
    field = purple_request_field_account_new("migrate_source_acct",
            _("Account"), NULL);

    /* mark the field as required */
    purple_request_field_set_required(field, TRUE);

    /* let's show offline accounts too */
    purple_request_field_account_set_show_all(field, TRUE);

    /* add the field to the group created above */
    purple_request_field_group_add_field(group, field);

    /* and finally we can create the request */
    purple_request_fields(purple_get_blist(), _("Listhandler - Copying"),
                          _("Choose the account to copy from:"), NULL, request,
                          _("C_opy"), G_CALLBACK(lh_migrate_source_request_cb),
                          _("_Cancel"), NULL, NULL, NULL, NULL, NULL);
    return;
}
Exemplo n.º 5
0
void BuddyList::request_add_chat(PurpleAccount *account, PurpleGroup *group,
    const char *alias, const char *name)
{
  if (!CheckAnyAccountConnected())
    return;

  if (account) {
    PurpleConnection *gc = purple_account_get_connection(account);

    if (!PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat) {
      LOG->Message(_("This protocol does not support chat rooms."));
      return;
    }
  }
  else {
    // find an account with chat capabilities
    for (GList *l = purple_connections_get_all(); l; l = l->next) {
      PurpleConnection *gc = reinterpret_cast<PurpleConnection*>(l->data);

      if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->join_chat) {
        account = purple_connection_get_account(gc);
        break;
      }
    }

    if (!account) {
      LOG->Message(_("You are not currently signed on with any "
            "protocols that have the ability to chat."));
      return;
    }
  }

  PurpleRequestFields *fields = purple_request_fields_new();
  PurpleRequestFieldGroup *g = purple_request_field_group_new(NULL);

  purple_request_fields_add_group(fields, g);

  PurpleRequestField *f;
  f = purple_request_field_account_new("account", _("Account"), account);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("name", _("Chat name"), NULL, FALSE);
  purple_request_field_group_add_field(g, f);
  f = purple_request_field_string_new("alias", _("Alias"), NULL, FALSE);
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_choice_new("group", _("Group"), 0);
  bool add_default_group = true;
  int dval = 0;
  bool dval_set = false;
  for (PurpleBlistNode *i = purple_blist_get_root(); i; i = i->next)
    if (PURPLE_BLIST_NODE_IS_GROUP(i)) {
      PurpleGroup *cur_group = reinterpret_cast<PurpleGroup*>(i);
      const char *cur_name = purple_group_get_name(cur_group);
      purple_request_field_choice_add(f, cur_name);
      if (!dval_set) {
        if (group == cur_group) {
          purple_request_field_choice_set_default_value(f, dval);
          dval_set = true;
        }
        dval++;
      }
      add_default_group = false;
    }
  if (add_default_group)
      purple_request_field_choice_add(f, _("Chats"));
  purple_request_field_group_add_field(g, f);

  f = purple_request_field_bool_new("autojoin", _("Auto-join"), FALSE);
  purple_request_field_group_add_field(g, f);

  purple_request_fields(NULL, _("Add chat"), NULL, NULL, fields, _("Add"),
      G_CALLBACK(add_chat_ok_cb_), CANCEL_BUTTON_TEXT, NULL, NULL, NULL, NULL,
      this);
}