Beispiel #1
0
	void CHistoryQueryHook::selectARow()
	{
		//历史记录
		if (m_avtivePageIndex == kPageHisRecord)
		{
			//进入地图
			CMapHook *pMapHook((CMapHook *)(m_view->GetHook(CViewHook::DHT_MapHook)));
			SQLRecord tmp;
			UeQuery::SQLSetting setting;
			m_query->ConnectTo(UeQuery::DT_HistoryRecords,setting);
			const HistoryRecordEntry *curEntry = m_query->GetHistoryRecord(m_Itemidx);
			tmp.m_x=curEntry->m_X;
			tmp.m_y=curEntry->m_Y;
			tmp.m_uniName=new char[128];
			strcpy(tmp.m_uniName,(char*)curEntry->m_addrName);
			m_query->Disconnect(UeQuery::DT_HistoryRecords);

			if (m_pCallBackEvent!=0)
			{
				m_pCallBackEvent(m_pDoCallBackObj,&tmp);
				delete[] tmp.m_uniName;
			}
			else
			{
				pMapHook->PeripheralInformationSwitch(&tmp);
				delete[] tmp.m_uniName;
			}
		}
		//历史线路
		else if (m_avtivePageIndex == kPageHisRoute)
		{
			if (m_route)
			{
				short planState = m_route->GetPlanState();
				if ((UeRoute::PS_DemoGuidance == planState) || (UeRoute::PS_RealGuidance == planState))
				{     
					CMessageDialogEvent dialogEvent(this, CViewHook::DHT_HistoryQueryHook, &UeGui::CHistoryQueryHook::OnSelectHistoryRoute);
					CMessageDialogHook::ShowMessageDialog(MB_INFORMATION, "是否结束导航?", dialogEvent);
					return;
				}
				else
				{
					PlanHistoryRoute();
				}
			}
		}
		//历史轨迹
		else //m_avtivePageIndex == kPageHisTrajectory
		{
			//SetRouteStart(...) //起点
			//SetRouteWay(...)	 //经过点
			//SetRouteEnd(...)	 //终点
			CMapHook *pMapHook((CMapHook *)(m_view->GetHook(CViewHook::DHT_MapHook)));
		}
	}
   void testEscaping()
      {
         const char* testString =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"&version;\" state=\"full\" entity=\"sip:entity&amp;@example.com;&amp;=&amp;\">\n"
            "<dialog id=\"&lt;&gt;&amp;\" call-id=\"callid&lt;&gt;\" local-tag=\"localtag\" remote-tag=\"remotetag\" direction=\"recipient\">\n"
            "<state event=\"rejected\" code=\"456\">terminated</state>\n"
            "<duration>1</duration>\n"
            "<local>\n"
            "<identity display=\"local&lt;&gt;&amp;\">sip:local&amp;@example.com;a&amp;=b&amp;</identity>\n"
            "<target uri=\"sip:localtarget&amp;@example.com;a&amp;=b&amp;\">\n"
            "<param pname=\"localparam\" pval=\"&lt;&gt;&amp;\"/>\n"
            "</target>\n"
            "</local>\n"
            "<remote>\n"
            "<identity display=\"remote&lt;&gt;&amp;\">sip:remote&amp;@example.com;a&amp;=b&amp;</identity>\n"
            "<target uri=\"sip:remotetarget&amp;@example.com;a&amp;=b&amp;\">\n"
            "<param pname=\"remoteparam\" pval=\"&lt;&gt;&amp;\"/>\n"
            "</target>\n"
            "</remote>\n"
            "</dialog>\n"
            "</dialog-info>\n"
            ;

         // Allocate *dialog on the heap, so that it is freed when
         // dialogEvent goes out of scope, and not freed when dialog
         // goes out of scope.
         Dialog* dialog =
            new Dialog("<>&", "callid<>", "localtag", "remotetag", "recipient");

         dialog->setState("terminated", "rejected", "456");
         dialog->setDuration(OsDateTime::getSecsSinceEpoch());

         dialog->setLocalIdentity("sip:local&@example.com;a&=b&", "local<>&");
         dialog->setLocalTarget("sip:localtarget&@example.com;a&=b&");
         dialog->addLocalParameter(new NameValuePairInsensitive("localparam", "<>&"));

         dialog->setRemoteIdentity("sip:remote&@example.com;a&=b&", "remote<>&");
         dialog->setRemoteTarget("sip:remotetarget&@example.com;a&=b&");
         dialog->addRemoteParameter(new NameValuePairInsensitive("remoteparam", "<>&"));

         SipDialogEvent dialogEvent("full", "sip:entity&@example.com;&=&");

         dialogEvent.insertDialog(dialog);

         sleep(1);              // so that the duration is now 1

         dialogEvent.buildBody(NULL);
         const char* b;
         ssize_t l;
         dialogEvent.getBytes(&b, &l);

         ASSERT_STR_EQUAL(testString, b);
      }
   void AppearanceTest()
   {
      instantiateAllTestFixtures( "appearance-groups1.xml",
                                  "subscription1",
                                  "credential1",
                                  "177.0.0.1:54140");

      UtlString sharedUri = "sip:[email protected]:54140";
      UtlString app1uri = "sip:127.0.0.1:45141";
      UtlString dialogHandle;

      // receive the reg-info subscribe
      SipMessage request;
      UtlString b;
      ssize_t l;
      while(getNextMessageFromAppearanceAgentUnderTest( request, 5 ))
      {
         request.getBytes(&b, &l);
         OsSysLog::add(FAC_RLS, PRI_DEBUG, "got message %s", b.data());
         UtlString method;
         request.getRequestMethod(&method);
         if(!request.isResponse() &&
            0 == method.compareTo(SIP_SUBSCRIBE_METHOD) )
         {
            // Accept the Subscription, regardless of whether it for a 'dialog' or 'reg' event
            // in order to stop retransmissions
            SipMessage regResponse;
            regResponse.setResponseData(&request, 202, "Accepted", app1uri);
            SipMessage * dispatchedMessage = new SipMessage(regResponse);
            dispatchedMessage->getBytes(&b, &l);
            OsSysLog::add(FAC_RLS, PRI_DEBUG, "sent message %s", b.data());
            pAppearanceAgentUnderTest->mServerUserAgent.dispatch(dispatchedMessage);

            // Deal with the two events separately
            UtlString eventField;
            request.getEventField(eventField);
            if(0 == eventField.compareTo("reg"))
            {
               UtlString contactInfo;
               request.getContactUri(0, &contactInfo);
               UtlString callid;
               request.getCallIdField(&callid);
               int cseq;
               request.getCSeqField(&cseq, NULL);

               Url toField;
               regResponse.getToUrl(toField);

               SipMessage regNotify;
               regNotify.setNotifyData(&request, 1, "", "", "reg");
               UtlString regInfo ("<?xml version=\"1.0\"?>\r\n"
                                 "<reginfo xmlns=\"urn:ietf:params:xml:ns:reginfo\" "
                                 "xmlns:gr=\"urn:ietf:params:xml:ns:gruuinfo\" version=\"911\" state=\"full\">\r\n"
                                 "   <registration aor=\"sip:[email protected]:54140\" id=\"sip:[email protected]:54140\" state=\"active\">\r\n "
                                 "      <contact id=\"sip:[email protected]:54140@@&lt;");
               regInfo.append(contactInfo);
               regInfo.append("&gt;\" state=\"active\" event=\"registered\" q=\"1\" callid=\"");
               regInfo.append(callid);
               regInfo.append("\" cseq=\"");
               regInfo.appendNumber(cseq);
               regInfo.append("\">\r\n");
               regInfo.append("<uri>");
               regInfo.append(app1uri);
               regInfo.append("</uri>");
               regInfo.append("      </contact>\r\n"
                              "   </registration>\r\n"
                              "</reginfo>");
               HttpBody * newBody = new HttpBody (regInfo, strlen(regInfo), "application/reginfo+xml");
               regNotify.setContentType("application/reginfo+xml");
               regNotify.setBody(newBody);

               // Set the From field the same as the to field from the 202 response, as it
               // contains the dialog identifying to tags
               regNotify.setRawFromField(toField.toString().data());
               sendToAppearanceAgentUnderTest( regNotify );
               regNotify.getBytes(&b, &l);
               OsSysLog::add(FAC_RLS, PRI_DEBUG, "sent reg NOTIFY to AppAgent");
               OsSysLog::add(FAC_RLS, PRI_DEBUG, "sent message %s", b.data());
            }
            else if (0 == eventField.compareTo(SLA_EVENT_TYPE))
             {
                // should send empty NOTIFY, but no one will care
                // save dialogHandle for this subscription/Appearance (ignore retransmissions)
                if (dialogHandle.isNull())
                {
                   SipMessage fake(b);
                   fake.getDialogHandle(dialogHandle);
                   OsSysLog::add(FAC_RLS, PRI_DEBUG, "got SUBSCRIBE(sla) request: dialogHandle %s", dialogHandle.data());
                }
             }
         }
      }

      CPPUNIT_ASSERT( !dialogHandle.isNull() );
      OsSysLog::add(FAC_RLS, PRI_DEBUG, "we now have an Appearance - test it");
      AppearanceGroup* pAppGroup = pAppearanceAgentUnderTest->getAppearanceGroupSet().
         findAppearanceGroup(sharedUri);
      CPPUNIT_ASSERT( pAppGroup );

      Appearance* pApp = pAppGroup->findAppearance(dialogHandle);
      CPPUNIT_ASSERT( pApp );
      ASSERT_STR_EQUAL( app1uri.data(), pApp->getUri()->data() );

      // test adding a new dialog
      const char* dialogEventString =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"0\" state=\"partial\" entity=\"sip:[email protected]:54140\">\n"
            "<dialog id=\"1\" call-id=\"[email protected]\" local-tag=\"264460498\" remote-tag=\"1c10982\" direction=\"recipient\">\n"
            "<state>confirmed</state>\n"
            "<local>\n"
            "<identity>[email protected]:5120</identity>\n"
            "<target uri=\"sip:[email protected]:5120\">\n"
            "<param pname=\"x-line-id\" pval=\"0\"/>\n"
            "<param pname=\"+sip.rendering\" pval=\"yes\"/>\n"
            "</target>\n"
            "</local>\n"
            "<remote>\n"
            "<identity>[email protected]</identity>\n"
            "</remote>\n"
            "</dialog>\n"
            "</dialog-info>\n"
            ;
      SipDialogEvent dialogEvent(dialogEventString);
      bool bFullContentChanged = false;
      bool bPartialContentChanged = pApp->updateState(&dialogEvent, bFullContentChanged);
      CPPUNIT_ASSERT(bPartialContentChanged);
      CPPUNIT_ASSERT(bFullContentChanged);
      pApp->dumpState();
      CPPUNIT_ASSERT(pApp->appearanceIsBusy());
      CPPUNIT_ASSERT(pApp->appearanceIdIsSeized("0"));
      CPPUNIT_ASSERT(!pApp->appearanceIdIsSeized("1"));

      // simulate user putting the call on hold
      const char* dialogEventString2 =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"0\" state=\"partial\" entity=\"sip:[email protected]:54140\">\n"
            "<dialog id=\"1\" call-id=\"[email protected]\" local-tag=\"264460498\" remote-tag=\"1c10982\" direction=\"recipient\">\n"
            "<state>confirmed</state>\n"
            "<local>\n"
            "<identity>[email protected]:5120</identity>\n"
            "<target uri=\"sip:[email protected]:5120\">\n"
            "<param pname=\"x-line-id\" pval=\"0\"/>\n"
            "<param pname=\"+sip.rendering\" pval=\"no\"/>\n"
            "</target>\n"
            "</local>\n"
            "<remote>\n"
            "<identity>[email protected]</identity>\n"
            "</remote>\n"
            "</dialog>\n"
            "</dialog-info>\n"
            ;
      SipDialogEvent dialogEvent2(dialogEventString2);
      bPartialContentChanged = pApp->updateState(&dialogEvent2, bFullContentChanged);
      CPPUNIT_ASSERT(bPartialContentChanged);
      CPPUNIT_ASSERT(bFullContentChanged);
      pApp->dumpState();
      CPPUNIT_ASSERT(!pApp->appearanceIsBusy());
      CPPUNIT_ASSERT(pApp->appearanceIdIsSeized("0"));
      CPPUNIT_ASSERT(!pApp->appearanceIdIsSeized("1"));

      // test MESSAGE debug handling
      const char* message =
         "MESSAGE sip:[email protected]:54140 SIP/2.0\r\n"
         "From: <sip:[email protected]>;tag=17211757-9E4FBD78\r\n"
         "To: <sip:[email protected]:54140>\r\n"
         "CSeq: 1 MESSAGE\r\n"
         "Call-ID: 51405734-b9be4835-dcd9d196\r\n"
         "Contact: <sip:[email protected]>\r\n"
         "Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, INFO, MESSAGE, SUBSCRIBE, NOTIFY, PRACK, UPDATE, REFER\r\n"
         "Event: dialog\r\n"
         "User-Agent: UnitTest\r\n"
         "Accept-Language: en\r\n"
         "Accept: application/dialog-info+xml\r\n"
         "Max-Forwards: 70\r\n"
         "Expires: 3600\r\n"
         "Content-Length: 0\r\n"
         "\r\n";

      // send the MESSAGE
      SipMessage messageRequest( message, strlen( message ) );
      CPPUNIT_ASSERT( sendToAppearanceAgentUnderTest( messageRequest ) );

      // receive the 200 OK response
      SipMessage response;
      CPPUNIT_ASSERT( getNextMessageFromAppearanceAgentUnderTest( response, 5 ) );
      CPPUNIT_ASSERT( response.isResponse() );
      CPPUNIT_ASSERT( response.getResponseStatusCode() == SIP_OK_CODE );
   }
Beispiel #4
0
void doFrame()
{
    if(Input::IsKeyDown(SDLK_LCTRL) && Input::IsPressed(SDLK_q))
    {
        if(connected)
        {
            MAKE_MSG(quit_msg,msg,QUIT_MSG);
            nc.send((unsigned char *)&msg,sizeof(quit_msg),SEND_GUARANTEED);
        }
        else
            done=1;
    }
    if ((Input::IsKeyDown(SDLK_LALT) || Input::IsKeyDown(SDLK_RALT)) && Input::IsPressed(SDLK_RETURN))
    {
        fullscreen = !fullscreen;
        Renderer::SetFullscreen(fullscreen);
        // The next block of code is stupid nonsense crap because it is already setup.
        // There is no reason to reload EVERYTHING just because we are going to fullscreen.
        /*initializeSystem();
        Renderer::Clear();
        Renderer::LoadIdentity();
        //load images and sounds
        char pnum[32];
        int i;
        soundMax=-1;
        bodyMax=-1;
        hairMax=-1;
        clothesMax=-1;
        monsterMax=-1;
        for(i=0;i<255;i++)
        {
        	if(soundMax==-1)
        	{
        		sprintf(pnum,"data/sounds/%d.wav",i);
        		if(!sounds.Load(i,pnum))
        			soundMax=i;
        	}
        	if(bodyMax==-1)
        	{
        		sprintf(pnum,"data/body/%d.png",i);
        		if(!pBody[i].Load(pnum))
        			bodyMax=i;
        	}
        	if(hairMax==-1)
        	{
        		sprintf(pnum,"data/hair/%d.png",i);
        		if(!pHair[i].Load(pnum))
        			hairMax=i;
        	}
        	if(clothesMax==-1)
        	{
        		sprintf(pnum,"data/clothes/%d.png",i);
        		if(!pClothes[i].Load(pnum))
        			clothesMax=i;
        	}
        	if(monsterMax==-1 && i>0)
        	{
        		sprintf(pnum,"data/monsters/%d.png",i);
        		if(!pMonster[i].Load(pnum))
        			monsterMax=i;
        	}
        }
        tiledata.Load("data/misc/tiledata.png");
        effdata.Load("data/misc/effects.png");
        itemdata.Load("data/misc/items.png");
        loading.Load("data/misc/loading.png");
        skin.Load("data/misc/skin0.png");

        //load fonts
        font.Load("data/misc/font.png");
        TEXTDRAWER.Initialize(font.img);
        TEXTDRAWER.setColor(0,0,0,1);
        //create effects,terminal,dialog boxes
        eff.create(MAX_EFFECTS);
        bar.create(MAX_HPBAR);
        term.create(255,11);

        //	setupDialogs();
        loadEffectsMap();
        updateFPS();*/

        //render images
        doGameGraphics();
    }
    if(Input::IsPressed(SDLK_F5))//change skins
    {
        guiskin++;
        char name[256];
        sprintf(name,"data/misc/skin%d.png",guiskin);
        FILE *f=fopen(name,"r");
        if(f==NULL)
        {
            guiskin=0;
            sprintf(name,"data/misc/skin%d.png",guiskin);
            skin.Load(name);
        }
        else
        {
            fclose(f);
            f=0;
            skin.Load(name);
        }
    }
    if(Input::IsPressed(SDLK_ESCAPE))
    {
        target=-1;
        mtarget_id=-1;
        MAKE_MSG(trgt_msg,tr,TRGT_MSG);
        tr.index=mtarget_id;
        nc.send((unsigned char *)&tr,sizeof(trgt_msg),SEND_GUARANTEED);
        ptarget_id=-1;
        chatting=0;
        Input::ResetString();
    }
    if(connected && dialog==-1 && Input::IsPressed(SDLK_RETURN) && !Input::IsKeyDown(SDLK_LALT) && !Input::IsKeyDown(SDLK_RALT))
    {
        if(chatting)
        {
            if(strlen(Input::GetString())==0)
                chatting=0;
        }
        else
            chatting=1;
    }
    if(connected && me > -1 && MYGUY.access > 5)
    {
        if(Input::IsPressed(SDLK_F1))
        {
            target=-1;
            if(mode==1) mode=0;
            else mode=1;
        }
        if(Input::IsPressed(SDLK_F11)) //debug
        {

            if(debug==1) debug=0;
            else debug=1;
        }
    }
    if(me > -1 && !chatting && dialog==-1 && MYGUY.hp>0 && (strcmp(world[MYGUY.p.map].name,"_EMPTY_")!=0 || mode==1))
        doGameInput();
    else if((ptarget_id!=-1&&MYGUY.front()==player[ptarget_id].p)&& attackTimer.tick(50))
        attack();
    if(dialog==-1 && chatting && Input::StringInput(240))
    {
        if(parse(Input::GetString()))
        {
            if(me > -1)
            {
                //sprintf(temp,"%s:%s",MYGUY.name, Input::GetString());
                //term.newLine("Here is a very long sentence i am using to test with will you please split it up correctly at the spaces so it will wrap around, thank you very much sir...");
                //term.newLine(Input::GetString());
                //balloon.add(Input::GetString(),me);
                MAKE_MSG(chat_msg,reply,CHAT_MSG);
                reply.size=strlen(Input::GetString())+1;//+1 for null
                char buf[256];
                char *InputString = Input::GetString();
                memcpy(&buf,(void *)&reply,sizeof(chat_msg));//store header
                memcpy(buf+sizeof(chat_msg),(void *)&InputString,reply.size);//store string
                nc.send((unsigned char *)&buf,sizeof(chat_msg)+reply.size,SEND_GUARANTEED);
                chatting=0;
            }
        }
        else if(me > -1)
        {
            chatting=0;
        }
        Input::ResetString();
    }
    updateFPS();
    //render images
    Renderer::Clear();
    Renderer::LoadIdentity();
    doGameGraphics();

    /*TEXTDRAWER.setColor(1,1,1,1);//draw bottleneck stats
    for(int i=0;i<4;i++)
    	TEXTDRAWER.PrintText(10,50+i*20,"%d) %d",i,bottle.times[i]);
    TEXTDRAWER.defaultColor();*/

    if(mode==1)
    {
        doMapDialog();
        int r=mapDialog.modified();
        if(r>-1)
            mapEvent(r);
    }
    //if(keyDown[SDLK_HOME])
    //	term.renderAll(0,200);
    //else
    term.render(0,480,246-chat_scroll,9);
    if(dialog!=-1)
    {
        vDialog[dialog].draw();
        if(dialog==4)//draw sprites
        {
            if(animTimer.tick(400))
                animSel=abs(animSel-1);
            TEXTDRAWER.PrintTextf(vDialog[4].x+160,vDialog[4].y+162,"%d",bodySel);
            TEXTDRAWER.PrintTextf(vDialog[4].x+160,vDialog[4].y+162+35,"%d",clothesSel);
            TEXTDRAWER.PrintTextf(vDialog[4].x+160,vDialog[4].y+162+70,"%d",hairSel);
            drawChar(vDialog[4].x+10,vDialog[4].y+10,-1,bodySel,clothesSel,hairSel,0,animSel,4);
            drawChar(vDialog[4].x+90,vDialog[4].y+10,-1,bodySel,clothesSel,hairSel,1,animSel,4);
            drawChar(vDialog[4].x+170,vDialog[4].y+10,-1,bodySel,clothesSel,hairSel,2,animSel,4);
            drawChar(vDialog[4].x+250,vDialog[4].y+10,-1,bodySel,clothesSel,hairSel,3,animSel,4);
        }
        else if(dialog==6)
        {
            if(animTimer.tick(400))
                animSel=abs(animSel-1);
            for(int i=0; i<4; i++)if(slot[i].lvl>0)
                {
                    TEXTDRAWER.PrintTextf(vDialog[6].x+16+128*i,vDialog[6].y+162,"%s",slot[i].name);
                    TEXTDRAWER.PrintTextf(vDialog[6].x+16+128*i,vDialog[6].y+162+16,"Level %d",slot[i].lvl);
                    drawChar(vDialog[6].x+10+128*i,vDialog[6].y+10,slot[i].sprite,slot[i].body,slot[i].clothes,slot[i].hair,0,animSel,4);
                    TEXTDRAWER.PrintTextf(vDialog[6].x+28+128*i,vDialog[6].y+196,"Use");
                }
                else TEXTDRAWER.PrintTextf(vDialog[6].x+28+128*i,vDialog[6].y+196,"New");
        }
        int r=vDialog[dialog].modified();
        if(r!=-1)
            dialogEvent(r);
    }
    else
    {
        if(me>-1 && strcmp(world[MYGUY.p.map].name,"_EMPTY_")==0)
        {
            loading.blitFast(150,150,float(Input::MouseX())/640.0f,float(Input::MouseY())/480.0f);
        }
        if(chatting)
        {
            char temp[256];
            int x=0,len;
            sprintf(temp,"Send:%s_",Input::GetString());
            len=pWidth(temp);
            if(len>636)
                x=636-len;
            TEXTDRAWER.setColor(1,1,1,1);
            TEXTDRAWER.PrintText(x,585,temp);
            TEXTDRAWER.defaultColor();
        }
    }
    //cursor
    skin.blit(Input::MouseX(),Input::MouseY(),64,0,32,32,1,1);
    Renderer::Swap();
}