Subject: url to lotus note
Maciej,
It may be too late to help you, but I also needed this information, and the replies you got seemed to entirely miss the point of your question… so I’ll share what I learned, and hopefully someone else will benefit.
I’ll start by repeating your question in my own words:
As I understand it, you want to construct a notes:// URL programmatically using the C API. You have not specified what you will do with that URL once you have it – you just want to be able to programmatically generate URLs that work like the URLs you can see when you right-click a note, choose Properties, and look at the tab labeled “<+>”.
As you already know, the URL’s form is:
notes://<server_name>/<database_id>/<note_unid>
That seems like plenty of information, but actually getting those individual pieces isn’t completely obvious.
For a Notes database stored on the local system (which is all I care about in my case), use an empty string for <server_name>. Otherwise specify the notes server name (I assume you can use any hostname that can be resolved with sockets).
Getting the database ID given the database handle is pretty straightforward if you want to access the server’s database.
If you’re running on the client and have a handle to a note on a server, but you want the URL to point at a replica (I mention this because it’s what I needed, and my use case sounds similar to yours), you need to call NSFDbReplicaInfoGet and pull the ID from the resulting DBREPLICAINFO.
Getting <note_unid> isn’t TOO tough once you realize that it MUST BE THE UNID (not just the ID). Call NSFDbGetNoteInfo() (specifying the database ID and the note ID) and the resulting OID/ORIGINATORID (the third argument) will (sort of) contain the note UNID as its File and Note members. You just have to pull them out and put them in a UNID. For example:
OID noteOID;
NSFDbGetNoteInfo(hNoteDB, noteID, &m_noteOID, &lastMod, ¬eClass);
UNID noteUNID;
noteUNID.File = noteOID.File;
noteUNID.Note = noteOID.Note;
Given that information, you just need to output a DBID and a UNID in the expected form. Here’s a printf() that will output a URL, assuming the you have a valid UNID called noteUNID, a valid DBID called dbID and a valid (possibly empty) null terminated string called serverName:
printf("notes://%s/%08x%08x/%08x%08x%08x%08x",
serverName,
dbID.Innards[1], dbID.Innards[0],
noteUNID.File.Innards[1], noteUNID.File.Innards[0],
noteUNID.Note.Innards[1], noteUNID.Note.Innards[0]);
Maybe there’s a more direct way to do that using the C API, but I didn’t find one in the documentation. If there’s a better way, hopefully someone will speak up.