From: <Dam...@us...> - 2007-02-19 01:45:35
|
Revision: 1337 http://svn.sourceforge.net/azsmrc/?rev=1337&view=rev Author: Damokles Date: 2007-02-18 17:45:26 -0800 (Sun, 18 Feb 2007) Log Message: ----------- moved downloadList from azUser to global User Modified Paths: -------------- trunk/azsmrc/lbms/azsmrc/plugin/main/User.java trunk/azsmrc/lbms/azsmrc/remote/client/Client.java trunk/azsmrc/lbms/azsmrc/shared/User.java trunk/azsmrc/plugin.properties Modified: trunk/azsmrc/lbms/azsmrc/plugin/main/User.java =================================================================== --- trunk/azsmrc/lbms/azsmrc/plugin/main/User.java 2007-02-14 15:09:46 UTC (rev 1336) +++ trunk/azsmrc/lbms/azsmrc/plugin/main/User.java 2007-02-19 01:45:26 UTC (rev 1337) @@ -1,11 +1,8 @@ package lbms.azsmrc.plugin.main; import java.util.Collection; -import java.util.HashSet; import java.util.LinkedList; -import java.util.List; import java.util.Queue; -import java.util.Set; import lbms.azsmrc.plugin.pluginsupport.PSupportAzJabber; import lbms.azsmrc.plugin.pluginsupport.PSupportStatusMailer; @@ -23,7 +20,6 @@ */ public class User extends lbms.azsmrc.shared.User { - private Set<String> downloadList = new HashSet<String>(); private Queue<Element> eventQueue = new LinkedList<Element>(); /** @@ -34,10 +30,6 @@ */ public User (Element userElement) { super(userElement); - List<Element> downloads = userElement.getChildren("Download"); - for (Element download:downloads) { - this.addDownload(download.getTextTrim()); - } } @@ -61,6 +53,7 @@ /** * @param download */ + @Override public void addDownload (String downloadHash) { try { Download dl = Plugin.getPluginInterface().getDownloadManager().getDownload(EncodingUtil.decode(downloadHash)); @@ -80,15 +73,8 @@ downloadList.retainAll(dls); } - /** - * The download will be removed from the user. - * - * @param download - */ - public void removeDownload (String download) { - downloadList.remove(download); - } + /** * The download will be removed from the user. * @@ -99,26 +85,8 @@ } /** - * @return list of Torrentnames - */ - public String[] getDownloads () { - return downloadList.toArray(new String[] {}); - } - - - /** * Checks if the user is an owner of the Download * - * @param dlHash - * @return - */ - public boolean hasDownload(String dlHash) { - return downloadList.contains(dlHash); - } - - /** - * Checks if the user is an owner of the Download - * * @param dl * @return */ @@ -149,11 +117,6 @@ */ public Element toElement () { Element user = super.toElement(); - for (String download:downloadList) { - Element downloadElement = new Element("Download"); - downloadElement.setText(download); - user.addContent(downloadElement); - } return user; } Modified: trunk/azsmrc/lbms/azsmrc/remote/client/Client.java =================================================================== --- trunk/azsmrc/lbms/azsmrc/remote/client/Client.java 2007-02-14 15:09:46 UTC (rev 1336) +++ trunk/azsmrc/lbms/azsmrc/remote/client/Client.java 2007-02-19 01:45:26 UTC (rev 1337) @@ -128,6 +128,9 @@ password = login.getPassword(); } + /** + * Initialises Variables + */ private void init() { downloadManager = new DownloadManagerImpl(this); responseManager = new ResponseManager(this); @@ -138,6 +141,11 @@ logger = Logger.getLogger("lbms.azsmrc.client"); } + /** + * Reset Variables that are Server specific. + * + * Call this when you disconnect from a Server. + */ private void reset() { userManager = new UserManagerImpl(this); remoteInfo = new RemoteInfoImpl(this); @@ -163,6 +171,9 @@ callConnectionListener(ConnectionListener.ST_DISCONNECTED); } + /** + * @return whether currently Connected to a Server + */ public boolean isConnected() { return connect; } Modified: trunk/azsmrc/lbms/azsmrc/shared/User.java =================================================================== --- trunk/azsmrc/lbms/azsmrc/shared/User.java 2007-02-14 15:09:46 UTC (rev 1336) +++ trunk/azsmrc/lbms/azsmrc/shared/User.java 2007-02-19 01:45:26 UTC (rev 1337) @@ -3,8 +3,10 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.jdom.DataConversionException; import org.jdom.Element; @@ -21,6 +23,7 @@ protected int downloadSlots; protected int userRights; protected Map<String, String> properties = new HashMap<String, String>(); + protected Set<String> downloadList = new HashSet<String>(); /** * Creates a User object and reads the data @@ -82,6 +85,11 @@ this.downloadSlots = userElement.getAttribute("downloadSlots").getIntValue(); if (userElement.getAttribute("userRights") != null) this.userRights = userElement.getAttribute("userRights").getIntValue(); + + List<Element> downloads = userElement.getChildren("Download"); + for (Element download:downloads) { + addDownload(download.getTextTrim()); + } } catch (DataConversionException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -178,6 +186,13 @@ user.setAttribute("autoImportDir",autoImportDir); user.setAttribute("downloadSlots",Integer.toString(downloadSlots)); user.setAttribute("userRights",Integer.toString(userRights)); + + for (String download:downloadList) { + Element downloadElement = new Element("Download"); + downloadElement.setText(download); + user.addContent(downloadElement); + } + try { for (String key:properties.keySet()) { Element e = new Element("Property"); @@ -328,4 +343,41 @@ public void setProperty(String key, String value) { properties.put(key, value); } + + /** + * Adds a download to the User + * + * @param download + */ + public void addDownload (String downloadHash) { + downloadList.add(downloadHash); + } + + /** + * The download will be removed from the user. + * + * @param download + */ + public void removeDownload (String download) { + downloadList.remove(download); + } + + + /** + * @return list of Torrentnames + */ + public String[] getDownloads () { + return downloadList.toArray(new String[downloadList.size()]); + } + + + /** + * Checks if the user is an owner of the Download + * + * @param dlHash + * @return + */ + public boolean hasDownload(String dlHash) { + return downloadList.contains(dlHash); + } } Modified: trunk/azsmrc/plugin.properties =================================================================== --- trunk/azsmrc/plugin.properties 2007-02-14 15:09:46 UTC (rev 1336) +++ trunk/azsmrc/plugin.properties 2007-02-19 01:45:26 UTC (rev 1337) @@ -1,6 +1,6 @@ -#Thu Oct 19 17:56:20 CEST 2006 +#Mon Feb 12 13:33:35 CET 2007 plugin.langfile=lbms.azsmrc.plugin.internat.Messages plugin.class=lbms.azsmrc.plugin.main.Plugin plugin.name=AzSMRC plugin.id=azsmrc -plugin.version=0.9.9 +plugin.version=0.9.9${beta} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |