karmalib-commits Mailing List for Karma Lib
Brought to you by:
justinkwaugh
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(21) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(8) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ia...@us...> - 2004-02-23 03:45:32
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib/Messages In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3167/src/KarmaLib/Messages Added Files: FileDetailsEnumerator.cs Log Message: re-added file that got deleted by lock removal process. --- NEW FILE: FileDetailsEnumerator.cs --- using System ; using System.Collections ; namespace KarmaLib.Messages { public class FileDetailsEnumerator : CollectionBase, IEnumerator { GetAllFileDetailsResponse _response; object _current = null; public FileDetailsEnumerator(GetAllFileDetailsResponse response ) { _response = response; } public object Current { get { if (_current == null ) { throw new InvalidOperationException(); } return _current; } } public bool MoveNext() { try { if ( _response.HasMoreElements() ) { _current = _response.NextElement(); return true; } else { return false; } } catch { } return false; } public void Reset() { } } } |
From: <chu...@us...> - 2004-02-18 02:19:48
|
Update of /cvsroot/karmalib/java/src/dev/karma In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20122 Added Files: KarmaBackup.java Log Message: Initial version of KarmaBackup...a utility to mass back up your karma in a relatively intelligent fashion. --- NEW FILE: KarmaBackup.java --- /* * This file is licensed under the GNU Library or "Lesser" General * Public License (LGPL). * * See the file LGPL or LGPL.txt included in this release, or * http://opensource.org/licenses/lgpl-license.php * for the text of the license. * * Copyright (c) 2004 Scott C. Gray */ package dev.karma; import dev.karma.lib.AdvancedKarmaClient; import dev.karma.lib.KarmaTCPConnection; import dev.karma.lib.KarmaClientFactory; import dev.karma.lib.data.AccessRights; import dev.karma.lib.data.FileDetails; import dev.karma.lib.exception.KarmaException; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.util.Iterator; import java.util.Properties; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import java.util.regex.Matcher; /** * KarmaBackup is a utility (both command line or API-wise) for backing up * the contents of your Rio Karma. I, like a lot of people, didn't have * the luxury of ripping my 300-some-odd CD's on a single machine and no * one machine could store it all so my Karma is my only single repository * of many hours worth of work. This utility is designed to make as easy * as possible to maintain a live working image of the contents of your * Karma. * * <p>Usage of the KarmaBackup utility from the command line is * relatively straight forward: * * <pre> * java -cp /path/to/karmalib.jar dev.karmalib.KarmaBackup [options] ipaddress * </pre> * * <p>where <b>options</b> are: * * <ul> * <li> <b>--directory</b> <i>dir</i><br> * Specifies the root directory into which all files will be * extrated. File placed in this directory will be named * according to the template specified with the * <b>--template</b> option. The default directory is ".". * <li> <b>--password</b> <i>pass</i><br> * Specifies the password used to connect to the Karma * player. The default is "password". * <li> <b>--match</b> <i>regex</i><br> * If supplied, only files matching <i>regex</i> regular * expression will be extracted from the player. * <li> <b>--port</b> <i>port</i><br> * If supplied, overrides the default TCP/IP communications * port utilized to communicate with the player. * <li> <b>--blocksize</b> <i>bytes</i><br> * Specifies the number of bytes to transfer in each read * request to the karma. The default is 8192. * <li> <b>--template</b> <i>template</i><br> * Used to provide a templated description of how files * extracted from the player are to be named. This * template is a string that may contain the following * special macros: * * <ul> * <li> <b>%r</b> Will be replaced by the Artist * attribute of the track. * <li> <b>%a</b> Will be replaced by the Album * attribute of the track. * <li> <b>%t</b> Will be replaced by the Track Title. * <li> <b>%n</b> Will be replaced by the Track Number * attribute of the track. * </ul> * * Any path separators ("/" or "\") will be honored and * directories created as necessary. All other characters * are left intact. A "%%" may be used to create a literal * "%". The default template is: "%r/%a/%n - %t" (or * "Artist/Album/#TrackNum - TrackTitle"). * </ul> * * <p><i>ipaddress</i> Specifies the IP address of your player. * * @author <a href="mailto:sg...@in...">Scott C. Gray</a> * @version 1.0 */ public class KarmaBackup { /** * <b>%r</b> - File naming template variable for referring to the artist * of a song. */ public static final char ARTIST = 'r'; /** * <b>%a</b> - File naming template variable for referring to the album * that a song comes from. */ public static final char ALBUM = 'a'; /** * <b>%t</b> - File naming template variable for referring to the track * title of a song. */ public static final char TRACK_TITLE = 't'; /** * <b>%n</b> - File naming template variable for referring to the track * number of a song. */ public static final char TRACK_NUMBER = 'n'; /* * Handy to have around. */ private static final String SEP = System.getProperty("file.separator"); /** * The default file template: "%r/%a/%n - %t" (these will be * backslashes on Winderz). */ public static final String DEFAULT_FILE_TEMPLATE = "%" + ARTIST + SEP + "%" + ALBUM + SEP + "%" + TRACK_NUMBER + " - %" + TRACK_TITLE; /** * Default number of Bytes to process at a time. */ private static long DEFAULT_BLOCK_SIZE = 8192; private String fileTemplate = DEFAULT_FILE_TEMPLATE; private String hostname = null; private int port = KarmaTCPConnection.PORT; private String repository = null; private String password = null; private Pattern pattern = null; private long blockSize = DEFAULT_BLOCK_SIZE; /** * Creates an instance of a KarmaBackup. * * @param hostname The hostname (or, rather, IP address) of the Karma. * @param password The password required to connect to the Karma. * @param repository The base directory into which files are to be placed. * * @throws KarmaException Thrown if the instance cannot be created. * Most likely causes are failure to access the repository directory. */ public KarmaBackup (String hostname, String password, String repository) throws KarmaException { File dir; this.hostname = hostname; this.repository = repository; this.password = password; /* * Sanity checks... */ dir = new File(repository); if (dir.exists() == false) { throw new KarmaException("The repository directory '" + repository + "' does not exist."); } if (dir.isDirectory() == false) { throw new KarmaException("The supplied repository '" + repository + "' is not a directory."); } if (dir.canWrite() == false) { throw new KarmaException("The supplied repository '" + repository + "' is not writable."); } } /** * Creates an instance of a KarmaBackup. * * @param hostname The hostname (or, rather, IP address) of the Karma. * @param password The password required to connect to the Karma. * @param port The port of the Karma. * @param repository The base directory into which files are to be placed. * * @throws KarmaException Thrown if the instance cannot be created. * Most likely causes are failure to access the repository directory. */ public KarmaBackup (String hostname, String password, int port, String repository) throws KarmaException { this(hostname, password, repository); this.port = port; } /** * Sets the number of bytes to transfer in each read request to the karma. * * @param BlockSize number of bytes to transfer in each read request * to the karma. */ public void setBlockSize(long blockSize) { this.blockSize = blockSize; } /** * Gets the number of bytes to transfer in each read request to the karma. * * @return the number of bytes to transfer in each read request to the karma. */ public long getBlockSize() { return (this.blockSize); } /** * Creates a template utilized for naming the resulting file that * is extracted from the Karma. This template may utilize the * following special identifiers to refer to items in the ID2/3 * tag associated with the track. * * <ul> * <li> <b>%r</b> - Will be replaced with the Artist * <li> <b>%a</b> - Will be replaced with the Album * <li> <b>%t</b> - Will be replaced with the Track Title * <li> <b>%n</b> - Will be replaced with the Track Number * </ul> * * <p>All other characters within the template will be left in-tact. * A '%%' may be utilized to place a literal '%' in the template. * * @param fileTemplate The template to be utilized when placing * files. The default template is <b>DEFAULT_FILE_TEMPLATE</b>. */ public void setFileTemplate(String fileTemplate) { this.fileTemplate = fileTemplate; } /** * Retrieves the current file template. * * @return The current file template. */ public String getFileTemplate() { return (fileTemplate); } /** * Provides a regular expression that will be utilized to determine * which files get extracted from the Karma. This pattern is * compared to the expanded file template. * * @param pat A regular expression to use for comparisons. A * null pattern matches all files. */ public void setMatchPattern(String pat) throws PatternSyntaxException { if (pat == null) { this.pattern = null; } else { this.pattern = Pattern.compile(pat); } } /** * Gets A regular expression specifying which files are to be backed up * * @return A regular expression specifying which files are to be backed up */ public String getMatchPattern() { return (pattern == null ? null : pattern.toString()); } /** * Sets the hostname (or IP address) at which the Karma resides * * @param hostname the hostname (or IP address) at which the Karma resides */ public void setHostname(String hostname) { this.hostname = hostname; } /** * Gets the hostname (or IP address) at which the Karma resides * * @return the hostname (or IP address) at which the Karma resides */ public String getHostname() { return (this.hostname); } /** * Sets the port at which the Karma resides. * * @param port the port at which the Karma resides. */ public void setPort(int port) { this.port = port; } /** * Gets the port at which the Karma resides. * * @return the port at which the Karma resides. */ public int getPort() { return (this.port); } /** * Sets The directory in which all files will be placed * (based upon the expansion of the file template). * * @param repository The directory in which all files will be * placed. */ public void setRepository(String repository) { this.repository = repository; } /** * Gets The directory in which all files will be placed (based upon * the expansion of the file template). * * @return The directory in which all files will be placed. */ public String getRepository() { return (this.repository); } /** * Sets the connection password for communicating with the karma * * @param password the connection password for communicating with the karma */ public void setPassword(String password) { this.password = password; } /** * Gets the connection password for communicating with the karma * * @return the connection password for communicating with the karma */ public String getPassword() { return (this.password); } /** * Performs the actual backup opertion. This first connects to the * Karma, retrieves the directory listing, then gets to work. */ public void backup() throws KarmaException { KarmaTCPConnection conn = new KarmaTCPConnection(hostname, port); AdvancedKarmaClient karma = KarmaClientFactory.getAdvancedClient(conn); boolean locked = false; try { /* * Make sure we know how to talk to this thing. */ if (karma.isValidDeviceProtocolVersion() == false) { throw new KarmaException("Device located at '" + hostname + "' does " + "not report the appropriate protocol version. Aborting."); } /* * Now, lets authenticate. */ AccessRights rights = karma.login(password); if (rights.hasReadAccess() == false) { throw new KarmaException("The password you have supplied does not " + "have sufficient rights to extract contents from the device " + "located at '" + hostname + "'"); } System.out.println("Retrieving file details..."); karma.getWriteLock(); locked = true; FileDetails allDetails[] = karma.getAllFileDetails(); for (int i = 0; i < allDetails.length; i++) { FileDetails details = allDetails[i]; String name = expand(details); File file = new File(name); long length = details.getLength(); if (file.exists() && file.length() == length) { System.out.print("[Already Exists] "); System.out.println(name); } else if (pattern != null && pattern.matcher(name).find() == false) { System.out.print("[No Match] "); System.out.println(name); } else { if (file.exists()) { file.delete(); } System.out.print("[Extracting] "); System.out.println(name); copy(karma, details, file); } } } finally { if (locked) { try { karma.releaseIOLock(); } catch (KarmaException e) { System.err.println("Failed to release I/O lock: " + e.getMessage()); } } /* * Done. */ disconnect(karma); } } /** * Copies a file out of the karma. * * @param karma The handle to the player. * @param details Which file to extract. * @param toFile The name of the output file to create. * * @throws KarmaException If no worky. */ private void copy(AdvancedKarmaClient karma, FileDetails details, File toFile) throws KarmaException { createDirectory(toFile); try { OutputStream out = new BufferedOutputStream( new FileOutputStream(toFile)); int fid = details.getFileId(); long totalBytes = details.getLength(); long offset = 0; while (offset < totalBytes) { long nBytes = (totalBytes - offset); if (nBytes > blockSize) { nBytes = blockSize; } // System.out.println(" readFileChunk(" // + offset + ", " + nBytes + ", " + fid + ")"); karma.readFileChunk(offset, nBytes, fid, out); offset += nBytes; } out.close(); } catch (IOException e) { throw new KarmaException("Failed to write to `" + toFile.toString() + "': " + e.getMessage()); } } /** * Recursively make sure that a given directory structure * exists. * * @param file Path to a file. * * @throws IOException If the directory structure cannot be * created. */ private void createDirectory(File file) throws KarmaException { File directory = new File(file.getParent()); if (directory.isDirectory() == false) { if (directory.mkdirs() == false) { throw new KarmaException("Unable to create directory: " + directory.toString()); } } } /** * Given the details of a file, expands to a full path name * (including the repository base directory) utilizing the * configured file template. * * @param details The details of the file. * * @return An expanded path to store the file. */ private String expand(FileDetails details) { StringBuffer sb = new StringBuffer(); int idx = 0; int len = fileTemplate.length(); sb.append(repository); if (!repository.endsWith("/") && !repository.endsWith("\\")) { sb.append(SEP); } while (idx < len) { char ch = fileTemplate.charAt(idx); ++idx; if (ch == '%' && idx < len) { ch = fileTemplate.charAt(idx); ++idx; switch (ch) { case ARTIST: append(sb, details.getArtist()); break; case TRACK_TITLE: append(sb, details.getTitle()); break; case TRACK_NUMBER: String num = details.getTrackNumber(); if (num.length() < 2) { sb.append('0'); } append(sb, num); break; case ALBUM: append(sb, details.getSource()); break; default: sb.append('%'); sb.append(ch); } } else { sb.append(ch); } } /* * Last little bit. Automagically append the file extension. */ String codec = details.getCodec(); if ("vorbis".equals(codec)) { sb.append(".ogg"); } else { sb.append('.'); sb.append(codec); } return (sb.toString()); } /** * Used to append a string to a string buffer, protecting or * removing characters that would screw up a filename. * * @param sb Buffer * @param str String to append. */ private void append(StringBuffer sb, String str) { int len = str.length(); for (int i = 0; i < len; i++) { char ch = str.charAt(i); /* * There has to be a better way....I don't know which characters * are valid for the O/S I happen to be running on. */ if (Character.isLetterOrDigit(ch) || Character.isWhitespace(ch) || ch == '_' || ch == '(' || ch == ')' || ch == '!' || ch == '.' || ch == '+' || ch == '\'' || ch == '#' || ch == ',') { sb.append(ch); } } } /** * Helper to cleanly disconnect. * * @param karma The Karma handle to disconnect. */ private void disconnect(AdvancedKarmaClient karma) { try { karma.disconnect(); } catch (Exception e) { System.err.println("Error while disconnecting from Karma device at '" + hostname + "': " + e.getMessage()); } } /** * Runnable version of KarmaBackup. * * <pre> * usage: KarmaBackup [--password pwd] [--port port] [--directory dir] * [--template tmp] ipaddress * </pre> * * @param argv Command line arguments. */ public static void main (String argv[]) { String hostname; String directory = "."; String template = DEFAULT_FILE_TEMPLATE; String password = "password"; String match = null; int port = KarmaTCPConnection.PORT; long blockSize = DEFAULT_BLOCK_SIZE; KarmaBackup backup; int idx = 0; while (idx < argv.length && argv[idx].startsWith("--")) { if (argv[idx].equals("--password") && idx < (argv.length - 2)) { password = argv[idx + 1]; idx += 2; } else if (argv[idx].equals("--match") && idx < (argv.length - 2)) { match = argv[idx + 1]; idx += 2; } else if (argv[idx].equals("--port") && idx < (argv.length - 2)) { try { port = Integer.parseInt(argv[idx + 1]); } catch (Exception e) { System.err.println("--port: Invalid port number supplied: " + argv[idx + 1]); System.exit(1); } idx += 2; } else if (argv[idx].equals("--blocksize") && idx < (argv.length - 2)) { try { blockSize = Long.parseLong(argv[idx + 1]); } catch (Exception e) { System.err.println("--blocksize: Invalid value supplied: " + argv[idx + 1]); System.exit(1); } idx += 2; } else if (argv[idx].equals("--directory") && idx < (argv.length - 2)) { directory = argv[idx + 1]; idx += 2; } else if (argv[idx].equals("--template") && idx < (argv.length - 2)) { template = argv[idx + 1]; idx += 2; } else { printUsage(); System.exit(1); } } if (idx == argv.length) { printUsage(); System.exit(1); } hostname = argv[idx]; try { backup = new KarmaBackup(hostname, password, port, directory); backup.setFileTemplate(template); backup.setMatchPattern(match); backup.setBlockSize(blockSize); backup.backup(); } catch (PatternSyntaxException e) { System.err.println("--match: Invalid regular expression"); System.exit(1); } catch (KarmaException e) { System.err.println(e.getMessage()); System.exit(1); } catch (Exception e) { e.printStackTrace(System.err); System.exit(1); } System.exit(0); } /** * Prints main() usage to stdout. */ private static void printUsage() { System.out.println( "usage: KarmaBackup [options] ipaddress"); System.out.println( " --directory dir Directory to extract files (default '.')"); System.out.println( " --password pass Password required to connect (default 'password')"); System.out.println( " --match regex Regular expression that restricts what gets extracted"); System.out.println( " --port port Port to connect to (default '" + KarmaTCPConnection.PORT + "')"); System.out.println( " --template tmpl File nameing template. This may contain: "); System.out.println( " --blocksize bytes Number of bytes to read at a time (default " + DEFAULT_BLOCK_SIZE + ")"); System.out.println( " %r - Will be replaced with the Artist"); System.out.println( " %a - Will be replaced with the Album"); System.out.println( " %t - Will be replaced with the Track Title"); System.out.println( " %n - Will be replaced with the Track Number"); } } |
From: <chu...@us...> - 2004-02-18 02:14:16
|
Update of /cvsroot/karmalib/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19118 Modified Files: README.txt Log Message: Documentation for ant compilation. Index: README.txt =================================================================== RCS file: /cvsroot/karmalib/java/README.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README.txt 26 Dec 2003 23:22:07 -0000 1.2 --- README.txt 18 Feb 2004 02:04:53 -0000 1.3 *************** *** 85,88 **** --- 85,106 ---- An ethernet connection to your Karma. JDK 1.4 or higher, preferably the latest and greatest + Jakarta Ant (http://jakarta.apache.org/ant) 1.4 or higher (optional) + + --------- + Compiling + --------- + + The easiest way to compile Karmalib is using the 'ant', from the Jakarta + project (http://jakarta.apache.org/ant). After following the ant installation + procedures, you should be able to do: + + $ ant build + + will leave you with a file karmalib.jar. To generate the Java documentation + (javadocs), simply run + + $ ant doc + + which will leave you with a directory doc/ containing all HTML javadocs. ------- *************** *** 105,107 **** Java is a registered trademark of Sun Microsystems, Inc. in the United States ! and other countries. \ No newline at end of file --- 123,125 ---- Java is a registered trademark of Sun Microsystems, Inc. in the United States ! and other countries. |
From: <chu...@us...> - 2004-02-18 02:12:41
|
Update of /cvsroot/karmalib/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18817 Modified Files: README build.xml Log Message: Added documentation on compiling the karmalib jar and documentation using ant (if so desired). Index: README =================================================================== RCS file: /cvsroot/karmalib/java/README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README 26 Dec 2003 23:22:07 -0000 1.2 --- README 18 Feb 2004 02:03:23 -0000 1.3 *************** *** 85,88 **** --- 85,106 ---- An ethernet connection to your Karma. JDK 1.4 or higher, preferably the latest and greatest + Jakarta Ant (http://jakarta.apache.org/ant) 1.4 or higher (optional) + + --------- + Compiling + --------- + + The easiest way to compile Karmalib is using the 'ant', from the Jakarta + project (http://jakarta.apache.org/ant). After following the ant installation + procedures, you should be able to do: + + $ ant build + + will leave you with a file karmalib.jar. To generate the Java documentation + (javadocs), simply run + + $ ant doc + + which will leave you with a directory doc/ containing all HTML javadocs. ------- *************** *** 105,107 **** Java is a registered trademark of Sun Microsystems, Inc. in the United States ! and other countries. \ No newline at end of file --- 123,125 ---- Java is a registered trademark of Sun Microsystems, Inc. in the United States ! and other countries. Index: build.xml =================================================================== RCS file: /cvsroot/karmalib/java/build.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** build.xml 18 Feb 2004 01:53:59 -0000 1.1 --- build.xml 18 Feb 2004 02:03:23 -0000 1.2 *************** *** 33,36 **** --- 33,41 ---- <delete dir="build"/> <delete dir="doc"/> + <delete> + <fileset dir="."> + <include name="*.jar"/> + </fileset> + </delete> </target> </project> |
From: <chu...@us...> - 2004-02-18 02:03:18
|
Update of /cvsroot/karmalib/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17265 Added Files: build.xml Log Message: Initial version. --- NEW FILE: build.xml --- <project name="karmalib" default="build" basedir="."> <target name="build"> <mkdir dir="build"/> <javac srcdir="src" destdir="build" includes="**/*.java" includeAntRuntime="no" optimize="${javac.optimize}" debug="${javac.debug}" verbose="${javac.verbose}" deprecation="${javac.deprecation}"/> <jar destfile="karmalib.jar"> <fileset dir="build" includes="**/*.class"/> </jar> </target> <target name="doc"> <mkdir dir="doc"/> <javadoc sourcepath="src" destdir="doc" author="true" version="true" use="true" access="public"> <fileset dir="src"> <include name="**/*.java"/> </fileset> </javadoc> </target> <target name="clean"> <delete dir="build"/> <delete dir="doc"/> </target> </project> |
From: <ia...@us...> - 2004-01-17 00:07:06
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib/Messages In directory sc8-pr-cvs1:/tmp/cvs-serv13539/src/KarmaLib/Messages Added Files: GetAllFileDetailsResponse.cs Log Message: new files for GetAllFileDetails implementation --- NEW FILE: GetAllFileDetailsResponse.cs --- using System; //using System.IO; using System.Net.Sockets; using KarmaLib.Data; using KarmaLib.Util; namespace KarmaLib.Messages { public class GetAllFileDetailsResponse : KarmaStatusResponse { private KarmaLib.Data.FileDetails current = null; private int totalRead = 0; public GetAllFileDetailsResponse(NetworkStream rns) : base(rns) { } public FileDetails NextElement() { FileDetails rv = current; current = ReadFileDetails(); return rv; } private FileDetails ReadFileDetails() { FileDetails rv = null; byte[] FileDetails = IOUtils.ReadUntilEmptyLineOrNull( this.rns ); if (FileDetails.Length > 0) { totalRead += FileDetails.Length; rv = new FileDetails(); rv.LoadFromByteArray(FileDetails); } else { totalRead++; int remainder = totalRead % 4; if (remainder > 0) { IOUtils.DiscardBytes(rns, 4 - remainder); } } return rv; } public bool HasMoreElements() { return (current == null ? false : true); } public override void ReadResponse() { base.ReadResponse(); current = ReadFileDetails(); } public FileDetailsEnumerator Files { get { return new FileDetailsEnumerator( this ); } } } } |
Update of /cvsroot/karmalib/csharp/src/KarmaLib/Messages In directory sc8-pr-cvs1:/tmp/cvs-serv10197/src/KarmaLib/Messages Modified Files: AcquireIOLockRequest.cs AuthenticationRequest.cs DeleteFileRequest.cs GetVersionRequest.cs KarmaMessage.cs KarmaRequest.cs KarmaResponse.cs PrepareRequest.cs ReadFileChunkRequest.cs ReadFileChunkResponse.cs WriteFileChunkRequest.cs Log Message: implementet GetAllFileDetails - tidied up empty exception handlers - moved static int MessageType constants to a MessageType enum - removed sourcesafe binding information from vs.net project files Index: AcquireIOLockRequest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/AcquireIOLockRequest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AcquireIOLockRequest.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- AcquireIOLockRequest.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 12,16 **** private int readWrite = 0; ! public AcquireIOLockRequest(NetworkStream wns, int readWrite) : base(wns,KarmaProtocol.ACQUIRE_IO_LOCK) { this.readWrite = readWrite; } --- 12,16 ---- private int readWrite = 0; ! public AcquireIOLockRequest(NetworkStream wns, int readWrite) : base(wns,KarmaMessageType.ACQUIRE_IO_LOCK) { this.readWrite = readWrite; } Index: AuthenticationRequest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/AuthenticationRequest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AuthenticationRequest.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- AuthenticationRequest.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 12,16 **** private byte[] passwordHash = null; ! public AuthenticationRequest(NetworkStream wns, byte[] passwordHash) : base(wns,KarmaProtocol.AUTHENTICATE) { this.passwordHash = passwordHash; --- 12,16 ---- private byte[] passwordHash = null; ! public AuthenticationRequest(NetworkStream wns, byte[] passwordHash) : base(wns,KarmaMessageType.AUTHENTICATE) { this.passwordHash = passwordHash; Index: DeleteFileRequest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/DeleteFileRequest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeleteFileRequest.cs 19 Dec 2003 05:15:13 -0000 1.1 --- DeleteFileRequest.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 13,17 **** private int fileId = 0; ! public DeleteFileRequest(NetworkStream wns, int fileId) : base(wns, KarmaProtocol.DELETE_FILE) { this.fileId = fileId; --- 13,17 ---- private int fileId = 0; ! public DeleteFileRequest(NetworkStream wns, int fileId) : base(wns, KarmaMessageType.DELETE_FILE) { this.fileId = fileId; Index: GetVersionRequest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/GetVersionRequest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** GetVersionRequest.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- GetVersionRequest.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 15,19 **** private KarmaLib.Data.Version supportedVersion; ! public GetVersionRequest(NetworkStream wns, KarmaLib.Data.Version supportedVersion) : base(wns, KarmaProtocol.GET_PROTOCOL_VERSION) { this.supportedVersion = supportedVersion; } --- 15,19 ---- private KarmaLib.Data.Version supportedVersion; ! public GetVersionRequest(NetworkStream wns, KarmaLib.Data.Version supportedVersion) : base(wns, KarmaMessageType.GET_PROTOCOL_VERSION) { this.supportedVersion = supportedVersion; } Index: KarmaMessage.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/KarmaMessage.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** KarmaMessage.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- KarmaMessage.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 16,25 **** protected MemoryStream header = new MemoryStream(8); ! public KarmaMessage(byte[] magicNumber, int messageType) { header.Write(magicNumber,0,magicNumber.Length); ! header.Write(BitConverter.GetBytes(messageType),0,4); } ! public KarmaMessage(int messageType) : this(MAGIC_NUMBER, messageType) { } public KarmaMessage() { } --- 16,25 ---- protected MemoryStream header = new MemoryStream(8); ! public KarmaMessage(byte[] magicNumber, KarmaMessageType messageType) { header.Write(magicNumber,0,magicNumber.Length); ! header.Write(BitConverter.GetBytes((int)messageType),0,4); } ! public KarmaMessage(KarmaMessageType messageType) : this(MAGIC_NUMBER, messageType) { } public KarmaMessage() { } Index: KarmaRequest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/KarmaRequest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** KarmaRequest.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- KarmaRequest.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 12,16 **** protected Stream wns = null; ! public KarmaRequest(Stream wns, int messageType) : base(messageType) { this.wns = wns; } --- 12,16 ---- protected Stream wns = null; ! public KarmaRequest(Stream wns, KarmaMessageType messageType) : base(messageType) { this.wns = wns; } Index: KarmaResponse.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/KarmaResponse.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** KarmaResponse.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- KarmaResponse.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 28,36 **** headerReader = new BinaryReader(header); ! int responseType = headerReader.ReadInt32(); ! if (responseType == KarmaProtocol.BUSY) { ReadActivityProgress(); ! } else if (responseType == KarmaProtocol.NAK) { throw new NakException(); } --- 28,36 ---- headerReader = new BinaryReader(header); ! KarmaMessageType responseType = (KarmaMessageType)headerReader.ReadInt32(); ! if (responseType == KarmaMessageType.BUSY) { ReadActivityProgress(); ! } else if (responseType == KarmaMessageType.NAK) { throw new NakException(); } Index: PrepareRequest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/PrepareRequest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PrepareRequest.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- PrepareRequest.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 14,18 **** private int storage = 0; ! public PrepareRequest(NetworkStream wns, long size, int fileId, int storage) : base(wns, KarmaProtocol.WRITE_FILE_CHUNK) { this.size = size; --- 14,18 ---- private int storage = 0; ! public PrepareRequest(NetworkStream wns, long size, int fileId, int storage) : base(wns, KarmaMessageType.WRITE_FILE_CHUNK) { this.size = size; Index: ReadFileChunkRequest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/ReadFileChunkRequest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ReadFileChunkRequest.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- ReadFileChunkRequest.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 15,19 **** private int fileId = 0; ! public ReadFileChunkRequest(NetworkStream wns, long offset, long size, int fileId) : base(wns,KarmaProtocol.READ_FILE_CHUNK) { this.offset = offset; --- 15,19 ---- private int fileId = 0; ! public ReadFileChunkRequest(NetworkStream wns, long offset, long size, int fileId) : base(wns,KarmaMessageType.READ_FILE_CHUNK) { this.offset = offset; Index: ReadFileChunkResponse.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/ReadFileChunkResponse.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ReadFileChunkResponse.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- ReadFileChunkResponse.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 24,29 **** public override void ReadPayload() { int bufSize = (bytesRead > MAX_BUFSIZE ? MAX_BUFSIZE : (int)bytesRead); ! //MemoryStream scratch = new MemoryStream(bufSize); ! byte[] scratch; BinaryReader reader = new BinaryReader(rns); BinaryWriter writer = new BinaryWriter(wns); --- 24,28 ---- public override void ReadPayload() { int bufSize = (bytesRead > MAX_BUFSIZE ? MAX_BUFSIZE : (int)bytesRead); ! BinaryReader reader = new BinaryReader(rns); BinaryWriter writer = new BinaryWriter(wns); Index: WriteFileChunkRequest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Messages/WriteFileChunkRequest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** WriteFileChunkRequest.cs 16 Dec 2003 01:58:48 -0000 1.1.1.1 --- WriteFileChunkRequest.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 21,25 **** private Stream rns = null; ! public WriteFileChunkRequest(Stream wns, long offset, long size, int fileId, int storage, Stream rns) : base(wns, KarmaProtocol.WRITE_FILE_CHUNK) { this.offset = offset; --- 21,25 ---- private Stream rns = null; ! public WriteFileChunkRequest(Stream wns, long offset, long size, int fileId, int storage, Stream rns) : base(wns, KarmaMessageType.WRITE_FILE_CHUNK) { this.offset = offset; |
Update of /cvsroot/karmalib/csharp/src/KarmaLib In directory sc8-pr-cvs1:/tmp/cvs-serv10197/src/KarmaLib Modified Files: IBasicKarmaClient.cs IKarmaProtocol.cs KarmaClient.cs KarmaLib.csproj KarmaProtocol.cs KarmaTCPConnection.cs Log Message: implementet GetAllFileDetails - tidied up empty exception handlers - moved static int MessageType constants to a MessageType enum - removed sourcesafe binding information from vs.net project files Index: IBasicKarmaClient.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/IBasicKarmaClient.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IBasicKarmaClient.cs 24 Dec 2003 05:51:52 -0000 1.1 --- IBasicKarmaClient.cs 16 Jan 2004 23:51:06 -0000 1.2 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections; using System.IO; using KarmaLib.Data; *************** *** 23,27 **** void WriteFile( FileDetails fd, int storage, Stream input ); void DeleteFile( int fileId ); ! FileDetails[] GetAllFileDetails(); FileDetails GetFileDetails( int fileId ); void UpdateFileDetails( FileDetails fd ); --- 24,28 ---- void WriteFile( FileDetails fd, int storage, Stream input ); void DeleteFile( int fileId ); ! IEnumerator GetAllFileDetails(); FileDetails GetFileDetails( int fileId ); void UpdateFileDetails( FileDetails fd ); Index: IKarmaProtocol.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/IKarmaProtocol.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IKarmaProtocol.cs 19 Dec 2003 05:13:12 -0000 1.2 --- IKarmaProtocol.cs 16 Jan 2004 23:51:06 -0000 1.3 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections; using System.Net.Sockets; *************** *** 12,18 **** public interface IKarmaProtocol { - - - KarmaLib.Data.Version GetVersion(); byte[] GetAuthenticationSalt(); --- 13,16 ---- *************** *** 23,30 **** // public abstract void UpdateDeviceSettings( DeviceSettings deviceSettings ); void AcquireIOLock( int readWrite ); ! // public abstract void ReleaseIOLock(); // public abstract int Prepare( long size, int fileId, int storage ); // public abstract void WriteFileChunk( long offset, long size, int fileId, int storage, NetworkStream ns); ! // public abstract FileInfo[] GetAllFileDetails(); // public abstract FileInfo GetFileDetails( int fileId ); // public abstract void UpdateFileDetails( FileInfo fileInfo ); --- 21,28 ---- // public abstract void UpdateDeviceSettings( DeviceSettings deviceSettings ); void AcquireIOLock( int readWrite ); ! void ReleaseIOLock(); // public abstract int Prepare( long size, int fileId, int storage ); // public abstract void WriteFileChunk( long offset, long size, int fileId, int storage, NetworkStream ns); ! IEnumerator GetAllFileDetails(); // public abstract FileInfo GetFileDetails( int fileId ); // public abstract void UpdateFileDetails( FileInfo fileInfo ); *************** *** 36,40 **** // void SetConnection(KarmaConnection conn); - } } --- 34,37 ---- Index: KarmaClient.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/KarmaClient.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KarmaClient.cs 24 Dec 2003 05:53:18 -0000 1.3 --- KarmaClient.cs 16 Jan 2004 23:51:06 -0000 1.4 *************** *** 221,224 **** --- 221,232 ---- } } + public IEnumerator GetAllFileDetails() + { + if (Connect()) + { + return protocol.GetAllFileDetails(); + } + return null; + } public void WriteDataFile( string filename, long size, int fileId, int storage, Stream input ) { *************** *** 238,244 **** } - public FileDetails[] GetAllFileDetails() { - throw new KarmaException("Not yet implemented"); - } public IEnumerator GetFileDetailsIterator() { --- 246,249 ---- Index: KarmaLib.csproj =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/KarmaLib.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KarmaLib.csproj 19 Dec 2003 05:13:12 -0000 1.2 --- KarmaLib.csproj 16 Jan 2004 23:51:06 -0000 1.3 *************** *** 5,12 **** SchemaVersion = "2.0" ProjectGuid = "{CD5ED192-4B3F-4509-8327-5FDFAFE44543}" - SccProjectName = "SAK" - SccLocalPath = "SAK" - SccAuxPath = "SAK" - SccProvider = "SAK" > <Build> --- 5,8 ---- *************** *** 94,97 **** --- 90,113 ---- /> <File + RelPath = "IAdvancedKarmaClient.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "IBasicKarmaClient.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "IKarmaConnection.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "IKarmaInterface.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "IKarmaProtocol.cs" SubType = "Code" *************** *** 104,108 **** /> <File ! RelPath = "KarmaConnection.cs" SubType = "Code" BuildAction = "Compile" --- 120,124 ---- /> <File ! RelPath = "KarmaClientFactory.cs" SubType = "Code" BuildAction = "Compile" *************** *** 114,117 **** --- 130,138 ---- /> <File + RelPath = "KarmaTCPConnection.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Data\AccessRights.cs" SubType = "Code" *************** *** 134,138 **** /> <File ! RelPath = "Data\FileInfo.cs" SubType = "Code" BuildAction = "Compile" --- 155,159 ---- /> <File ! RelPath = "Data\FileDetails.cs" SubType = "Code" BuildAction = "Compile" *************** *** 194,197 **** --- 215,228 ---- /> <File + RelPath = "Messages\FileDetailsEnumerator.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Messages\GetAllFileDetailsResponse.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Messages\GetAuthenticationSaltResponse.cs" SubType = "Code" Index: KarmaProtocol.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/KarmaProtocol.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KarmaProtocol.cs 24 Dec 2003 05:53:49 -0000 1.3 --- KarmaProtocol.cs 16 Jan 2004 23:51:06 -0000 1.4 *************** *** 2,5 **** --- 2,6 ---- using System.Net.Sockets; + using System.Collections; using KarmaLib.Data; using KarmaLib.Messages; *************** *** 8,39 **** namespace KarmaLib { ! /// <summary> ! /// Summary description for KarmaProtocol. /// </summary> public class KarmaProtocol : IKarmaProtocol { private IKarmaConnection conn = null; ! public static KarmaLib.Data.Version supportedVersion = new KarmaLib.Data.Version(2,0); ! ! public static int GET_PROTOCOL_VERSION = 0; ! public static int NAK = 1; ! public static int BUSY = 2; ! public static int GET_AUTHENTICATION_SALT = 3; ! public static int AUTHENTICATE = 4; ! public static int GET_DEVICE_DETAILS = 5; ! public static int GET_STORAGE_DETAILS = 6; ! public static int GET_DEVICE_SETTINGS = 7; ! public static int UPDATE_DEVICE_SETTINGS = 8; ! public static int ACQUIRE_IO_LOCK = 9; ! public static int RELEASE_IO_LOCK = 10; ! public static int PREPARE = 11; ! public static int WRITE_FILE_CHUNK = 12; ! public static int GET_ALL_FILE_DETAILS = 13; ! public static int GET_FILE_DETAILS = 14; ! public static int UPDATE_FILE_DETAILS = 15; ! public static int READ_FILE_CHUNK = 16; ! public static int DELETE_FILE = 17; ! public static int FORMAT_STORAGE = 18; ! public static int HANGUP = 19; ! public static int DEVICE_OPERATION = 20; public KarmaProtocol(IKarmaConnection conn) { --- 9,45 ---- namespace KarmaLib { ! /// <summary> ! /// Enum defining supported Message type constants ! /// </summary> ! public enum KarmaMessageType : int { ! GET_PROTOCOL_VERSION = 0, ! NAK = 1, ! BUSY = 2, ! GET_AUTHENTICATION_SALT = 3, ! AUTHENTICATE = 4, ! GET_DEVICE_DETAILS = 5, ! GET_STORAGE_DETAILS = 6, ! GET_DEVICE_SETTINGS = 7, ! UPDATE_DEVICE_SETTINGS = 8, ! ACQUIRE_IO_LOCK = 9, ! RELEASE_IO_LOCK = 10, ! PREPARE = 11, ! WRITE_FILE_CHUNK = 12, ! GET_ALL_FILE_DETAILS = 13, ! GET_FILE_DETAILS = 14, ! UPDATE_FILE_DETAILS = 15, ! READ_FILE_CHUNK = 16, ! DELETE_FILE = 17, ! FORMAT_STORAGE = 18, ! HANGUP = 19, ! DEVICE_OPERATION = 20, ! ! }; ! /// <summary> ! /// Summary description for KarmaMessageType. /// </summary> public class KarmaProtocol : IKarmaProtocol { private IKarmaConnection conn = null; ! public static KarmaLib.Data.Version supportedVersion = new KarmaLib.Data.Version(2,0); public KarmaProtocol(IKarmaConnection conn) { *************** *** 59,64 **** return response; } ! public KarmaLib.Data.Version GetVersion() { GetVersionRequest request = new GetVersionRequest(conn.GetOutputStream(),KarmaProtocol.supportedVersion); GetVersionResponse response = new GetVersionResponse(conn.GetInputStream()); --- 65,72 ---- return response; } + #region IKarmaProtocol Implementation ! public KarmaLib.Data.Version GetVersion() ! { GetVersionRequest request = new GetVersionRequest(conn.GetOutputStream(),KarmaProtocol.supportedVersion); GetVersionResponse response = new GetVersionResponse(conn.GetInputStream()); *************** *** 69,75 **** } public DeviceSettings GetDeviceSettings() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(),KarmaProtocol.GET_DEVICE_SETTINGS); GetDeviceSettingsResponse response = new GetDeviceSettingsResponse(conn.GetInputStream()); --- 77,113 ---- } + public byte[] GetAuthenticationSalt() + { + + KarmaRequest request = new KarmaRequest(conn.GetOutputStream(), KarmaMessageType.GET_AUTHENTICATION_SALT); + GetAuthenticationSaltResponse response = new GetAuthenticationSaltResponse(conn.GetInputStream()); + ExecuteKarmaCommand( request, response ); + + return response.Salt; + } + + public AccessRights Authenticate(byte[] passwordHash) + { + AuthenticationRequest request = new AuthenticationRequest(conn.GetOutputStream(),passwordHash); + AuthenticationResponse response = new AuthenticationResponse(conn.GetInputStream()); + + ExecuteKarmaCommand( request, response ); + + return response.AccessRights; + } + public DeviceDetails GetDeviceDetails() + { + + KarmaRequest request = new KarmaRequest(conn.GetOutputStream(), KarmaMessageType.GET_DEVICE_DETAILS); + GetDeviceDetailsResponse response = new GetDeviceDetailsResponse(conn.GetInputStream()); + + ExecuteKarmaCommand( request, response ); + + return response.DeviceDetails; + + } public DeviceSettings GetDeviceSettings() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(),KarmaMessageType.GET_DEVICE_SETTINGS); GetDeviceSettingsResponse response = new GetDeviceSettingsResponse(conn.GetInputStream()); *************** *** 87,115 **** public void ReleaseIOLock() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(),KarmaProtocol.RELEASE_IO_LOCK); KarmaStatusResponse response = new KarmaStatusResponse(conn.GetInputStream()); ExecuteKarmaCommand( request, response ); } ! public byte[] GetAuthenticationSalt() { ! ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(), KarmaProtocol.GET_AUTHENTICATION_SALT); ! GetAuthenticationSaltResponse response = new GetAuthenticationSaltResponse(conn.GetInputStream()); ! ! ExecuteKarmaCommand( request, response ); ! ! return response.Salt; ! } ! ! public AccessRights Authenticate(byte[] passwordHash) { ! AuthenticationRequest request = new AuthenticationRequest(conn.GetOutputStream(),passwordHash); ! AuthenticationResponse response = new AuthenticationResponse(conn.GetInputStream()); ! ! ExecuteKarmaCommand( request, response ); ! ! return response.AccessRights; ! } ! public void DeleteFile( int fileId ) { --- 125,143 ---- public void ReleaseIOLock() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(),KarmaMessageType.RELEASE_IO_LOCK); KarmaStatusResponse response = new KarmaStatusResponse(conn.GetInputStream()); ExecuteKarmaCommand( request, response ); } + public IEnumerator GetAllFileDetails() + { + KarmaRequest request = new KarmaRequest(conn.GetOutputStream(),KarmaMessageType.GET_ALL_FILE_DETAILS); + GetAllFileDetailsResponse response = new GetAllFileDetailsResponse(conn.GetInputStream()); ! ExecuteKarmaCommand( request, response ); ! ! return response.Files; ! } ! public void DeleteFile( int fileId ) { *************** *** 119,136 **** ExecuteKarmaCommand( request, response ); ! } ! ! public DeviceDetails GetDeviceDetails() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(), KarmaProtocol.GET_DEVICE_DETAILS); ! GetDeviceDetailsResponse response = new GetDeviceDetailsResponse(conn.GetInputStream()); ! ! ExecuteKarmaCommand( request, response ); ! ! return response.DeviceDetails; ! ! } ! ! } } --- 147,153 ---- ExecuteKarmaCommand( request, response ); ! } ! #endregion } } Index: KarmaTCPConnection.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/KarmaTCPConnection.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** KarmaTCPConnection.cs 24 Dec 2003 05:51:52 -0000 1.1 --- KarmaTCPConnection.cs 16 Jan 2004 23:51:06 -0000 1.2 *************** *** 35,39 **** client.Connect(ipAddress,port); } ! catch (SocketException ex) { client = null; --- 35,39 ---- client.Connect(ipAddress,port); } ! catch (SocketException ) { client = null; *************** *** 51,55 **** client.Close(); } ! catch (SocketException ex) { //TODO: Should a SocketException be ignored if client can't disconnect? --- 51,55 ---- client.Close(); } ! catch (SocketException ) { //TODO: Should a SocketException be ignored if client can't disconnect? |
From: <ia...@us...> - 2004-01-16 23:51:10
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib/Util In directory sc8-pr-cvs1:/tmp/cvs-serv10197/src/KarmaLib/Util Modified Files: IOUtils.cs Log Message: implementet GetAllFileDetails - tidied up empty exception handlers - moved static int MessageType constants to a MessageType enum - removed sourcesafe binding information from vs.net project files Index: IOUtils.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Util/IOUtils.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** IOUtils.cs 16 Dec 2003 01:58:48 -0000 1.1.1.1 --- IOUtils.cs 16 Jan 2004 23:51:07 -0000 1.2 *************** *** 11,15 **** { public static byte[] ReadUntilEmptyLineOrNull(Stream rns) { ! int b; bool eol = false; bool done = false; --- 11,15 ---- { public static byte[] ReadUntilEmptyLineOrNull(Stream rns) { ! char b; bool eol = false; bool done = false; *************** *** 19,23 **** while (!done) { ! b = reader.ReadInt32(); if (b == 0) { done = true; --- 19,23 ---- while (!done) { ! b = reader.ReadChar(); if (b == 0) { done = true; *************** *** 41,45 **** public static byte[] ReadUntilNullTermination(Stream rns) { int b; ! bool eol = false; bool done = false; BinaryReader reader = new BinaryReader(rns); --- 41,45 ---- public static byte[] ReadUntilNullTermination(Stream rns) { int b; ! //bool eol = false; bool done = false; BinaryReader reader = new BinaryReader(rns); |
From: <ia...@us...> - 2004-01-16 23:51:09
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib/Data In directory sc8-pr-cvs1:/tmp/cvs-serv10197/src/KarmaLib/Data Modified Files: PropertiesWrapper.cs Log Message: implementet GetAllFileDetails - tidied up empty exception handlers - moved static int MessageType constants to a MessageType enum - removed sourcesafe binding information from vs.net project files Index: PropertiesWrapper.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/Data/PropertiesWrapper.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PropertiesWrapper.cs 16 Dec 2003 01:58:47 -0000 1.1.1.1 --- PropertiesWrapper.cs 16 Jan 2004 23:51:06 -0000 1.2 *************** *** 69,74 **** ms.WriteByte(0); } ! catch (System.Exception ex) { ! // } return ms.ToArray(); --- 69,74 ---- ms.WriteByte(0); } ! catch (System.Exception ) { ! } return ms.ToArray(); |
From: <ia...@us...> - 2004-01-16 23:51:09
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib.Test In directory sc8-pr-cvs1:/tmp/cvs-serv10197/src/KarmaLib.Test Modified Files: KarmaLib.Test.csproj Log Message: implementet GetAllFileDetails - tidied up empty exception handlers - moved static int MessageType constants to a MessageType enum - removed sourcesafe binding information from vs.net project files Index: KarmaLib.Test.csproj =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib.Test/KarmaLib.Test.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KarmaLib.Test.csproj 19 Dec 2003 05:13:12 -0000 1.2 --- KarmaLib.Test.csproj 16 Jan 2004 23:51:06 -0000 1.3 *************** *** 5,12 **** SchemaVersion = "2.0" ProjectGuid = "{DF0D48F8-4182-4A1E-BB6B-379C30D11B38}" - SccProjectName = "SAK" - SccLocalPath = "SAK" - SccAuxPath = "SAK" - SccProvider = "SAK" > <Build> --- 5,8 ---- *************** *** 114,117 **** --- 110,114 ---- /> <Folder RelPath = "Data\" /> + </Include> </Files> |
From: <ia...@us...> - 2004-01-06 15:14:58
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib.Test In directory sc8-pr-cvs1:/tmp/cvs-serv20396/src/KarmaLib.Test Modified Files: KarmaClientTest.cs Log Message: change to create AdvancedClient instead of BasicClient to test. Index: KarmaClientTest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib.Test/KarmaClientTest.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** KarmaClientTest.cs 2 Jan 2004 14:43:12 -0000 1.3 --- KarmaClientTest.cs 6 Jan 2004 15:14:55 -0000 1.4 *************** *** 29,34 **** [SetUp] public void Connect() { ! client = new KarmaClient( new KarmaTCPConnection(IP_ADDRESS), true ); ! client.Connect(); Assertion.Assert("Client could not connect.",client.IsConnected()); --- 29,33 ---- [SetUp] public void Connect() { ! client = (KarmaClient)KarmaClientFactory.GetAdvancedClient( new KarmaTCPConnection(IP_ADDRESS )) ; client.Connect(); Assertion.Assert("Client could not connect.",client.IsConnected()); |
From: <ia...@us...> - 2004-01-02 14:43:16
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib.Test In directory sc8-pr-cvs1:/tmp/cvs-serv15800/src/KarmaLib.Test Modified Files: KarmaClientTest.cs Log Message: small fix to work with Justins recent changes Index: KarmaClientTest.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib.Test/KarmaClientTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KarmaClientTest.cs 19 Dec 2003 05:13:12 -0000 1.2 --- KarmaClientTest.cs 2 Jan 2004 14:43:12 -0000 1.3 *************** *** 29,33 **** [SetUp] public void Connect() { ! client = new KarmaClient(IP_ADDRESS); client.Connect(); --- 29,33 ---- [SetUp] public void Connect() { ! client = new KarmaClient( new KarmaTCPConnection(IP_ADDRESS), true ); client.Connect(); |
From: <jus...@us...> - 2003-12-26 23:22:10
|
Update of /cvsroot/karmalib/java In directory sc8-pr-cvs1:/tmp/cvs-serv7452 Modified Files: README.txt README HISTORY.txt HISTORY Log Message: updated for 0.9.1 alpha Index: README.txt =================================================================== RCS file: /cvsroot/karmalib/java/README.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README.txt 10 Dec 2003 18:19:45 -0000 1.1 --- README.txt 26 Dec 2003 23:22:07 -0000 1.2 *************** *** 42,47 **** KarmaLib is a software library. It is intended for developer use only, and can not be run as an application by itself. Right now there is minimal documentation, but if you ! check out the source of dev.karma.lib.KarmaClient, there should be enough java docs to ! get you started. -------- --- 42,56 ---- KarmaLib is a software library. It is intended for developer use only, and can not be run as an application by itself. Right now there is minimal documentation, but if you ! check out the dev.karma.lib.BasicKarmaClient and dev.karma.lib.AdvancedKarmaClient ! interfaces, there should be enough java docs to get you started. ! ! Here is a super-basic sequence of steps to get your feet wet: ! ! 1. Instantiate a KarmaTCPConnection object passing in the karma's IP address ! 2. Call KarmaClientFactory.getBasicClient() passing in the KarmaConnection object you ! just created. ! 3. Start calling methods on the BasicKarmaClient object returned by the factory to ! manipulate your karma. ! -------- *************** *** 56,60 **** Read / Write device settings Read / Write device information - Format storage Note: --- 65,68 ---- *************** *** 64,72 **** Writing audio files requires some work to generate the file information needed for the ! device (duration, bitrate, rid etc.). These features will be provided in a future version ! (soon), but are not in the current version. This is an ALPHA release. Lots of things might not work. Please give feedback and report ! bugs at http://sourceforge.net/projects/karmalib/ ------------ --- 72,80 ---- Writing audio files requires some work to generate the file information needed for the ! device (duration, bitrate, rid etc.). Rid and fid generation are provided by the library. ! Others will be in a future version, but are not in the current version. This is an ALPHA release. Lots of things might not work. Please give feedback and report ! bugs at http://karmalib.sourceforge.net/ ------------ Index: README =================================================================== RCS file: /cvsroot/karmalib/java/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README 10 Dec 2003 18:19:45 -0000 1.1 --- README 26 Dec 2003 23:22:07 -0000 1.2 *************** *** 42,47 **** KarmaLib is a software library. It is intended for developer use only, and can not be run as an application by itself. Right now there is minimal documentation, but if you ! check out the source of dev.karma.lib.KarmaClient, there should be enough java docs to ! get you started. -------- --- 42,56 ---- KarmaLib is a software library. It is intended for developer use only, and can not be run as an application by itself. Right now there is minimal documentation, but if you ! check out the dev.karma.lib.BasicKarmaClient and dev.karma.lib.AdvancedKarmaClient ! interfaces, there should be enough java docs to get you started. ! ! Here is a super-basic sequence of steps to get your feet wet: ! ! 1. Instantiate a KarmaTCPConnection object passing in the karma's IP address ! 2. Call KarmaClientFactory.getBasicClient() passing in the KarmaConnection object you ! just created. ! 3. Start calling methods on the BasicKarmaClient object returned by the factory to ! manipulate your karma. ! -------- *************** *** 56,60 **** Read / Write device settings Read / Write device information - Format storage Note: --- 65,68 ---- *************** *** 64,72 **** Writing audio files requires some work to generate the file information needed for the ! device (duration, bitrate, rid etc.). These features will be provided in a future version ! (soon), but are not in the current version. This is an ALPHA release. Lots of things might not work. Please give feedback and report ! bugs at http://sourceforge.net/projects/karmalib/ ------------ --- 72,80 ---- Writing audio files requires some work to generate the file information needed for the ! device (duration, bitrate, rid etc.). Rid and fid generation are provided by the library. ! Others will be in a future version, but are not in the current version. This is an ALPHA release. Lots of things might not work. Please give feedback and report ! bugs at http://karmalib.sourceforge.net/ ------------ Index: HISTORY.txt =================================================================== RCS file: /cvsroot/karmalib/java/HISTORY.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HISTORY.txt 10 Dec 2003 18:19:45 -0000 1.1 --- HISTORY.txt 26 Dec 2003 23:22:07 -0000 1.2 *************** *** 1,3 **** --- 1,20 ---- ------------------------ + Version 0.9.1 Alpha + December 26, 2003 + ------------------------ + + Bugfixes: + Fixed bad nio implementation.. uses large buffers now. + Fixed incorrectly named property in dev.karma.lib.FileDetails + + Changes/Additions: + Created basic and advanced interfaces and a client factory. + Created connection interface and moved TCP stuff to an + implementing class. + Moved TCP information out of client class + Added fid and rid calculation utilities in dev.karma.lib.util.FileUtils + + + ------------------------ Version 0.9.0 Alpha December 8, 2003 Index: HISTORY =================================================================== RCS file: /cvsroot/karmalib/java/HISTORY,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HISTORY 10 Dec 2003 18:19:45 -0000 1.1 --- HISTORY 26 Dec 2003 23:22:07 -0000 1.2 *************** *** 1,3 **** --- 1,20 ---- ------------------------ + Version 0.9.1 Alpha + December 26, 2003 + ------------------------ + + Bugfixes: + Fixed bad nio implementation.. uses large buffers now. + Fixed incorrectly named property in dev.karma.lib.FileDetails + + Changes/Additions: + Created basic and advanced interfaces and a client factory. + Created connection interface and moved TCP stuff to an + implementing class. + Moved TCP information out of client class + Added fid and rid calculation utilities in dev.karma.lib.util.FileUtils + + + ------------------------ Version 0.9.0 Alpha December 8, 2003 |
From: <jus...@us...> - 2003-12-26 23:06:13
|
Update of /cvsroot/karmalib/java/src/dev/karma/lib In directory sc8-pr-cvs1:/tmp/cvs-serv5417/src/dev/karma/lib Modified Files: KarmaProgressObserver.java KarmaClient.java Log Message: comments Index: KarmaProgressObserver.java =================================================================== RCS file: /cvsroot/karmalib/java/src/dev/karma/lib/KarmaProgressObserver.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KarmaProgressObserver.java 17 Dec 2003 18:47:26 -0000 1.2 --- KarmaProgressObserver.java 26 Dec 2003 23:06:10 -0000 1.3 *************** *** 11,15 **** */ ! public interface KarmaProgressObserver { --- 11,17 ---- */ ! /** ! * This interface has not been thought out, is not complete, and is not used. ! */ public interface KarmaProgressObserver { Index: KarmaClient.java =================================================================== RCS file: /cvsroot/karmalib/java/src/dev/karma/lib/KarmaClient.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** KarmaClient.java 17 Dec 2003 18:43:20 -0000 1.6 --- KarmaClient.java 26 Dec 2003 23:06:10 -0000 1.7 *************** *** 21,31 **** /** - * Currently there is some problem which is preventing reading or writing from/to - * the device with a reasonable size buffer. Currently reads are using a 4 byte - * buffer and writes an 8 byte buffer. The performance hit for this rather large, - * but hopefully can be resolved. Ideally IO should be done with a buffer on the - * order of 8-32K. Perhaps the implementation of the java.nio.* classes in the - * jdk I'm using are bad, or maybe I'm just stupid and don't know what I'm doing. - * <p> * JDK 1.4 or higher is required, as the java.nio.* packages are used to try to * improve performance, and to handle little endianness. 1.4.2 is recommended --- 21,24 ---- *************** *** 65,69 **** * The version of the client */ ! public static final String version = "0.9.0 Alpha"; /** --- 58,62 ---- * The version of the client */ ! public static final String version = "0.9.1 Alpha"; /** |
From: <jus...@us...> - 2003-12-26 23:06:13
|
Update of /cvsroot/karmalib/java/src/dev/karma/lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv5417/src/dev/karma/lib/test Modified Files: TestProgressObserver.java Log Message: comments Index: TestProgressObserver.java =================================================================== RCS file: /cvsroot/karmalib/java/src/dev/karma/lib/test/TestProgressObserver.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TestProgressObserver.java 10 Dec 2003 18:11:30 -0000 1.1.1.1 --- TestProgressObserver.java 26 Dec 2003 23:06:10 -0000 1.2 *************** *** 12,15 **** --- 12,18 ---- import dev.karma.lib.*; + /** + * No progress observer behavior is implemented in the library yet. + */ public class TestProgressObserver implements KarmaProgressObserver { |
From: <jus...@us...> - 2003-12-24 06:08:21
|
Update of /cvsroot/karmalib/java/src/dev/karma/lib/data In directory sc8-pr-cvs1:/tmp/cvs-serv7263 Removed Files: PlaylistEntry.jbx Log Message: should not have been commited --- PlaylistEntry.jbx DELETED --- |
From: <jus...@us...> - 2003-12-24 05:53:52
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib In directory sc8-pr-cvs1:/tmp/cvs-serv5426 Modified Files: KarmaProtocol.cs Log Message: updated because of method name change in IKarmaConnection Index: KarmaProtocol.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/KarmaProtocol.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KarmaProtocol.cs 19 Dec 2003 05:13:12 -0000 1.2 --- KarmaProtocol.cs 24 Dec 2003 05:53:49 -0000 1.3 *************** *** 12,16 **** /// </summary> public class KarmaProtocol : IKarmaProtocol { ! private KarmaConnection conn = null; public static KarmaLib.Data.Version supportedVersion = new KarmaLib.Data.Version(2,0); --- 12,16 ---- /// </summary> public class KarmaProtocol : IKarmaProtocol { ! private IKarmaConnection conn = null; public static KarmaLib.Data.Version supportedVersion = new KarmaLib.Data.Version(2,0); *************** *** 37,45 **** public static int DEVICE_OPERATION = 20; ! public KarmaProtocol(KarmaConnection conn) { this.conn = conn; } ! public void SetConnection(KarmaConnection conn) { this.conn = conn; } --- 37,45 ---- public static int DEVICE_OPERATION = 20; ! public KarmaProtocol(IKarmaConnection conn) { this.conn = conn; } ! public void SetConnection(IKarmaConnection conn) { this.conn = conn; } *************** *** 61,66 **** public KarmaLib.Data.Version GetVersion() { ! GetVersionRequest request = new GetVersionRequest(conn.GetOutputChannel(),KarmaProtocol.supportedVersion); ! GetVersionResponse response = new GetVersionResponse(conn.GetInputChannel()); ExecuteKarmaCommand( request, response ); --- 61,66 ---- public KarmaLib.Data.Version GetVersion() { ! GetVersionRequest request = new GetVersionRequest(conn.GetOutputStream(),KarmaProtocol.supportedVersion); ! GetVersionResponse response = new GetVersionResponse(conn.GetInputStream()); ExecuteKarmaCommand( request, response ); *************** *** 71,76 **** public DeviceSettings GetDeviceSettings() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputChannel(),KarmaProtocol.GET_DEVICE_SETTINGS); ! GetDeviceSettingsResponse response = new GetDeviceSettingsResponse(conn.GetInputChannel()); ExecuteKarmaCommand(request,response); --- 71,76 ---- public DeviceSettings GetDeviceSettings() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(),KarmaProtocol.GET_DEVICE_SETTINGS); ! GetDeviceSettingsResponse response = new GetDeviceSettingsResponse(conn.GetInputStream()); ExecuteKarmaCommand(request,response); *************** *** 80,85 **** public void AcquireIOLock(int readWrite) { ! AcquireIOLockRequest request = new AcquireIOLockRequest(conn.GetOutputChannel(),readWrite); ! KarmaStatusResponse response = new KarmaStatusResponse(conn.GetInputChannel()); ExecuteKarmaCommand(request,response); --- 80,85 ---- public void AcquireIOLock(int readWrite) { ! AcquireIOLockRequest request = new AcquireIOLockRequest(conn.GetOutputStream(),readWrite); ! KarmaStatusResponse response = new KarmaStatusResponse(conn.GetInputStream()); ExecuteKarmaCommand(request,response); *************** *** 87,92 **** public void ReleaseIOLock() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputChannel(),KarmaProtocol.RELEASE_IO_LOCK); ! KarmaStatusResponse response = new KarmaStatusResponse(conn.GetInputChannel()); ExecuteKarmaCommand( request, response ); --- 87,92 ---- public void ReleaseIOLock() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(),KarmaProtocol.RELEASE_IO_LOCK); ! KarmaStatusResponse response = new KarmaStatusResponse(conn.GetInputStream()); ExecuteKarmaCommand( request, response ); *************** *** 95,100 **** public byte[] GetAuthenticationSalt() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputChannel(), KarmaProtocol.GET_AUTHENTICATION_SALT); ! GetAuthenticationSaltResponse response = new GetAuthenticationSaltResponse(conn.GetInputChannel()); ExecuteKarmaCommand( request, response ); --- 95,100 ---- public byte[] GetAuthenticationSalt() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(), KarmaProtocol.GET_AUTHENTICATION_SALT); ! GetAuthenticationSaltResponse response = new GetAuthenticationSaltResponse(conn.GetInputStream()); ExecuteKarmaCommand( request, response ); *************** *** 104,109 **** public AccessRights Authenticate(byte[] passwordHash) { ! AuthenticationRequest request = new AuthenticationRequest(conn.GetOutputChannel(),passwordHash); ! AuthenticationResponse response = new AuthenticationResponse(conn.GetInputChannel()); ExecuteKarmaCommand( request, response ); --- 104,109 ---- public AccessRights Authenticate(byte[] passwordHash) { ! AuthenticationRequest request = new AuthenticationRequest(conn.GetOutputStream(),passwordHash); ! AuthenticationResponse response = new AuthenticationResponse(conn.GetInputStream()); ExecuteKarmaCommand( request, response ); *************** *** 114,119 **** public void DeleteFile( int fileId ) { ! DeleteFileRequest request = new DeleteFileRequest(conn.GetOutputChannel(),fileId); ! KarmaStatusResponse response = new KarmaStatusResponse(conn.GetInputChannel()); ExecuteKarmaCommand( request, response ); --- 114,119 ---- public void DeleteFile( int fileId ) { ! DeleteFileRequest request = new DeleteFileRequest(conn.GetOutputStream(),fileId); ! KarmaStatusResponse response = new KarmaStatusResponse(conn.GetInputStream()); ExecuteKarmaCommand( request, response ); *************** *** 123,128 **** public DeviceDetails GetDeviceDetails() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputChannel(), KarmaProtocol.GET_DEVICE_DETAILS); ! GetDeviceDetailsResponse response = new GetDeviceDetailsResponse(conn.GetInputChannel()); ExecuteKarmaCommand( request, response ); --- 123,128 ---- public DeviceDetails GetDeviceDetails() { ! KarmaRequest request = new KarmaRequest(conn.GetOutputStream(), KarmaProtocol.GET_DEVICE_DETAILS); ! GetDeviceDetailsResponse response = new GetDeviceDetailsResponse(conn.GetInputStream()); ExecuteKarmaCommand( request, response ); |
From: <jus...@us...> - 2003-12-24 05:53:23
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib In directory sc8-pr-cvs1:/tmp/cvs-serv5384 Modified Files: KarmaClient.cs Log Message: now implements both IKarmaAdvancedClient and IKarmaBasicClient. The TCP stuff was moved out as well. Use KarmaClientFactory to get an instance. Index: KarmaClient.cs =================================================================== RCS file: /cvsroot/karmalib/csharp/src/KarmaLib/KarmaClient.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KarmaClient.cs 19 Dec 2003 05:13:12 -0000 1.2 --- KarmaClient.cs 24 Dec 2003 05:53:18 -0000 1.3 *************** *** 1,4 **** --- 1,5 ---- using System; + using System.Collections; using System.IO; using System.Net; *************** *** 14,28 **** /// Summary description for KarmaClient. /// </summary> ! public class KarmaClient { ! public static readonly string version = "0.1.0 Alpha"; ! public static readonly int PORT = 8302; ! private KarmaConnection conn = null; private KarmaProtocol protocol = null; ! public KarmaClient(string ipAddress) { ! conn = new KarmaConnection(ipAddress,PORT); ! protocol = new KarmaProtocol(conn); } --- 15,52 ---- /// Summary description for KarmaClient. /// </summary> ! public class KarmaClient: IBasicKarmaClient, IAdvancedKarmaClient { ! private bool isBasic = true; ! private static readonly string version = "0.1.0 Alpha"; ! ! enum IOLock { Read, Write, None }; ! ! private string password = ""; ! ! private IKarmaConnection conn = null; private KarmaProtocol protocol = null; ! public KarmaClient( IKarmaConnection connection, bool isBasic ) ! { ! conn = connection; ! this.isBasic = isBasic; ! protocol = new KarmaProtocol( connection ); ! } ! ! public IKarmaConnection Connection ! { ! get ! { ! return conn; ! } ! } ! ! public string Version ! { ! get ! { ! return version; ! } } *************** *** 51,56 **** } ! public KarmaLib.Data.Version GetDeviceProtocolVersion() ! { KarmaLib.Data.Version rv = null; if (Connect()) --- 75,122 ---- } ! private void BasicConnect( IOLock locktype ) { ! if (isBasic) ! { ! if (!IsValidDeviceProtocolVersion()) ! { ! throw new KarmaException("Unsupported Protocol Version"); ! } ! ! switch (locktype) ! { ! case IOLock.Read: ! { ! Login(password); ! GetReadLock(); ! break; ! } ! case IOLock.Write: ! { ! Login(password); ! GetWriteLock(); ! break; ! } ! case IOLock.None: ! { ! goto default; ! } ! default: ! { ! break; ! } ! } ! } ! } ! ! private void BasicDisconnect() { ! if (isBasic) ! { ! ReleaseIOLock(); ! Hangup(); ! Disconnect(); ! } ! } ! ! public KarmaLib.Data.Version GetDeviceProtocolVersion() { KarmaLib.Data.Version rv = null; if (Connect()) *************** *** 61,64 **** --- 127,191 ---- } + public bool IsValidDeviceProtocolVersion() { + bool rv = false; + if (Connect()) + { + KarmaLib.Data.Version deviceVersion = protocol.GetVersion(); + if (KarmaProtocol.supportedVersion.Equals(deviceVersion)) + { + rv = true; + } + } + return rv; + } + + public AccessRights Login(string password) { + AccessRights rv = null; + if (Connect()) + { + byte[] salt = protocol.GetAuthenticationSalt(); + byte[] newPassword = new byte[salt.Length + password.Length]; + byte[] encodedPassword = null; + MD5CryptoServiceProvider crypto = new MD5CryptoServiceProvider(); + + System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding(); + encodedPassword = encoder.GetBytes(password); + + salt.CopyTo(newPassword,0); + encodedPassword.CopyTo(newPassword,salt.Length); + + byte[] hash = null; + + try + { + hash = crypto.ComputeHash(newPassword); + } + catch + { + throw new KarmaException("Could not find MD5 algorithm"); + } + + rv = protocol.Authenticate(hash); + this.password = password; + } + return rv; + } + + public DeviceDetails GetDeviceDetails() { + + DeviceDetails rv = null; + if (Connect()) + { + BasicConnect( IOLock.None ); + rv = protocol.GetDeviceDetails(); + BasicDisconnect(); + } + return rv; + } + + public StorageDetails GetStorageDetails( int storageId ){ + throw new KarmaException("Not yet implemented"); + } + public DeviceSettings GetDeviceSettings() { *************** *** 66,74 **** --- 193,207 ---- if (Connect()) { + BasicConnect( IOLock.Read ); rv = protocol.GetDeviceSettings(); + BasicDisconnect(); } return rv; } + public void UpdateDeviceSettings( DeviceSettings deviceSettings ){ + throw new KarmaException("Not yet implemented"); + } + public void GetReadLock() { if (Connect()) { *************** *** 89,135 **** } ! public AccessRights Login(string password) { ! AccessRights rv = null; ! if (Connect()) { ! byte[] salt = protocol.GetAuthenticationSalt(); ! byte[] newPassword = new byte[salt.Length + password.Length]; ! byte[] encodedPassword = null; ! MD5CryptoServiceProvider crypto = new MD5CryptoServiceProvider(); ! System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding(); ! encodedPassword = encoder.GetBytes(password); ! salt.CopyTo(newPassword,0); ! encodedPassword.CopyTo(newPassword,salt.Length); ! byte[] hash = null; ! try { ! hash = crypto.ComputeHash(newPassword); ! } ! catch { ! throw new KarmaException("Could not find MD5 algorithm"); ! } ! rv = protocol.Authenticate(hash); ! } ! return rv; } public void DeleteFile( int fileId ) { if (Connect()) { protocol.DeleteFile( fileId ); } } ! ! public DeviceDetails GetDeviceDetails() { ! ! DeviceDetails rv = null; ! if (Connect()) { ! rv = protocol.GetDeviceDetails(); } - return rv; } - } } --- 222,285 ---- } ! public void WriteDataFile( string filename, long size, int fileId, int storage, Stream input ) { ! throw new KarmaException("Not yet implemented"); ! } ! public void WriteDataFile( string pathname, int fileId, int storage ) { ! throw new KarmaException("Not yet implemented"); ! } ! public void WriteFile( FileDetails fd, int storage, Stream input ) { ! throw new KarmaException("Not yet implemented"); ! } ! public void WriteFileChunk( long offset, long size, int fileId, int storage, Stream input ) { ! throw new KarmaException("Not yet implemented"); ! } ! public FileDetails[] GetAllFileDetails() { ! throw new KarmaException("Not yet implemented"); ! } ! public IEnumerator GetFileDetailsIterator() { ! throw new KarmaException("Not yet implemented"); ! } ! ! public FileDetails GetFileDetails( int fileId ) { ! throw new KarmaException("Not yet implemented"); ! } ! ! public void UpdateFileDetails( FileDetails fd ) { ! throw new KarmaException("Not yet implemented"); ! } ! ! public void ReadFileChunk( long offset, long size, int fileId, Stream output) { ! throw new KarmaException("Not yet implemented"); ! } ! ! public byte[] ReadFileChunk(long offset, long size, int fileId) { ! throw new KarmaException("Not yet implemented"); ! } ! ! public void ReadFile( int fileId, Stream output ) { ! throw new KarmaException("Not yet implemented"); } public void DeleteFile( int fileId ) { if (Connect()) { + BasicConnect( IOLock.Write ); protocol.DeleteFile( fileId ); + BasicDisconnect(); } } ! ! public void Hangup() { ! if (Connect()) ! { ! //todo.. implement ! // protocol.Hangup(); ! Disconnect(); } } } } |
Update of /cvsroot/karmalib/csharp/src/KarmaLib In directory sc8-pr-cvs1:/tmp/cvs-serv5198 Added Files: KarmaTCPConnection.cs KarmaClientFactory.cs IKarmaConnection.cs IBasicKarmaClient.cs IAdvancedKarmaClient.cs Log Message: New and improved. --- NEW FILE: KarmaTCPConnection.cs --- using System; using System.Net; using System.Net.Sockets; using KarmaLib.Exception; namespace KarmaLib { /// <summary> /// Summary description for KarmaConnection. /// </summary> public class KarmaTCPConnection: IKarmaConnection { public const int PORT = 8302; private TcpClient client = null; private string ipAddress = null; private int port = -1; public KarmaTCPConnection(string ipAddress):this(ipAddress,PORT) { } public KarmaTCPConnection(string ipAddress, int port) { this.ipAddress = ipAddress; this.port = port; } public bool Connect() { try { client = new TcpClient(); client.Connect(ipAddress,port); } catch (SocketException ex) { client = null; throw new CommunicationException("Error connection to device"); } return true; } public void Disconnect() { if (client != null) { try { client.Close(); } catch (SocketException ex) { //TODO: Should a SocketException be ignored if client can't disconnect? // Ignore } finally { client = null; } } } public bool IsConnected() { bool connected = false; if (client != null) { connected = true; } return connected; } public NetworkStream GetOutputStream() { return client.GetStream(); } public NetworkStream GetInputStream() { return client.GetStream(); } } } --- NEW FILE: KarmaClientFactory.cs --- using System; namespace KarmaLib { /// <summary> /// Summary description for KarmaClientFactory. /// </summary> public abstract class KarmaClientFactory { public static IBasicKarmaClient GetBasicClient(IKarmaConnection conn) { return new KarmaClient(conn, true); } public static IAdvancedKarmaClient GetAdvancedClient(IKarmaConnection conn) { return new KarmaClient(conn, false); } } } --- NEW FILE: IKarmaConnection.cs --- using System; using System.Net; using System.Net.Sockets; using KarmaLib.Exception; namespace KarmaLib { /// <summary> /// Summary description for KarmaConnection. /// </summary> public interface IKarmaConnection { bool Connect(); void Disconnect(); bool IsConnected(); NetworkStream GetOutputStream(); NetworkStream GetInputStream(); } } --- NEW FILE: IBasicKarmaClient.cs --- using System; using System.IO; using KarmaLib.Data; namespace KarmaLib { /// <summary> /// Summary description for IBasicKarmaClient. /// </summary> public interface IBasicKarmaClient { string Version { get; } AccessRights Login( string password ); DeviceDetails GetDeviceDetails(); StorageDetails GetStorageDetails( int storageId ); DeviceSettings GetDeviceSettings(); void UpdateDeviceSettings( DeviceSettings deviceSettings ); void ReadFile( int fileId, Stream output ); void WriteDataFile( string filename, long size, int fileId, int storage, Stream input ); void WriteDataFile( string pathname, int fileId, int storage ); void WriteFile( FileDetails fd, int storage, Stream input ); void DeleteFile( int fileId ); FileDetails[] GetAllFileDetails(); FileDetails GetFileDetails( int fileId ); void UpdateFileDetails( FileDetails fd ); } } --- NEW FILE: IAdvancedKarmaClient.cs --- using System; using System.IO; using System.Collections; namespace KarmaLib { /// <summary> /// Summary description for IAdvancedKarmaClient. /// </summary> public interface IAdvancedKarmaClient: IBasicKarmaClient { IKarmaConnection Connection { get; } bool Connect(); void Disconnect(); bool IsConnected(); KarmaLib.Data.Version GetDeviceProtocolVersion(); bool IsValidDeviceProtocolVersion(); void GetReadLock(); void GetWriteLock(); void ReleaseIOLock(); IEnumerator GetFileDetailsIterator(); void WriteFileChunk( long offset, long size, int fileId, int storage, Stream input ); void ReadFileChunk(long offset, long size, int fileId, Stream output); byte[] ReadFileChunk(long offset, long size, int fileId); void Hangup(); } } |
From: <jus...@us...> - 2003-12-24 05:51:26
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib In directory sc8-pr-cvs1:/tmp/cvs-serv5151 Removed Files: KarmaConnection.cs Log Message: Not needed now... implemented as KarmaTCPConnection --- KarmaConnection.cs DELETED --- |
From: <jus...@us...> - 2003-12-24 05:50:40
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib/Data In directory sc8-pr-cvs1:/tmp/cvs-serv5047 Added Files: FileDetails.cs Log Message: new --- NEW FILE: FileDetails.cs --- using System; namespace KarmaLib.Data { /// <summary> /// Summary description for FileInfo. /// </summary> public class FileDetails : PropertiesWrapper { public FileDetails() { } // int Duration public int Duration { get { return int.Parse(props["duration"].ToString()); } set { Set("duration",value); } } // int FileId public int FileID { get { return int.Parse(props["fid"].ToString()) ; } set { Set("fid",value); } } // string Bitrate public string Bitrate { get { return props["bitrate"].ToString(); } set { Set("bitrate",value); } } // String Genre public string Genre { get { return props["genre"].ToString(); } set { Set("genre",value); } } // String OtherFileID public string OtherFileID { get { return props["file_id"].ToString(); } set { Set("file_id", value); } } // byte[] Profile (R) //HACK: Find a better way to convert to byte[]? public byte[] Profile { get { return (byte[])props["profile"]; } } // String Type //HACK: Renamed to FileType to prevent confusion with Type public string FileType { get { return props["type"].ToString(); } set { Set("type",value); } } // long Length public Int64 Length { get { return Int64.Parse(props["length"].ToString()); } set { Set("length",value); } } // String Codec public string Codec { get { return props["codec"].ToString(); } set { Set("codec",value); } } // String Artist public string Artist { get { return props["artist"].ToString(); } set { Set("artist",value); } } // String PlayCountLimit (R) public string PlayCountLimit { get { return props["play_count_limit"].ToString(); } } // String TrackNumber public string TrackNumber { get { return props["tracknr"].ToString(); } set { Set("tracknr",value); } } // int PlayCount (R) public int PlayCount { get { return int.Parse(props["play_count"].ToString()); } } // int ProfilerVersion (R) public int ProfilerVersion { get { return int.Parse(props["profiler_version"].ToString()); } } // long PlayLast (R) public Int64 PlayLast { get { return Int64.Parse(props["play_last"].ToString()); } } // int Marked (R) public int Marked { get { return int.Parse(props["marked"].ToString()); } } // String Source public string Source { get { return props["source"].ToString(); } set { Set("source",value); } } // String Rid public string Rid { get { return props["rid"].ToString(); } set { Set("rid",value); } } // String Trailer (R) public string Trailer { get { return props["trailer"].ToString(); } } // String Rms (R) public string Rms{ get { return props["rms"].ToString(); } } // String StdDev (R) public string StdDev { get { return props["stddev"].ToString(); } } // int SampleRate public int SampleRate { get { return int.Parse(props["samplerate"].ToString()); } set { Set("samplerate",value); } } // String Title public string Title { get { return props["title"].ToString(); } set { Set("title",value); } } // long TimeCreated public Int64 TimeCreated { get { return Int64.Parse(props["ctime"].ToString()); } set { Set("ctime",value); } } // long TimeFileIdCreated public Int64 TimeFileIdCreated { get { return Int64.Parse(props["fid_generation"].ToString()); } set { Set("fid_generation",value); } } // byte[] Playlist (R) //HACK: Find a better way to convert to byte[]? public byte[] Playlist { get { return (byte[])props["playlist"]; } } // long Offset public Int64 Offset { get { return Int64.Parse(props["offset"].ToString()); } set { Set("offset",value); } } } } |
From: <jus...@us...> - 2003-12-24 05:50:15
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib/Data In directory sc8-pr-cvs1:/tmp/cvs-serv5015 Removed Files: FileInfo.cs Log Message: Renamed to FileDetails to stay equivalent to java source --- FileInfo.cs DELETED --- |
From: <jus...@us...> - 2003-12-22 03:08:42
|
Update of /cvsroot/karmalib/java/src/dev/karma/lib/util In directory sc8-pr-cvs1:/tmp/cvs-serv10633 Modified Files: IOUtils.java Log Message: added Mike Hiner to author credit Index: IOUtils.java =================================================================== RCS file: /cvsroot/karmalib/java/src/dev/karma/lib/util/IOUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IOUtils.java 22 Dec 2003 00:37:11 -0000 1.3 --- IOUtils.java 22 Dec 2003 03:08:39 -0000 1.4 *************** *** 19,23 **** /** * This class contains a few helper methods used to write/read to/from Channels. ! * @author Justin Waugh */ public class IOUtils --- 19,23 ---- /** * This class contains a few helper methods used to write/read to/from Channels. ! * @author Justin Waugh, Mike Hiner */ public class IOUtils |
From: <jus...@us...> - 2003-12-22 03:07:28
|
Update of /cvsroot/karmalib/java/src/dev/karma/lib/test In directory sc8-pr-cvs1:/tmp/cvs-serv10502 Modified Files: TestBasic.java Log Message: no message Index: TestBasic.java =================================================================== RCS file: /cvsroot/karmalib/java/src/dev/karma/lib/test/TestBasic.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestBasic.java 22 Dec 2003 03:06:03 -0000 1.2 --- TestBasic.java 22 Dec 2003 03:07:25 -0000 1.3 *************** *** 80,84 **** fd = files[i]; } - if (files[i].getTitle().equals("Test")) System.out.println("Playlist: " + files[i]); if (files[i].getFileId() > maxId) maxId = files[i].getFileId(); } --- 80,83 ---- |