Example #1
0
        public static void checkForUpdates(bool silent)
        {
            RHUpdater.silent = silent;
            if (Custom.GetBool("removeUpdates", false))
            {
                return;                                         // Do not try to look for updates.
            }
            url = "http://www.repetier.com/updates/rh/version_windows.txt";
            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                url = "http://www.repetier.com/updates/rh/version_linux.txt";
            }
            url = Custom.GetString("updateUrl", url);

            long lastcheck = RegMemory.GetLong("lastUpdateCheck", 0);

            if (silent && timeInSeconds() - lastcheck < 86400 * 7)
            {
                return;                                                    // Test only once a week silently
            }
            //if (!pingServer("176.9.149.139")) return; // No network

            thread  = new Thread(RHUpdater.CheckThread);
            running = true;
            Main.main.checkForUpdatesToolStripMenuItem.Enabled = false;
            thread.Start();
        }
Example #2
0
            public void Save(string fname)
            {
                if (list.Count > 0 && list.First.Value.file == fname)
                {
                    return;
                }
                foreach (HistoryFile f in list)
                {
                    if (f.file == fname)
                    {
                        list.Remove(f);
                        break;
                    }
                }
                list.AddFirst(new HistoryFile(fname));
                while (list.Count > maxLength)
                {
                    list.RemoveLast();
                }
                // Build string
                string store = "";

                foreach (HistoryFile f in list)
                {
                    store += "|" + f.file;
                }
                RegMemory.SetString(name, store.Substring(1));
            }
Example #3
0
            public FilesHistory(string id, int max)
            {
                name      = id;
                maxLength = max;
                string l = RegMemory.GetString(name, "");

                foreach (string fn in l.Split('|'))
                {
                    if (fn.Length > 0 && File.Exists(fn))
                    {
                        list.AddLast(new HistoryFile(fn));
                        if (list.Count == max)
                        {
                            break;
                        }
                    }
                }
            }
Example #4
0
        static public void parseVersion(string s)
        {
            string[] arr = s.Split('\n');
            if (arr.Length < 4)
            {
                return;
            }
            newestVersion = arr[0].Trim();
            int.TryParse(arr[1].Trim(), out newestBuildVersion);
            downloadUrl = arr[2].Trim();
            StringBuilder b = new StringBuilder();

            for (int i = 3; i < arr.Length; i++)
            {
                b.AppendLine(arr[i].Trim());
            }
            updateText = b.ToString();
            RegMemory.SetLong("lastUpdateCheck", timeInSeconds());
        }
Example #5
0
 private void buttonSkipVersion_Click(object sender, EventArgs e)
 {
     RegMemory.SetInt("checkUpdateSkipBuild", newestBuildVersion);
     Hide();
 }
Example #6
0
        private static void ReadCallBack(IAsyncResult asyncResult)
        {
            try
            {
                // Get the RequestState object from AsyncResult.
                RequestState rs = (RequestState)asyncResult.AsyncState;

                // Retrieve the ResponseStream that was set in RespCallback.
                Stream responseStream = rs.ResponseStream;

                // Read rs.BufferRead to verify that it contains data.
                int read = responseStream.EndRead(asyncResult);
                if (read > 0)
                {
                    // Prepare a Char array buffer for converting to Unicode.
                    Char[] charBuffer = new Char[BUFFER_SIZE];

                    // Convert byte stream to Char array and then to String.
                    // len contains the number of characters converted to Unicode.
                    int len =
                        rs.StreamDecode.GetChars(rs.BufferRead, 0, read, charBuffer, 0);

                    String str = new String(charBuffer, 0, len);

                    // Append the recently read data to the RequestData stringbuilder
                    // object contained in RequestState.
                    rs.RequestData.Append(
                        Encoding.ASCII.GetString(rs.BufferRead, 0, read));

                    // Continue reading data until
                    // responseStream.EndRead returns –1.
                    IAsyncResult ar = responseStream.BeginRead(
                        rs.BufferRead, 0, BUFFER_SIZE,
                        new AsyncCallback(ReadCallBack), rs);
                }
                else
                {
                    if (rs.RequestData.Length > 0)
                    {
                        //  Display data to the console.
                        string strContent;
                        strContent = rs.RequestData.ToString();
                        parseVersion(strContent);
                        if (buildVersion < newestBuildVersion)
                        {
                            if (silent && RegMemory.GetInt("checkUpdateSkipBuild", 0) == newestBuildVersion)
                            {
                                return; // User didn't want to see this update.
                            }
                            Main.main.Invoke(RHUpdater.Execute);
                        }
                        else if (!silent)
                        {
                            // MessageBox.Show("No new updates available.\r\nYou are using the latest version.", "Update status", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            MessageBox.Show(Trans.T("L_NO_NEW_UPDATES"), Trans.T("L_UPDATE_STATUS"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    // Close down the response stream.
                    responseStream.Close();
                    // Set the ManualResetEvent so the main thread can exit.
                    allDone.Set();
                }
            }
            finally
            {
                Main.main.Invoke(RHUpdater.Finished);
            }
            return;
        }
 private void buttonSkipVersion_Click(object sender, EventArgs e)
 {
     RegMemory.SetInt("checkUpdateSkipBuild", UpdateSoftwareXML.newestUpdate.buildnum);
     this.Hide();
     this.Dispose();
 }