从 libpurple(支撑 Pidgin 的 IM 库)检索另一个用户的状态
我正在尝试在简单网络(Microsoft Office Communicator)上获取另一个人的当前状态。我正在使用 libpurple,围绕 libpurple 构建了一个 C++ 包装器,并且我可以与 SIMPLE 网络上的其他用户发送/接收 IM。我仍然需要获取其他用户的当前状态
这是我当前尝试检索另一个用户的状态。
之前定义并初始化:
PurpleAccount *CommonIM::m_account ->我可以使用此帐户发送消息
// the username of the person I want to get the status of, e.g.
username = "sip:[email protected]";
//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,试图找到它,但找不到检索状态的“正确”方法。
I'm trying to pull the current status of another person on a SIMPLE network (Microsoft Office Communicator). I'm using libpurple, built a c++ wrapper around libpurple, and I can send/receive IMs with other users on the SIMPLE network. What I still need is to get the current status of other users
Here's my current attempt at retrieving status of another user.
Previously defined and initialized:
PurpleAccount *CommonIM::m_account -> I can send messages using this account
// the username of the person I want to get the status of, e.g.
username = "sip:[email protected]";
//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;
This code always returns offline as the status. It's as if purple doesn't refresh the buddy after creating a new instance, it always remains as "offline". I've dived into libpurple and pidgin to try to find this for the past few days but can't find the 'proper' way of retrieving status.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于某种原因,从
signed-on
信号调用此函数不起作用。从
buddy-signed-on
信号调用它对我来说很有效。当然,在这种情况下,将为每个登录好友调用一次...从“好友登录”信号调用的示例函数:
连接信号:
For some reason, calling this from the
signed-on
signal doesn't work.Calling it from the
buddy-signed-on
signal works for me. Of course, in that case it will be called once for each signed-on buddy ...sample function to be called from the "buddy-signed-on" signal:
Connect the signal: