示例#1
0
        // NOTE: pass in the ENTIRE response
        public static void HandleUserRegistrationData(XElement pResponse)
        {
            string sKey   = pResponse.Element("Data").Element("Key").Value;
            string sEmail = pResponse.Element("Data").Element("Email").Value;

            // write _key file
            File.WriteAllLines(Master.GetBaseDir() + "_key.dat", new List <string>()
            {
                sKey, sEmail
            });
            Master.SetKey(sKey);
            Master.SetEmail(sEmail);

            // check if clan data
            if (pResponse.Element("Data").Element("ClanStubs") != null)
            {
                List <string> lClanLines = new List <string>();
                foreach (XElement pElement in pResponse.Element("Data").Element("ClanStubs").Elements("ClanStub"))
                {
                    string sClanName = pElement.Attribute("ClanName").Value;
                    string sUserName = pElement.Attribute("UserName").Value;

                    lClanLines.Add(sClanName + "|" + sUserName);
                }

                File.WriteAllLines(Master.GetBaseDir() + "_clans.dat", lClanLines);
            }
        }
示例#2
0
        private void OnWakeInitializationProtocol()
        {
            //Directory.SetCurrentDirectory(Master.GetBaseDir());

            /*string[] aLines = File.ReadAllLines(Master.GetBaseDir() + "_active.dat");
             * Master.SetActiveClan(aLines[0]);
             * Master.SetActiveUserName(aLines[1]);*/
            Master.SetKey(File.ReadAllText(Master.GetBaseDir() + "_key.dat"));
        }
示例#3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.JoinGroup);

            EditText pClan = FindViewById <EditText>(Resource.Id.txtClanName);
            EditText pPass = FindViewById <EditText>(Resource.Id.txtClanPassword);
            EditText pUser = FindViewById <EditText>(Resource.Id.txtUserName);
            Button   pJoin = FindViewById <Button>(Resource.Id.btnSubmitJoin);

            pJoin.Click += delegate
            {
                // TODO: SANITIZATION!
                _hidden.InitializeWeb();
                //string sUserPass = File.ReadAllText(Master.GetBaseDir() + "_key.dat");
                string sUserPass = Master.GetKey();
                string sBody     = "<params><param name='sEmail'>" + Master.GetEmail() + "</param><param name='sClanName'>" + pClan.Text.ToString() + "</param><param name='sClanPassPhrase'>" + pPass.Text.ToString() + "</param><param name='sUserName'>" + pUser.Text.ToString() + "</param><param name='sUserPassPhrase'>" + sUserPass + "</param></params>";
                //string sResponse = WebCommunications.SendPostRequest("http://dwlapi.azurewebsites.net/api/reflection/GameClansServer/GameClansServer/ClanServer/JoinClan", sBody, true);
                string sResponse = WebCommunications.SendPostRequest(Master.GetBaseURL() + Master.GetServerURL() + "JoinClan", sBody, true);

                XElement pResponse = Master.ReadResponse(sResponse);

                //Master.Popup(this, pResponse.Element("Text").Value);
                string sResponseMessage = pResponse.Element("Text").Value;


                // TODO: even if user is already part of clan, need to check local clans file and make sure the data is there (and add it if not)



                var pBuilder = new AlertDialog.Builder(this);
                pBuilder.SetMessage(sResponseMessage);

                if (pResponse.Attribute("Type").Value == "Error" || pResponse.Element("Data").Element("ClanStub") == null)
                {
                    pBuilder.SetPositiveButton("Ok", (e, s) => { return; });
                }
                else
                {
                    pBuilder.SetPositiveButton("Ok", (e, s) =>
                    {
                        XElement pClanStub = pResponse.Element("Data").Element("ClanStub");
                        string sClanName   = pClanStub.Attribute("ClanName").Value;
                        string sUserName   = pClanStub.Attribute("UserName").Value;

                        File.AppendAllLines(Master.GetBaseDir() + "_clans.dat", new List <string>()
                        {
                            sClanName + "|" + sUserName
                        });
                        this.SetResult(Result.Ok);
                        this.Finish();
                    });
                }
                pBuilder.Create().Show();
            };
        }
示例#4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            _hidden.InitializeWeb();

            _RunTempCommands();             // TODO: REMOVE

            if (!this.CheckVersion())
            {
                return;
            }

            // make sure that all the necessary files exist
            if (!File.Exists(Master.GetBaseDir() + "_clans.dat"))
            {
                File.Create(Master.GetBaseDir() + "_clans.dat").Dispose();
            }
            if (!File.Exists(Master.GetBaseDir() + "_settings.dat"))
            {
                File.WriteAllText(Master.GetBaseDir() + "_settings.dat", "notifications=on");
            }
            if (!File.Exists(Master.GetBaseDir() + "_key.dat"))
            {
                //Intent pIntent = new Intent(this, (new KeyActivity().Class));
                Intent pIntent = new Intent(this, typeof(RegisterOrLogInActivity));
                StartActivity(pIntent);
            }
            else
            {
                Master.FillKeyEmail();
            }

            // TODO: save temp currently active clan so persistent between app open times, and load it here
            if (File.Exists(Master.GetBaseDir() + "_active.dat"))
            {
                string[] aLines = File.ReadAllLines(Master.GetBaseDir() + "_active.dat");
                Master.SetActiveClan(aLines[0]);
                Master.SetActiveUserName(aLines[1]);
            }

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            base.CreateDrawer();

            if (Master.GetActiveClan() != "")
            {
                this.Title = Master.GetActiveClan() + " - " + Master.GetActiveUserName();
                this.BuildHomeDashboard();
            }

            //StartService(new Intent(this, typeof(NotificationsService)));
        }
示例#5
0
        public override void OnReceive(Context context, Intent intent)
        {
            PowerManager pPowerManager = (PowerManager)context.GetSystemService(Context.PowerService);

            PowerManager.WakeLock pWakeLock = pPowerManager.NewWakeLock(WakeLockFlags.Partial, "GC_NOTIFS");

            pWakeLock.Acquire();

            if (Master.GetSetting("notifications") == "on")
            {
                this.OnWakeInitializationProtocol();

                foreach (string sLine in File.ReadAllLines(Master.GetBaseDir() + "_clans.dat").ToList())
                {
                    string sClan     = sLine.Substring(0, sLine.IndexOf("|"));
                    string sUserName = sLine.Substring(sLine.IndexOf("|") + 1);
                    this.CheckServerNotifications(context, sClan, sUserName);
                }
            }

            pWakeLock.Release();
        }
        private void RefreshClanList()
        {
            m_lClanNames = File.ReadAllLines(Master.GetBaseDir() + "_clans.dat").ToList();
            m_lClanParts = new List <string>();
            m_lUserParts = new List <string>();

            // clan name|user name
            //for (int i = 0; i < aClansList.Length; i++) { aClansList[i] = aClansList[i].Substring(0, aClansList[i].IndexOf("|")); }
            for (int i = 0; i < m_lClanNames.Count; i++)
            {
                m_lClanParts.Add(m_lClanNames[i].Substring(0, m_lClanNames[i].IndexOf("|")));
                m_lUserParts.Add(m_lClanNames[i].Substring(m_lClanNames[i].IndexOf("|") + 1));
                m_lClanNames[i] = m_lClanNames[i].Replace("|", " - ");
            }

            ListView pClansList = FindViewById <ListView>(Resource.Id.clansList);

            pClansList.Adapter = new DrawerItemCustomAdapter(this, Resource.Layout.ListViewItemRow, m_lClanNames.ToArray());

            pClansList.ItemClick += (object sender, Android.Widget.AdapterView.ItemClickEventArgs e) =>
            {
                int iChoice = e.Position;
                Master.SetActiveClan(m_lClanParts[iChoice]);
                Master.SetActiveUserName(m_lUserParts[iChoice]);

                // store this in the _active file, so as to persist between app openings and closings
                List <string> lLines = new List <string>();
                lLines.Add(m_lClanParts[iChoice]);
                lLines.Add(m_lUserParts[iChoice]);
                File.WriteAllLines(Master.GetBaseDir() + "_active.dat", lLines.ToArray());

                Intent pIntent = new Intent(this, (new MainActivity()).Class);
                this.Finish();
                StartActivity(pIntent);
            };
        }
示例#7
0
 public static void FillKeyEmail()
 {
     string[] aLines = File.ReadAllLines(Master.GetBaseDir() + "_key.dat");
     Master.SetKey(aLines[0]);
     Master.SetEmail(aLines[1]);
 }