Ejemplo n.º 1
0
void
Opal::Presentity::edit_presentity ()
{
  boost::shared_ptr<Ekiga::FormRequestSimple> request =
    boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&Opal::Presentity::edit_presentity_form_submitted, this, _1, _2, _3)));

  /* Translators: This is Edit name of the contact
   * e.g. Editing Contact Claire Fleury.
   */
  char *title = g_strdup_printf (_("Editing Contact %s"), get_name ().c_str ());
  request->title (title);
  g_free (title);

  request->action (_("Done"));
  request->text ("name", _("Name"),
                 get_name (),
                 _("John Doe"),
                 Ekiga::FormVisitor::STANDARD,
                 false, false);
  request->text ("uri", _("URI"),
                 get_uri (),
                 _("sip:[email protected]"),
                 Ekiga::FormVisitor::URI,
                 false, false);

  request->editable_list ("groups", _("Groups"),
                          get_groups (), existing_groups ());

  questions (request);
}
Ejemplo n.º 2
0
void
Local::Presentity::edit_presentity ()
{
  ClusterPtr cluster = local_cluster.lock ();

  if (!cluster)
    return;

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

  std::string name = get_name ();
  std::string uri = get_uri ();
  std::set<std::string> groups = get_groups ();
  std::set<std::string> all_groups = cluster->existing_groups ();

  request->title (_("Edit roster element"));
  request->instructions (_("Please fill in this form to change an existing "
			   "element of ekiga's internal roster"));
  request->text ("name", _("Name:"), name, _("Name of the contact, as shown in your roster"));
  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"));
  request->boolean ("preferred", _("Is a preferred contact"), is_preferred ());

  request->editable_set ("groups", _("Choose groups:"),
			 groups, all_groups);

  questions (request);
}
Ejemplo n.º 3
0
void
RL::Heap::new_entry ()
{
    boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&RL::Heap::on_new_entry_form_submitted, this, _1, _2, _3)));

    request->title (_("Add a remote contact"));
    request->instructions (_("Please fill in this form to create a new "
                             "contact on a remote server"));

    std::set<std::string> all_groups;
    for (std::map<PresentityPtr,std::list<boost::signals2::connection> >::const_iterator
            iter = presentities.begin ();
            iter != presentities.end ();
            ++iter) {

        std::set<std::string> groups = iter->first->get_groups ();
        all_groups.insert (groups.begin (), groups.end ());
    }

    request->text ("name", _("Name:"), "", std::string ());
    request->text ("uri", _("Address:"), "", std::string ());
    request->editable_set ("groups", _("Choose groups:"),
                           std::set<std::string>(), all_groups);

    questions (request);
}
Ejemplo n.º 4
0
 static void RigUpQuestions()
{
	switch(Questions.current_state)  //Enter each training class
	{
		case(QUESTIONS_INITIALIZE):
			questionsInitialize();
			break;
		case(QUESTIONS):
			questions();
			break;
	}
	
	/*void(*state_table3[])() = 
		{
		questionsInitialize,
		questions		
		};

	state_table3[Questions.current_state]();
	
	 //This below enum is found in Training::Training.typ
	
		enum {       
					QUESTIONS_INITIALIZE = 0,	
					QUESTIONS
									
				}   State_Type;*/
}
Ejemplo n.º 5
0
void
Opal::Bank::new_account (Account::Type acc_type,
			 std::string username,
			 std::string password)
{
  boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&Opal::Bank::on_new_account_form_submitted, this, _1, _2, acc_type)));

  request->title (_("Edit account"));
  request->instructions (_("Please update the following fields:"));

  switch (acc_type) {

  case Opal::Account::Ekiga:
    request->link (_("Get an Ekiga.net SIP account"), "http://www.ekiga.net");
    request->hidden ("name", "Ekiga.net");
    request->hidden ("host", "ekiga.net");
    request->text ("user", _("_User:"******"The user name, e.g. jim"));
    request->hidden ("authentication_user", username);
    request->private_text ("password", _("_Password:"******"Password associated to the user"));
    request->hidden ("timeout", "3600");
    break;

  case Opal::Account::DiamondCard:
    request->link (_("Get an Ekiga Call Out account"),
		   "https://www.diamondcard.us/exec/voip-login?act=sgn&spo=ekiga");
    request->hidden ("name", "Ekiga Call Out");
    request->hidden ("host", "sip.diamondcard.us");
    request->text ("user", _("_Account ID:"), username, _("The user name, e.g. jim"));
    request->hidden ("authentication_user", username);
    request->private_text ("password", _("_PIN code:"), password, _("Password associated to the user"));
    request->hidden ("timeout", "3600");
    break;

  case Opal::Account::H323:
    request->text ("name", _("_Name:"), std::string (), _("Account name, e.g. MyAccount"));
    request->text ("host", _("_Gatekeeper:"), std::string (), _("The gatekeeper, e.g. ekiga.net"));
    request->text ("user", _("_User:"******"The user name, e.g. jim"));
    request->hidden ("authentication_user", username);
    request->private_text ("password", _("_Password:"******"Password associated to the user"));
    request->text ("timeout", _("_Timeout:"), "3600", _("Time in seconds after which the account registration is automatically retried"));
    break;

  case Opal::Account::SIP:
  default:
    request->text ("name", _("_Name:"), std::string (), _("Account name, e.g. MyAccount"));
    request->text ("host", _("_Registrar:"), std::string (), _("The registrar, e.g. ekiga.net"));
    request->text ("user", _("_User:"******"The user name, e.g. jim"));
    request->text ("authentication_user", _("_Authentication user:"******"The user name used during authentication, if different than the user name; leave empty if you do not have one"));
    request->private_text ("password", _("_Password:"******"Password associated to the user"));
    request->text ("timeout", _("_Timeout:"), "3600", _("Time in seconds after which the account registration is automatically retried"));
    break;
  }
  request->boolean ("enabled", _("Enable account"), true);

  if (!username.empty () && !password.empty ())
    request->submit (*request);
  else
    questions (request);
}
Ejemplo n.º 6
0
void
OPENLDAP::Book::edit ()
{
  boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&OPENLDAP::Book::on_edit_form_submitted, this, _1, _2, _3)));

  OPENLDAP::BookForm (request, bookinfo);

  questions (request);
}
Ejemplo n.º 7
0
void
Local::Heap::on_rename_group (std::string name)
{
  boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&Local::Heap::rename_group_form_submitted, this, name, _1, _2)));

  request->title (_("Rename group"));
  request->instructions (_("Please edit this group name"));
  request->text ("name", _("Name:"), name, std::string ());

  questions (request);
}
Ejemplo n.º 8
0
void
LM::Account::edit ()
{
  boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&LM::Account::on_edit_form_submitted, this, _1, _2)));
  xmlChar* xml_str = NULL;

  request->title (_("Edit account"));

  request->instructions (_("Please update the following fields:"));

  xml_str = xmlGetProp (node, BAD_CAST "name");
  request->text ("name", _("Name:"), (const char*)xml_str, std::string ());
  xmlFree (xml_str);

  xml_str = xmlGetProp (node, BAD_CAST "user");
  request->text ("user", _("User:"******"server");
  request->text ("server", _("Server:"), (const char*)xml_str, std::string ());
  xmlFree (xml_str);

  xml_str = xmlGetProp (node, BAD_CAST "port");
  request->text ("port", _("Port:"), (const char*)xml_str, std::string ());
  xmlFree (xml_str);

  xml_str = xmlGetProp (node, BAD_CAST "resource");
  request->text ("resource", _("Resource:"), (const char*)xml_str, std::string ());
  xmlFree (xml_str);

  xml_str = xmlGetProp (node, BAD_CAST "password");
  request->private_text ("password", _("Password:"******"startup");
  bool enable_on_startup = false;
  if (xmlStrEqual (xml_str, BAD_CAST "true")) {

    enable_on_startup = true;
  } else {

    enable_on_startup = false;

  }
  xmlFree (xml_str);
  request->boolean ("enabled", _("Enable Account"), enable_on_startup);

  questions (request);
}
Ejemplo n.º 9
0
void
LM::Presentity::edit_presentity ()
{
  boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&LM::Presentity::edit_presentity_form_submitted, this, _1, _2)));

  request->title (_("Edit roster element"));
  request->instructions (_("Please fill in this form to change an existing "
			   "element of the remote roster"));
  request->text ("name", _("Name:"), get_name (), std::string ());

  request->editable_set ("groups", _("Choose groups:"),
			 get_groups (), get_groups ());

  questions (request);
}
Ejemplo n.º 10
0
int main(){
	Interface *i;
	int won;
	
	_term_init();
	i = i_create(MAXCOLS - 30, MAXROWS - 6, 30, 6, '@', 40, 37, 40, 37, 40, 37);
	if(!i) return -1;
	i_drawAll(i);
	won = questions(i);
	sleep(2);
	i_free(i);
	_term_close();
	return won;
	
}
Ejemplo n.º 11
0
void
LM::HeapRoster::add_item ()
{
  boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&LM::HeapRoster::add_item_form_submitted, this, _1, _2)));

  request->title (_("Add a roster element"));
  request->instructions (_("Please fill in this form to add a new"
			   " element to the remote roster"));
  request->text ("jid", _("Identifier:"), _("identifier@server"), std::string ());
  request->text ("name", _("Name:"), "", _("Name of the contact, as shown in your roster"));
  request->editable_set ("groups",
			 _("Put contact in groups:"),
                         std::list<std::string>(), existing_groups ());

  questions (request);
}
Ejemplo n.º 12
0
void Opal::Bank::on_new_account_form_submitted (bool submitted,
						Ekiga::Form &result,
                                                Account::Type acc_type)
{
  if (!submitted)
    return;

  boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&Opal::Bank::on_new_account_form_submitted, this, _1, _2, acc_type)));

  std::string error;
  std::string new_name = (acc_type == Opal::Account::SIP
			  || acc_type == Opal::Account::H323) ? result.text ("name") : result.hidden ("name");
  std::string new_host = (acc_type == Opal::Account::SIP
			  || acc_type == Opal::Account::H323) ? result.text ("host") : result.hidden ("host");
  std::string new_user = result.text ("user");
  std::string new_authentication_user = (acc_type == Opal::Account::SIP) ? result.text ("authentication_user") : new_user;
  std::string new_password = result.private_text ("password");
  bool new_enabled = result.boolean ("enabled");
  unsigned new_timeout = atoi ((acc_type == Opal::Account::SIP
				|| acc_type == Opal::Account::H323) ?
			       result.text ("timeout").c_str () : result.hidden ("timeout").c_str ());

  result.visit (*request);

  if (new_name.empty ())
    error = _("You did not supply a name for that account.");
  else if (new_host.empty ())
    error = _("You did not supply a host to register to.");
  else if (new_user.empty ())
    error = _("You did not supply a user name for that account.");
  else if (new_timeout < 10)
    error = _("The timeout should be at least 10 seconds.");

  if (!error.empty ()) {
    request->error (error);

    questions (request);
  }
  else {

    add (acc_type, new_name, new_host, new_user, new_authentication_user,
	 new_password, new_enabled, new_timeout);
    save ();
  }
}
Ejemplo n.º 13
0
void
LM::Bank::new_account ()
{
  boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&LM::Bank::on_new_account_form_submitted, this, _1, _2)));

  request->title (_("Edit account"));

  request->instructions (_("Please fill in the following fields:"));

  request->text ("name", _("Name:"), "", _("Account name, e.g. MyAccount"));
  request->text ("user", _("User:"******"", _("The user name, e.g. jim"));
  request->text ("server", _("Server:"), "", _("The server, e.g. jabber.org"));
  request->text ("resource", _("Resource:"), "", _("The resource, such as home or work, allowing to distinguish among several terminals registered to the same account; leave empty if you do not know what it is"));
  request->private_text ("password", _("Password:"******"", _("Password associated to the user"));
  request->boolean ("enabled", _("Enable account"), true);

  questions (request);
}
Ejemplo n.º 14
0
void
RL::Presentity::edit_presentity ()
{
    boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&RL::Presentity::edit_presentity_form_submitted, this, _1, _2)));

    // FIXME: we should be able to know all groups in the heap
    std::set<std::string> all_groups = groups;

    request->title (_("Edit remote contact"));
    request->instructions (_("Please fill in this form to change an existing "
                             "contact on a remote server"));
    request->text ("name", _("Name:"), get_name (), std::string ());
    request->text ("uri", _("Address:"), uri, std::string ());

    request->editable_set ("groups", _("Choose groups:"),
                           groups, all_groups);

    questions (request);
}
Ejemplo n.º 15
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);
  }
}
Ejemplo n.º 16
0
void
RL::Cluster::new_heap (const std::string name,
		       const std::string uri,
		       const std::string username,
		       const std::string password,
		       const std::string user,
		       bool writable)
{
  boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&RL::Cluster::on_new_heap_form_submitted, this, _1, _2, _3)));

  request->title (_("Add new resource-list"));
  request->instructions (_("Please fill in this form to add a new "
			   "contact list to ekiga's remote roster"));
  request->text ("name", _("Name:"), name, std::string ());
  request->text ("uri", _("Address:"), uri, std::string ());
  request->boolean ("writable", _("Writable:"), writable);
  request->text ("username", _("Username:"******"password", _("Password:"******"user", _("User:"), user, std::string ());

  questions (request);
}
Ejemplo n.º 17
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);
  }
}
Ejemplo n.º 18
0
void
RL::Heap::edit ()
{
    boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&RL::Heap::on_edit_form_submitted, this, _1, _2, _3)));

    std::string name_str;
    std::string root_str;
    std::string username_str;
    std::string password_str;
    std::string user_str;
    bool writable = false;

    {
        xmlChar* str = xmlNodeGetContent (root);
        if (str != NULL) {

            root_str = (const char*)str;
            xmlFree (str);
        }
    }
    {
        xmlChar* str = xmlNodeGetContent (user);
        if (str != NULL) {

            user_str = (const char*)str;
            xmlFree (str);
        }
    }
    {
        xmlChar* str = xmlNodeGetContent (username);
        if (str != NULL) {

            username_str = (const char*)str;
            xmlFree (str);
        }
    }
    {
        xmlChar* str = xmlNodeGetContent (password);
        if (str != NULL) {

            password_str = (const char*)str;
            xmlFree (str);
        }
    }
    {
        xmlChar* str = xmlGetProp (node, BAD_CAST "writable");
        if (str != NULL) {

            if (xmlStrEqual (str, BAD_CAST "1"))
                writable = true;
            xmlFree (str);
        }
    }

    request->title (_("Edit contact list properties"));

    request->instructions (_("Please edit the following fields (no identifier"
                             " means global)"));

    request->text ("name", _("Contact list's name:"), get_name (), std::string ());
    /* "Document" used as a name -- uri point to the root of a document tree */
    request->text ("root", _("Document root:"), root_str, std::string ());
    request->text ("user", _("Identifier:"), user_str, std::string ());
    request->boolean ("writable", _("Writable:"), writable);
    request->text ("username", _("Server username:"******"password", _("Server password:"), password_str, std::string (), Ekiga::FormVisitor::PASSWORD);

    questions (request);
}
Ejemplo n.º 19
0
main(){
	int *ptr1;//Pointer for  Row of player 1
	int *ptr2;//Pointer for  Column of player 1
	int *temp;// Value for the function checker
	char *g;// Address of the goal
	char *g1;// Address of the goal
	int *op;// Value for summoning question 
	int *ptrhp;
	op=&e;
	temp=&d;
	ptr1=&x1;
	ptr2=&x2;
	ptrhp=&hp;
	g=&maze[7][14];
	g1=&maze[7][15];

	while(l!=3){

		
		printf("______________________________\n");
        printf("|                            |\n");
        printf("|                            |\n");
        printf("|                            |\n");
        printf("|      ::::::::::::::::      |\n");
        printf("|      ::    M O Q   ::      |\n");
        printf("|      ::::::::::::::::      |\n");
        printf("|                            |\n");
        printf("|       [1] START GAME       |\n");
        printf("|       [2] HOW TO PLAY      |\n");
        printf("|       [3] QUIT             |\n");
        printf("|                            |\n");
        printf("|                            |\n");
        printf("|                            |\n");
        printf("::::::::::::::::::::::::::::::\n");
		scanf("%d",&l);
		if(l==1){
			loading();
			*ptr1=7;
			*ptr2=16;
			*temp=0;
			*op=2;
			*g='[';
			*g1=']';
			pos(ptr1,ptr2,maze,x);
			show(maze);
			while(d!=3){

		       while(*op==2){
                  if(*ptrhp==0){
                     *temp=3;
                     *op=3;
                     break;
                     }
                  if(*ptrhp!=0){
                      printf("\nQuestion:\n");
                      questions(op,ptrhp);
                      break;
                  }
                }
         
		       if(e==1){//IF the player answer the question correctly
    		       show(maze);
    		       for(z=1;z<5;){//Sets the limit for the number of moves the player can
    				scanf("%c",&p);
    				if(p=='w'){
    					up(maze,ptr1,ptr2,temp,x);
    					z=z+1;
    					if(z!=5){
							printf("\nMove:");
                        }
    				}
    				else if(p=='a'){
    					left(maze,ptr1,ptr2,temp,x);
    					z=z+1;
    					if(z!=5){
							printf("\nMove:");
                        }
    				}
    				else if(p=='s'){
    					down(maze,ptr1,ptr2,temp,x);
    					z=z+1;
    					if(z!=5){
							printf("\nMove:");
                        }
    				}
    				else if(p=='d'){
    					right(maze,ptr1,ptr2,temp,x);
    					z=z+1;
    					if(z!=5){
							printf("\nMove:");
                        }
    				}
	            }
	            *op=2;
              }
              if(e==3){
                       gameover();
                       break;     
              }
              else{// If player got a wrong answer or time's up
                     *op=2;
              }
              }
		}
		if(l==2){
            printf("\n*********************************************************************************\n");
			printf("*\t\t\t\t\t\t\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t\t*\n*\t\t\t\tHOW TO PLAY\t\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t\t*\n*");
            printf("        \tThe player is bound to finish the maze by answering questions, \t*\n*     riddles, and logic puzzles. Some of the questions are related to \t\t*\n*     "); 
            printf("Computer Science.\t\t\t\t\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t\t*\n*");
            printf("     1. A player is given a 100 percent life at the beginning of the game.\t*\n*\t\t\t\t\t\t\t\t\t\t*\n*     2. If a player answers a question correctly, she/he can move 4 times\t*\n*");
            printf("        (up, down, left, right) depending on which direction will lead\t\t*\n*        her/him to the finish line faster.\t\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t\t*\n*");
            printf("     3. If a player answers a question incorrectly, her/his life will\t\t*\n*        decrease by 5 percent.\t\t\t\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t\t*\n*");
            printf("     4. The player will win the maze by the time she/he reaches the\t\t*\n*        end of the maze (of course), depicted by [].\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t\t*\n*");
            printf("     5. However, there is a 15-second limit for the player to answer a\t\t*\n*        given question. Failure to answer a question will lead to reduction    *\n*        of life as well.\t\t\t\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t\t*");
            printf("\n*\t\t\t\t\t\t\t\t\t\t*\n*\t\t\t\tCONTROLS:\t\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t\t*\n*\t\t\t\tUP - [W]\t\t\t\t\t*\n*\t\t\t\tDOWN - [S]\t\t\t\t\t*\n*\t\t\t\tLEFT - [A]\t\t\t\t\t*\n*\t\t\t\tRIGHT - [D]\t\t\t\t\t*\n*\t\t\t\t\t\t\t\t\t    EXIT*\n*");
            printf("********************************************************************************\n\n");
	        }
	        
		if(l>3){
			printf("\nInvalid input. Try again.\n");
	        }
	}
	quit();
}
Ejemplo n.º 20
0
LmHandlerResult
LM::HeapRoster::handle_presence (LmConnection* /*connection*/,
				 LmMessage* message)
{
  LmHandlerResult result = LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
  const gchar* from_c = lm_message_node_get_attribute (lm_message_get_node (message), "from");
  const gchar* type_attr = lm_message_node_get_attribute (lm_message_get_node (message), "type");
  std::string base_jid;
  std::string resource;

  if (from_c != 0) {

    std::string from (from_c);
    std::string::size_type index = from.find ('/');
    base_jid = std::string (from, 0, index);
    resource = std::string (from, index + 1, std::string::npos);
  }

  PresentityPtr item = find_item (base_jid);

  if (type_attr != NULL && g_strcmp0 (type_attr, "subscribe") == 0) {

    result = LM_HANDLER_RESULT_REMOVE_MESSAGE;
    boost::shared_ptr<Ekiga::FormRequestSimple> request = boost::shared_ptr<Ekiga::FormRequestSimple> (new Ekiga::FormRequestSimple (boost::bind (&LM::HeapRoster::subscribe_from_form_submitted, this, _1, _2)));
    LmMessageNode* status = lm_message_node_find_child (lm_message_get_node (message), "status");
    gchar* instructions = NULL;
    std::string item_name;

    if (item) {

      item_name = item->get_name ();
    } else {

      item_name = base_jid;
    }

    request->title (_("Authorization to see your presence"));

    if (status != NULL && lm_message_node_get_value (status) != NULL) {

      instructions = g_strdup_printf (_("%s asks the permission to see your presence, saying: \"%s\"."),
				      item_name.c_str (), lm_message_node_get_value (status));
    } else {

      instructions = g_strdup_printf (_("%s asks the permission to see your presence."),
				      item_name.c_str ());
    }
    request->instructions (instructions);
    g_free (instructions);

    std::map<std::string, std::string> choices;
    choices["grant"] = _("grant him/her the permission to see your presence");
    choices["refuse"] = _("refuse him/her the permission to see your presence");
    choices["later"] = _("decide later (also close or cancel this dialog)");
    request->single_choice ("answer", _("Your answer is: "), "grant", choices);

    request->hidden ("jid", base_jid);

    questions (request);
  } else {

    if (item) {

     result = LM_HANDLER_RESULT_REMOVE_MESSAGE;
     item->push_presence (resource, lm_message_get_node (message));
    }
  }

  return result;
}