Example #1
0
        private bool AddURLToList(Imageboard imageboard)
        {
            if (imageboard == null)
            {
                return(false);
            }

            if (imageboard.isBoard())
            {
                lock (boardLock)
                {
                    ListBoards.Add(imageboard);
                    updateDataSource(typeURL.board);
                }
            }
            else
            {
                lock (threadLock)
                {
                    ListThreads.Add(imageboard);
                    updateDataSource(typeURL.thread);
                }
            }

            return(true);
        }
Example #2
0
        private void btnClearAll_Click(object sender, EventArgs e)
        {
            bool board = (tcApp.SelectedIndex == 1);                             // Board Tab is open -> board=true; Thread tab -> board=false

            string type = "threads";

            if (board)
            {
                type = "boards";
            }

            DialogResult dialogResult = MessageBox.Show("Are you sure?", "Clear all " + type, MessageBoxButtons.YesNo);    // confirmation prompt

            if (dialogResult == DialogResult.Yes)
            {
                if (board)
                {
                    ListBoards.Clear();
                    updateDataSource(typeURL.board);
                }
                else
                {
                    ListThreads.Clear();
                    updateDataSource(typeURL.thread);
                }

                if (General.saveOnClose)
                {
                    General.writeURLs(ListBoards, ListThreads);
                }
            }
        }
Example #3
0
        private void ScanThread()
        {
            lock (threadLock)
            {
                //Removes 404'd threads
                foreach (Imageboard imB in ListThreads.ToArray())
                {
                    if (imB.isGone())
                    {
                        ListThreads.Remove(imB);
                        updateDataSource(typeURL.thread);

                        if (General.saveOnClose)
                        {
                            General.writeURLs(ListBoards, ListThreads);
                        }
                    }
                }
            }

            lock (boardLock)
            {
                //Searches for new threads on the watched boards
                foreach (Imageboard imB in ListBoards)
                {
                    string[] Threads = { };
                    try
                    {
                        Threads = imB.getThreads();
                    }
                    catch (Exception exep)
                    {
                    }
                    foreach (string thread in Threads)
                    {
                        Imageboard newImageboard = General.createNewIMB(thread, false);
                        if (newImageboard != null && isUnique(newImageboard.getURL(), ListThreads))
                        {
                            lock (threadLock)
                            {
                                ListThreads.Add(newImageboard);
                                updateDataSource(typeURL.thread);
                            }
                        }
                    }
                }
            }

            lock (threadLock)
            {
                //Download threads
                foreach (Imageboard imB in ListThreads)
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(imB.download));
                }
            }
        }
Example #4
0
        private void ScanThread()
        {
            lock (threadLock)
            {
                //Removes 404'd threads
                foreach (Imageboard imB in ListThreads.ToArray())
                {
                    if (imB.isGone())
                    {
                        ListThreads.Remove(imB);
                        updateDataSource(typeURL.thread);

                        if (Properties.Settings.Default.saveOnClose)
                        {
                            General.WriteURLs(ListBoards, ListThreads);
                        }
                    }
                }
            }

            lock (boardLock)
            {
                //Searches for new threads on the watched boards
                foreach (Imageboard imB in ListBoards)
                {
                    string[] Threads = { };
                    try
                    {
                        Threads = imB.getThreads();
                    }
                    catch
                    {
                    }
                    finally
                    {
                        foreach (string thread in Threads)
                        {
                            Imageboard newImageboard = General.CreateNewImageboard(thread);
                            if (newImageboard != null && isUnique(newImageboard.getURL(), ListThreads))
                            {
                                AddURLToList(newImageboard);
                            }
                        }
                    }
                }
            }

            lock (threadLock)
            {
                //Download threads
                foreach (Imageboard imB in ListThreads)
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(imB.download));
                }
            }
        }
Example #5
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            General.loadSettings();                                                     // load settings on startup
            if (!General.minimizeToTray)                                                // if trayicon deactivated
            {
                nfTray.Visible = false;                                                 // hide it
            }
            scnTimer.Enabled  = false;                                                  // disable timer
            scnTimer.Interval = General.timer;                                          // set interval
            scnTimer.Tick    += new EventHandler(this.scan);                            // when Timer ticks call scan()
            ThreadPool.SetMaxThreads(Environment.ProcessorCount, Environment.ProcessorCount);

            if (General.firstStart)
            {
                FirstStart tFirstStart = new FirstStart();                              // if first start, show first start message
                tFirstStart.ShowDialog();
            }

            if (General.saveOnClose)                                                    // if enabled load URLs from file
            {
                string boards  = General.loadURLs(true);
                string threads = General.loadURLs(false);                               // load threads

                if (!String.IsNullOrWhiteSpace(boards))
                {
                    lock (boardLock)
                    {
                        string[] URLs = boards.Split('\n');
                        for (int i = 0; i < URLs.Length - 1; i++)
                        {
                            Imageboard newImageboard = General.createNewIMB(URLs[i], true); // and add them
                            ListBoards.Add(newImageboard);
                        }
                    }
                }

                if (!String.IsNullOrWhiteSpace(threads))
                {
                    lock (threadLock)
                    {
                        string[] URLs = threads.Split('\n');
                        for (int i = 0; i < URLs.Length - 1; i++)
                        {
                            Imageboard newImageboard = General.createNewIMB(URLs[i], false);
                            ListThreads.Add(newImageboard);
                        }
                    }
                }

                lbBoards.DataSource  = ListBoards;
                lbThreads.DataSource = ListThreads;

                scnTimer.Enabled = true;                                       // activate the timer
                scan(null, null);                                              // and start scanning
            }
        }
Example #6
0
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (tPos != -1)
     {
         lock (threadLock)
         {
             ListThreads.RemoveAt(tPos);
             updateDataSource(typeURL.thread);
         }
     }
 }
Example #7
0
        private void AddUrl(string url, bool board)
        {
            Imageboard newImageboard = General.createNewIMB(url, board);

            if (newImageboard != null)
            {
                if (isUnique(newImageboard.getURL(), ListThreads))
                {
                    if (board)
                    {
                        lock (boardLock)
                        {
                            ListBoards.Add(newImageboard);
                            updateDataSource(typeURL.board);
                        }
                    }
                    else
                    {
                        lock (threadLock)
                        {
                            ListThreads.Add(newImageboard);
                            updateDataSource(typeURL.thread);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("URL is already in queue!");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Corrupt URL, unsupported website or not a board/thread!");
                edtURL.Text = "";
                return;
            }

            if (!scnTimer.Enabled)
            {
                scnTimer.Enabled = true;
            }
            if (General.saveOnClose)
            {
                General.writeURLs(ListBoards, ListThreads);
            }

            scan(null, null);
        }
Example #8
0
        private void lbThreads_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                int pos = lbThreads.SelectedIndex;

                if (pos > -1)
                {
                    lock (threadLock)
                    {
                        ListThreads.RemoveAt(pos);
                        updateDataSource(typeURL.thread);
                    }
                }
            }
        }
Example #9
0
        private void btnClearAll_Click(object sender, EventArgs e)
        {
            if (tcApp.SelectedIndex > 1)
            {
                return;
            }
            bool board = (tcApp.SelectedIndex == 1);                             // Board Tab is open -> board=true; Thread tab -> board=false

            string type = "threads";

            if (board)
            {
                type = "boards";
            }

            DialogResult dialogResult = MessageBox.Show("Are you sure you want to clear all " + type + "?", "Clear all " + type,
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); // confirmation prompt

            if (dialogResult == DialogResult.Yes)
            {
                if (board)
                {
                    ListBoards.Clear();
                    updateDataSource(typeURL.board);
                }
                else
                {
                    ListThreads.Clear();
                    updateDataSource(typeURL.thread);
                }

                if (Properties.Settings.Default.saveOnClose)
                {
                    General.WriteURLs(ListBoards, ListThreads);
                }
            }
        }