示例#1
0
void
Local::Heap::new_presentity_form_submitted (bool submitted,
					    Ekiga::Form &result)
{
  if (!submitted)
    return;

  gmref_ptr<Ekiga::PresenceCore> presence_core = core.get ("presence-core");
  const std::string name = result.text ("name");
  const std::string good_uri = result.hidden ("good-uri");
  std::string uri;
  const std::set<std::string> groups = result.editable_set ("groups");

  if (good_uri == "yes")
    uri = result.hidden ("uri");
  else
    uri = result.text ("uri");

  size_t pos = uri.find_first_of (' ');
  if (pos != std::string::npos)
    uri = uri.substr (0, pos);
  if (presence_core->is_supported_uri (uri)
      && !has_presentity_with_uri (uri)) {

    add (name, uri, groups);
    save ();
  } else {

    Ekiga::FormRequestSimple request(sigc::mem_fun (this, &Local::Heap::new_presentity_form_submitted));

    result.visit (request);
    if (!presence_core->is_supported_uri (uri))
      request.error (_("You supplied an unsupported address"));
    else
      request.error (_("You already have a contact with this address!"));

    if (!questions.handle_request (&request)) {

      // FIXME: better error handling
#ifdef __GNUC__
      std::cout << "Unhandled form request in "
		<< __PRETTY_FUNCTION__ << std::endl;
#endif
    }
  }
}
示例#2
0
void
Local::Heap::new_presentity_form_submitted (bool submitted,
					    Ekiga::Form &result)
{
  if (!submitted)
    return;

  boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
  if (!pcore)
    return;

  const std::string name = result.text ("name");
  const std::string good_uri = result.hidden ("good-uri");
  std::string uri;
  const std::set<std::string> groups = result.editable_set ("groups");

  if (good_uri == "yes")
    uri = result.hidden ("uri");
  else
    uri = result.text ("uri");

  uri = canonize_uri (uri);

  if (pcore->is_supported_uri (uri)
      && !has_presentity_with_uri (uri)) {

    add (name, uri, groups);
    save ();
  } else {

    boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple>(new Ekiga::FormRequestSimple (boost::bind (&Local::Heap::new_presentity_form_submitted, this, _1, _2)));

    result.visit (*request);
    if (!pcore->is_supported_uri (uri))
      request->error (_("You supplied an unsupported address"));
    else
      request->error (_("You already have a contact with this address!"));

    questions (request);
  }
}
示例#3
0
void
Local::Heap::new_presentity (const std::string name,
			     const std::string uri)
{
  if (!has_presentity_with_uri (uri)) {

    gmref_ptr<Ekiga::PresenceCore> presence_core = core.get ("presence-core");
    Ekiga::FormRequestSimple request(sigc::mem_fun (this, &Local::Heap::new_presentity_form_submitted));
    std::set<std::string> groups = existing_groups ();

    request.title (_("Add to local roster"));
    request.instructions (_("Please fill in this form to add a new contact "
			    "to ekiga's internal roster"));
    request.text ("name", _("Name:"), name);
    if (presence_core->is_supported_uri (uri)) {

      request.hidden ("good-uri", "yes");
      request.hidden ("uri", uri);
    } else {

      request.hidden ("good-uri", "no");
      if ( !uri.empty ())
	request.text ("uri", _("Address:"), uri);
      else
	request.text ("uri", _("Address:"), "sip:"); // let's put a default
    }

    request.editable_set ("groups",
			  _("Put contact in groups:"),
			  std::set<std::string>(), groups);

    if (!questions.handle_request (&request)) {

      // FIXME: better error reporting
#ifdef __GNUC__
      std::cout << "Unhandled form request in "
		<< __PRETTY_FUNCTION__ << std::endl;
#endif
    }
  }
}
示例#4
0
void
Local::Heap::new_presentity (const std::string name,
			     const std::string uri)
{
  if (!has_presentity_with_uri (uri)) {

    boost::shared_ptr<Ekiga::PresenceCore> pcore = presence_core.lock ();
    if (!pcore)
      return;

    boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&Local::Heap::new_presentity_form_submitted, this, _1, _2)));
    std::set<std::string> groups = existing_groups ();

    request->title (_("Add to local roster"));
    request->instructions (_("Please fill in this form to add a new contact "
			    "to ekiga's internal roster"));
    request->text ("name", _("Name:"), name, _("Name of the contact, as shown in your roster"));
    if (pcore->is_supported_uri (uri)) {

      request->hidden ("good-uri", "yes");
      request->hidden ("uri", uri);
    } else {

      request->hidden ("good-uri", "no");
      if ( !uri.empty ())
        request->text ("uri", _("Address:"), uri, _("Address, e.g. sip:[email protected]; if you do not specify the host part, e.g. sip:xyz, then you can choose it by right-clicking on the contact in roster"));
      else
        request->text ("uri", _("Address:"), "sip:", _("Address, e.g. sip:[email protected]; if you do not specify the host part, e.g. sip:xyz, then you can choose it by right-clicking on the contact in roster")); // let's put a default
    }

    request->editable_set ("groups",
			   _("Put contact in groups:"),
			   std::set<std::string>(), groups);

    questions (request);
  }
}