void *SoundPlugin::processEvent(Event *e) { if (e->type() == EventContactOnline){ Contact *contact = (Contact*)(e->param()); SoundUserData *data = (SoundUserData*)(contact->getUserData(user_data_id)); if (data && data->Alert && *data->Alert && (!getDisableAlert() || (core && ((core->getManualStatus() == STATUS_ONLINE) || (core->getManualStatus() == STATUS_OFFLINE))))){ Event eSound(EventPlaySound, data->Alert); eSound.process(); } return NULL; } if (e->type() == EventMessageSent){ Message *msg = (Message*)(e->param()); const char *err = msg->getError(); if (err && *err) return NULL; const char *sound = NULL; if (msg->type() == MessageFile){ sound = getFileDone(); }else if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){ if ((msg->getFlags() & MESSAGE_MULTIPLY) && ((msg->getFlags() & MESSAGE_LAST) == 0)) return NULL; sound = getMessageSent(); } if (sound && *sound && (!getDisableAlert() || (core && (core->getManualStatus() == STATUS_ONLINE)))){ Event eSound(EventPlaySound, (void*)sound); eSound.process(); } return NULL; } if (e->type() == EventMessageReceived){ Message *msg = (Message*)(e->param()); if (msg->type() == MessageStatus) return NULL; if (getDisableAlert() && core && (core->getManualStatus() != STATUS_ONLINE)) return NULL; Contact *contact = getContacts()->contact(msg->contact()); if (contact == NULL) return NULL; SoundUserData *data = (SoundUserData*)(contact->getUserData(user_data_id)); string sound = messageSound(msg->type(), data); if (!sound.empty()) playSound(sound.c_str()); return NULL; } if (e->type() == EventPlaySound){ char *name = (char*)(e->param()); playSound(name); return e->param(); } return NULL; }
void *AutoAwayPlugin::processEvent(Event *e) { if (e->type() == EventPlaySound){ if (getDisableAlert() && (bAway || bNA || bOff)) return e->param(); } if (e->type() == EventContactOnline){ unsigned long commonStatus = STATUS_UNKNOWN; for (unsigned i = 0; i < getContacts()->nClients(); i++){ Client *client = getContacts()->getClient(i); if (!client->getCommonStatus()) continue; commonStatus = client->getManualStatus(); break; } if ((commonStatus == STATUS_ONLINE) || (commonStatus == STATUS_OFFLINE)) return NULL; if (getDisableAlert() && (bAway || bNA || bOff)) return (void*)commonStatus; } return NULL; }
void *SoundPlugin::processEvent(Event *e) { if (e->type() == EventSoundChanged){ Command cmd; cmd->id = CmdSoundDisable; SoundUserData *data = (SoundUserData*)(getContacts()->getUserData(user_data_id)); if (data->Disable == 0) cmd->flags |= COMMAND_CHECKED; m_bChanged = true; Event e(EventCommandChecked, cmd); e.process(); m_bChanged = false; return NULL; } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if (cmd->id == CmdSoundDisable){ cmd->flags &= ~COMMAND_CHECKED; SoundUserData *data = (SoundUserData*)(getContacts()->getUserData(user_data_id)); if (data->Disable == 0) cmd->flags |= COMMAND_CHECKED; return e->param(); } return NULL; } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if (!m_bChanged && (cmd->id == CmdSoundDisable)){ SoundUserData *data = (SoundUserData*)(getContacts()->getUserData(user_data_id)); data->Disable = (data->Disable == 0); Event eChanged(EventSoundChanged); eChanged.process(); return e->param(); } return NULL; } if (e->type() == EventContactOnline){ Contact *contact = (Contact*)(e->param()); SoundUserData *data = (SoundUserData*)(contact->getUserData(user_data_id)); if (data && data->Alert && *data->Alert && (data->Disable == 0) && (!getDisableAlert() || (core && ((core->getManualStatus() == STATUS_ONLINE) || (core->getManualStatus() == STATUS_OFFLINE))))){ Event eSound(EventPlaySound, data->Alert); eSound.process(); } return NULL; } if (e->type() == EventMessageSent){ Message *msg = (Message*)(e->param()); const char *err = msg->getError(); if (err && *err) return NULL; const char *sound = NULL; if (msg->type() == MessageFile){ sound = getFileDone(); }else if ((msg->getFlags() & MESSAGE_NOHISTORY) == 0){ if ((msg->getFlags() & MESSAGE_MULTIPLY) && ((msg->getFlags() & MESSAGE_LAST) == 0)) return NULL; sound = getMessageSent(); } if (sound && *sound && (!getDisableAlert() || (core && (core->getManualStatus() == STATUS_ONLINE)))){ Event eSound(EventPlaySound, (void*)sound); eSound.process(); } return NULL; } if (e->type() == EventMessageReceived){ Message *msg = (Message*)(e->param()); if (msg->type() == MessageStatus) return NULL; if (getDisableAlert() && core && (core->getManualStatus() != STATUS_ONLINE)) return NULL; if (msg->getFlags() & MESSAGE_LIST) return NULL; Contact *contact = getContacts()->contact(msg->contact()); if (contact == NULL) return NULL; SoundUserData *data = (SoundUserData*)(contact->getUserData(user_data_id)); bool bEnable = (data->Disable == 0); if (bEnable && data->NoSoundIfActive){ Event e(EventActiveContact); if ((unsigned)(e.process()) == contact->id()) bEnable = false; } if (bEnable){ string sound = messageSound(msg->baseType(), data); if (!sound.empty()) playSound(sound.c_str()); } return NULL; } if (e->type() == EventPlaySound){ char *name = (char*)(e->param()); playSound(name); return e->param(); } return NULL; }