我正在尝试在 SIMPLE 网络(Microsoft Office Communicator)上提取另一个人的当前状态。我正在使用 libpurple,围绕 libpurple 构建了一个 c++ 包装器,我可以在 SIMPLE 网络上与其他用户发送/接收即时消息。我仍然需要的是获取其他用户的当前状态
这是我目前尝试检索另一个用户的状态。
之前定义和初始化的:
PurpleAccount *CommonIM::m_account -> 我可以使用这个帐户发送消息
// the username of the person I want to get the status of, e.g.
username = "sip:blah@blah.blah.com";
//TEST instance 1
PurpleBuddy* newbody1 = purple_buddy_new(m_account, username.c_str(), NULL);
sleep(5);
PurplePresence *p1 = purple_buddy_get_presence(newbody1);
PurpleStatus *status1 = purple_presence_get_active_status(p1);
PurpleStatusType *statusType1 = purple_status_get_type(status1);
PurpleStatusPrimitive prim1 = purple_status_type_get_primitive(statusType1);
switch(prim1)
{
case PURPLE_STATUS_UNSET:
{
status = "unset";
}
break;
case PURPLE_STATUS_OFFLINE:
{
status = "offline";
}
break;
case PURPLE_STATUS_AVAILABLE:
{
status = "available";
}
break;
case PURPLE_STATUS_UNAVAILABLE:
{
status = "unavailable";
}
break;
case PURPLE_STATUS_INVISIBLE:
{
status = "invisible";
}
break;
case PURPLE_STATUS_AWAY:
{
status = "away";
}
break;
case PURPLE_STATUS_EXTENDED_AWAY:
{
status = "extended away";
}
break;
case PURPLE_STATUS_MOBILE:
{
status = "mobile";
}
break;
case PURPLE_STATUS_TUNE:
{
status = "tune";
}
break;
case PURPLE_STATUS_NUM_PRIMITIVES:
default:
{
status = "unknown";
}
break;
}
//TEST instance 1 complete
cout << _TAG << "Test instance 1: Status for " << username << " is reported as " << status << endl;
此代码始终以脱机状态返回。好像紫色在创建新实例后没有刷新好友,它始终保持“离线”状态。在过去的几天里,我潜入了 libpurple 和 pidgin 试图找到它,但找不到检索状态的“正确”方式。