Skip to content

Commit

Permalink
Added
Browse files Browse the repository at this point in the history
  • Loading branch information
craigk5n committed Aug 1, 2004
1 parent 2cd6ab9 commit 444851d
Show file tree
Hide file tree
Showing 19 changed files with 1,545 additions and 0 deletions.
48 changes: 48 additions & 0 deletions java/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# WebCalendar java Makefile
# $Id#
#

JCC = javac
JAR = jar
JAVADOC = javadoc

PACKAGEDIR = us/k5n/webcalendar

.SUFFIXES: .java .class

.java.class:
$(JCC) -classpath . $*.java

# START CLASSLIST
CLASSLIST = \
$(PACKAGEDIR)/Event.class $(PACKAGEDIR)/EventDisplayer.class $(PACKAGEDIR)/EventList.class $(PACKAGEDIR)/EventLoader.class $(PACKAGEDIR)/Login.class $(PACKAGEDIR)/LoginSession.class $(PACKAGEDIR)/MessageDisplayer.class $(PACKAGEDIR)/Reminder.class $(PACKAGEDIR)/ReminderDisplayer.class $(PACKAGEDIR)/ReminderList.class $(PACKAGEDIR)/ReminderLoader.class $(PACKAGEDIR)/ShowReminder.class $(PACKAGEDIR)/ui/ReminderApp.class $(PACKAGEDIR)/ui/SampleApp.class $(PACKAGEDIR)/Utils.class $(PACKAGEDIR)/WebCalendarClient.class $(PACKAGEDIR)/WebCalendarErrorException.class $(PACKAGEDIR)/WebCalendarParseException.class
# END CLASSLIST

all: webcalendar.jar

webcalendar.jar: $(CLASSLIST) manifest-mod
$(JAR) cmf manifest-mod webcalendar.jar \
us/k5n/webcalendar/*class us/k5n/webcalendar/ui/*class

clean:
rm -f $(CLASSLIST) webcalendar.jar

update:
@echo "Updating makefile"; \
sed -n '1,/^# START CLASSLIST/ p' Makefile > Makefile.new; \
echo "CLASSLIST = " | tr -d '\012\015' >> Makefile.new; \
make classlist >> Makefile.new; \
sed -n '/^# END CLASSLIST/,$$ p' Makefile >> Makefile.new; \
mv Makefile Makefile.old; \
mv Makefile.new Makefile


classlist:
@find $(PACKAGEDIR) -name "*.java" -print | \
sed 's?$(PACKAGEDIR)?$$(PACKAGEDIR)?g' | \
sed 's;\.java;.class;g' | tr '\012\015' ' '; \
echo ""


doc:
$(JAVADOC) -d api us.k5n.webcalendar us.k5n.webcalendar.ui
86 changes: 86 additions & 0 deletions java/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
WebCalendar Web Services - version 0.1
------------------------------------------------------------------------------

What this package contains:
- Propietary Web Services written in PHP (that are not SOAP or
XML-RPC)
+ login.php
+ get_reminders.php
+ get_events.php
+ more to come soon... ?
- A Java library for accessing WebCalendar functions via a proprietary
Web Services API. You can use this library to access WebCalendar
functions from within any Java application (including a servlet
or JSP)
- The javadoc API for using the library
- Swing-based applications:
+ SampleApp: displays events (read-only) for a week or day, allows user to
navigate next/previous.
+ ReminderApp: displays reminders in a popup at the appropriate time
+ more to come soon.... ?

Java 1.4 is required since the org.w3c.dom package is used to parse
XML (which is new in Java 1.4).

The XML that is returned from the WebCalendar server is not SOAP.
It is just XML. This may change in the future if additional functions are
added. Until then SOAP is probably overkill and would require users to install
additional software (like the PEAR SOAP module) on their WebCalendar
server.


------------------------------------------------------------------------------
NOTES ON THE SAMPLE APP

SampleApp is intended to illustrate how to develop a WebCalendar client.
The app could be modified with a much improved UI.

This application may evolve into more than just a sample, I'm on the lookout
for an existing java-based calendar app where I could just replace/extend
the methods that get/update event data. No need to rewrite a
complete UI if there is one out there already.


------------------------------------------------------------------------------
NOTES ON THE REMINDER APP

This ReminderApp client works independently from the email reminders that the
WebCalendar server sends out. If you wish to use this instead of
the email reminders, you can turn off them in your WebCalendar
preferences. If you do, be aware that you may miss a reminder if
this app is not running.

------------------------------------------------------------------------------
INSTALLATION

The .php files whould be installed in a "ws" subdirectory of your
main WebCalendar directory on the server.

Users should install the webcalendar.jar file locally and run it as
follows (for the ReminderApp, for SampleApp, just replace "ReminderApp"
with "SampleApp"):

[for web-based authentication]
java -classpath webcalendar.jar com.cknudsen.webcalendar.ui.ReminderApp \
-url=http://yourwebcalurlhere/ \
-user=UUU -password=PPP
[where "UUU" is the your username and "PPP" is your password]

[for http-based authentication]
java -classpath webcalendar.jar com.cknudsen.webcalendar.ReminderApp \
-url=http://yourwebcalurlhere/ \
-httpuser=UUU -httppasswd=PPP
[where "UUU" is the your username and "PPP" is your password]

Note that you can use both web-based and HTTP-based authentication if
your site is configured to do that. (The WebCalendar username will be
based on the -user argument.)

------------------------------------------------------------------------------
LICENSE

The license for this code is the same GPL license used by WebCalendar.

------------------------------------------------------------------------------
Craig Knudsen
[email protected]
1 change: 1 addition & 0 deletions java/manifest-mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main-Class: us.k5n.webcalendar.ui.SampleApp
170 changes: 170 additions & 0 deletions java/us/k5n/webcalendar/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* $Id$
*
* Description:
* Event object
*
*/

package us.k5n.webcalendar;

import java.util.Vector;
import java.util.Calendar;
import java.io.IOException;

// JAXP
import javax.xml.parsers.*;
// SAX
import org.xml.sax.*;
// DOM
import org.w3c.dom.*;

class siteExtra {
public int number;
public String name;
public String description;
public int type;
public String value;
}

public class Event {
/** Unique event id */
public String id = null;
/** Name of event */
public String name = null;
/** Full description of event */
public String description = null;
/** URL to view event in a browser */
public String url = null;
/** Date formatted to view in local timezone */
String dateFormatted = null;
/** Time formatted to view in local timezone */
String timeFormatted = null;
/** Date in YYYYMMDD format in server timezone */
String date = null;
/** Date as Calendar object */
Calendar dateCalendar;
/** Time in HHMM format in server timezone */
String time = null;
/** Duration of event (in minutes) */
String duration = null;
/** Priority of event */
String priority = null;
/** Access to event */
String access = null;
/** Username of creator of event */
String createdBy = null;
/** Date event was last updated */
String updateDate = null;
/** Time event was last updated */
String updateTime = null;
/** Vector of SiteExtra objects */
Vector siteExtras = null;

/**
* Construct the reminder from the specified XML DOM node
* (which corresponds to the <reminder> tag).
*/
public Event ( Node eventNode ) throws WebCalendarParseException
{
NodeList list = eventNode.getChildNodes ();
int len = list.getLength ();

for ( int i = 0; i < len; i++ ) {
Node n = list.item ( i );

if ( n.getNodeType() == Node.ELEMENT_NODE ) {
String nodeName = n.getNodeName ();
if ( "name".equals ( nodeName ) ) {
name = Utils.xmlNodeGetValue ( n );
} else if ( "id".equals ( nodeName ) ) {
id = Utils.xmlNodeGetValue ( n );
} else if ( "description".equals ( nodeName ) ) {
description = Utils.xmlNodeGetValue ( n );
} else if ( "url".equals ( nodeName ) ) {
url = Utils.xmlNodeGetValue ( n );
} else if ( "dateFormatted".equals ( nodeName ) ) {
dateFormatted = Utils.xmlNodeGetValue ( n );
} else if ( "date".equals ( nodeName ) ) {
date = Utils.xmlNodeGetValue ( n );
dateCalendar = Utils.YYYYMMDDToCalendar ( date );
} else if ( "time".equals ( nodeName ) ) {
time = Utils.xmlNodeGetValue ( n );
} else if ( "timeFormatted".equals ( nodeName ) ) {
timeFormatted = Utils.xmlNodeGetValue ( n );
} else if ( "duration".equals ( nodeName ) ) {
duration = Utils.xmlNodeGetValue ( n );
} else if ( "priority".equals ( nodeName ) ) {
priority = Utils.xmlNodeGetValue ( n );
} else if ( "access".equals ( nodeName ) ) {
access = Utils.xmlNodeGetValue ( n );
} else if ( "createdBy".equals ( nodeName ) ) {
createdBy = Utils.xmlNodeGetValue ( n );
} else if ( "updateDate".equals ( nodeName ) ) {
updateDate = Utils.xmlNodeGetValue ( n );
} else if ( "updateTime".equals ( nodeName ) ) {
updateTime = Utils.xmlNodeGetValue ( n );
} else if ( "siteExtras".equals ( nodeName ) ) {
// NOT YET IMPLEMENTED
} else if ( "participants".equals ( nodeName ) ) {
// NOT YET IMPLEMENTED
} else {
System.err.println ( "Not sure what to do with <" + nodeName +
"> tag (ignoring)" );
}
}
}
}

/**
* Does the event's date match the specified date?
*/
public boolean dateMatches ( Calendar c )
{
if ( dateCalendar == null )
return false;
if ( dateCalendar.get ( Calendar.DAY_OF_MONTH ) !=
c.get ( Calendar.DAY_OF_MONTH ) )
return false;
if ( dateCalendar.get ( Calendar.MONTH ) !=
c.get ( Calendar.MONTH ) )
return false;
if ( dateCalendar.get ( Calendar.YEAR ) !=
c.get ( Calendar.YEAR ) )
return false;
return true;
}


/**
* Create a multiline String representation of this event.
* This will include the event name, date and time.
*/
public String toString()
{
StringBuffer sb = new StringBuffer ( 100 );
if ( name != null ) {
sb.append ( name );
sb.append ( "\n" );
}
if ( description != null &&
( name == null || ! name.equals ( description ) ) ) {
sb.append ( "Description: " );
sb.append ( description );
sb.append ( "\n" );
}
if ( dateFormatted != null ) {
sb.append ( "Date: " );
sb.append ( dateFormatted );
sb.append ( "\n" );
}
if ( timeFormatted != null ) {
sb.append ( "Time: " );
sb.append ( timeFormatted );
sb.append ( "\n" );
}
return sb.toString();
}

}

16 changes: 16 additions & 0 deletions java/us/k5n/webcalendar/EventDisplayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* $Id$
*/

package us.k5n.webcalendar;

/**
* Defines the API for receiving an event list once it is
* returned from the server.
*/
public interface EventDisplayer {

public void storeEvents ( EventList events );

}

Loading

0 comments on commit 444851d

Please sign in to comment.