Setting Custom Presence State with Office Communicator 2007 R2 Automation API - Matthijs Hoekstra
Zoeken binnen blogs.microsoft.nl

Matthijs Hoekstra

About Life, Microsoft and Everything

Setting Custom Presence State with Office Communicator 2007 R2 Automation API

Dec 29 2009, 01:01 AM

Deze posting is geschreven in het engels. Dit onderwerp worden veel vragen over gesteld op diverse fora, ook door niet Nederlanders.

Last week I tried to write some code to set a custom presence state in Office Communicator 2007 R2. I want to set my current work location to display in Office Communicator 2007 R2.

image

I downloaded the Microsoft Office Communicator 2007 SDK and tried some code to change the presence state. Changing the state from Available to Busy etc was easy. The following code will do that for you:

_messenger = new Messenger();
IMessengerContactAdvanced a_contact = (IMessengerContactAdvanced)_messenger.GetContact(_messenger.MySigninName,_messenger.MyServiceId)
object[] mPP = new object[8];
mPP[(int)PRESENCE_PROPERTY.PRESENCE_PROP_AVAILABILITY] = 6500;
a_contact.PresenceProperties = (object)_presProps;

In the SDK the following sample is posted to change the custom status string: (search for PRESENCE_PROP_CUSTOM_STATUS_STRING in the SDK)

// Publish custom activity
mPP[(int)PRESENCE_PROPERTY.PRESENCE_PROP_MSTATE] = MISTATUS.MISTATUS_CUSTOM;
mPP[(int)PRESENCE_PROPERTY.PRESENCE_PROP_CUSTOM_STATUS_STRING] = "at lunch";
a_contact.PresenceProperties = (object)mPP;

But this code will result in a exception: Exception is [System.ArgumentException] {"Value does not fall within the expected range."} System.ArgumentException

The online SDK sample is changed to remove this sample because it’s not working.

There is a way to get this code working but not exactly I was hoping for. It is possible to extend Office Communicator with custom presence status. You need a XML file available through HTTPS (this changed from Office Communicato 2007 to 2007 R2, before R2 you could have a local file as well). The file below is placed at https://www.hoekstraonline.net/CustomPresence.xml

<customStates>
  <customState ID="1" availability="online">
    <activity LCID="1033">Out and about - use mobile</activity>
  </customState>
  <customState ID="2" availability="Busy">
    <activity LCID="1033">Down in the lab - use mobile</activity>
  </customState>
  <customState ID="3" availability="busy">
    <activity LCID="1033">Reviewing program documents</activity>
  </customState>
  <customState ID="4" availability="do-not-disturb">
    <activity LCID="1033">Executive Briefing with Customer</activity>
  </customState>
</customStates>

You need to change the registry to make Communicator read this file:

Add a  String Value to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Communicator called CustomStateURL with in my example the value  https://www.hoekstraonline.net/CustomPresence.xml  (create the key Communicator when it doesn’t exist). When you restart Communicator you will see the following list with states:

image

Now when I change the code to the lines below it will not fail and successfully change the status to the custom text:

// Publish custom activity
mPP[(int)PRESENCE_PROPERTY.PRESENCE_PROP_MSTATE] = MISTATUS.MISTATUS_CUSTOM;
mPP[(int)PRESENCE_PROPERTY.PRESENCE_PROP_CUSTOM_STATUS_STRING] = "Executive Briefing with Customer";
a_contact.PresenceProperties = (object)mPP;

So unfortunately the behavior of setting the custom status only allows changing it in code to the predefined custom states. In my case that’s isn’t good enough because I don’t want to specify all possible locations in the Netherlands in the custom XML file but want to change it dynamically.

The solution for this is writing a UCC API or UCMA API based application which will do this for me. I have some samples ready but the hard part is you have to create new endpoints to publish the custom status and keep it working when users close laptops, change networks, work offline and online again etc. I didn’t write a robust enough UCC or UCMA application to make this happen. Writing against the OC Automation API would really helped me here. Hopefully it’s changed in the Wave 14 API of Communicator.

Opgeslagen onder: , , ,

Commentaar:

Twitter Trackbacks for Setting Custom Presence State with Office Communicator 2007 R2 Automation API - Matthijs Hoekstra [microsoft.nl] on Topsy.com zei:

PingBack vanaf  Twitter Trackbacks for                 Setting Custom Presence State with Office Communicator 2007 R2 Automation API - Matthijs Hoekstra         [microsoft.nl]        on Topsy.com

# December 29, 2009 8:45 AM

uberVU - social comments zei:

This post was mentioned on Twitter by mahoekst: New Blogpost: Setting Custom Presence State with Office Communicator 2007 R2 Automation API http://bit.ly/6SMt7J

# December 30, 2009 9:14 PM
Wat denkt u?

(Verplicht) 

(Verplicht) 

(Optioneel)

(Verplicht) 
CaptchaCube Vraag:


Antwoord: