Download Manager Project
Short Description
"DOWNLOAD MANAGER" is my 5th sem. project. which is fully completed by me. * Auther: Pramod kushwaha * Email...
Description
A
PROJECT REPORT ON
“DOWNLOAD MANAGER” COMPUTER SCIENCE & ENGINEERING
BUNDELKHAND INSTITUTE OF ENGG. & TECHNOLOGYJHANSI SESSION: 2009-10 UNDER THE ABLE GUIDANCE OF Dr. YASHPAL SINGH (H.O.D, COMPUTER SC. & ENGG ) SUBMITTED BY
Pramod ku. Kushwaha
CERTIFICATE This is to certify that the following project group of Third Year Computer Science & Engineering students has worked upon and successfully accomplished the project titled “DOWNLOAD MANAGER MANAGER”” under my guidance as partial fulfillment of their B.Tech degree in third year during the academic session 2009-2010. I wish the following students all the best for their future endeavors.
Project Group:
Pramod ku. Kushwaha
Project Guide: Dr. yashpal singh (H.O.D, COMPUTER SC. & ENGG.) B.I.E.T. Jhansi
ACKNOLEDGEMENT The Beatitude, bliss & euphoria that accompany the successful completion of any task would be incomplete without the expression of gratitude to the people who made it possible with their every bit of help. As success in any work is credited to the hard work, but without a proper guidance it may be out of one’s reach. So, with reverence and honor, we acknowledge all those who helped us in carrying out this project successfully. We avail this opportunity to express our profound sense of sincere and deep gratitude to Dr. YASHPAL SINGH who guided us with invaluable help in channeling my efforts in the right direction during the course of the project. We thankfully acknowledge the help that we received from all other faculty members of the Information Technology department, BIET Jhansi.
CONTENTS
1. Introduction 2. Requirements specification 3. System Analysis • Identification of need • Problem with existing system 4. Feasibility Study • Technical feasibility • Economical feasibility • Operational feasibility 5. Software Engineering Paradigm • •
Approach for System Development System Development Process Model
6. System Design • Coding 7. Testing 8. Future Scope 9. Bibliography
Introduction and objectives of the project
Introduction: A download manager is a computer program dedicated to the task of downloading possibly unrelated stand-alone files from the Internet for storage. This is unlike a World Wide Web browser, which is mainly intended to browse web pages, composed of a multitude of smaller files, where error-free moving of files for permanent storage is of secondary importance. (A failed or incomplete web page file rarely ruins the page.) The typical download manager at a minimum provides means to recover from errors without losing the work already completed, and can optionally split the file to be downloaded into 2 or more segments, which are then moved in parallel, potentially making the process faster within the limits of the available bandwidth. (A few servers are known to block moving files in parallel segments, on the principle that server capacity should be shared equally by all users.) Multi-source is the name given to files that are downloaded in parallel Download managers are useful for very active Internet users. For dial-up users, they can automatically dial the Internet Service Provider at night, when rates or tariffs are usually much lower, download the specified files, and hang-up. They can record which links the user clicks on during the day, and queue these files for later download. For broadband users, download managers can help download very large files by resuming broken downloads, by limiting the bandwidth used, so that other internet activities are not affected (slowed) and the server is not overloaded, or by automatically navigating a site and downloading pre-specified content (photo galleries, MP3 collections, etc.) this can also include automatically downloading whole sites and regularly updating them (see Mirroring). Many download managers support Metalink, an XML file listing mirrors, checksums, and other information useful for downloading
REQUIREMENTS Program Name: Download Manager
Hardware Requirement and Recommendations Hardware Component Recommendation
Minimum
Processor
133 MHz 486
RAM
32 MB
Free Hard disk Space Monitor
30 MB VGA
Language: JAVA (jdk1.6.0, jre1.6.0) Pakage used: .io, .net, .util, .awt.event, .swing Internet speed required: ➢ Upto 56kbs for MODEM connection. ➢ Upto 256kbs for BROADBAND connection.
System Requirements: 32-Bit versions •
Windows Vista
•
Windows XP
•
Windows 2000
•
Windows 98
•
Windows 95
500MHz Pentium 128 MB 50 MB SVGA
64-Bit Versions •
Windows Vista x64
•
Windows XP x64
Software requirement specifications: Main objective of the download manager is a computer program dedicated to the task of downloading possibly unrelated standalone files from the Internet for storage. This is unlike a World Wide Web browser, which is mainly intended to browse web pages, composed of a multitude of smaller files, where error-free moving of files for permanent storage is of secondary importance. MAIN MODULES : There are four main modules. 1. 2. 3. 4.
Download DownloadManager DownloadTableModel ProgressRenderer
1. DOWNLOAD: ➢ This class used for download a file from URL. ➢ Set max size of download buffer. ➢ There are status names. Downloading Pause Complete Error Cancel ➢ Get file name portion of URL. ➢ Connect to server. ➢ Set the size for download if it is not set. ➢ Read from server into buffer. ➢ Change status to complete if this point was reached bacause downloading has finished. ➢ Close connection to server. 1. DOWNLOAD MANAGER: ➢ This class used for ADD and REMOVE the file into the table. ➢ ADD download text file. ➢ Download tble data model showing downloads. ➢ There are buttoms for managing the selected downloads.
1. ➢ ➢
➢ ➢
➢
Pause Resume Cancel Clear ➢ Set the flag foe whether or not table selection is being cleard. ➢ Setup file menu. ➢ Setup ADD menu. ➢ Setup download table. ➢ Setup Progress bar. ➢ Add panel to display. ➢ Exit this program. ➢ Add a new download. ➢ Varify download URL. ➢ Update is called when download notifices it observer of any change ➢ Run the download manager. DOWNLOAD TABLE MODEL: This class manage the download table data. There are names for the tables columns. URL Progress Size Status Get a download for the specified row. Remove the download from the table. Fire table row deletion notification to the table.
1. PROGRESS RENDERER: ➢ This class renderes Jprogress bar in a table sell. ➢ Return this Jprogress bar for the given table sell. ➢ Set Jprogress bar percent complete value.
SYSTEM ANALYSIS IDENTIFICATION OF NEED: Existing system description In the description given below we have talked about the system used by the various Organization & Institutes for chatting. We are describing the nature, purpose and limitation of their existing system, and what we have done to improve the functionality of their system in the new system. Existing system can only work, if internet facility is provided, which result in high cost. Person not belonging to the organization can also interfere and can try to break the security of the organizational data.
Existing system details In the system used by the various Organization’s and institutions, communication is generally being held frequently. The institutes used telephones, fax & e-mail systems to communicate with each other in which redundancy of data is normal. A lot of work has to be done for every task for mailing & fax. Besides this all the management is also difficult and user has to depend upon the services of ISPs for too long unnecessarily.
PROBLEM WITH EXISTING SYSTEM: This existing system has several limitation and drawbacks so switch to a better and effective system. • • • •
Low functionality Security problem Future improvement is difficult. Miscellaneous.
FEASIBILITY STUDY The objective of feasibility study is to examine the technical, operational and economical viability.
Technical feasibility Technical feasibility centers on the existing computer system (hardware, software etc) and to what extent it can support the proposed addition. In our proposed solution formulated, did not require any additional technology. Hence the system is technically feasible. The entire solution enlisted does not require any additional software for this solution.
Economic feasibility More commonly known as cost benefit analysis, the procedure is to determine the benefits and savings that are expected from proposed system compare them with cost. The proposed system utilizes the currently available technologies. The cost during the development of the product is low. The interface and the scripts used are as simple as it could be. Therefore the net cost in its development is less.
Operational Feasibility Organizational, political and human aspects are considered in order to ensure that the proposed system will be workable when implemented.
SOFTWARE ENGINEERING PARADIGM USED Like any other product, a software product completes a cycle from its inception to obsolescence/replacement/wearing out. The process of software development not only needs writing the program and maintains it, but also a detail study of the system to identify current requirements related to
software development as well as to anticipate the future requirements. It also needs to meet the objective of low cost, and good quality along with minimum development time. ➢ Requirement analysis and specification for clear understanding of the problem. ➢ Software design for planning the solution of the problem. ➢ Coding (implementation) for writing program as per the suggested solution. ➢ Testing for verifying and validating the objective of the product. ➢ Operation and maintenance for use and to ensure its availability to users. This application was also developed in phases for effective output. Each phase was given its due importance with respect to time and cost. The time scheduling is later described in the PERT and Gantt chart. The system development life cycle of Project Management Information System is shown below. Operation Requirement Testing and & validation Analysis Designing Coding and Specification Maintenance
SOFTWARE DEVELOPMENT PROCESS MODEL A software development process model is a description of the work practices, tools and techniques used to develop software. Software models serve as standards as well provide guidelines while developing software. It is beneficial to one or more software development model while developing software
Water Fall Model It includes a sequential approach to software development. It includes phases like task definition, analysis, design, implementation, testing and maintenance. The phases are always in order and are never overlapped. Requirement Implementation Requirement Testing Design And Analysis And Maintenance Definition Specification
Waterfall Model
CODING Coding section is divided into four parts. i. Download (front) ii.DownloadManager iii.DownloadTableModel iv.ProgressRenderer 1. Download. import java.io.*; import java.net.*; import java.util.*; // This class downloads a file from a URL. class Download extends Observable implements Runnable { // Max size of download buffer. private static final int MAX_BUFFER_SIZE = 1024; // These are the status names. public static final String STATUSES[] = {"Downloading", "Paused", "Complete", "Cancelled", "Error"}; // These are the status codes. public static final int DOWNLOADING = 0; public static final int PAUSED = 1; public static final int COMPLETE = 2; public static final int CANCELLED = 3; public static final int ERROR = 4; private private private private
URL url; // download URL int size; // size of download in bytes int downloaded; // number of bytes downloaded int status; // current status of download
// Constructor for Download. public Download(URL url) { this.url = url; size = -1;
downloaded = 0; status = DOWNLOADING; // Begin the download. download(); } // Get this download's URL. public String getUrl() { return url.toString(); } // Get this download's size. public int getSize() { return size; } // Get this download's progress. public float getProgress() { return ((float) downloaded / size) * 100; } // Get this download's status. public int getStatus() { return status; } // Pause this download. public void pause() { status = PAUSED; stateChanged(); } // Resume this download. public void resume() { status = DOWNLOADING; stateChanged(); download(); } // Cancel this download. public void cancel() { status = CANCELLED; stateChanged();
} // Mark this download as having an error. private void error() { status = ERROR; stateChanged(); } // Start or resume downloading. private void download() { Thread thread = new Thread(this); thread.start(); } // Get file name portion of URL. private String getFileName(URL url) { String fileName = url.getFile(); return fileName.substring(fileName.lastIndexOf('/') + 1); } // Download file. public void run() { RandomAccessFile file = null; InputStream stream = null; try { // Open connection to URL. HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // Specify what portion of file to download. connection.setRequestProperty("Range", "bytes=" + downloaded + "-"); // Connect to server. connection.connect(); // Make sure response code is in the 200 range. if (connection.getResponseCode() / 100 != 2) { error(); } // Check for valid content length. int contentLength = connection.getContentLength();
if (contentLength < 1) { error(); } /* Set the size for this download if it hasn't been already set. */ if (size == -1) { size = contentLength; stateChanged(); } // Open file and seek to the end of it. file = new RandomAccessFile(getFileName(url), "rw"); file.seek(downloaded); stream = connection.getInputStream(); while (status == DOWNLOADING) { /* Size buffer according to how much of the file is left to download. */ byte buffer[]; if (size - downloaded > MAX_BUFFER_SIZE) { buffer = new byte[MAX_BUFFER_SIZE]; } else { buffer = new byte[size - downloaded]; } // Read from server into buffer. int read = stream.read(buffer); if (read == -1) break; // Write buffer to file. file.write(buffer, 0, read); downloaded += read; stateChanged(); } /* Change status to complete if this point was reached because downloading has finished. */ if (status == DOWNLOADING) { status = COMPLETE; stateChanged(); } } catch (Exception e) {
error(); } finally { // Close file. if (file != null) { try { file.close(); } catch (Exception e) {} } // Close connection to server. if (stream != null) { try { stream.close(); } catch (Exception e) {} } } } // Notify observers that this download's status has changed. private void stateChanged() { setChanged(); notifyObservers(); } } 2. DownloadManager.
import java.awt.*; import java.awt.event.*; import java.net.*; import java.util.*; import javax.swing.*; import javax.swing.event.*; // The Download Manager. public class DownloadManager extends JFrame implements Observer { // Add download text field.
private JTextField addTextField; // Download table's data model. private DownloadsTableModel tableModel; // Table showing downloads. private JTable table; // These are the buttons for managing the selected download. private JButton pauseButton, resumeButton; private JButton cancelButton, clearButton; // Currently selected download. private Download selectedDownload; // Flag for whether or not table selection is being cleared. private boolean clearing; // Constructor for Download Manager. public DownloadManager() { // Set application title. setTitle("Download Manager"); // Set window size. setSize(640, 480); // Handle window closing events. addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { actionExit(); } });
// Set up file menu. JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); JMenuItem fileExitMenuItem = new JMenuItem("Exit", KeyEvent.VK_X); fileExitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionExit(); } }); fileMenu.add(fileExitMenuItem); menuBar.add(fileMenu); setJMenuBar(menuBar); // Set up add panel. JPanel addPanel = new JPanel(); addTextField = new JTextField(30); addPanel.add(addTextField); JButton addButton = new JButton("Add Download"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionAdd(); } }); addPanel.add(addButton); // Set up Downloads table. tableModel = new DownloadsTableModel(); table = new JTable(tableModel); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) { tableSelectionChanged(); } }); // Allow only one row at a time to be selected. table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Set up ProgressBar as renderer for progress column. ProgressRenderer renderer = new ProgressRenderer(0, 100); renderer.setStringPainted(true); // show progress text table.setDefaultRenderer(JProgressBar.class, renderer); // Set table's row height large enough to fit JProgressBar. table.setRowHeight( (int) renderer.getPreferredSize().getHeight()); // Set up downloads panel. JPanel downloadsPanel = new JPanel(); downloadsPanel.setBorder( BorderFactory.createTitledBorder("Downloads")); downloadsPanel.setLayout(new BorderLayout()); downloadsPanel.add(new JScrollPane(table), BorderLayout.CENTER); // Set up buttons panel. JPanel buttonsPanel = new JPanel(); pauseButton = new JButton("Pause"); pauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionPause(); } }); pauseButton.setEnabled(false);
buttonsPanel.add(pauseButton); resumeButton = new JButton("Resume"); resumeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionResume(); } }); resumeButton.setEnabled(false); buttonsPanel.add(resumeButton); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionCancel(); } }); cancelButton.setEnabled(false); buttonsPanel.add(cancelButton); clearButton = new JButton("Clear"); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { actionClear(); } }); clearButton.setEnabled(false); buttonsPanel.add(clearButton); // Add panels to display. getContentPane().setLayout(new BorderLayout()); getContentPane().add(addPanel, BorderLayout.NORTH); getContentPane().add(downloadsPanel, BorderLayout.CENTER); getContentPane().add(buttonsPanel, BorderLayout.SOUTH); }
// Exit this program. private void actionExit() { System.exit(0); } // Add a new download. private void actionAdd() { URL verifiedUrl = verifyUrl(addTextField.getText()); if (verifiedUrl != null) { tableModel.addDownload(new Download(verifiedUrl)); addTextField.setText(""); // reset add text field } else { JOptionPane.showMessageDialog(this, "Invalid Download URL", "Error", JOptionPane.ERROR_MESSAGE); } } // Verify download URL. private URL verifyUrl(String url) { // Only allow HTTP URLs. if (!url.toLowerCase().startsWith("http://")) return null; // Verify format of URL. URL verifiedUrl = null; try { verifiedUrl = new URL(url); } catch (Exception e) { return null; } // Make sure URL specifies a file.
if (verifiedUrl.getFile().length() < 2) return null; return verifiedUrl; } // Called when table row selection changes. private void tableSelectionChanged() { /* Unregister from receiving notifications from the last selected download. */ if (selectedDownload != null) selectedDownload.deleteObserver(DownloadManager.this); /* If not in the middle of clearing a download, set the selected download and register to receive notifications from it. */ if (!clearing && table.getSelectedRow() > -1) { selectedDownload = tableModel.getDownload(table.getSelectedRow()); selectedDownload.addObserver(DownloadManager.this); updateButtons(); } } // Pause the selected download. private void actionPause() { selectedDownload.pause(); updateButtons(); } // Resume the selected download. private void actionResume() { selectedDownload.resume();
updateButtons(); } // Cancel the selected download. private void actionCancel() { selectedDownload.cancel(); updateButtons(); } // Clear the selected download. private void actionClear() { clearing = true; tableModel.clearDownload(table.getSelectedRow()); clearing = false; selectedDownload = null; updateButtons(); } /* Update each button's state based off of the currently selected download's status. */ private void updateButtons() { if (selectedDownload != null) { int status = selectedDownload.getStatus(); switch (status) { case Download.DOWNLOADING: pauseButton.setEnabled(true); resumeButton.setEnabled(false); cancelButton.setEnabled(true); clearButton.setEnabled(false); break; case Download.PAUSED: pauseButton.setEnabled(false); resumeButton.setEnabled(true);
cancelButton.setEnabled(true); clearButton.setEnabled(false); break; case Download.ERROR: pauseButton.setEnabled(false); resumeButton.setEnabled(true); cancelButton.setEnabled(false); clearButton.setEnabled(true); break; default: // COMPLETE or CANCELLED pauseButton.setEnabled(false); resumeButton.setEnabled(false); cancelButton.setEnabled(false); clearButton.setEnabled(true); } } else { // No download is selected in table. pauseButton.setEnabled(false); resumeButton.setEnabled(false); cancelButton.setEnabled(false); clearButton.setEnabled(false); } } /* Update is called when a Download notifies its observers of any changes. */ public void update(Observable o, Object arg) { // Update buttons if the selected download has changed. if (selectedDownload != null && selectedDownload.equals(o)) updateButtons(); } // Run the Download Manager.
public static void main(String[] args) { DownloadManager manager = new DownloadManager(); manager.setVisible(true); } }
3. DownloadTableModel.
import java.util.*; import javax.swing.*; import javax.swing.table.*; // This class manages the download table's data. class DownloadsTableModel extends AbstractTableModel implements Observer { // These are the names for the table's columns. private static final String[] columnNames = {"URL", "Size", "Progress", "Status"}; // These are the classes for each column's values. private static final Class[] columnClasses = {String.class, String.class, JProgressBar.class, String.class}; // The table's list of downloads. private ArrayList downloadList = new ArrayList(); // Add a new download to the table. public void addDownload(Download download) { // Register to be notified when the download changes.
download.addObserver(this); downloadList.add(download); // Fire table row insertion notification to table. fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1); } // Get a download for the specified row. public Download getDownload(int row) { return (Download) downloadList.get(row); } // Remove a download from the list. public void clearDownload(int row) { downloadList.remove(row); // Fire table row deletion notification to table. fireTableRowsDeleted(row, row); } // Get table's column count. public int getColumnCount() { return columnNames.length; } // Get a column's name. public String getColumnName(int col) { return columnNames[col]; } // Get a column's class. public Class getColumnClass(int col) {
return columnClasses[col]; } // Get table's row count. public int getRowCount() { return downloadList.size(); } // Get value for a specific row and column combination. public Object getValueAt(int row, int col) { Download download = downloadList.get(row); switch (col) { case 0: // URL return download.getUrl(); case 1: // Size int size = download.getSize(); return (size == -1) ? "" : Integer.toString(size); case 2: // Progress return new Float(download.getProgress()); case 3: // Status return Download.STATUSES[download.getStatus()]; } return ""; } /* Update is called when a Download notifies its observers of any changes */ public void update(Observable o, Object arg) { int index = downloadList.indexOf(o); // Fire table row update notification to table. fireTableRowsUpdated(index, index); }}
4. ProgressRenderer.
import java.awt.*; import javax.swing.*; import javax.swing.table.*; // This class renders a JProgressBar in a table cell. class ProgressRenderer extends JProgressBar implements TableCellRenderer { // Constructor for ProgressRenderer. public ProgressRenderer(int min, int max) { super(min, max); } /* Returns this JProgressBar as the renderer for the given table cell. */ public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { // Set JProgressBar's percent complete value. setValue((int) ((Float) value).floatValue()); return this; }
TESTING Testing is the varification and validation activity for the software product. The goad of testing phases are : ➢ To affirm the quality of the product by finding and eliminating faults in the programs. ➢ To demonstrate th presence of all specified functionality in the product. ➢ To estimate the operation reliability of the software.
TESTING PHASES: The Testing phase consist of
➢ Unit Testing ➢ Integration Testing ➢ System Teting UNIT TESTING In this phase each module check indivisualy. Each module run independently from other modules and check the error’s.
INTEGRATION TESTING In this phase two or more module combine and run and checks the error’s. It is two type. 1. Top down testing 2. Bottom up testing
SYSTEM TESTING In this phase we run software as a single unit. These are two types. 1. ALFA TESTING This testing performed at company level. 2. BETA TESTING This testing performed by users.
FUTURE SCOPE Our software is based on completely the java language to provide platform independency in a graphical manner. This software is usefull for downloading the files from the internet. The cost of software is very low. There it is easily available for all customers. Download managers commonly include one or more of the following features: Resuming broken or paused downloads (especially for very large files). Downloading files on poor connections.
Downloading several files from a site automatically according to simple rules (file types, updated files, etc. - see also Offline Browser).
Automatic recursive downloads.
Pausing the downloading of large files.
Scheduled downloads (including, automatic hang-up and shutdown). Variable bandwidth usage.
BIBLOGRAPHY The following books were consulted during the Project➢ java Complete Refrence ➢ Black Book of java ➢ An Integrated Approach to software engineering by Pankaj Jalote
The following website were consulted during the Project➢ www.wikipedia.com ➢ www.planet-source-code.com ➢ www.pramodsoft.blogspot.com
OUTPUT OF THE “DOWNLOAD MANAGER”
View more...
Comments