예제 #1
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);
        }
예제 #2
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);
            }
        }
예제 #3
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"));
        }
예제 #4
0
 public bool toggleUGC()
 {
     if (mUGCState)
     {
         XMLement xml = new XMLement(Protocol.TAG_UGC_OFF_REQ);
         lock (this) {
             xml = utopiaRequest(xml);
         }
         if (xml != null && xml.tag == Protocol.TAG_UGC_OFF_RSP)
         {
             return(mUGCState = false);
         }
     }
     else
     {
         XMLement xml = new XMLement(Protocol.TAG_UGC_ON_REQ);
         lock (this) {
             xml = utopiaRequest(xml);
         }
         if (xml != null && xml.tag == Protocol.TAG_UGC_ON_RSP)
         {
             return(mUGCState = true);
         }
     }
     return(false);
 }
예제 #5
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);
                    }
                }
            }
        }
예제 #6
0
        void doTerugStart(int i, string s)
        {
            XMLement xml = AppController.sKwxClient.routeHome();

            xml = xml.getChildByName("route");
            // string xs = xml.toString();
            // AppController.sEventLog.WriteLine(xml.toString());
            if (xml != null && xml.getAttributeValue("id") != null)
            {
                if (AppController.sActiveRouteID != -1)
                {
                    AppController.sKwxClient.deActivateRoute();
                    AppController.sActiveRouteID = -1;
                    AppController.sActiveRoute   = null;
                }
                AppController.sActiveRouteID = int.Parse(xml.getAttributeValue("id"));
                AppController.sKwxClient.activateRoute(AppController.sActiveRouteID, false);
                AppController.sActiveRoute           = xml;
                AppController.sActiveRouteMapPathHor = null;
                AppController.sActiveRouteMapPathVer = null;
                AppController.sKwxClient.activateRoute(AppController.sActiveRouteID, true);
                walkRoute(0, "");
            }
            else
            {
                resetMenu();
            }
        }
예제 #7
0
        void doUgcs(List <XMLement> ugcs)
        {
            AppController.poiHit();


            XMLement raw = XMLement.createFromRawXml("<poi><name>VolksMond</name><description>Door andere gebruikers gemaakte media</description></poi>");
            XMLement mmd = new XMLement("media");

            foreach (XMLement x in ugcs)
            {
                mmd.addChild(x);
            }

            raw.addChild(mmd);

            AppController.sEventLog.WriteLine("hit {0} ugc:", ugcs.Count);
            AppController.sEventLog.WriteLine("\t", raw.toString());

            if (sUgcViewerPage == null)
            {
                sUgcViewerPage = new PoiViewerPage(this);
            }

            if (sUgcViewerPage.setContent(raw))
            {
                mIsActive = false;
                sUgcViewerPage.ShowDialog();
                mBlendTimer.Change(0, 3000);
            }
        }
예제 #8
0
        public XMLement sendEchoRequest()
        {
            XMLement xml = new XMLement(Protocol.TAG_ECHO_REQ);

            lock (this) {
                xml = doRequest(xml, 0);
            }
            return(xml);
        }
예제 #9
0
        public string getChildValue(string childTag)
        {
            XMLement child = getChildByName(childTag);

            if (child != null)
            {
                return(child.mNodeText);
            }
            return(null);
        }
예제 #10
0
        public XMLement doLogout()
        {
            XMLement xml = new XMLement(Protocol.TAG_LOGOUT_REQ);

            AppController.showStatus("logout");
            lock (this) {
                xml = doRequest(xml, 0);
            }
            mAgentKey = null;
            return(xml);
        }
예제 #11
0
        void doDownloadMedium(int index)
        {
            char[]   trimChars = { '\t', ' ', '\n', '\r' };
            XMLement kichUri   = mAllMedia.getChild(index);

            if (kichUri.tag == "ugc-hit")
            {
                doDownloadUGC(index);
                return;
            }
            mDownloadIndex = index;
            if (kichUri != null)
            {
                string fn   = "";
                string url  = kichUri.nodeText;
                string ext  = (url.Substring(url.LastIndexOf('.'))).TrimEnd(trimChars);
                string type = kichUri.getAttributeValue("type");
                mDnlName = (url.Substring(1 + url.LastIndexOf('/'))).TrimEnd(trimChars);

                string   localF = AppController.sMediaStore + mDnlName;
                FileInfo fi     = new System.IO.FileInfo(localF);
                if (fi.Exists)
                {
                    dnlDoneT(localF, true);
                    return;
                }

                AppController.sPoiSelectPage.setDownloadMessage("ophalen: " + mDnlName);
                mDnlUrl = url;
                switch (type)
                {
                case "image":
                    fn = AppController.sAppDir + "poiImage" + mMediaIndex.ToString() + ext;
                    break;

                case "audio":
                    fn = AppController.sAppDir + "poiSound" + mMediaIndex.ToString() + ext;
                    break;

                case "video":
                    fn = AppController.sAppDir + "poiVideo" + mMediaIndex.ToString() + ext;
                    break;

                case "text":
                    fn = AppController.sAppDir + "poiText" + mMediaIndex.ToString() + ext;
                    break;
                }
                if (fn != "")
                {
                    mMediaDnl = new MediaDownloader(url, fn, new AppController.DownloadCallbackHandler(dnlDoneT));
                }
            }
        }
예제 #12
0
        public XMLement navState()
        {
            XMLement xml = new XMLement(Protocol.TAG_NAV_STATE_REQ);

            lock (this) {
                xml = utopiaRequest(xml);
            }
            if (xml != null && xml.tag == Protocol.TAG_NAV_STATE_RSP)
            {
                return(xml);
            }
            else
            {
                return(null);
            }
        }
예제 #13
0
        public void setContent(XMLement r)
        {
            string mapUrl = AppController.sKwxClient.getRouteMap(r.getAttributeValue("id"), horizontal);

            if (mapUrl != null)
            {
                new MediaDownloader(mapUrl, horizontal ? "horMap.jpg" : "verMap.jpg", new AppController.DownloadCallbackHandler(openMapT));
            }
            mVerMap       = null;
            mHorMap       = null;
            route         = r;
            mTextBox.Text = route.getChildValue("description") + "\n\n" + "Afstand is " + int.Parse(route.getChildValue("distance")) / 1000 + "km.";
            title         = route.getChildValue("name");
            reOrient();
            draw();
        }
예제 #14
0
        void doBekijkRoute(int i, string s)
        {
            XMLement route = AppController.sRoutes.getChild(i + mRouteOffset);

            if (rInfoPage == null)
            {
                rInfoPage = new RouteInfoPage(this);
            }
            rInfoPage.setContent(route);
            rInfoPage.ShowDialog();
            if (AppController.sActiveRouteID != -1)
            {
                AppController.sKwxClient.activateRoute(AppController.sActiveRouteID, true);
                doTerug(0, null);
            }
        }
예제 #15
0
 void navPointMessage(XMLement xml, float lat, float lon)
 {
     if (this.mIsActive)
     {
         if (xml != null)
         {
             if (InvokeRequired)
             {
                 Invoke(poiCB, new object[] { xml, lat, lon });
             }
             else
             {
                 navPointReceive(xml, lat, lon);
             }
         }
     }
 }
예제 #16
0
        public XMLement deActivateRoute()
        {
            XMLement xml = new XMLement(Protocol.TAG_DEACTIVATE_ROUTE_REQ);

            AppController.showStatus("deActivateRoute");
            lock (this) {
                xml = utopiaRequest(xml);
            }
            if (xml != null && xml.tag == Protocol.TAG_DEACTIVATE_ROUTE_RSP)
            {
                return(xml);
            }
            else
            {
                return(null);
            }
        }
예제 #17
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);
        }
예제 #18
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);
            }
        }
예제 #19
0
        public XMLement doNavStart()
        {
            XMLement xml = new XMLement(Protocol.TAG_NAV_START_REQ);

            AppController.showStatus("navStart");
            lock (this) {
                xml = utopiaRequest(xml);
            }
            if (xml != null && xml.tag == Protocol.TAG_NAV_START_RSP)
            {
                mNavStarted = true;
                return(xml);
            }
            else
            {
                return(null);
            }
        }
예제 #20
0
        public XMLement routeHome()
        {
            XMLement xml = new XMLement(Protocol.TAG_NAV_HOME_REQ);

            AppController.showStatus("route to start");

            lock (this) {
                xml = utopiaRequest(xml);
            }
            if (xml != null && xml.tag == Protocol.TAG_NAV_HOME_RSP)
            {
                return(xml);
            }
            else
            {
                return(null);
            }
        }
예제 #21
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);
            }
        }
예제 #22
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"));
        }
예제 #23
0
        /// <summary>
        /// Encapsulate request in utopia request.
        /// </summary>
        public XMLement utopiaRequest(XMLement anElement)
        {
            XMLement req = new XMLement();

            req.tag = Protocol.TAG_UTOPIA_REQ;
            req.addChild(anElement);
            lock (this) {
                req = doRequest(req, 0);
            }
            if ((req != null) && (req.tag == "utopia-rsp"))
            {
                return(req.firstChild());
            }
            else
            {
                // add error handling!
            }

            return(null);
        }
예제 #24
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);
            }
        }
예제 #25
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);
            }
        }
예제 #26
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);
        }
예제 #27
0
        bool offerPOI(string poiID)
        {
            XMLement x = AppController.sKwxClient.getPOI(poiID);

            if (x != null)
            {
                AppController.sEventLog.WriteLine("\tpoi: {0}", poiID);
                x = x.getChildByName("poi");

                if (x != null)
                {
                    mCurrentPOI = x;
                    XMLement name_xml = x.getChildByName("name");
                    if (name_xml != null)
                    {
                        AppController.sEventLog.WriteLine("\tname: {0}", name_xml.nodeText);
                        title = name_xml.nodeText;
                    }
                    XMLement desc_xml = x.getChildByName("description");
                    if (desc_xml != null)
                    {
                        AppController.sEventLog.WriteLine("\tdesc: {0}", desc_xml.nodeText);
                        mTextBox.Text = desc_xml.nodeText;
                    }
                    mTextBox.Visible = true;
                    mHasContent      = sPoiPage.setContent(x);
                    if (mHasContent)
                    {
                        setMenuText(0, "Toon Media");
                    }
                    else
                    {
                        setMenuText(0, "Geen Media");
                    }
                    return(true);
                }
            }
            return(false);
        }
예제 #28
0
        void doDownloadUGC(int index)
        {
            char[]   trimChars = { '\t', ' ', '\n', '\r' };
            XMLement ugc       = mAllMedia.getChild(index);

            mDownloadIndex = index;
            if (ugc != null)
            {
                string fn       = "";
                string filename = ugc.getAttributeValue("filename");
                string url      = Diwi.Properties.Resources.KwxMediaServerUrl + "?id=" + ugc.getAttributeValue("id");
                string ext      = (filename.Substring(filename.LastIndexOf('.'))).TrimEnd(trimChars);
                string type     = ugc.getAttributeValue("kind");
                mDnlName = ugc.getAttributeValue("name");
                drawDnlText("ophalen: " + mDnlName);
                switch (type)
                {
                case "image":
                    fn = AppController.sAppDir + "poiImage" + mMediaIndex.ToString() + ext;
                    break;

                case "audio":
                    fn = AppController.sAppDir + "poiSound" + mMediaIndex.ToString() + ext;
                    break;

                case "video":
                    fn = AppController.sAppDir + "poiVideo" + mMediaIndex.ToString() + ext;
                    break;

                case "text":
                    fn = AppController.sAppDir + "poiText" + mMediaIndex.ToString() + ext;
                    break;
                }
                if (fn != "")
                {
                    mMediaDnl = new MediaDownloader(url, fn, new AppController.DownloadCallbackHandler(dnlDoneT));
                }
            }
        }
예제 #29
0
        void doNext(int i, string s)
        {
            mMediaIndex++;
            XMLement kichUri = mAllMedia.getChild(mMediaIndex);

            if (kichUri != null)
            {
                mTextBox.Visible = false;
                mImage.x         = 500;
                if (dnlFileNames[mMediaIndex] != null)
                {
                    openFile(dnlFileNames[mMediaIndex]);
                }
                else
                {
                    mTextBox.Visible = false;
                    mImage.x         = 800;
                    draw();
                }
            }
            else
            {
                if (mMediaDnl != null)
                {
                    mMediaDnl.abort();
                }
                reset();
                if (mIsInitialized)
                {
                    doTerug(0, "");
                }
            }
            if (mAllMedia.getChild(mMediaIndex + 1) == null)
            {
                setMenuText(0, "Terug");
                setMenuIcon(0, AppController.sTerugIcon);
            }
            draw();
        }
예제 #30
0
        public bool setContent(XMLement xml)
        {
            setMenuText(0, "Volgende");
            setMenuIcon(0, AppController.sVolgIcon);
            abortDownload();
            XMLement name = xml.getChildByName("name");

            if (name != null)
            {
                title = name.nodeText;
            }
            mAllMedia = xml.getChildByName("media");
            AppController.sEventLog.WriteLine(mAllMedia.toString());
            mDnlName = "";
            drawNameText();

            mMediaIndex    = -1;
            mDownloadIndex = -1;
            mImage.x       = 500;

            for (int i = 0; i < 10; i++)
            {
                dnlFileNames[i] = null;
            }
            if (mAllMedia.getChild(0) != null)
            {
                doDownloadMedium(0);
            }
            else
            {
                setMenuText(0, "Terug");
                setMenuIcon(0, AppController.sTerugIcon);
                return(false);
            }
            return(true);
        }