|In this example you will want to get the current
accounts and identities for Groove on the current PC. The
accounts/identities will be displayed in a TreeView control named tvAccounts.
Here is what it looks like:
First, we want to set up a class to hold the account information the
application will be working with.
Public Class AccountData
Public AccountURL As String
Public ContactURL As String
Public AccountIdentityURL As String
Public IdentitySpaceURL As String
Public Name As String
Using Groove Web Services you will want to request Groove to return all the
current accounts and information about those accounts. When you request
account information from Groove using GWS you need to give it two pieces of
information: the current Groove Nonce, and the Groove URL for account
The Nonce is changed every time Groove is
started. See this page for how to get the current Nonce.
The Groove Account URL is made up of the
Groove Host and the string "/GWS/Groove/1.0/Accounts/". See this page for
how to create the Groove Host string.
Dim svc As New gwsAccounts.GrooveAccounts()
svc.GrooveHeaderValue = New gwsAccounts.GrooveHeader()
svc.GrooveHeaderValue.GrooveNonce = gwsNonce()
svc.Url = gwsHost & "/GWS/Groove/1.0/Accounts/"
Then you send the request for the account
information and you will receive an array of account information. You may
want to wrap this in a try/catch structure to handle any exceptions.
accounts = svc.Read
Once you have the array of accounts you will
want to go through each account and store the information in your
application and display these accounts in the user interface. Each account
can have one or more identities in that account. All of the shared spaces
are associated with an identity. So an accountData object will be created
for each identity in an account. The accountData object holds the needed
information. Then a tree node is created for the account TreeView and the
node text is set to the identity name, with the node tag holding the
accountData object. The node is then added to the TreeView.
'Cache the account/identity information in the application
For Each act In accounts
'An account can have multiple identities
Dim anIdentity As gwsAccounts.Identity
For Each anIdentity In act.Identities
'Cache this account/identity info in an object
Dim account As AccountData = New AccountData()
account.AccountURL = act.URI
account.ContactURL = act.Contacts
account.Name = anIdentity.Name
account.AccountIdentityURL = anIdentity.URI
account.IdentitySpaceURL = anIdentity.Spaces
'This accountNode object is used to hold the account info in the UI
Dim accountNode As TreeNode
accountNode = tvAccounts.Nodes.Add(anIdentity.Name)
accountNode.Tag = account