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 *SoundPlugin::processEvent(Event *e) { if (e->type() == EventSoundChanged){ Command cmd; cmd->id = CmdSoundDisable; SoundUserData *data = (SoundUserData*)(getContacts()->getUserData(user_data_id)); if (!data->Disable.bValue) 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.bValue) 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.bValue = !data->Disable.bValue; 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.ptr && *data->Alert.ptr && !data->Disable.bValue){ Event eSound(EventPlaySound, data->Alert.ptr); 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){ 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 (msg->getFlags() & MESSAGE_LIST) return NULL; Contact *contact = getContacts()->contact(msg->contact()); SoundUserData *data; if (contact){ data = (SoundUserData*)(contact->getUserData(user_data_id)); }else{ data = (SoundUserData*)(getContacts()->getUserData(user_data_id)); } bool bEnable = !data->Disable.bValue; if (bEnable && data->NoSoundIfActive.bValue){ 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; }