Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37853068
en ru br
ALT Linux repos
S:0.2-alt8

Group :: Graphical desktop/GNUstep
RPM: gnustep-cddb.bundle

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

gnustep-cddb.bundle-0.2/000075500000000000000000000000001227727001500152035ustar00rootroot00000000000000gnustep-cddb.bundle-0.2/COPYING000064400000000000000000000431311227727001500162400ustar00rootroot00000000000000		    GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
gnustep-cddb.bundle-0.2/Cddb/000075500000000000000000000000001227727001500160375ustar00rootroot00000000000000gnustep-cddb.bundle-0.2/Cddb/.CddbProtocol.h.swp000064400000000000000000000400001227727001500214460ustar00rootroot00000000000000b0VIM 6.0L=$Z!>aheahe~ahe/Projekte/Cddb/Cddb/CddbProtocol.h3210#"! UtpghadgWRL ; ] 

}
[
C
B


 ~ M 8
p95[$lk=f1SR:)jB>}|T$ 
 - (int) proto; /* Ask the proto */- (NSString *) version;- (NSArray *) category;- (NSArray *) sites; */ * site, port, latitude, longitude, description/* Array of NSDictionary, the keys are:- (NSString *) discid: (NSString *) input; */ * "ntrks off_1 off_2 ... off_n nsecs" * Input format:/* It would be better to calculate it locally. - (NSArray *) query: (NSString *) input; */ * "category", "discid", "description" * The returned array of NSDictionary have these keys: * "discid ntrks off_1 off_2 ... off_n nsecs" /* Input format:- (NSDictionary *) read: (NSString *) input; */ * "category discid" /* Input format:/* Low-level methods */ postProcess: (BOOL) bool; discid: (NSString *) discid- (NSDictionary *) readWithCategory: (NSString *) category */ * NSArray, "exttitles" (extra-title of each track) * NSString, "extdata" (extra data about this album) * NSArray, "titles" (title of each track) * NSString, "genre" (level 4 or up) * NSString, "year" (level 4 or up) * NSString, "album" * NSString, "discid" * The class of objects and keys of returned value are:/* Return the read using category and discid - (NSArray *) queryWithCDTracks: (NSArray *) tracks; */ * The keys of return NSDictionary are "category", "discid", "description". * The return value are a NSArray of NSDictionary. * The keys of NSDictionary are "length" and "offset". * The number of object in NSArray are the number of tracks./* Return the query using a NSArray of NSDictionary. locally: (BOOL) bool;- (NSString *) discidWithCDTracks: (NSArray *) tracks */ * The keys of NSDictionary are "length" and "offset". * The number of object in NSArray are the number of tracks./* Return the discid either through cddb site or calculated locally/* High-level methods*/- (NSString *) request: (NSString *) command;- (void) disconnect;- (BOOL) connect; /* return YES when success. */ */ * If the return value is NSArray, empty array for nothing (failed), not nil./* If the return value is NSString or NSDictionary, nil for nothing (failed).@protocol CddbProtocol <NSObject> s = f / CD_FPS;#define FRAMES_TO_SECONDS(f, s) \} *(M) = value; \ value /= 60; \ *(S) = value%60; \ value /= CD_FPS; \ *(F) = value%CD_FPS; \ int value = f; \#define FRAMES_TO_MSF(f, M, S, F) { \#define CD_FPS 75#import <Foundation/Foundation.h>*/** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA** along with this program; if not, write to the Free Software** You should have received a copy of the GNU Lesser General Public License**** GNU General Public License for more details.** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the** but WITHOUT ANY WARRANTY; without even the implied warranty of** This program is distributed in the hope that it will be useful,**** (at your option) any later version.** the Free Software Foundation; either version 2 of the License, or** it under the terms of the GNU Lesser General Public License as published by** This program is free software; you can redistribute it and/or modify**** Author: Yen-Ju <yjchenx@hotmail.com>**** Copyright (c) 2002**** CddbProtocol.h/*adBntsnm@end- (NSString *) defaultSite;- (void) setDefaultSite: (NSString *) site;- (int) proto: (int) level; /* Set proto, and return the result */gnustep-cddb.bundle-0.2/Cddb/Cddb.h000064400000000000000000000074461227727001500170570ustar00rootroot00000000000000/*
** Cddb.h
**
** Copyright (c) 2002
**
** Author: Yen-Ju <yjchenx@hotmail.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <objc2/runtime.h>
#import <Foundation/Foundation.h>

#define CD_FPS 75
#define FRAMES_TO_MSF(f, M, S, F) { \
int value = f; \
*(F) = value%CD_FPS; \
value /= CD_FPS; \
*(S) = value%60; \
value /= 60; \
*(M) = value; \
}
#define FRAMES_TO_SECONDS(f, s) \
s = f / CD_FPS;

@interface Cddb: NSObject
{
NSURL *defaultSite;
NSFileHandle *fileHandler;
int level;
}

/* If the return value is NSString or NSDictionary, nil for nothing (failed).
* If the return value is NSArray, empty array for nothing (failed), not nil.
*/

- (BOOL) connect; /* return YES when success. */
- (void) disconnect;
- (NSString *) request: (NSString *) command;

/* High-level methods*/
/* Return the discid either through cddb site or calculated locally
* The number of object in NSArray are the number of tracks.
* The keys of NSDictionary are "length" and "offset".
*/
- (NSString *) discidWithCDTracks: (NSArray *) tracks
locally: (BOOL) bool_;

/* Return the query using a NSArray of NSDictionary.
* The number of object in NSArray are the number of tracks.
* The keys of NSDictionary are "length" and "offset".
* The return value are a NSArray of NSDictionary.
* The keys of return NSDictionary are "category", "discid", "description".
*/
- (NSArray *) queryWithCDTracks: (NSArray *) tracks;

/* Return the read using category and discid
* The class of objects and keys of returned value are:
* NSString, "discid"
* NSString, "album"
* NSString, "year" (level 4 or up)
* NSString, "genre" (level 4 or up)
* NSArray, "titles" (title of each track)
* NSString, "extdata" (extra data about this album)
* NSArray, "exttitles" (extra-title of each track)
*/
- (NSDictionary *) readWithCategory: (NSString *) category
discid: (NSString *) discid
postProcess: (BOOL) bool_;

/* Low-level methods */
/* Input format:
* "category discid"
*/
- (NSDictionary *) read: (NSString *) input;

/* Input format:
* "discid ntrks off_1 off_2 ... off_n nsecs"
* The returned array of NSDictionary have these keys:
* "category", "discid", "description"
*/
- (NSArray *) query: (NSString *) input;

/* It would be better to calculate it locally.
* Input format:
* "ntrks off_1 off_2 ... off_n nsecs"
*/
- (NSString *) discid: (NSString *) input;

/* Array of NSDictionary, the keys are:
* site, port, latitude, longitude, description
*/
- (NSArray *) sites;

- (NSArray *) category;
- (NSString *) version;
- (int) proto; /* Ask the proto */
- (int) proto: (int) level; /* Set proto, and return the result */

- (void) setDefaultSite: (NSString *) site;
- (NSString *) defaultSite;

@end
gnustep-cddb.bundle-0.2/Cddb/Cddb.m000064400000000000000000000544641227727001500170660ustar00rootroot00000000000000/*
** Cddb.m
**
** Copyright (c) 2002
**
** Author: Yen-Ju <yjchenx@hotmail.com>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#import "Cddb.h"
#import <unistd.h>

#define SetObject(dict, object, key) \
if (object != nil) \
[dict setObject: object forKey: key];

@implementation Cddb

int cddb_sum (int n)
{
/* a number like 2344 becomes 2+3+4+4 (13) */
int ret=0;

while (n > 0) {
ret = ret + (n % 10);
n = n / 10;
}

return ret;
}


- (NSString *) discidWithCDTracks: (NSArray *) tracks
locally: (BOOL) bool_
{
NSMutableString *string = [NSMutableString new];
int i = 0, numtracks = 0;
int cksum = 0;
int totaltime = 0;

RETAIN(tracks);

numtracks = [tracks count];
[string appendFormat: @"%d", numtracks];

if (numtracks)
{
totaltime = (([[[tracks objectAtIndex: numtracks-1] objectForKey: @"offset"] intValue]
+ [[[tracks objectAtIndex: numtracks-1] objectForKey: @"length"] intValue])/ CD_FPS)
- ([[[tracks objectAtIndex: 0] objectForKey: @"offset"] intValue] / CD_FPS);
}

while (i < numtracks)
{
cksum += cddb_sum([[[tracks objectAtIndex: i] objectForKey: @"offset"] intValue] / CD_FPS);
[string appendFormat: @" %d", [[[tracks objectAtIndex: i] objectForKey: @"offset"] intValue]];
i++;
}

[string appendFormat: @" %d", totaltime];

if (bool_ == YES) // Calculate locally
{
RELEASE(string);
RELEASE(tracks);
return [NSString stringWithFormat: @"%08lx", ((cksum % 0xff) << 24 | totaltime << 8 | numtracks)];
}
else // throught Freedb site
{
AUTORELEASE(string);
RELEASE(tracks);
return [self discid: string];
}
}

- (NSArray *) queryWithCDTracks: (NSArray *) tracks
{
NSString *discid = [self discidWithCDTracks: tracks locally: YES];
NSMutableString *string = [NSMutableString new];
int totaltime = 0, numtracks = 0, i = 0;

RETAIN(discid);
RETAIN(tracks);

numtracks = [tracks count];
[string appendFormat: @"%d", numtracks];

if (numtracks)
{
totaltime = (([[[tracks objectAtIndex: numtracks-1] objectForKey: @"offset"] intValue]
+ [[[tracks objectAtIndex: numtracks-1] objectForKey: @"length"] intValue])/ CD_FPS)
- ([[[tracks objectAtIndex: 0] objectForKey: @"offset"] intValue] / CD_FPS);
}

while (i < numtracks)
{
[string appendFormat: @" %d", [[[tracks objectAtIndex: i] objectForKey: @"offset"] intValue]];
i++;
}

[string appendFormat: @" %d", totaltime];
[string setString: [discid stringByAppendingFormat: @" %@", string]];

RELEASE(discid);
RELEASE(tracks);

AUTORELEASE(string);
return [self query: string];
}

- (NSDictionary *) readWithCategory: (NSString *) category
discid: (NSString *) discid
postProcess: (BOOL) bool_
{
if (bool_ == NO)
return [self read: [NSString stringWithFormat: @"%@ %@", category, discid]];
else
{
NSMutableDictionary *result = [NSMutableDictionary dictionaryWithDictionary: [self read: [NSString stringWithFormat: @"%@ %@", category, discid]]];

int i = 0, count = [[result objectForKey: @"titles"] count];
NSMutableArray *artistArray = [NSMutableArray new];
NSMutableArray *titleArray = [NSMutableArray new];
NSArray *albumField = [[result objectForKey: @"album"] componentsSeparatedByString: @" / "];
NSArray *titleField;

if ([albumField count] == 2) {
[result setObject: [albumField objectAtIndex: 1]
forKey: @"album"];
}

while (i < count)
{
titleField = [[[result objectForKey: @"titles"] objectAtIndex: i] componentsSeparatedByString: @" / "];
if ([titleField count] == 1) {
[titleArray addObject: [titleField objectAtIndex: 0]];
if ([albumField count] == 2) {
[artistArray addObject: [albumField objectAtIndex: 0]];
}
else {
[artistArray addObject: @""];
}
} else {
[artistArray addObject: [titleField objectAtIndex: 0]];
[titleArray addObject: [titleField objectAtIndex: 1]];
}
i++;
}
[result setObject: artistArray forKey: @"artists"];
[result setObject: titleArray forKey: @"titles"];

return result;
}
}

- (NSDictionary *) read: (NSString *) input
{
NSString *read;
int code;

read = [self request: [NSString stringWithFormat: @"cddb read %@\n", input]];
if (read == nil) return nil;
code = [[read substringToIndex: 3] intValue];
if (code == 210) {
int i;
NSScanner *scanner;
NSMutableDictionary *file = [NSMutableDictionary new];
NSString *scannerResult;
NSMutableArray *readArray = [NSMutableArray arrayWithArray: [read componentsSeparatedByString: @"\r\n"]];
NSMutableArray *titlesArray = [NSMutableArray new];
NSMutableArray *exttitlesArray = [NSMutableArray new];
NSString *line;

/* Remove extra lines */
[readArray removeObjectAtIndex: 0];
[readArray removeLastObject];
[readArray removeLastObject];
for(i = 0; i < [readArray count]; i++) {
scannerResult = nil;
line = [[readArray objectAtIndex: i] stringByTrimmingLeadSpaces];
if ([line characterAtIndex: 0] == (unichar)'#') {
/* Comment line */
continue;
}
scanner = [NSScanner scannerWithString: line];
if ([scanner scanString: @"DISCID" intoString: NULL]) {
[scanner scanUpToString: @"=" intoString: NULL];
[scanner setScanLocation: [scanner scanLocation] + 1];
[scanner scanUpToString: @"\r\n" intoString: &scannerResult];
SetObject(file, [scannerResult stringByTrimmingSpaces], @"discid");
/*
[file setObject: [scannerResult stringByTrimmingSpaces]
forKey: @"discid"];
*/
continue;
}
if ([scanner scanString: @"DTITLE" intoString: NULL]) {
[scanner scanUpToString: @"=" intoString: NULL];
[scanner setScanLocation: [scanner scanLocation] + 1];
[scanner scanUpToString: @"\r\n" intoString: &scannerResult];
if ([file objectForKey: @"album"] == nil) {
SetObject(file, [scannerResult stringByTrimmingSpaces], @"album");
/*
[file setObject: [scannerResult stringByTrimmingSpaces]
forKey: @"album"];
*/
} else {
SetObject(file,
[[file objectForKey: @"album"] stringByAppendingString: scannerResult],
@"album");
/*
[file setObject: [[file objectForKey: @"album"] stringByAppendingString: scannerResult]
forKey: @"album"];
*/
}
continue;
}
if ([scanner scanString: @"DYEAR" intoString: NULL]) {
[scanner scanUpToString: @"=" intoString: NULL];
[scanner setScanLocation: [scanner scanLocation] + 1];
[scanner scanUpToString: @"\r\n" intoString: &scannerResult];
SetObject(file, [scannerResult stringByTrimmingSpaces], @"year");
/*
[file setObject: [scannerResult stringByTrimmingSpaces]
forKey: @"year"];
*/
continue;
}
if ([scanner scanString: @"DGENRE" intoString: NULL]) {
[scanner scanUpToString: @"=" intoString: NULL];
[scanner setScanLocation: [scanner scanLocation] + 1];
[scanner scanUpToString: @"\r\n" intoString: &scannerResult];
SetObject(file, [scannerResult stringByTrimmingSpaces], @"genre");
/*
[file setObject: [scannerResult stringByTrimmingSpaces]
forKey: @"genre"];
*/
continue;
}
if ([scanner scanString: @"TTITLE" intoString: NULL]) {
int index;
[scanner scanUpToString: @"=" intoString: &scannerResult];
index = [[scannerResult stringByTrimmingSpaces] intValue];
[scanner setScanLocation: [scanner scanLocation] + 1];
[scanner scanUpToString: @"\r\n" intoString: &scannerResult];

if([titlesArray count] > index) {
/* FIXME: Never test this part */
/* append more data into this objectAtIndex: index */
NSString *temp;
temp = [titlesArray objectAtIndex: index];
[titlesArray replaceObjectAtIndex: index
withObject: [temp stringByAppendingString: scannerResult]];

} else {
[titlesArray addObject: [scannerResult stringByTrimmingSpaces]];
}
continue;
}
if ([scanner scanString: @"EXTD" intoString: NULL]) {
[scanner scanUpToString: @"=" intoString: NULL];
[scanner setScanLocation: [scanner scanLocation] + 1];
[scanner scanUpToString: @"\r\n" intoString: &scannerResult];
if ([file objectForKey: @"extdata"] == nil) {
SetObject(file, scannerResult, @"extdata");
/*
[file setObject: scannerResult
forKey: @"extdata"];
*/
} else {
SetObject(file,
[[file objectForKey: @"extdata"] stringByAppendingString: scannerResult],
@"extdata");
/*
[file setObject: [[file objectForKey: @"extdata"] stringByAppendingString: scannerResult]
forKey: @"extdata"];
*/
}
continue;
}
if ([scanner scanString: @"EXTT" intoString: NULL]) {
int index;
[scanner scanUpToString: @"=" intoString: &scannerResult];
index = [[scannerResult stringByTrimmingSpaces] intValue];
[scanner setScanLocation: [scanner scanLocation] + 1];

if ([scanner scanUpToString: @"\r\n" intoString: &scannerResult] == NO) {
continue;
}

if([exttitlesArray count] > index) {
/* FIXME: Never test this part */
/* append more data into this objectAtIndex: index */
NSString *temp;
temp = [exttitlesArray objectAtIndex: index];
[exttitlesArray replaceObjectAtIndex: index
withObject: [temp stringByAppendingString: scannerResult]];

} else {
[exttitlesArray addObject: [scannerResult stringByTrimmingSpaces]];
}
continue;
}
/* Ignore the PLAYORDER */
}
SetObject(file, titlesArray, @"titles");
SetObject(file, exttitlesArray, @"exttitles");
/*
[file setObject: titlesArray forKey: @"titles"];
[file setObject: exttitlesArray forKey: @"exttitles"];
*/
RELEASE(titlesArray);
RELEASE(exttitlesArray);
return AUTORELEASE(file);
} else {
/* 401 Specified CDDB entry not found
* 402 Server error.
* 403 Database entry is corrupt.
* 409 No handshake.
*/
NSLog(@"Can't read from FreeDB");
}
return nil;
}

- (NSArray *) query: (NSString *) input
{
NSMutableArray *array = [NSMutableArray new];
NSString *query;
int code;
NSMutableDictionary *dict;
NSScanner *scanner;
NSString *category;
NSString *discid;
NSString *description;

query = [self request: [NSString stringWithFormat: @"cddb query %@\n", input]];
if (query == nil) return AUTORELEASE(array);
code = [[query substringToIndex: 3] intValue];
if (code == 200) {
/* Found exact match */
dict = [NSMutableDictionary new];
scanner = [NSScanner scannerWithString: query];
[scanner scanUpToString: @" " intoString: NULL];
[scanner scanUpToString: @" " intoString: &category];
[scanner scanUpToString: @" " intoString: &discid];
description = [query substringFromIndex: [scanner scanLocation]];
description = [description stringByTrimmingSpaces];
[dict setObject: category forKey: @"category"];
[dict setObject: discid forKey: @"discid"];
[dict setObject: description forKey: @"description"];
[array addObject: dict];
RELEASE(dict);
} else if ((code == 211) | (code == 210)){
/* Found multiple matches */
int i;
NSMutableArray *queryArray = [NSMutableArray arrayWithArray: [query componentsSeparatedByString: @"\r\n"]];
/* Remove extra lines */
[queryArray removeObjectAtIndex: 0];
[queryArray removeLastObject];
[queryArray removeLastObject];
for(i = 0; i < [queryArray count]; i++) {
dict = [NSMutableDictionary new];
scanner = [NSScanner scannerWithString: [queryArray objectAtIndex: i]];
[scanner scanUpToString: @" " intoString: &category];
[scanner scanUpToString: @" " intoString: &discid];
description = [[queryArray objectAtIndex: i] substringFromIndex: [scanner scanLocation]];
description = [description stringByTrimmingSpaces];
[dict setObject: category forKey: @"category"];
[dict setObject: discid forKey: @"discid"];
[dict setObject: description forKey: @"description"];
[array addObject: dict];
RELEASE(dict);
}
} else if (code == 202) {
NSLog(@"No match found");
} else if (code == 403) {
NSLog(@"Database entry is corrupt");
} else if (code == 409) {
NSLog(@"No handshake");
}
return AUTORELEASE(array);
}

- (NSString *) discid: (NSString *) input
{
NSString *discid;
int code;

discid = [self request: [NSString stringWithFormat: @"discid %@\n", input]];
if (discid == nil) return nil;
code = [[discid substringToIndex: 3] intValue];
if (code == 200) {
NSScanner *scanner = [NSScanner scannerWithString: discid];
NSString *result;
[scanner scanUpToString: @"is " intoString: NULL];
[scanner scanUpToString: @"\r" intoString: &result];
return result; /* Already AUTORELEASEd by scanner */
} else if (code == 500) {
NSLog(@"Syntax error");
}
return nil;
}

- (NSArray *) category
{
int code;
NSMutableArray *array = nil;
NSString *lscat;

lscat = [self request: @"cddb lscat\n"];
if (lscat == nil)
return AUTORELEASE([NSArray new]);
code = [[lscat substringToIndex: 3] intValue];
if (code == 210) {
array = [NSMutableArray arrayWithArray: [lscat componentsSeparatedByString: @"\r\n"]];
[array removeObjectAtIndex: 0];
[array removeLastObject];
[array removeLastObject];
}
return array; /* Already AUTORELEASEd */
}

- (NSArray *) sites
{
NSString *sites;
NSMutableArray *array = [NSMutableArray new];
int code;
sites = [self request: @"sites\n"];
if (sites == nil) return AUTORELEASE(array);
code = [[sites substringToIndex: 3] intValue];
if (code == 210) {
/* Only handel level 1 */
NSScanner *scanner;
int i;
NSString *site;
NSString *protocol;
NSString *port;
NSString *address;
NSString *latitude;
NSString *longitude;
NSString *desc;
NSMutableArray *siteArray = [NSMutableArray arrayWithArray: [sites componentsSeparatedByString: @"\r\n"]];
/* Remove extra lines */
[siteArray removeObjectAtIndex: 0];
[siteArray removeLastObject];
[siteArray removeLastObject];
for(i = 0; i < [siteArray count]; i++) {
NSMutableDictionary *dict = [NSMutableDictionary new];
scanner = [NSScanner scannerWithString: [siteArray objectAtIndex: i]];
[scanner scanUpToString: @" " intoString: &site];
if (level > 2)
[scanner scanUpToString: @" " intoString: &protocol];
[scanner scanUpToString: @" " intoString: &port];
if (level > 2)
[scanner scanUpToString: @" " intoString: &address];
[scanner scanUpToString: @" " intoString: &latitude];
[scanner scanUpToString: @" " intoString: &longitude];
desc = [[siteArray objectAtIndex: i] substringFromIndex: [scanner scanLocation]];
[dict setObject: site forKey: @"site"];
[dict setObject: port forKey: @"port"];
[dict setObject: latitude forKey: @"latitude"];
[dict setObject: longitude forKey: @"longitude"];
[dict setObject: desc forKey: @"description"];
if (level > 2) {
[dict setObject: protocol forKey: @"protocol"];
[dict setObject: address forKey: @"address"];
}
[array addObject: dict];
RELEASE(dict);
}
} else if (code == 401) {
NSLog(@"No sites");
}

return AUTORELEASE(array);
}

- (NSString *) request: (NSString *) command
{
NSString *readin;
NSMutableString *final;
NSRange range;
unichar secondDigit;

if ([[[defaultSite scheme] lowercaseString] isEqualToString: @"http"]) {
int i;
NSArray *commandArray;
NSMutableString *newCommand = [[NSMutableString alloc] initWithString: @"cmd="];

if (fileHandler)
[self disconnect];
[self connect];

commandArray = [[command stringByTrimmingSpaces] componentsSeparatedByString: @" "];
[newCommand appendFormat: @"%@", [commandArray objectAtIndex: 0]];
for (i = 1; i < [commandArray count] ;i++) {
[newCommand appendFormat: @"+%@", [commandArray objectAtIndex: i]];
}
command = [NSString stringWithFormat: @"GET %@?%@&hello=%@+%@+%@.app+1.0&proto=%d\r\n",
[defaultSite path],
newCommand,
NSUserName(),
[[NSProcessInfo processInfo] hostName],
[[NSProcessInfo processInfo] processName],
level];
RELEASE(newCommand);
}

if (command) {
[fileHandler writeData:[command dataUsingEncoding: NSISOLatin1StringEncoding]];
}

final = [[NSMutableString alloc] initWithData: [fileHandler readDataOfLength: 3]
encoding: NSISOLatin1StringEncoding];

if ([final isEqualToString: @""])
{
RELEASE(final);
return nil;
}

secondDigit = [final characterAtIndex: 1];

/* For only one line (end with '\n') */
if ((secondDigit == (unichar)'0') || (secondDigit == (unichar)'3')) {
while(1) {
readin = [[NSString alloc] initWithData: [fileHandler availableData]
encoding: NSISOLatin1StringEncoding];
range = [readin rangeOfString: @"\r\n"];
[final appendString: readin];
RELEASE(readin);
if (range.location != NSNotFound) {
return AUTORELEASE(final);
}
sleep(2);
}
}
/* For multiple lines (end with '.') */
else if (secondDigit == (unichar)'1') {
while(1) {
readin = [[NSString alloc] initWithData: [fileHandler availableData]
encoding: NSISOLatin1StringEncoding];
[final appendString: readin];
range = [final rangeOfString: @"\r\n.\r"];
RELEASE(readin);
if (range.location != NSNotFound) {
return AUTORELEASE(final);
}
sleep(5);
}
return nil;
}
return nil;
}

- (id) init
{
self = [super init];
defaultSite = [NSURL URLWithString: @"cddbp://freedb.freedb.org:8880"];
fileHandler = nil;
level = 5;
return self;
}

- (void) dealloc
{
[super dealloc];
}

- (int) proto
{
return [self proto: 0];
}

- (int) proto: (int) number
{
NSString *proto;
NSScanner *scanner;
int code;

/* HTTP don't support proto */
if ([[[defaultSite scheme] lowercaseString] isEqualToString: @"http"])
return level;

if (number == 0)
proto = @"proto\n";
else
proto = [NSString stringWithFormat: @"proto %d\n", number];

proto = [self request: proto];
code = [[proto substringToIndex: 3] intValue];
scanner = [NSScanner scannerWithString: proto];
if (code == 200) {
[scanner scanUpToString: @"current" intoString: NULL];
[scanner scanUpToString: @" " intoString: NULL];
[scanner scanUpToString: @"," intoString: &proto];
level = [[proto stringByTrimmingSpaces] intValue];
return level;
} else if (code == 201) {
[scanner scanUpToString: @":" intoString: NULL];
[scanner scanUpToString: @" " intoString: NULL];
[scanner scanUpToString: @"\r\n" intoString: &proto];
level = [[proto stringByTrimmingSpaces] intValue];;
return level;
} else if (code == 501) {
/* Illegal protocol level, return current level */
return [self proto];
} else if (code == 502) {
/* The level doesn't change */
return number;
}
return 0;
}

- (BOOL) connect
{
fileHandler = [NSFileHandle fileHandleAsClientAtAddress: [defaultSite host]
service: [[defaultSite port] description]
protocol: @"tcp"];

if (fileHandler)
{
if ([[[defaultSite scheme] lowercaseString] isEqualToString: @"cddbp"])
{
NSString *signOn;
int code;

signOn = [self request: nil];
code = [[signOn substringToIndex: 3] intValue];
if ((code == 200) | (code == 201))
{
/* Try to set level 5 */
level = [self proto: 5];

/* Hand Shake */
signOn = [NSString stringWithFormat: @"cddb hello %@ %@ %@ %@\n",
NSUserName(),
[[NSProcessInfo processInfo] hostName],
[[NSProcessInfo processInfo] processName],
@"0.2"];

signOn = [self request: signOn];
code = [[signOn substringToIndex: 3] intValue];
if ((code == 200) | (code == 402))
{
return YES;
} else if (code == 431) {
NSLog(@"Hand Shake failed");
return NO;
}
}
}
else if ([[[defaultSite scheme] lowercaseString] isEqualToString: @"http"])
{
return YES;
}
}
/* Don't support protocol other than cddb and http */
return NO;
}

- (void) disconnect
{
if (fileHandler)
if ([[[defaultSite scheme] lowercaseString] isEqualToString: @"cddbp"])
{
[self request: @"quit\n"];
}
[fileHandler closeFile];
fileHandler = nil;
}

- (NSString *) version
{
return [self request: @"ver\n"];
}

- (void) setDefaultSite: (NSString *) site
{
/* Do a simple test */
if ([[site stringByTrimmingSpaces] isEqualToString: @""])
defaultSite = [NSURL URLWithString: @"cddbp://freedb.freedb.org:8880"];
else
defaultSite = [NSURL URLWithString: site];
}

- (NSString *) defaultSite
{
return [defaultSite absoluteString];
}

@end
gnustep-cddb.bundle-0.2/Cddb/GNUmakefile000064400000000000000000000007711227727001500201160ustar00rootroot00000000000000include $(GNUSTEP_MAKEFILES)/common.make

BUNDLE_NAME = Cddb
BUNDLE_EXTENSION = .bundle

BUNDLE_INSTALL_DIR = $(GNUSTEP_INSTALLATION_DIR)/Bundles

Cddb_RESOURCE_FILES =

Cddb_OBJC_FILES = Cddb.m

Cddb_HEADERS = Cddb.h

Cddb_PRINCIPAL_CLASS = Cddb

Cddb_HEADER_FILES = Cddb.h
Cddb_HEADER_FILES_DIR = .
Cddb_HEADER_FILES_INSTALL_DIR = Cddb

ADDITIONAL_OBJCFLAGS = -Wall

ADDITIONAL_INCLUDE_DIRS += -I..

-include GNUmakefile.preable

include $(GNUSTEP_MAKEFILES)/bundle.make

-include GNUmakefile.postamble
gnustep-cddb.bundle-0.2/CddbTest/000075500000000000000000000000001227727001500166775ustar00rootroot00000000000000gnustep-cddb.bundle-0.2/CddbTest/GNUmakefile000064400000000000000000000026561227727001500207620ustar00rootroot00000000000000#
# GNUmakefile for CddbTest.app
# Copyright (C) 2002
#
# Author: Yen-Ju Chen <yjchenx@yahoo.com.tw>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software


include $(GNUSTEP_MAKEFILES)/common.make

# Subprojects
SUBPROJECTS =

# The application to be compiled
APP_NAME = CddbTest

CddbTest_APPLICATION_ICON =

# The Resource files to be copied into the app's resources directory
CddbTest_RESOURCE_FILES =

# The Objective-C source files to be compiled
CddbTest_OBJC_FILES = main.m

CddbTest_HEADERS =

# The C source files to be compiled
CddbTest_C_FILES =

CddbTest_LIB_DIRS =

CddbTest_GUI_LIBS =

CddbTest_LANGUAGES =

CddbTest_LOCALIZED_RESOURCE_FILES =

ADDITIONAL_INCLUDE_DIRS += -I..

-include GNUmakefile.preable

include $(GNUSTEP_MAKEFILES)/aggregate.make
include $(GNUSTEP_MAKEFILES)/application.make

-include GNUmakefile.postamble

gnustep-cddb.bundle-0.2/CddbTest/main.m000064400000000000000000000072621227727001500200100ustar00rootroot00000000000000/*
** main.m for CddbTest.app
**
** Copyright (c) 2002
**
** Author: Yen-Ju <yjchenx@yahoo.com.tw>
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#import <AppKit/AppKit.h>
#import <Cddb/Cddb.h>

int main(int argc, const char **argv)
{
NSAutoreleasePool *pool;
Cddb *cddb;
id result;
Class bundleClass;
NSBundle *bundle;
NSString *bundlePath;
NSWindow *window;

pool = [NSAutoreleasePool new];

bundlePath = [NSString stringWithFormat: @"%@/Bundles/Cddb.bundle",
[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSLocalDomainMask,
YES)
objectAtIndex:0] ];
bundle = [NSBundle bundleWithPath: bundlePath];
if (bundle)
{
bundleClass = [bundle principalClass];
if (bundleClass)
{
cddb = [bundleClass new];
}
else
{
NSLog(@"Failed to get Class from Cddb.bundle");
return 0;
}
}
else
{
NSLog(@"Failed to get Cddb.bundle");
return 0;
}


// [cddb setDefaultSite: @"http://www.freedb.org:80/~cddb/cddb.cgi"];

if([cddb connect]) {
int i;
id object;

NSLog(@"site: %@", [cddb defaultSite]);

NSLog(@"FreeDB version:%@", [cddb version]);

/*
object = [cddb sites];
for(i = 0; i < [object count]; i++) {
NSLog(@"%@ %@ %@ %@ at %@",
[[object objectAtIndex: i] objectForKey: @"site"],
[[object objectAtIndex: i] objectForKey: @"protocol"],
[[object objectAtIndex: i] objectForKey: @"port"],
[[object objectAtIndex: i] objectForKey: @"address"],
[[object objectAtIndex: i] objectForKey: @"description"]);
}
*/
/*
NSLog(@"Disc ID is %@", [cddb discid: @"3 150 202227 326942 4721"]);
NSLog(@"Category:\n%@", [cddb category]);
NSLog(@"Current level %d", [cddb proto]);
*/
// NSLog(@"Set level to %d", [cddb proto: 5]);
/* Multiple exact match */
NSLog(@"Query:\n%@", [cddb query: @"e011c210 16 182 10797 16160 24297 31017 40187 58922 96737 119315 176925 204105 216385 227215 258642 291035 305657 4548"]);

/* Not exact match */
// NSLog(@"Query:\n%@", [cddb query: @"cf0a19qe 14 150 17677 29912 44045 57455 73122 96812 108380 119995 132665 143302 155250 166757 176672 2587"]);

/* Multiple EXTD line */
// NSLog(@"Read:\n%@", [cddb read: @"classical e011c210"]);

/* Single EXTD line */
// NSLog(@"READ:\n%@", [cddb read: @"jazz 2e126f03"]);

// NSLog(@"Query:\n%@", [cddb query: @"fe0fa612 18 183 13008 32408 44795 59858 75495 85045 101845 119808 134033 156533 174108 189120 220670 241295 250670 266295 289158 4008"]);

// NSLog(@"Read:\n%@", [cddb read: @"classical fe0fa612"]);

[cddb disconnect];
}

NSLog(@"FreeDB disconnected");
RELEASE(cddb);
NSLog(@"FreeDB released");
RELEASE(pool);
return 0;
}

gnustep-cddb.bundle-0.2/GNUmakefile000064400000000000000000000016461227727001500172640ustar00rootroot00000000000000#
# GNUmakefile for Cddb
# Copyright (C) 2002
#
# Author: Yen-Ju Chen <yjchenx@yahoo.com.tw>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software


include $(GNUSTEP_MAKEFILES)/common.make

# Subprojects
SUBPROJECTS = Cddb

-include GNUmakefile.preamble

include $(GNUSTEP_MAKEFILES)/aggregate.make

-include GNUmakefile.postamble

gnustep-cddb.bundle-0.2/README000064400000000000000000000037401227727001500160670ustar00rootroot00000000000000Cddb - A GNUstep cddb bundle
-------------------------------------
This is a GNUstep bundle for cddb access
It contains:
Cddb/ as cddb bundle,
CddbTest/ as the command-line application for test

Cddb/ will install the header of cddb bundle.
Therefore, use #include <Cddb/Cddb.h> in your source code.
Cddb bundle offers high-level and low-level methods.
Read TUTORIAL and CddbTest/ as examples

Low-level method corresponds to the cddbp protocol.
Read the cddbp protocol for more details

High-level method use a NSArray of NSDictionary as input.
The keys of NSDictionary are "length" and "offset" of each CD track in frames.
The object of NSDictionary can be NSString or NSNumber (has intValue method).
The number of objects in NSArray are the number of CD tracks.

The return value of read: is a NSDictionary depending on the postProcess.
If postProcess: NO, the return value corresponds to the cddb format.
The class of objects and keys of return NSDictionary (postProcess: NO) are:
NSString, "discid"
NSString, "album"
NSString, "year" (level 4 or up)
NSString, "genre" (level 4 or up)
NSArray, "titles" (title of each track)
NSString, "extdata" (extra data about this album)
NSArray, "exttitles" (extratitle of each track)

Becuase the cddb format doesn't have an artist field,
So the artist is either in album or titles fields.
Use postProcess: YES to process the cddb format
and give out the artist field.
The class of objects and Keys of return NSDictionary (postProcess: YES) are:
NSString, "discid"
NSString, "album"
NSString, "year"
NSString, "genre"
NSArray, "artists" <= This is new
NSArray, "titles"
NSString, 'extdata"
NSArray, "exttitles"

The return of query: is an NSArray of NSDictionary.
The keys of NSDictionary are "category", "discid", "description".

Right now, Cddb.bundle uses block I/O.
Beware it will block your applcation when accessing cddb server.

Install
-------
`make install` should work.

License
-------
GNU General Public License

Author
------
Yen-Ju Chen <yjchenx@hotmail.com>
gnustep-cddb.bundle-0.2/TUTORIAL000064400000000000000000000101011227727001500163620ustar00rootroot00000000000000TUTORIAL for cddb bundle.
-------------------------

1. Set up a cddb instance.

Load the bundle, instanize it using general methods: alloc and init.
By default, it will use cddbp://freedb.freedb.org:8880.
If you are in the firewall, you might want to change it.

2. Set up the cddb server.

cddb bundle doesn't read/write any user defaults.
Use these two methods to access the cddb server.
- (void) setDefaultSite: (NSString *) site;
- (NSString *) defaultSite;
Be sure the use standard URL in NSString.
This NSString will be read into NSURL.
Applications are responsible for store their own server information.

3. Connect to cddb server.

Always use

if ([cddbInstance connect])
{
...
[cddbInstance disconnect];
}

even you are using http protocol to access cddb server.

4. Get the mirror server.

After you connect to the cddb server, you can get a list of mirrors servers.

NSArray *sites = [cddbInstance sites];

The return value is an NSArray of NSDictionary.
The keys of NSDictionary are "site", "port", "latitude",
"longitude", "description", "protocol" and "address".
"protocol" and "address" are supported only for level 2 and up.
(The default level is 5).

In order to build a standard NSString for NSURL from this information,
you can use this format:
If protocol is "http":
@"%@://%@:%@%@", protocol, site, port, address
If protocol is "cddbp":
@"%@://%@:%@", protocol, site, port

5. Calculate discid.

You can get the discid directly from CD information.
First, you have to fill an NSArray of NSDictionary.
Each CD track has length and offset in frames.
Fill the NSDictionary with @"length" and @"offset" as keys.
The objects should have intValue method (NSString or NSNumber).
Fill the NSArray with these NSDictionary for each track.
The number of objects in this NSArray is the number of tracks.

Use [cddbInstance discidWithCDTracks: tracks
locally: YES];
to get the discid in NSString.
locally: YES will calculate discid locally in cddb bundle,
Therefore, you don't need to connect to cddb server.
locally: NO will ask the cddb server to calculate discid for you,
which is only useful for debug of discid algorithm.

6. Get the category of CD.

You need the category information in order to get the cddb entry.
Use the same CD information above and this method:

[cddbInstance queryWithCDTracks: tracks];

Sometimes you will have multiple matches.
Therefore, the return value is an NSArray of NSDictionary.
Each object of NSArray is a match.
The keys of each match are "category", "discid", "description".
The objects are NSString.
Use the "category" and "discid" to get the cddb entry later.

7. Get the entry of CD.

Once you know the category and discid of the CD,
you can use

[cddbInstance readWithCategory: category
discid: discid
postProcess: YES];

to get the CD information.

If postProcess: NO, the return value is a NSDictionary corresponding
to the cddb format.
The class of objects and keys are:
NSString, "discid"
NSString, "album"
NSString, "year" (level 4 or up)
NSString, "genre" (level 4 or up)
NSArray, "titles" (title of each track)
NSString, "extdata" (extra data about this album)
NSArray, "exttitles" (extratitle of each track)

Becuase the cddb format doesn't have an artist field,
So the artist is either in album or titles fields.
Use postProcess: YES to process the cddb format
and give out the artist field and clean album/titles field.
The class of objects and keys are:
NSString, "discid"
NSString, "album"
NSString, "year"
NSString, "genre"
NSArray, "artists" <= This is new
NSArray, "titles"
NSString, 'extdata"
NSArray, "exttitles"

8. How do I know it fails ?

If the cddb bundle fails (no connection, no match, etc.),
for return value is NSString or NSDictionary, it will return nil;
for return value is NSArray, it will retun an emtpy NSArray (not nil).
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin