Пример #1
0
        public string getRouteMap(string id, bool hor)
        {
            XMLement xml = new XMLement(Protocol.TAG_GET_ROUTE_MAP_REQ);

            AppController.showStatus("getRouteMap");
            xml.addAttribute("id", id);
            if (hor)
            {
                xml.addAttribute("height", "240");
                xml.addAttribute("width", "320");
            }
            else
            {
                xml.addAttribute("height", "320");
                xml.addAttribute("width", "240");
            }
            xml = utopiaRequest(xml);

            if (xml != null && xml.tag == Protocol.TAG_GET_ROUTE_MAP_RSP)
            {
                return(xml.getAttributeValue("url"));
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        ///  Sends position sample to the server.
        /// lat/lon format broken on server ?
        /// </summary>
        public void sendSample(float lat, float lon)
        {
//            if (DiwiPageBase.sCurrentPage != null)
//                DiwiPageBase.sCurrentPage.printStatus(AppController.sDistanceMoved.ToString());


            if (mAgentKey != null)
            {
                XMLement xml = new XMLement(Protocol.TAG_NAV_POINT_REQ);
                XMLement pt  = new XMLement("pt");

                pt.addAttribute("lon", lon.ToString(GpsReader.mUSFormat));
                pt.addAttribute("lat", lat.ToString(GpsReader.mUSFormat));

                xml.addChild(pt);

                xml = utopiaRequest(xml);

                if (xml != null && xml.tag == Protocol.TAG_NAV_POINT_RSP)
                {
                    if (poiCallback != null)
                    {
                        poiCallback(xml, GpsReader.lat, GpsReader.lon);
                    }
                }
            }
        }
Пример #3
0
        public XMLement doLogin()
        {
            XMLement xml = new XMLement(Protocol.TAG_LOGIN_REQ);

            xml.addAttribute(Protocol.ATTR_NAME, mUser);
            xml.addAttribute(Protocol.ATTR_PASSWORD, mPass);
            xml.addAttribute(Protocol.ATTR_PROTOCOLVERSION, Diwi.Properties.Resources.KwxServerProtocolVersion);

            lock (this) {
                xml = doRequest(xml, 0);
            }

            if (xml != null && xml.tag == Protocol.TAG_LOGIN_RSP)
            {
                mAgentKey = xml.getAttributeValue("agentkey");
                if (messageCallback != null)
                {
                    messageCallback("Kwx login succes: " + mAgentKey);
                }
            }
            else
            {
                if (messageCallback != null)
                {
                    messageCallback("Kwx login failed: " + xml.getAttributeValue("reason"));
                }
            }
            return(xml);
        }
Пример #4
0
        /// <summary>
        /// get route list.
        /// </summary>
        public XMLement getRouteList()
        {
            if (mAgentKey != null)
            {
                XMLement req1 = new XMLement(Protocol.TAG_GET_ROUTELIST_REQ);
                XMLement req2 = new XMLement(Protocol.TAG_GET_ROUTELIST_REQ);
                req1.addAttribute("type", "fixed");
                req2.addAttribute("type", "generated");

                req1 = utopiaRequest(req1);
                req2 = utopiaRequest(req2);

                if (req1 != null && req2 != null && (req1.tag == Protocol.TAG_GET_ROUTELIST_RSP) && (req1.tag == Protocol.TAG_GET_ROUTELIST_RSP))
                {
                    for (int i = 0; ; i++)
                    {
                        XMLement x = req1.getChild(i);
                        if (x != null)
                        {
                            req2.addChild(x);
                        }
                        else
                        {
                            break;
                        }
                    }
                    return(req2);
                }
                else
                {
                    return(null);
                }
            }
            return(new XMLement("NotLoggedInError"));
        }
Пример #5
0
        /// <summary>
        /// Select application on server.
        /// </summary>
        public XMLement selectApp()
        {
            // Create XML request
            XMLement request = new XMLement(Protocol.TAG_SELECT_APP_REQ);

            request.addAttribute(Protocol.ATTR_APPNAME, Diwi.Properties.Resources.KwApp);
            request.addAttribute(Protocol.ATTR_ROLENAME, Diwi.Properties.Resources.KwRole);

            // Save for later session restore
            selectAppRequest = request;

            // Execute request
            request = doRequest(request, 0);

            // Throw exception or return positive response
            return(request);
        }
Пример #6
0
        public XMLement addMedium(string id)
        {
            XMLement xml = new XMLement(Protocol.TAG_ADD_MEDIUM_REQ);

            AppController.showStatus("addMedium");
            xml.addAttribute(Protocol.ATTR_ID, id);
            xml.addAttribute("lat", AppController.sGpsReader.storedLattitude);
            xml.addAttribute("lon", AppController.sGpsReader.storedLongtitude);
            lock (this) {
                xml = utopiaRequest(xml);
            }
            if (xml != null && xml.tag == Protocol.TAG_ADD_MEDIUM_RSP)
            {
                return(xml);
            }
            else
            {
                return(null);
            }
        }
Пример #7
0
        public XMLement activateRoute(int routeID, bool init)
        {
            XMLement xml = new XMLement(Protocol.TAG_ACTIVATE_ROUTE_REQ);

            AppController.showStatus("activateRoute");
            xml.addAttribute(Protocol.ATTR_ID, routeID);
            xml.addAttribute(Protocol.ATTR_INIT, init.ToString());

            lock (this) {
                xml = utopiaRequest(xml);
            }
            if (xml != null && xml.tag == Protocol.TAG_ACTIVATE_ROUTE_RSP)
            {
                return(xml);
            }
            else
            {
                return(null);
            }
        }
Пример #8
0
        public XMLement navUGC(bool ugc)
        {
            XMLement xml = new XMLement(Protocol.TAG_NAV_UGC_REQ);

            xml.addAttribute("visible", (ugc) ? "true" : "false");
            lock (this) {
                xml = utopiaRequest(xml);
            }
            if (xml != null && xml.tag == Protocol.TAG_NAV_UGC_RSP)
            {
                return(xml);
            }
            else
            {
                return(null);
            }
        }
Пример #9
0
        public string getBoundsMap(int id, float radiusKm, bool hor)
        {
            float    urtLat, urtLon, llbLat, llbLon;
            XMLement req = new XMLement(Protocol.TAG_NAV_GET_MAP_REQ);

            AppController.showStatus("getBoundedMap");

            if (hor)
            {
                urtLat = GpsReader.lat + GpsReader.km2degLat(radiusKm);
                llbLat = GpsReader.lat - GpsReader.km2degLat(radiusKm);
                urtLon = GpsReader.lon + GpsReader.km2degLon((float)(radiusKm * 1.5));
                llbLon = GpsReader.lon - GpsReader.km2degLon((float)(radiusKm * 1.5));
                req.addAttribute("height", "240");
                req.addAttribute("width", "320");
            }
            else
            {
                urtLat = GpsReader.lat + GpsReader.km2degLat((float)(radiusKm * 1.5));
                llbLat = GpsReader.lat - GpsReader.km2degLat((float)(radiusKm * 1.5));
                urtLon = GpsReader.lon + GpsReader.km2degLon(radiusKm);
                llbLon = GpsReader.lon - GpsReader.km2degLon(radiusKm);
                req.addAttribute("height", "320");
                req.addAttribute("width", "240");
            }

            MapHandler.setTempBounds(hor, urtLat, urtLon, llbLat, llbLon);

            req.addAttribute("llbLat", llbLat.ToString(mUSFormat));
            req.addAttribute("llbLon", llbLon.ToString(mUSFormat));
            req.addAttribute("urtLat", urtLat.ToString(mUSFormat));
            req.addAttribute("urtLon", urtLon.ToString(mUSFormat));

            req = utopiaRequest(req);

            if ((req != null) && (req.tag == Protocol.TAG_NAV_GET_MAP_RSP))
            {
                return(req.getAttributeValue("url"));
            }
            return(null);
        }
Пример #10
0
        public XMLement getPOI(string id)
        {
            XMLement xml = new XMLement(Protocol.TAG_POI_GET_REQ);

            AppController.showStatus("getPOI");
            xml.addAttribute(Protocol.ATTR_ID, id);
            lock (this) {
                xml = utopiaRequest(xml);
            }
            if (xml != null && xml.tag == Protocol.TAG_POI_GET_RSP)
            {
                xmlString = xml.toString();
                return(xml);
            }
            else
            {
                return(null);
            }
        }
Пример #11
0
        public XMLement getRoute(string id)
        {
            if (mAgentKey != null)
            {
                XMLement xml = new XMLement(Protocol.TAG_GET_ROUTE_REQ);
                xml.addAttribute("id", id);

                xml = utopiaRequest(xml);

                if (xml != null && xml.tag == Protocol.TAG_GET_ROUTE_RSP)
                {
                    return(xml);
                }
                else
                {
                    return(null);
                }
            }
            return(new XMLement("NotLoggedInError"));
        }