本文整理汇总了C++中ContactRef::isVirtualContact方法的典型用法代码示例。如果您正苦于以下问题:C++ ContactRef::isVirtualContact方法的具体用法?C++ ContactRef::isVirtualContact怎么用?C++ ContactRef::isVirtualContact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContactRef
的用法示例。
在下文中一共展示了ContactRef::isVirtualContact方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SignalMessageAck
void WPclient::SignalMessageAck(MessageEvent *ev) {
if(!ev->isFinished()) return;
unsigned int uin = 0;
ContactRef c = ev->getContact();
if (c->isVirtualContact())
uin = 0;
else
uin = c->getUIN();
if (ev->getType() == ICQ2000::MessageEvent::AwayMessage){
AwayMessageEvent *aev = static_cast<AwayMessageEvent*>(ev);
log_debug(ZONE,"Away message received");
sendContactPresence(uin,aev->getAwayMessage());
return;
}
if(!ev->isDelivered()) {
jid id;
xmlnode msg;
switch(ev->getDeliveryFailureReason()) {
case MessageEvent::Failed_Denied:
msg = xmlnode_new_tag("message");
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"body"),
it_convert_windows2utf8(xmlnode_pool(msg),LNG_M_ACK_IGNORE),
(unsigned int) -1);
break;
case MessageEvent::Failed_Occupied:
msg = xmlnode_new_tag("message");
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"body"),
it_convert_windows2utf8(xmlnode_pool(msg),LNG_M_ACK_BUSY),
(unsigned int) -1);
break;
case MessageEvent::Failed_DND:
msg = xmlnode_new_tag("message");
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"body"),
it_convert_windows2utf8(xmlnode_pool(msg),LNG_M_ACK_DND),
(unsigned int) -1);
break;
case MessageEvent::Failed_NotConnected:
return;
msg = xmlnode_new_tag("message");
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"body"),
it_convert_windows2utf8(xmlnode_pool(msg),LNG_M_ACK_NC),
(unsigned int) -1);
break;
case MessageEvent::Failed:
default:
msg = xmlnode_new_tag("message");
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"body"),
it_convert_windows2utf8(xmlnode_pool(msg),LNG_M_ACK_FAIL),
(unsigned int) -1);
}
xmlnode_put_attrib(msg,"to",jid_full(sesja->id));
id = it_uin2jid(xmlnode_pool(msg),uin,sesja->from->server);
xmlnode_put_attrib(msg,"from",jid_full(id));
it_deliver(sesja->ti,msg);
return;
}
/* Parsing away messages included in message acks would be nice
* but does not work with ICQ Lite and some other clients which
* either put in a "not supported" here or echo the last message
* sent to them.
ICQMessageEvent *cev = dynamic_cast<ICQMessageEvent*>(ev);
if (cev && (cev->getAwayMessage().size())) {
log_debug(ZONE,"Away message received with message ack");
sendContactPresence(uin,cev->getAwayMessage());
} */
}
示例2: SignalMessaged
void WPclient::SignalMessaged(MessageEvent *ev) {
jid id;
xmlnode msg;
unsigned int uin = 0;
ContactRef c = ev->getContact();
if (c->isVirtualContact())
uin = 0;
else
uin = c->getUIN();
switch(ev->getType()){
case MessageEvent::Normal: {
NormalMessageEvent* nm=static_cast<NormalMessageEvent*>(ev);
msg = xmlnode_new_tag("message");
contact sc;
bool type_chat;
sc = it_contact_get(sesja,uin);
if (sc)
type_chat = sc->use_chat_msg_type;
else
if (sesja->ti->msg_chat)
type_chat = true;
else
type_chat = false;
if(type_chat)
xmlnode_put_attrib(msg,"type","chat");
log_debug(ZONE,"Message: len->%i encoding->%i text->%s",int((nm->getMessage()).length()),
int(nm->getTextEncoding()),(nm->getMessage()).c_str());
if (nm->getTextEncoding()==2) // UCS2BE
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"body"),
it_convert_ucs2utf8(xmlnode_pool(msg),
(nm->getMessage()).length(),
(nm->getMessage()).c_str()),
(unsigned int)-1);
else if (nm->getTextEncoding()==8) // UTF-8
xmlnode_insert_cdata( xmlnode_insert_tag(msg,"body") ,
(nm->getMessage()).c_str() ,
(unsigned int)-1);
else // 0==ASCII and 3==locale_encoded will go here.
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"body"),
it_convert_windows2utf8(xmlnode_pool(msg),
(nm->getMessage()).c_str()),
(unsigned int)-1);
if ((ev->getTime()!=0) && ((ev->getTime()+120)<time(NULL))) {
// if the message travels more than 2 minutes it is not online anyway. Stamp it.
xmlnode x;
char timestamp[24];
const time_t time=ev->getTime();
struct tm *t=gmtime(&time);
snprintf(timestamp,24,"%04i%02i%02iT%02i:%02i:%02i",t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
x=xmlnode_insert_tag(msg,"x");
xmlnode_put_attrib(x,"xmlns","jabber:x:delay");
xmlnode_put_attrib(x,"stamp",timestamp);
}
break;
}
case MessageEvent::URL: {
URLMessageEvent* urlm=static_cast<URLMessageEvent*>(ev);
msg = xmlnode_new_tag("message");
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"subject"),
"ICQ URL Message",(unsigned int)-1);
/* add a message body that most clients can understand */
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"body"),
it_convert_windows2utf8(xmlnode_pool(msg),
("URL: "+(urlm->getURL())+"\nDescription:\n"+
(urlm->getMessage())).c_str()),
(unsigned int)-1);
xmlnode x = xmlnode_insert_tag(msg,"x");
xmlnode_put_attrib(x,"xmlns",NS_XOOB);
xmlnode_insert_cdata(xmlnode_insert_tag(x,"desc"),
it_convert_windows2utf8(xmlnode_pool(msg),
(urlm->getMessage()).c_str()),
(unsigned int)-1);
xmlnode_insert_cdata(xmlnode_insert_tag(x,"url"),
it_convert_windows2utf8(xmlnode_pool(msg),
(urlm->getURL()).c_str()),
(unsigned int)-1);
break;
}
case MessageEvent::AuthReq: {
contact cc;
AuthReqEvent *autr = static_cast<AuthReqEvent*>(ev);
log_debug(ZONE,"Authorization request received");
msg = xmlnode_new_tag("presence");
xmlnode_insert_cdata(xmlnode_insert_tag(msg,"status"),
it_convert_windows2utf8(xmlnode_pool(msg),
autr->getMessage().c_str()),
(unsigned int)-1);
//.........这里部分代码省略.........