本文整理汇总了C++中EventMessage类的典型用法代码示例。如果您正苦于以下问题:C++ EventMessage类的具体用法?C++ EventMessage怎么用?C++ EventMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fill
bool AIMInfo::processEvent(Event *e)
{
if (e->type() == eEventContact){
EventContact *ec = static_cast<EventContact*>(e);
if(ec->action() != EventContact::eChanged)
return false;
Contact *contact = ec->contact();
if (contact->have(m_data))
fill();
} else
if ((e->type() == eEventMessageReceived) && m_data){
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
if (msg->type() == MessageStatus){
if (m_client->dataName(m_data) == msg->client())
fill();
}
} else
if ((e->type() == eEventClientChanged) && (m_data == 0)){
EventClientChanged *ecc = static_cast<EventClientChanged*>(e);
if (ecc->client() == m_client)
fill();
}
return false;
}
示例2: HandleIOMessageFailure
void IOHandler::HandleIOMessageFailure(const EventMessage& message) {
ProtocolMessage* protocol_message = message.GetProtocolMessage();
if (protocol_message->direction == ProtocolMessage::kOutgoingRequest) {
protocol_message->status = ProtocolMessage::kInternalFailure;
if (!GetIOService()->GetServiceStage()->Send(protocol_message)) {
MI_LOG_WARN(logger, "IOHandler::HandleIOMessageFailure send fail");
}
} else {
message.Destroy();
}
}
示例3: ClientsRegistered
size_t Client::ClientsRegistered(std::string eventType)
{
EventMessage msg;
msg.setEventType(REGISTERED_MSG);
msg.pushParam(eventType);
this->Send(msg, PRIORITY_COMMAND);
this->WaitForEvent(msg, REGISTERED_RESP);
return (size_t)msg.getParamInt(0);
}
示例4: IsClientConnected
bool Client::IsClientConnected(std::string target)
{
EventMessage msg;
msg.setEventType(ISCONNECTED_MSG);
msg.pushParam(target);
this->Send(msg, PRIORITY_COMMAND);
this->WaitForEvent(msg, ISCONNECTED_RESP);
return ( msg.getParamInt(0) != 0 );
}
示例5: processEvent
bool DeclineDlg::processEvent(Event *e)
{
if (e->type() == eEventMessageDeleted)
{
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
if (msg->id() == m_msg->id())
close();
}
return false;
}
示例6: EventMessage
Serializable*
EventMessage::deserialize(SerializedInstance* data) {
unsigned int source = data->getUnsigned();
unsigned int dest = data->getUnsigned();
unsigned int incNum = data->getUnsigned();
Event* event = dynamic_cast<Event*>(data->getSerializable());
const string gvtInfo = data->getString();
EventMessage* retval = new EventMessage(source, dest, event, gvtInfo);
retval->setIncarnationNumber(incNum);
return retval;
}
示例7: HandleIOMessageEvent
void IOHandler::HandleIOMessageEvent(const EventMessage& message) {
MI_LOG_TRACE(logger, "HandleIOMessageEvent");
IODescriptor* descriptor =
IODescriptorFactory::GetIODescriptor(message.descriptor_id);
if (!descriptor) {
MI_LOG_DEBUG(logger, "HandleIOCloseEvent descriptor not found:"
<< message.descriptor_id);
HandleIOMessageFailure(message);
return;
}
Channel* channel = dynamic_cast<Channel*>(descriptor);
if (!channel) {
MI_LOG_ERROR(logger, "IOHandler::HandleIOMessageEvent descriptor is not channel");
HandleIOMessageFailure(message);
return;
}
ProtocolMessage* protocol_message = message.GetProtocolMessage();
if (0 != channel->EncodeMessage(protocol_message)) {
HandleIOMessageFailure(message);
return;
}
descriptor->OnWrite();
}
示例8: Peek
bool Client::Peek(EventMessage &msg)
{
message_queue* const mq = (message_queue*)this->privateQueue;
// check local deque for message
if(!this->storedMessages.empty())
{
// get first queued element and pop it
msg = this->storedMessages.front();
this->storedMessages.pop_front();
return true;
}
std::stringbuf msgBuffer;
char buff[MAX_MSG_SIZE];
size_t recvd;
unsigned int priority;
if(mq->try_receive(buff, MAX_MSG_SIZE, recvd, priority))
{
msgBuffer.sputn(buff, recvd);
msg.deserialize(msgBuffer);
return HandleMessage(msg, priority);
}
else
return false;
return true;
}
示例9: processEvent
bool WarnDlg::processEvent(Event *e)
{
if (e->type() == eEventMessageSent) {
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
if (msg == m_msg) {
m_msg = false;
QString err = msg->getError();
if (!err.isEmpty()) {
showError(err);
} else {
QTimer::singleShot(0, this, SLOT(close()));
}
}
}
return false;
}
示例10: registerEventCallback
static void registerEventCallback(char *name, char *buf, int bufSize, void *arg, bool isSynch, int retSize, char *retData, int type)
{
printf("REGISTER EVENT CALLBACK %s %s\n", name, buf);
EventMessage *evMessage = new EventMessage(buf);
int msgLen;
char *msg = evMessage->serialize(msgLen, msgManager);
for(int i = 0; i < numExtAddresses; i++)
{
try {
msgManager->sendMessage(extAddresses[i], msg, msgLen);
}catch(SystemException *exc)
{
printf("Error Sending registration message: %s\n", exc->what());
}
}
((UDPNetworkManager*)udpMsgManager)->join(getMulticastAddr(evMessage->name));
delete [] msg;
delete evMessage;
}
示例11: HandleMessage
bool Client::HandleMessage(EventMessage &msg, size_t priority)
{
if( // dataPacket
0 == msg.getEventType().compare(PACKET_MSG) )
{
if(HandlePacket(msg, *this->packetData))
return this->HandleMessage(msg, priority); // handle recieved data
else
return this->Peek(msg); // packet discarded, continue peek
}
else
return true;
}
示例12: SendTo
void Client::SendTo(const std::string target, EventMessage &msg)
{
msg.setSender(this->name);
std::stringbuf msgBuffer;
msg.serialize(msgBuffer);
EventMessage targetPacket;
targetPacket.setEventType(DIRECTSEND_MSG);
targetPacket.pushParam(target);
targetPacket.pushParam(msgBuffer.str());
targetPacket.setSender(this->name);
this->Send(targetPacket, PRIORITY_COMMAND);
}
示例13: switch
bool Container::processEvent(Event *e)
{
if (m_tabBar == NULL)
return false;
switch (e->type()){
case eEventMessageReceived: {
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
if (msg->type() == MessageStatus){
Contact *contact = getContacts()->contact(msg->contact());
if (contact)
contactChanged(contact);
return false;
}
if (msg->getFlags() & MESSAGE_NOVIEW)
return false;
if (CorePlugin::m_plugin->getContainerMode()){
if (isActiveWindow() && !isMinimized()){
UserWnd *userWnd = m_tabBar->currentWnd();
if (userWnd && (userWnd->id() == msg->contact()))
userWnd->markAsRead();
}else{
UserWnd *userWnd = wnd(msg->contact());
if (userWnd)
QTimer::singleShot(0, this, SLOT(flash()));
}
}
// no break here - otherwise we have to duplicate the code below...
}
case eEventMessageRead: {
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
UserWnd *userWnd = wnd(msg->contact());
if (userWnd){
bool bBold = false;
for (list<msg_id>::iterator it = CorePlugin::m_plugin->unread.begin(); it != CorePlugin::m_plugin->unread.end(); ++it){
if ((*it).contact != msg->contact())
continue;
bBold = true;
break;
}
m_tabBar->setBold(msg->contact(), bBold);
}
break;
}
case eEventActiveContact: {
EventActiveContact *eac = static_cast<EventActiveContact*>(e);
if (!isActiveWindow())
return false;
UserWnd *userWnd = m_tabBar->currentWnd();
if (userWnd) {
eac->setContactID(userWnd->id());
return true;
}
break;
}
case eEventContact: {
EventContact *ec = static_cast<EventContact*>(e);
Contact *contact = ec->contact();
UserWnd *userWnd = wnd(contact->id());
if(!userWnd)
break;
switch(ec->action()) {
case EventContact::eDeleted: {
removeUserWnd(userWnd);
break;
}
case EventContact::eChanged: {
if (contact->getIgnore()){
removeUserWnd(userWnd);
break;
}
m_tabBar->changeTab(contact->id());
contactChanged(contact);
break;
}
case EventContact::eStatus: {
unsigned style = 0;
QString wrkIcons;
QString statusIcon;
contact->contactInfo(style, statusIcon, &wrkIcons);
bool bTyping = false;
while (!wrkIcons.isEmpty()){
if (getToken(wrkIcons, ',') == "typing"){
bTyping = true;
break;
}
}
if (userWnd->m_bTyping != bTyping){
userWnd->m_bTyping = bTyping;
if (bTyping){
userWnd->setStatus(g_i18n("%1 is typing", contact) .arg(contact->getName()));
}else{
userWnd->setStatus("");
}
userWnd = m_tabBar->currentWnd();
if (userWnd && (contact->id() == userWnd->id()))
m_status->message(userWnd->status());
}
}
//.........这里部分代码省略.........
示例14: switch
bool SoundPlugin::processEvent(SIM::Event *e)
{
switch (e->type())
{
case eEventLoginStart:
{
playSound(value("StartUp").toString());
break;
}
case eEventPluginLoadConfig:
{
PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("sound");
if(!hub.isNull())
setPropertyHub(hub);
if(!value("StartUp").isValid())
setValue("StartUp", "sounds/startup.ogg");
if(!value("MessageSent").isValid())
setValue("MessageSent", "sounds/msgsent.ogg");
if(!value("FileDone").isValid())
setValue("FileDone", "sounds/filedone.ogg");
break;
}
case eEventContact:
{
EventContact *ec = static_cast<EventContact*>(e);
if(ec->action() != EventContact::eOnline)
break;
Contact *contact = ec->contact();
bool disable = contact->getUserData()->root()->value("sound/Disable").toBool();
QString alert = contact->getUserData()->root()->value("sound/Alert").toString();
if(alert.isEmpty())
alert = getContacts()->userdata()->value("sound/Alert").toString();
if (!alert.isEmpty() && !disable)
EventPlaySound(alert).process();
break;
}
case eEventMessageSent:
{
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
QString err = msg->getError();
if (!err.isEmpty())
return false;
QString sound;
if (msg->type() == MessageFile)
sound = value("FileDone").toString();
else if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0)
{
if ((msg->getFlags() & MESSAGE_MULTIPLY) && ((msg->getFlags() & MESSAGE_LAST) == 0))
return false;
sound = value("MessageSent").toString();
}
if (!sound.isEmpty())
EventPlaySound(sound).process();
break;
}
case eEventMessageReceived:
{
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
if(msg->type() == MessageStatus)
return false;
Contact *contact = getContacts()->contact(msg->contact());
bool nosound, disable;
if(contact)
{
nosound = contact->getUserData()->root()->value("sound/NoSoundIfActive").toBool();
disable = contact->getUserData()->root()->value("sound/Disable").toBool();
}
else
{
nosound = getContacts()->userdata()->value("sound/NoSoundIfActive").toBool();
disable = getContacts()->userdata()->value("sound/Disable").toBool();
}
if(!disable && nosound)
{
EventActiveContact e;
e.process();
if (e.contactID() == contact->id())
disable = true;
}
if(!disable)
{
QString sound = messageSound(msg->baseType(), contact->id());
playSound(sound);
}
break;
}
case eEventPlaySound:
{
EventPlaySound *s = static_cast<EventPlaySound*>(e);
playSound(s->sound());
return true;
}
default:
break;
}
return false;
}
示例15: switch
bool OSDPlugin::processEvent(Event *e)
{
OSDRequest osd;
switch (e->type()){
case eEventContact: {
EventContact *ec = static_cast<EventContact*>(e);
Contact *contact = ec->contact();
if (contact->getIgnore())
break;
switch(ec->action()) {
case EventContact::eOnline: {
osd.contact = contact->id();
osd.type = OSD_ALERTONLINE;
queue.push_back(osd);
processQueue();
break;
}
case EventContact::eStatus: {
OSDUserData *data = (OSDUserData*)(contact->getUserData(user_data_id));
if (data){
unsigned style = 0;
QString wrkIcons;
QString statusIcon;
contact->contactInfo(style, statusIcon, &wrkIcons);
bool bTyping = false;
while (!wrkIcons.isEmpty()){
if (getToken(wrkIcons, ',') == "typing"){
bTyping = true;
break;
}
}
if (bTyping){
list<unsigned>::iterator it;
for (it = typing.begin(); it != typing.end(); ++it)
if ((*it) == contact->id())
break;
if (it == typing.end()){
typing.push_back(contact->id());
osd.contact = contact->id();
osd.type = OSD_TYPING;
queue.push_back(osd);
processQueue();
}
}else{
list<unsigned>::iterator it;
for (it = typing.begin(); it != typing.end(); ++it)
if ((*it) == contact->id())
break;
if (it != typing.end())
typing.erase(it);
if ((m_request.type == OSD_TYPING) && (m_request.contact == contact->id())){
m_timer->stop();
m_timer->start(100);
}
}
}
break;
}
default:
break;
}
break;
}
case eEventMessageReceived: {
EventMessage *em = static_cast<EventMessage*>(e);
Message *msg = em->msg();
Contact *contact = getContacts()->contact(msg->contact());
if (contact == NULL)
break;
OSDUserData *data = (OSDUserData*)(contact->getUserData(user_data_id));
if (data == NULL)
break;
osd.contact = msg->contact();
if (! core->unread.empty())
bHaveUnreadMessages=true;
if (msg->type() == MessageStatus) {
StatusMessage *smsg = (StatusMessage*)msg;
switch (smsg->getStatus()) {
case STATUS_AWAY:
osd.type = OSD_ALERTAWAY;
break;
case STATUS_NA:
osd.type = OSD_ALERTNA;
break;
case STATUS_DND:
osd.type = OSD_ALERTDND;
break;
case STATUS_OCCUPIED: /* STATUS_OCCUPIED, took over from contacts.h! */
osd.type = OSD_ALERTOCCUPIED;
break;
case STATUS_FFC:
osd.type = OSD_ALERTFFC;
break;
case STATUS_OFFLINE:
osd.type = OSD_ALERTOFFLINE;
break;
case STATUS_ONLINE:
osd.type = OSD_NONE;
return false;
default:
//.........这里部分代码省略.........