Jenerate Company Blog

November 6th, 2008

Introducing Jenerate Solutions

Posted by dermdaly in Uncategorized

We’ve always had two sides to Jenerate.  There’s our web design, graphic design, hosting, SEO, Online Marketing and so on, and there’s our Software Development, Consulting and general solutions business (including our Workflow Intelligence product).

Traditionally, our jenerate.com website has mainly focused on our “web” business, and had little information on our “solutions” business.  This is confusing for someone who are wondering about our solutions business, only to be presented with lots of information about web design.

So…to correct this, we’ve launched a website dedicated to Jenerate Solutions.  We even came up with a great name for it! Hop over to Jenerate Solutions to find out all about how we can provide software solutions to your business problems.

October 10th, 2008

Sony Ericsson HCB 700 and iPhone Sync Issues

Posted by dermdaly in Uncategorized

The Sony Ericsson HCB 700 is a pretty nifty hands free car kit.  It supports voice commands, is really easy to use and works great with most bluetooth phones that I’ve tried it with.

 

Except of course the iPhone.  It works well as a general hands free kit with the phone, but it refuses to sync with the iPhone address book, so you can use its scroll wheel to find contacts to call.  This certainly reduces its usefulness.

I guess I put this one down to the iPhone and have accepted this for some time - The iPhone does seem to have a pretty crippled bluetooth stack, however the other day I was using the company Discovery, which has a Parrot handsfree kit.  Guess what?  It paired in seconds, and sync’d the address book with no problems whatsoever.  So….I’m thinking that perhaps the Sony Ericsson kit is at fault here.

I’ve googled to no avail for suggestion, and then I wondered if it has a firmware upgrade.  Nobody seems to know if there is a software upgrade.  In fact, I called Sony Ericsson tech support who claim that they only test their car kits with their own phones (Shyeah…right - They list a ton of Nokia’s on their site that it is tested against), and said that they’ve not heard of anyone getting it to work with the iPhone.

 

Grrrrrrrr.

July 2nd, 2008

And while I’m on the subject of the iPhone

Posted by dermdaly in Uncategorized

Why oh why can’t they do something more intelligent with caller id matching?  I have tons of people in my address book beginning 086… or 087…, but when a call or text comes in, it has its full international format (i.e. +35386…).  The iPhone software is not intelligent enough to match them up.  So…I have to find which contact it is in, and add their international fomat phone number to them so that next time the text or call, I’ll know who it is.

Apple: If you are listening.  Here’s how Nokia do it: They basically use the number in reverse.  They look for the entry in the contacts with the most matching numbers (also in reverse).  They show this one.  Easy eh?

June 27th, 2008

Is the iPhone all it is cracked up to be?

Posted by dermdaly in Uncategorized

Well, I’ve had the iPhone for a couple of months.  In the majority of uses it is better than anything out there.  Here’s where I think it is particularly good

  1. Its browser is the best mobile browser on the planet bar none.  Even without flash, it is a superb browsing device.  Its zoom in capabilities and auto rotate are very slick, and show anyone a demo in 2 seconds, and they’ve got the hang of the interface. It jumps on to my home and work WiFi so browsing is free.  I also hear that I’ll soon be able to use every bitbuzz hotspot in the country for free using my iphone.
  2. Actually, the interface in general - the whole multi touch interface is the most intuitive I’ve ever used; In fact I saw my 5 year old pick up my wife’s Sony-Ericsson and was confused by the fact he couldn’t zoom into the wallpaper with a pinch movement.
  3. The SMS interface is superb.  Showing SMS as a conversation just works.  Pity my 18 year old niece who makes 500 texts per day can’t afford an iPhone.
  4. Syncing with my MacBook - I’ve all my mail accounts, contacts, etc.   iTunes just does it right.
  5. The funky apps made just for iPhone - I do actually use the weather app, the google maps, etc.
  6. Its a cool portable video device.  Worked a treat on a recent trip to Chengdu (I ripped “Team America” onto the phone and watched it on the plane).
But
Its not without its flaws.  They’ve been mentioned on other sites, but here’s what I find worst about it.
  1. A lot of people complain of echo on the line.  If there is anything close to the mic, it causes serious echo.  After a bit of research I found that this is reasonably common.  Apparently it affects left-handers worse than right-handers (and I’m left handed).  The answer is to keep your pinky off the mic when using the phone and it seems to solve it.  
  2. The iPhone is the worst phone for the car I’ve had to date (that’s 4 Nokias and a Sony-Ericsson later).  Why is it rubbish in the car?
    1. It doesn’t support voice dialling, so I can’t click a button on the car and say a name.  Didn’t Nokia have that about 6 years back?
    2. Its bluetooth is purposely clobbered so it supports a remote mic and speaker only.  So…my sony ericcson car kit, that can sync address books with other phones can’t be used here.  Again, I can’t use the kit’s handy wheel for finding someone to call.
    3. Because of the aforementioned echo, I have to put it into the cup holder (or wherever I keep it) upside down.  That’s just silly.
This means that to make a call when in the car, I need to pick up the phone.  Where I live, that is illegal.  And rightly so.
 It is dangerous to pick up your phone when driving.  The only option would be to dash mount a holder for the iPhone so at least I could pick a user from the contacts, but surely voice dialling is far safer?
I have heard of  a 3rd party application for voice dialling, but I’d need to jailbreak the phone, or wait for version 2.0 of the firmware.  But, this is something that should be integrated into the phone (so that it works with car kits, etc.).  I wonder will the version 2.0 phone next month improve any of these?  I’ve looked through the spec and noting has caught my eye.
So..the Apple iPhone.  The best personal internet device on the planet.  Not so hot as a phone mind you.  Sucker that I am, I still want the 3G one.  That’s Apple for ya.
June 9th, 2008

Calling legacy Libraries from a .NET Web Service

Posted by dermdaly in Programming

In one of Jenerate’s recent projects, I had to work out how we would call some static libraries from a .NET web service.

There’s a number of hoops to jump through.  Once they are done, it works well, but it took a bit of digging and learning.  Hopefully this post will help others who have to do the same.

Firstly a bit of background.  The project involved integrating to nCipher’s pretty impressive hardware security module.  NCipher offer a number of ways of integrating into this including Java libraries and static libraries for Windows (and Unix, Linux, etc.), but unfortunately, no .NET API.  Our customer had already mandated that we develop the particular piece of software using .NET, so our choices on how to achieve this integration were pretty much set for us.

There are a number of ways of integrating static libraries with .NET, but here’s how I went about this.

  1. Using the nCipher headers and libraries, I created a Windows DLL that exposed any features I needed at a high level.  I.E. I did most of the difficult work in straight C, only exposing a small number of functions that provided the features I needed.
  2. Within this DLL, any data structures I required, I made global to the DLL, but returned a “Handle” to this to the caller (the caller stored this, and used in in subsequent calls to the DLL). 
  3. In the C# world, I wrote a class which statically imported the DLL functions for calls by other C# code.  For ease of access, I also wrapped the high level functions calls as public methods in my caller class. This class uses functions of the System.Runtime.Interop namespace.
  4. There was also a bit more work on marshalling structures between C# and the DLL, and also if I had to retrieve data from a pointer, but that is shown in the example below.
Some examples may make this clearer.  I’ll not go into too much detail, but hopefully enough to explain the main concepts.  For the purposes of my examples, I’ll have just two exposed functions.  One to initialise the data structures in the DLL (we’ll call this init), and another to carry out an encryption; This is what I did, but I’ll leave out key management, etc. for the sake of clarity of the example.
The initialise method had the following signature in C:
__declspec(dllexport) PMYHANDLE __stdcall init(int *pRc, int p1, int p2);
where 
PMYHANDLE is a pointer to a MYHANDLE structure (which we don’t need details on)
pRc is a pointer to an integer to receive a return code if something doesn’t work
p1 and p2 don’t matter as such.
The encrypt function had the following signature:
__declspec(dllexport) M_Status __stdcall simpleEncryptString(
        MYHANDLE *pHandle, char *pszStringToEncrypt,
        PCIPHERTEXT pCipherText);
Where
pHandle should be obtained from a prevoius init call
PCIPHERTEXT is a pointer to a structure to store the cipher text.  This was defined as
typedef struct tagCipherText {
int numBytes;
char *pData;
} CIPHERTEXT, *PCIPHERTEXT;

The C# code that imports and uses this looks a bit like this:

StructLayout(LayoutKind.Sequential)]
// Copy the structure format from the C code 
public struct CIPHERTEXT
{
  public int numBytes;
  public IntPtr pData;
}
[DllImport("mydll.dll")]
public static extern IntPtr init(ref int i, int p1, int p2);
[DllImport("mydll.dll")]
public static extern int simpleEncryptString(IntPtr pHandle,
        string pszStringToEncrypt, ref CIPHERTEXT cipherText);

Points to note:

In init, we can pass the pRc by ref using “ref int i”.  We do something similar for ref CIPHERTEXT in simpleEncryptString.

So, putting it together we have something like the following

public class EncryptCaller {
  IntPtr m_handle;
  public EncryptCaller(int p1, int p2) {
    int rc;
    m_handle = init(ref rc, p1, p2);

    if (rc != 0) {
      // Error handle here
    }
  }
  public byte[] simpleEncrypt(string s) {
    CIPHERTEXT ct = new CIPHERTEXT();
    int rc;
    byte[] ret;
    rc = simpleEncryptString(m_handle, s, ref ct);
    ret = new byte[ct.numBytes];
    Marshal.Copy(ct.pData, ret, 0, ct.numBytes);
    freeCipherText(ref ct);
  }
}

And that is more or less it.  There are two things worth noting from the example

  1. The data member within the CIPHERTEXT structure was malloc’d within the C code.  So, there’s also a function exposed which issues the corresponding free.  I didn’t show its definition,etc. here, but you see where it was called.
  2. Knowing that I would free this pointer, I copied the data from it into a local byte array.  I used the Marshal class to do that.  There’s plenty of online help from MSDN on this.