I was able to glean a lot of information from the printexample project in the SDK and I would recommend anyone looking for printer information to look there first for a good look at implementation. It still seems that you are able to pass the PrintService a text input stream or formatted html and it will work just fine. I still don't see any thorough documentation on what different ways the InputStream can be formatted.
The PrintService must register as a component of the bundle and must be registered in the bundle.permissions file as well. As I have implemented it thus far, the main Profile (GoudaProfile) has a callback function that sets the PrintService member variable when it becomes available and sets it to null if it is not available. From there the GoudaProfile constructs a MeetingPrinter object by passing the PrintService member variable to the MeetingPrinter Constructor.
Gavin took care of the Google API's and he created the main data class which is Meeting.java. He used the builder pattern but the way he implemented it, each builder can only build a single object so if you want multiple objects you must create multiple builders.
Meeting.Builder expects a certain date-time format for it's argument which is based off an ISO standard but a simple example of something I used to mock a Meeting object was 2013-10-30T14:00:00-05:00
Today Gavin and Daniel will be coming over here to work on the project further and we will soon be moving the printer back to Marksbury so that we can all VLC into it.
Here is the test code i usedc to mock meeting objects and send them to the MeetingPrinter
//Create a new meeting object
Meeting.Builder builder = new Builder(DateTimeZone.UTC, false);
builder.host("Batman", "b@tman.com");
builder.name("Deep voice lessons");
builder.startDatetime("2013-10-30T10:00:00-05:00");
builder.endDatetime("2013-10-30T11:00:00-05:00");
Meeting meeting = builder.build();
Meeting.Builder builder2 = new Builder(DateTimeZone.UTC, false);
builder2.host("Batman", "b@tman.com");
builder2.name("Play COD with Robin");
builder2.startDatetime("2013-10-30T13:00:00-05:00");
builder2.endDatetime("2013-10-30T14:00:00-05:00");
Meeting meeting2 = builder2.build();
if(printService != null) {
MeetingPrinter meetingPrinter = new MeetingPrinter(printService);
meetingPrinter.print(new Meeting[]{meeting, meeting2});
}
Sunday, October 20, 2013
Thursday, October 17, 2013
Working with the printing APIs
So on the high level I have learned that all things are packaged into things called bundles, these bundles are managed by the OSGi framework. Each bundle has an activator that is run when the bundle is being prepared for use. When the bundles activator has completed the framework gives control to dependent bundles callback that is listening for the activation to be complete. Bundles must declare their dependencies explicitly in their manifest and must also say the cardinality of the dependency.
The Print Service API is really simple though it is not well documented. I gained most of my knowledge by looking at the example app in the sdk which showed that it was possible to print from a url by getting a handle to an inputStream object that contains the html of the webpage. I took this concept further and constructed a string and from that a String into an InputStream via the following code:
// convert String into InputStream
inputStream = new ByteArrayInputStream(str.getBytes());
The Print Service API is really simple though it is not well documented. I gained most of my knowledge by looking at the example app in the sdk which showed that it was possible to print from a url by getting a handle to an inputStream object that contains the html of the webpage. I took this concept further and constructed a string and from that a String into an InputStream via the following code:
// convert String into InputStream
inputStream = new ByteArrayInputStream(str.getBytes());
Sunday, October 6, 2013
Setting up Development Environment
Setting up a new development environment is usually a tricky endeavour so I am going to go through the steps here to show how I got the environment up and running.
First off I set up a new user on my Ubuntu machine as the environment is calling for a few unique environment variables to be set and I don't want it to interfere with my main user on my machine.
The Lexmark SDK called for the Java Development Kit version 1.4.2 so I downloaded that after setting up an account with Oracle. And after 2 hours of trying to install the jdk on linux it's a no go. Something about the tail command not being recognized. Whatever I'll develop on Windows.
So I downloaded the LES-SDK zip file that lexmark provided and extracted it's contents to a local directory within my home directory. I downloaded the 1.4.2 JDK from the oracle website and set the java home environment variable. I downloaded the latest version of Eclipse from eclipse.org and extracted that zip file to my home directory.
Inside the SDK zip file you find a file called index.html which goes step by step on how to install eclipse, ant, the java jdk, and how to set up environment variables and get the eclipse plugin working. I won't repeat the steps here as they are already well laid out in the document there.
First off I set up a new user on my Ubuntu machine as the environment is calling for a few unique environment variables to be set and I don't want it to interfere with my main user on my machine.
The Lexmark SDK called for the Java Development Kit version 1.4.2 so I downloaded that after setting up an account with Oracle. And after 2 hours of trying to install the jdk on linux it's a no go. Something about the tail command not being recognized. Whatever I'll develop on Windows.
So I downloaded the LES-SDK zip file that lexmark provided and extracted it's contents to a local directory within my home directory. I downloaded the 1.4.2 JDK from the oracle website and set the java home environment variable. I downloaded the latest version of Eclipse from eclipse.org and extracted that zip file to my home directory.
Inside the SDK zip file you find a file called index.html which goes step by step on how to install eclipse, ant, the java jdk, and how to set up environment variables and get the eclipse plugin working. I won't repeat the steps here as they are already well laid out in the document there.
Subscribe to:
Posts (Atom)