180 Lotus Instant Messaging/Web Conferencing (Sametime): Building Sametime-Enabled Applications
if (currGroupId == sampleGroupId)
{
pvtGroup->addUser(newUser);
groupFound = TRUE;
break;
}
}
}
if (!groupFound)
{
//there is no sample group, we need to add a new private group
BSTR bstrId(sampleGroupId.AllocSysString());
list<BLUser*> users;
users.push_back(newUser);
PrivateGroup* pvtGroup = new PrivateGroup(bstrId,bstrId,L"",true,users);
m_pMyBuddyList->addGroup(pvtGroup);
::SysFreeString(bstrId);
}
m_pBuddyListService->setBuddyList(*m_pMyBuddyList);
}
}
If the user trying to add people while the BuddyList service is not available, the
service will display a message indicating that this change will not be saved.
If the BuddyList service is available, we will search for the ExLiveNamesGroup. If
we find it, we will add the new user to this group. Otherwise, we will create the
group and add the user to the new group. The final step is to call the
setBuddyList API method for storing the update list on the server.
If you log in from another application (for example, the Sametime Connect client),
you will see a new private group called ExLiveNamesGroup with the user that
you added.
7.6.2 Removing a person from the list
When removing a person from the list, we would like to immediately update the
stored buddylist on the server. To accomplish this, we will update the
AwarenessList::RemoveSelectedUser method.
First, we need to save the removed user ID before deleting the user object:
CString removedUserId(pWatchedUser->GetId().getId().c_str());
delete pWatchedUser;
We will use the user ID for searching for this user in our BL structure.