bool WinDockPlugin::processEvent(Event *e) { if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->id == CmdAutoHide){ dock->setAutoHide((cmd->flags & COMMAND_CHECKED) != 0); bAutoHideVisible = true; setBarState(); enableAutoHide(getAutoHide()); return true; } } else if (e->type() == eEventCheckCommandState){ EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if ((cmd->id == CmdAutoHide) && (dock->getState() != ABE_FLOAT)){ cmd->flags &= ~COMMAND_CHECKED; if (dock->getAutoHide()) cmd->flags |= COMMAND_CHECKED; return true; } } else if ((e->type() == eEventInit) && !m_bInit) init(); if (e->type() == eEventInTaskManager){ EventInTaskManager *eitm = static_cast<EventInTaskManager*>(e); if ((dock->getState() != ABE_FLOAT) && eitm->showInTaskmanager()){ EventInTaskManager(false).process(); return true; } } return false; }
bool MsgUrl::processEvent(Event *e) { if (e->type() == eEventCheckCommandState){ EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if (cmd->param == m_edit){ unsigned id = cmd->bar_grp; if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){ cmd->flags |= BTN_HIDE; if (cmd->id == CmdUrlInput) cmd->flags &= ~BTN_HIDE; return true; } switch (cmd->id){ case CmdTranslit: case CmdSmile: case CmdSend: case CmdSendClose: e->process(this); cmd->flags &= ~BTN_HIDE; return true; case CmdNextMessage: case CmdMsgAnswer: e->process(this); cmd->flags |= BTN_HIDE; return true; } } } else if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if ((cmd->id == CmdSend) && (cmd->param == m_edit)){ QString msgText = m_edit->m_edit->toPlainText(); QString urlText; Command cmd; cmd->id = CmdUrlInput; cmd->param = m_edit; EventCommandWidget eWidget(cmd); eWidget.process(); CToolEdit *edtUrl = qobject_cast<CToolEdit*>(eWidget.widget()); if (edtUrl) urlText = edtUrl->text(); if (!urlText.isEmpty()){ UrlMessage *msg = new UrlMessage; msg->setContact(m_edit->m_userWnd->id()); msg->setText(msgText); msg->setUrl(urlText); msg->setClient(m_client); m_edit->sendMessage(msg); } return true; } } return false; }
bool MsgJournal::processEvent(Event *e) { if (e->type() == eEventCheckCommandState){ EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if (cmd->param == m_edit){ unsigned id = cmd->bar_grp; if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){ cmd->flags |= BTN_HIDE; if ((cmd->id == CmdDeleteJournalMessage + CmdReceived) && m_ID) cmd->flags &= ~BTN_HIDE; return true; } switch (cmd->id){ case CmdSend: case CmdSendClose: e->process(this); cmd->flags &= ~BTN_HIDE; return true; case CmdTranslit: case CmdSmile: case CmdNextMessage: case CmdMsgAnswer: e->process(this); cmd->flags |= BTN_HIDE; return true; } } } else if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->param == m_edit){ if (cmd->id == CmdSend){ QString msgText = m_edit->m_edit->text(); if (!msgText.isEmpty()) send(msgText); return true; } if (cmd->id == CmdDeleteJournalMessage + CmdReceived){ QWidget *w = m_edit->m_bar; Command cmd; cmd->id = CmdDeleteJournalMessage + CmdReceived; cmd->param = m_edit; EventCommandWidget eWidget(cmd); eWidget.process(); QWidget *btnRemove = eWidget.widget(); if (btnRemove) w = btnRemove; BalloonMsg::ask(NULL, i18n("Remove record from journal?"), w, SLOT(removeRecord(void*)), NULL, NULL, this); return true; } return false; }
bool MsgContacts::processEvent(Event *e) { if (e->type() == eEventCheckCommandState){ EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if (cmd->param == m_edit){ unsigned id = cmd->bar_grp; if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){ cmd->flags |= BTN_HIDE; return true; } switch (cmd->id){ case CmdSend: case CmdSendClose: e->process(this); cmd->flags &= ~BTN_HIDE; return true; case CmdTranslit: case CmdSmile: case CmdNextMessage: case CmdMsgAnswer: e->process(this); cmd->flags |= BTN_HIDE; return true; } } } else if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if ((cmd->id == CmdSend) && (cmd->param == m_edit)){ QString msgText = m_edit->m_edit->text(); QString contacts; for (list<unsigned>::iterator it = m_list->selected.begin(); it != m_list->selected.end(); ++it){ Contact *contact = getContacts()->contact(*it); if (contact){ if (!contacts.isEmpty()) contacts += ';'; contacts += QString("sim:%1,%2") .arg(*it) .arg(contact->getName()); } } if (!contacts.isEmpty()){ ContactsMessage *msg = new ContactsMessage; msg->setContact(m_edit->m_userWnd->id()); msg->setContacts(contacts); msg->setClient(m_client); m_edit->sendMessage(msg); } return true; } } return false; }
bool MsgGen::processEvent(Event *e) { if (e->type() == eEventCheckCommandState){ EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if (cmd->param == m_edit){ unsigned id = cmd->bar_grp; if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){ cmd->flags |= BTN_HIDE; return true; } switch (cmd->id){ case CmdTranslit: case CmdSmile: case CmdSend: case CmdSendClose: e->process(this); cmd->flags &= ~BTN_HIDE; return true; case CmdNextMessage: case CmdMsgAnswer: e->process(this); cmd->flags |= BTN_HIDE; return true; } } } else if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if ((cmd->id == CmdSend) && (cmd->param == m_edit)){ QString msgText = m_edit->m_edit->text(); if (!msgText.isEmpty()){ log(L_DEBUG, "Send: %s", msgText.local8Bit().data()); Message *msg = new Message; msg->setText(msgText); msg->setContact(m_edit->m_userWnd->id()); msg->setClient(m_client); msg->setFlags(MESSAGE_RICHTEXT); msg->setForeground(m_edit->m_edit->foreground().rgb() & 0xFFFFFF); msg->setBackground(m_edit->m_edit->background().rgb() & 0xFFFFFF); msg->setFont(CorePlugin::m_plugin->getEditFont()); m_edit->sendMessage(msg); } return true; } } return false; }
bool ListView::processEvent(Event *e) { if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if ((cmd->id == CmdListDelete) && (cmd->menu_id == MenuListView)){ ListViewItem *item = (ListViewItem*)(cmd->param); if (item->listView() == this){ emit deleteItem(item); return true; } } } return false; }
bool NetmonitorPlugin::processEvent(Event *e) { if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->id == CmdNetMonitor){ showMonitor(); return true; } } else if(e->type() == eEventPluginLoadConfig) { PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("netmonitor"); if(!hub.isNull()) setPropertyHub(hub); } return false; }
bool WeatherPlugin::processEvent(Event *e) { if (e->type() == eEventLanguageChanged) updateButton(); if (e->type() == eEventInit) showBar(); if (e->type() == eEventCommandExec) { EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if ((cmd->id == CmdWeather) && !getID().isEmpty()) { QString url = "http://www.weather.com/outlook/travel/local/"; url += getID(); EventGoURL(url).process(); return true; } } return false; }
bool MsgAuth::processEvent(Event *e) { if (e->type() == eEventCheckCommandState){ EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if (cmd->param == m_edit){ unsigned id = cmd->bar_grp; if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){ cmd->flags |= BTN_HIDE; return true; } switch (cmd->id){ case CmdTranslit: case CmdSmile: case CmdSend: case CmdSendClose: e->process(this); cmd->flags &= ~BTN_HIDE; return true; case CmdNextMessage: case CmdMsgAnswer: e->process(this); cmd->flags |= BTN_HIDE; return true; } } } else if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if ((cmd->id == CmdSend) && (cmd->param == m_edit)){ QString msgText = m_edit->m_edit->text(); AuthMessage *msg = new AuthMessage(m_type); msg->setText(msgText); msg->setContact(m_edit->m_userWnd->id()); msg->setClient(m_client); m_edit->sendMessage(msg); return true; } } return false; }
bool AboutPlugin::processEvent(Event *e) { if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->id == CmdBugReport){ QString s = "http://developer.berlios.de/bugs/?group_id=4482"; EventGoURL eURL(s); eURL.process(); } if (cmd->id == CmdAbout){ if (about == NULL) { KAboutData *about_data = getAboutData(); about_data->setTranslator( I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"), I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails")); about = new KAboutApplication( about_data, NULL, "about", false ); connect(about, SIGNAL(finished()), this, SLOT(aboutDestroyed())); } raiseWindow(about); } #ifdef USE_KDE if (cmd->id == CmdAboutKDE){ if (about_kde == NULL) { about_kde = new KAboutKDE( NULL, "aboutkde", false); connect(about_kde, SIGNAL(finished()), this, SLOT(aboutDestroyed())); } raiseWindow(about_kde); } #endif } return false; }
bool DockPlugin::processEvent(Event *e) { switch (e->type()){ case eEventInit: init(); break; case eEventQuit: if (m_dock){ delete m_dock; m_dock = NULL; } break; case eEventRaiseWindow: { EventRaiseWindow *w = static_cast<EventRaiseWindow*>(e); if (w->widget() == getMainWindow()){ if (m_dock == NULL) init(); if (!getShowMain()) return (void*)1; } break; } case eEventCommandCreate: { EventCommandCreate *ecc = static_cast<EventCommandCreate*>(e); CommandDef *def = ecc->cmd(); if (def->menu_id == MenuMain){ CommandDef d = *def; if (def->flags & COMMAND_IMPORTANT){ if (d.menu_grp == 0) d.menu_grp = 0x1001; }else{ d.menu_grp = 0; } d.menu_id = DockMenu; d.bar_id = 0; EventCommandCreate(&d).process(); } break; } case eEventCheckCommandState: { EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *def = ecs->cmd(); if (def->id == CmdToggle){ def->flags &= ~COMMAND_CHECKED; def->text = isMainShow() ? I18N_NOOP("Hide main window") : I18N_NOOP("Show main window"); return (void*)1; } break; } case eEventCommandExec: { EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *def = ece->cmd(); if (def->id == CmdToggle){ QWidget *main = getMainWindow(); if(!main) return false; if (isMainShow()){ setShowMain(false); main->hide(); }else{ m_inactiveTime = 0; setShowMain(true); raiseWindow(main,getDesktop()); } return (void*)1; } if (def->id == CmdCustomize){ EventMenu(DockMenu, EventMenu::eCustomize).process(); return (void*)1; } if (def->id == CmdQuit) m_bQuit = true; break; } default: break; } return false; }
bool DockPlugin::processEvent(Event *e) { switch (e->type()) { case eEventInit: init(); break; case eEventQuit: if (m_dock){ delete m_dock; m_dock = NULL; } break; case eEventRaiseWindow: { EventRaiseWindow *w = static_cast<EventRaiseWindow*>(e); if (w->widget() == getMainWindow()){ if (!m_dock) init(); if (!value("ShowMain").toBool()) return true; } break; } case eEventCommandCreate: { EventCommandCreate *ecc = static_cast<EventCommandCreate*>(e); CommandDef *def = ecc->cmd(); if (def->menu_id == MenuMain) { CommandDef d = *def; if (def->flags & COMMAND_IMPORTANT) { if (d.menu_grp == 0) d.menu_grp = 0x1001; } else d.menu_grp = 0; d.menu_id = DockMenu; d.bar_id = 0; EventCommandCreate(&d).process(); } break; } case eEventCheckCommandState: { EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *def = ecs->cmd(); if (def->id == CmdToggle) { def->flags &= ~COMMAND_CHECKED; def->text = isMainShow() ? I18N_NOOP("Hide main window") : I18N_NOOP("Show main window"); return true; } break; } case eEventCommandExec: { EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *def = ece->cmd(); if (def->id == CmdToggle) { QWidget *main = getMainWindow(); if(!main) return false; if (isMainShow()) { setValue("ShowMain", false); main->hide(); } else { m_inactiveTime = QDateTime(); setValue("ShowMain", true); raiseWindow(main, value("Desktop").toUInt()); } return true; } if (def->id == CmdCustomize){ EventMenu(DockMenu, EventMenu::eCustomize).process(); return true; } if (def->id == CmdQuit) m_bQuit = true; break; } case eEventPluginLoadConfig: { PropertyHubPtr hub = ProfileManager::instance()->getPropertyHub("dock"); if(!hub.isNull()) setPropertyHub(hub); break; } default: break; } return false; }
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()); } } default: break; } break; } case eEventClientsChanged: setupAccel(); break; case eEventContactClient: { EventContactClient *ecc = static_cast<EventContactClient*>(e); contactChanged(ecc->contact()); break; } case eEventInit: init(); break; case eEventCommandExec: { EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); UserWnd *userWnd = m_tabBar->currentWnd(); if (userWnd && ((unsigned long)(cmd->param) == userWnd->id())){ if (cmd->menu_id == MenuContainerContact){ m_tabBar->raiseTab(cmd->id); return true; } if (cmd->id == CmdClose){ delete userWnd; return true; } if (cmd->id == CmdInfo && cmd->menu_id != MenuContact){ CommandDef c = *cmd; c.menu_id = MenuContact; c.param = (void*)userWnd->id(); EventCommandExec(&c).process(); return true; } } break; } case eEventCheckCommandState: { EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); UserWnd *userWnd = m_tabBar->currentWnd(); if (userWnd && ((unsigned long)(cmd->param) == userWnd->id()) && (cmd->menu_id == MenuContainerContact) && (cmd->id == CmdContainerContacts)){ list<UserWnd*> userWnds = m_tabBar->windows(); CommandDef *cmds = new CommandDef[userWnds.size() + 1]; unsigned n = 0; for (list<UserWnd*>::iterator it = userWnds.begin(); it != userWnds.end(); ++it){ cmds[n].id = (*it)->id(); cmds[n].flags = COMMAND_DEFAULT; cmds[n].text_wrk = (*it)->getName(); cmds[n].icon = (*it)->getIcon(); cmds[n].text = "_"; cmds[n].menu_id = n + 1; if (n < sizeof(accels) / sizeof(const char*)) cmds[n].accel = accels[n]; if (*it == m_tabBar->currentWnd()) cmds[n].flags |= COMMAND_CHECKED; n++; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; return true; } break; } default: break; } return false; }
bool MainWindow::processEvent(Event *e) { switch(e->type()){ case eEventSetMainIcon: { EventSetMainIcon *smi = static_cast<EventSetMainIcon*>(e); m_icon = smi->icon(); setWindowIcon(Icon(m_icon)); break; } case eEventInit: { setTitle(); EventToolbar e(ToolBarMain, this); e.process(); m_bar = e.toolBar(); m_bar->setObjectName("MainToolbar"); this->addToolBar(m_bar); // m_bar->setMaximumHeight(30); // m_bar->setMinimumHeight(30); // FIXME //restoreToolbar(m_bar, CorePlugin::instance()->data.toolBarState); raiseWindow(this); break; } case eEventCommandExec: { EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->id == CmdQuit) quit(); break; } case eEventAddWidget: { EventAddWidget *aw = static_cast<EventAddWidget*>(e); switch(aw->place()) { case EventAddWidget::eMainWindow: addWidget(aw->widget(), aw->down()); break; case EventAddWidget::eStatusWindow: addStatus(aw->widget(), aw->down()); break; default: return false; } return true; } case eEventIconChanged: setWindowIcon(Icon(m_icon)); break; case eEventContact: { EventContact *ec = static_cast<EventContact*>(e); Contact *contact = ec->contact(); if (contact == getContacts()->owner()) setTitle(); break; } default: break; } return false; }
bool HistoryWindow::processEvent(Event *e) { switch(e->type()) { case eEventContact: { EventContact *ec = static_cast<EventContact*>(e); Contact *contact = ec->contact(); if (contact->id() != m_id) break; switch(ec->action()) { case EventContact::eDeleted: QTimer::singleShot(0, this, SLOT(close())); break; case EventContact::eChanged: setName(); break; default: break; } break; } case eEventCheckCommandState: { EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if (cmd->id == CmdHistoryDirection && (unsigned long)(cmd->param) == m_id) { cmd->flags &= ~COMMAND_CHECKED; if (m_bDirection) cmd->flags |= COMMAND_CHECKED; return true; } if (cmd->id != CmdDeleteMessage && cmd->id != CmdCutHistory || cmd->param != m_view || !m_view->currentMessage()) return false; cmd->flags &= ~COMMAND_CHECKED; return true; } case eEventCommandExec: { EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if ((unsigned long)(cmd->param) != m_id) return false; if (cmd->id == CmdHistoryDirection) { bool bDirection = ((cmd->flags & COMMAND_CHECKED) != 0); CorePlugin::instance()->setValue("HistoryDirection", bDirection); if (bDirection != m_bDirection) { m_bDirection = bDirection; m_page = 0; m_states.clear(); fill(); } return true; } if (cmd->id == CmdHistoryNext) { if (m_page + 1 < m_states.size()) { m_page++; fill(); } return true; } if (cmd->id == CmdHistoryPrev) { if (m_page > 0) { m_page--; fill(); } return true; } if (cmd->id == CmdHistorySave) { QString str = QFileDialog::getSaveFileName(this, QString::null, QString::null, i18n("Textfile (*.txt)")); if(!str.isEmpty()) { bool res = true; if (QFile::exists(str)) { QMessageBox mb(i18n("Error"), i18n("File already exists. Overwrite?"), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape); mb.setButtonText(QMessageBox::Yes, i18n("&Overwrite")); mb.setButtonText(QMessageBox::No, i18n("&Append")); switch (mb.exec()) { case QMessageBox::Yes: res = History::save(m_id, str, false); break; case QMessageBox::No: res = History::save(m_id, str, true); break; case QMessageBox::Cancel: break; } }else res = History::save(m_id, str); if (!res) QMessageBox::critical(this, i18n("Error"), i18n("Save failed"), QMessageBox::Ok, Qt::NoButton, Qt::NoButton); } return true; } if (cmd->id == CmdHistoryFind) { m_filter.clear(); if (cmd->flags & COMMAND_CHECKED) { Command cmd; cmd->id = CmdHistoryFind; cmd->param = (void*)m_id; EventCommandWidget eWidget(cmd); eWidget.process(); CToolCombo *cmbFind = qobject_cast<CToolCombo*>(eWidget.widget()); QString text = cmbFind->lineEdit()->text(); if (cmbFind && !text.isEmpty()) { addHistory(text); m_filter = text; } } m_page = 0; m_states.clear(); m_view->setSelect(m_filter); fill(); return true; } break; } default: break; } return false; }
bool FilterPlugin::processEvent(Event *e) { switch (e->type()) { case eEventContact: { EventContact *ec = static_cast<EventContact*>(e); if(ec->action() != EventContact::eChanged) break; Contact *contact = ec->contact(); if (contact->getGroup()){ Command cmd; cmd->id = CmdIgnore; cmd->flags = BTN_HIDE; cmd->param = (void*)(contact->id()); EventCommandShow(cmd).process(); } break; } case eEventPluginLoadConfig: { setPropertyHub( ProfileManager::instance()->getPropertyHub("filter") ); break; } case eEventMessageReceived: { EventMessage *em = static_cast<EventMessage*>(e); Message *msg = em->msg(); if (!msg || (msg->type() == MessageStatus)) return false; Contact *contact = getContacts()->contact(msg->contact()); PropertyHubPtr data = contact->getUserData("filter"); // check if we accept only from users on the list if (((contact == NULL) || contact->getFlags() & CONTACT_TEMPORARY) && ((value("FromList").toBool() && msg->type() != MessageAuthRequest && msg->type() != MessageAuthGranted && msg->type() != MessageAuthRefused) || (value("AuthFromList").toBool() && msg->type() <= MessageContacts))) { delete msg; delete contact; return msg; } if (!contact) return false; // check if the user is a ignored user if (contact->getIgnore()){ delete msg; return true; } // get filter-data if (data && !data->value("SpamList").toString().isEmpty() && (!contact || (contact->getFlags() & CONTACT_TEMPORARY) )) { if (checkSpam(msg->getPlainText(), data->value("SpamList").toString())){ delete msg; return true; } } break; } case eEventCheckCommandState: { EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if (cmd->id == CmdIgnore){ cmd->flags &= ~BTN_HIDE; Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact && contact->getGroup()) cmd->flags |= BTN_HIDE; return true; } if (cmd->id == CmdIgnoreText){ cmd->flags &= ~COMMAND_CHECKED; if (cmd->menu_id == MenuMsgView){ MsgViewBase *edit = (MsgViewBase*)(cmd->param); if (edit->textCursor().hasSelection()) return true; } else /*if (cmd->menu_id == MenuTextEdit){ TextEdit *edit = ((MsgEdit*)(cmd->param))->m_edit; if (edit->textCursor().hasSelection()) return true; }*/ //Fixme Block (crashing on rightclick in msgedit from container) return false; } if (cmd->menu_id == MenuContactGroup){ if (cmd->id == CmdIgnoreList){ Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact == NULL) return false; cmd->flags &= COMMAND_CHECKED; if (contact->getIgnore()) cmd->flags |= COMMAND_CHECKED; return true; } } break; } case eEventCommandExec: { EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->id == CmdIgnore){ Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact){ QString text = i18n("Add %1 to ignore list?") .arg(contact->getName()); Command cmd; cmd->id = CmdIgnore; cmd->param = (void*)(contact->id()); EventCommandWidget eWidget(cmd); eWidget.process(); QWidget *w = eWidget.widget(); BalloonMsg::ask((void*)(contact->id()), text, w, SLOT(addToIgnore(void*)), NULL, NULL, this); } return true; } if (cmd->id == CmdIgnoreText){ QString text; unsigned id = 0; if (cmd->menu_id == MenuMsgView){ MsgViewBase *view = (MsgViewBase*)(cmd->param); if (view->textCursor().hasSelection()){ text = view->textCursor().selectedText(); text = unquoteText(text); id = view->m_id; } }else if (cmd->menu_id == MenuTextEdit){ MsgEdit *medit = (MsgEdit*)(cmd->param); TextEdit *edit = medit->m_edit; if (edit->textCursor().hasSelection()){ text = edit->textCursor().selectedText(); text = unquoteText(text); id = medit->m_userWnd->id(); } } Contact *contact = getContacts()->contact(id); PropertyHubPtr data = contact->getUserData("filter"); QString s = data->value("SpamList").toString(); while (!text.isEmpty()){ QString line = getToken(text, '\n'); line = line.remove('\r'); if (line.isEmpty()) continue; bool bSpace = false; for (int i = 0; i < (int)(line.length()); i++) if (line[i] == ' '){ bSpace = true; break; } if (bSpace) line = '\"' + line + '\"'; if (!s.isEmpty()) s += ' '; s += line; } data->setValue("SpamList", s); return false; } if (cmd->menu_id == MenuContactGroup) { if (cmd->id == CmdIgnoreList) { Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (!contact) return false; contact->setIgnore((cmd->flags & COMMAND_CHECKED) == 0); EventContact(contact, EventContact::eChanged).process(); return true; } } break; } default: break; }
bool TextEdit::processEvent(Event *e) { if (m_param == NULL) return false; if (e->type() == eEventCheckCommandState){ EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if (cmd->param != m_param) return false; switch (cmd->id){ case CmdBgColor: case CmdFgColor: case CmdBold: case CmdItalic: case CmdUnderline: case CmdFont: if (!isReadOnly()){ cmd->flags &= ~BTN_HIDE; }else{ cmd->flags |= BTN_HIDE; } return true; default: break; } } else if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->param != m_param) return false; switch (cmd->id){ case CmdBgColor:{ EventCommandWidget eWidget(cmd); eWidget.process(); CToolButton *btnBg = dynamic_cast<CToolButton*>(eWidget.widget()); if (btnBg){ ColorPopup *popup = new ColorPopup(this, background()); popup->move(CToolButton::popupPos(btnBg, popup)); connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(bgColorChanged(QColor))); popup->show(); } return true; } case CmdFgColor:{ EventCommandWidget eWidget(cmd); eWidget.process(); CToolButton *btnFg = dynamic_cast<CToolButton*>(eWidget.widget()); if (btnFg){ ColorPopup *popup = new ColorPopup(this, foreground()); popup->move(CToolButton::popupPos(btnFg, popup)); connect(popup, SIGNAL(colorChanged(QColor)), this, SLOT(fgColorChanged(QColor))); popup->show(); } return true; } case CmdBold: if (!m_bChanged){ m_bSelected = true; setFontWeight((cmd->flags & COMMAND_CHECKED) != 0 ? QFont::Bold : QFont::Normal); } return true; case CmdItalic: if (!m_bChanged){ m_bSelected = true; setFontItalic((cmd->flags & COMMAND_CHECKED) != 0); } return true; case CmdUnderline: if (!m_bChanged){ m_bSelected = true; setFontUnderline((cmd->flags & COMMAND_CHECKED) != 0); } return true; case CmdFont:{ #ifdef USE_KDE QFont f = font(); if (KFontDialog::getFont(f, false, topLevelWidget()) != KFontDialog::Accepted) break; #else bool ok = false; QFont f = QFontDialog::getFont(&ok, font(), topLevelWidget()); if (!ok) break; #endif m_bSelected = true; setCurrentFont(f); break; } default: return false; } } return false; }
bool SearchDialog::processEvent(Event *e) { switch (e->type()){ case eEventClientsChanged: case eEventClientChanged: fillClients(); break; case eEventCommandExec:{ if (m_result != m_currentResult) return false; EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->menu_id == MenuSearchGroups){ Group *grp = getContacts()->group(cmd->id - CmdContactGroup); if (grp){ Contact *contact = NULL; if ((QWidget*)(cmd->param) == m_search->btnSearch){ if (m_current){ connect(this, SIGNAL(createContact(unsigned,SIM::Contact*&)), m_current, SLOT(createContact(unsigned,SIM::Contact*&))); emit createContact(CONTACT_TEMP, contact); disconnect(this, SIGNAL(createContact(unsigned,SIM::Contact*&)), m_current, SLOT(createContact(unsigned,SIM::Contact*&))); } }else{ contact = createContact(CONTACT_TEMP); } if (contact){ if ((contact->getFlags() & CONTACT_TEMP) == 0){ QString err = i18n("%1 already in contact list") .arg(contact->getName()); if ((QWidget*)(cmd->param) == m_search->btnAdd){ BalloonMsg::message(err, m_search->btnAdd); }else if ((QWidget*)(cmd->param) == m_search->btnSearch){ BalloonMsg::message(err, m_search->btnSearch); }else{ BalloonMsg::message(err, m_result); } return true; } contact->setFlags(contact->getFlags() & ~CONTACT_TEMP); contact->setGroup(grp->id()); EventContact(contact, EventContact::eChanged).process(); } } return true; } if (cmd->id == CmdSearchInfo){ Contact *contact = createContact(CONTACT_TEMP); if (contact == NULL) return true; Command cmd; cmd->id = CmdInfo; cmd->menu_id = MenuContact; cmd->param = (void*)(contact->id()); CorePlugin::instance()->showInfo(cmd); return true; } if (cmd->id == CmdSearchMsg){ Contact *contact = createContact(CONTACT_TEMP); if (contact == NULL) return true; Message *m = new Message(MessageGeneric); m->setContact(contact->id()); EventOpenMessage(m).process(); delete m; } break; }
bool SpellHighlighter::processEvent(SIM::Event *e) { if (e->type() == SIM::eEventCheckCommandState){ SIM::EventCheckCommandState *ecs = static_cast<SIM::EventCheckCommandState*>(e); SIM::CommandDef *cmd = ecs->cmd(); if (cmd->id == m_plugin->CmdSpell){ MsgEdit *m_edit = (MsgEdit*)(cmd->param); if (m_edit->m_edit != textEdit()) return false; //m_index = textEdit()->charAt(static_cast<TextEdit*>(textEdit())->m_popupPos, &m_parag); //m_pos = 0; int from = textEdit()->charAt(static_cast<TextEdit*>(textEdit())->m_popupPos, &m_parag); int to = from; int step =0; QString word; int sel_paraFrom; int sel_indexFrom; int sel_paraTo; int sel_indexTo; textEdit()->getSelection (&sel_paraFrom, &sel_indexFrom, &sel_paraTo, &sel_indexTo); int cursor_para,cursor_index; textEdit()->getCursorPosition(&cursor_para,&cursor_index); while(1) { /* Now we are spreading aroud the click position in order to find word's boudaries step = 0 -- we are moving left boundary to the left step = 1 -- we are moving right boundary to the right step = 2 -- all boundaries are found, we are just remembering the word... */ textEdit()->setSelection(m_parag,from,m_parag,to); word = textEdit()->selectedText(); // SIM::log(SIM::L_DEBUG, "%i %i %i %i %s ",step,from,to,textEdit()->paragraphLength(m_parag),word.utf8().data()); // SIM::log(SIM::L_DEBUG, "%s",word.utf8().data()); word.replace(QRegExp("^\\<\\!\\-\\-StartFragment\\-\\-\\>"),""); word.replace(QRegExp("^\\<p\\>"),""); word.replace(QRegExp("^\\<span [^\\>]*\\>\\<\\/span\\>"),""); // Ignore empty <span></span> at the beggining of the word word.replace(QRegExp("^\\<span [^\\>]*\\>"),""); // SIM::log(SIM::L_DEBUG, "%i %i %i %i |%s|\n",step,from,to,textEdit()->paragraphLength(m_parag),word.utf8().data()); if (step>=2) break; if ((word.find(QRegExp("\\<span ")) != -1) || // Stop expanding word's borders if we've crossed the change of the color (or other style) (word.find(QRegExp("\\<\\/span\\>")) != -1)|| (word[0].isPunct() || word[0].isSpace()) || // Stop expanding word's borders if we've crossed the space or puct char (word[word.length()-1].isPunct() || word[word.length()-1].isSpace()) ) { if (step==0) from++; //go back to the position when everything were ok if (step==1) to--; step++; // SIM::log(SIM::L_DEBUG, "Swthc to step= %i (%i %i)",step,from,to); continue; } if ( ((step==0) && (from<=0)) || ((step==1) && (to>=textEdit()->paragraphLength(m_parag))) ) { step++; continue; } if (step==0) from--; if (step==1) to++; } textEdit()->setCursorPosition(cursor_para,cursor_index); textEdit()->setSelection (sel_paraFrom, sel_indexFrom, sel_paraTo, sel_indexTo); /* m_bError = false; m_bInError = false; m_curStart = 0; m_word = QString::null; m_curWord = QString::null; while (!m_fonts.empty()) m_fonts.pop(); m_bCheck = true; parse(textEdit()->text(m_paragraph)); flushText(); m_curText = QString::null; m_bCheck = false; */ // if (!m_bInError) // return false; if (m_plugin->checkWord(word)) return false; m_word = word; m_start_word = from; m_sug = m_plugin->suggestions(m_word); // SIM::CommandDef *cmds = new SIM::CommandDef[m_sug.count() + 3]; // +3 instead of +1 were for Add and Ignore commands SIM::CommandDef *cmds = new SIM::CommandDef[m_sug.count() + 1]; unsigned i = 0; for (QStringList::Iterator it = m_sug.begin(); it != m_sug.end(); ++it, i++){ cmds[i].id = m_plugin->CmdSpell + i /*+ 2*/; // +2 were for Add and Ignore commands cmds[i].text = "_"; cmds[i].text_wrk = (*it); if (i >= 10){ i++; break; } } cmds[i].text = QString::null; // Empty text marks end of command list for COMMAND::RECURSIVE // Add and Ignore seems never really worked, at least do not saves this to config file (shaplov): /* cmds[i].id = m_plugin->CmdSpell; cmds[i].text = "_"; cmds[i].text_wrk = i18n("Add '%1'").arg(m_word);*/ /* i++; cmds[i].id = m_plugin->CmdSpell + 1; cmds[i].text = "_"; cmds[i].text_wrk = i18n("Ignore '%1'").arg(m_word); */ cmd->param = cmds; cmd->flags |= SIM::COMMAND_RECURSIVE; return true; } } else if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->id == CmdSend){ if (((MsgEdit*)(cmd->param))->m_edit == textEdit()){ // m_bDisable = true; // rehighlight(); // QTimer::singleShot(50, this, SLOT(restore())); removeHighlight(); } } if ((cmd->id >= m_plugin->CmdSpell) && (cmd->id < m_plugin->CmdSpell + m_sug.count() + 1)){ MsgEdit *m_edit = (MsgEdit*)(cmd->param); if (m_edit->m_edit != textEdit()) return false; if (0 && cmd->id == m_plugin->CmdSpell){ // Interlas of Add command. /* m_plugin->add(m_word); MAP_BOOL::iterator it = m_words.find(SIM::my_string(m_word)); if (it == m_words.end()){ m_words.insert(MAP_BOOL::value_type(SIM::my_string(m_word), true)); }else{ if ((*it).second) return false; (*it).second = true; } // m_bDirty = true; // QTimer::singleShot(300, this, SLOT(reformat())); */ }else if (0 && cmd->id == m_plugin->CmdSpell + 1){ // Internals of Ignore command /* MAP_BOOL::iterator it = m_plugin->m_ignore.find(SIM::my_string(m_word)); if (it == m_plugin->m_ignore.end()) m_plugin->m_ignore.insert(MAP_BOOL::value_type(SIM::my_string(m_word), true)); it = m_words.find(SIM::my_string(m_word)); if (it == m_words.end()){ m_words.insert(MAP_BOOL::value_type(SIM::my_string(m_word), true)); }else{ if ((*it).second) return false; (*it).second = true; } // m_bDirty = true; // QTimer::singleShot(300, this, SLOT(reformat())); */ }else{ unsigned n = cmd->id - m_plugin->CmdSpell /*- 2*/; // -2 were because of Add and Ignore commands QString word = m_sug[n]; textEdit()->setSelection(m_parag, m_start_word, m_parag, m_start_word + m_word.length(), 0); textEdit()->insert(word, true, true, true); } } } return false; }
bool MsgEdit::processEvent(Event *e) { switch (e->type()) { case eEventContact: { EventContact *ec = static_cast<EventContact*>(e); if (ec->contact()->id() != m_userWnd->m_id) break; adjustType(); break; } case eEventClientChanged: { adjustType(); break; } case eEventMessageReceived: { EventMessage *em = static_cast<EventMessage*>(e); Message *msg = em->msg(); if (msg->getFlags() & MESSAGE_NOVIEW) return false; if ((msg->contact() == m_userWnd->id()) && (msg->type() != MessageStatus)){ if (CorePlugin::instance()->getContainerMode()){ bool bSetFocus = false; if (topLevelWidget() && topLevelWidget()->inherits("Container")){ Container *container = static_cast<Container*>(topLevelWidget()); if (container->wnd() == m_userWnd) bSetFocus = true; } setMessage(msg, bSetFocus); }else{ if (m_edit->isReadOnly()) QTimer::singleShot(0, this, SLOT(setupNext())); } } break; } case eEventRealSendMessage: { EventRealSendMessage *ersm = static_cast<EventRealSendMessage*>(e); if (ersm->edit() == this){ sendMessage(ersm->msg()); return true; } break; } case eEventCheckCommandState: { EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if ((cmd->param == (TextEdit*)m_edit) && (cmd->id == CmdTranslit)){ Contact *contact = getContacts()->contact(m_userWnd->id()); if (contact){ SIM::PropertyHubPtr data = contact->getUserData("translit"); if(!data.isNull()) { cmd->flags &= ~COMMAND_CHECKED; if (data->value("Translit").toBool()) cmd->flags |= COMMAND_CHECKED; // FIXME: return true; missing here? } } return false; } if ((cmd->menu_id != MenuTextEdit) || (cmd->param != (TextEdit*)m_edit)) return false; cmd->flags &= ~(COMMAND_CHECKED | COMMAND_DISABLED); switch (cmd->id){ case CmdUndo: if (m_edit->isReadOnly()) return false; if (!m_edit->document()->isUndoAvailable()) cmd->flags |= COMMAND_DISABLED; return true; case CmdRedo: if (m_edit->isReadOnly()) return false; if (!m_edit->document()->isRedoAvailable()) cmd->flags |= COMMAND_DISABLED; return true; case CmdCut: if (m_edit->isReadOnly()) return false; case CmdCopy: if (m_edit->textCursor().selectedText().isEmpty()) cmd->flags |= COMMAND_DISABLED; return true; case CmdPaste: if (m_edit->isReadOnly()) return false; if (QApplication::clipboard()->text().isEmpty()) cmd->flags |= COMMAND_DISABLED; return true; case CmdClear: if (m_edit->isReadOnly()) return false; case CmdSelectAll: if (m_edit->toPlainText().isEmpty()) cmd->flags |= COMMAND_DISABLED; return true; } break; } case eEventCommandExec: { EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); #if defined(USE_KDE) #if KDE_IS_VERSION(3,2,0) if (cmd->id == CmdEnableSpell){ m_edit->setCheckSpellingEnabled(cmd->flags & COMMAND_CHECKED); return false; } else if ((cmd->id == CmdSpell) && (cmd->param == this)){ m_edit->checkSpelling(); return true; } else #endif #endif if ((cmd->id == CmdSmile) && (cmd->param == this)){ EventCommandWidget eWidget(cmd); eWidget.process(); QToolButton *btnSmile = qobject_cast<QToolButton*>(eWidget.widget()); if (btnSmile){ SmilePopup *popup = new SmilePopup(this); connect(popup, SIGNAL(insert(const QString &)), this, SLOT(insertSmile(const QString &))); QPoint p = CToolButton::popupPos(btnSmile, popup); popup->move(p); popup->show(); } return true; } else if ((cmd->id == CmdTranslit) && (cmd->param == this)){ Contact *contact = getContacts()->contact(m_userWnd->id()); if (contact){ SIM::PropertyHubPtr data = contact->getUserData("translit", true); data->setValue("Translit", ((cmd->flags & COMMAND_CHECKED) != 0)); } return true; } else if ((cmd->id == CmdMultiply) && (cmd->param == this)){ m_userWnd->showListView((cmd->flags & COMMAND_CHECKED) != 0); return true; } else if ((cmd->bar_id == ToolBarMsgEdit) && m_edit->isReadOnly() && (cmd->param == this)){ switch (cmd->id){ case CmdMsgAnswer:{ Message *msg = new Message(MessageGeneric); msg->setContact(m_userWnd->id()); msg->setClient(m_client); EventOpenMessage(msg).process(); delete msg; } case CmdNextMessage: QTimer::singleShot(0, this, SLOT(goNext())); break; } } else if ((cmd->menu_id != MenuTextEdit) || (cmd->param != this)) return false; switch (cmd->id){ case CmdUndo: m_edit->undo(); return true; case CmdRedo: m_edit->redo(); return true; case CmdCut: m_edit->cut(); return true; case CmdCopy: m_edit->copy(); return true; case CmdPaste: m_edit->paste(); return true; case CmdClear: m_edit->clear(); return true; case CmdSelectAll: m_edit->selectAll(); return true; } break; }
bool ActionPlugin::processEvent(Event *e) { switch (e->type() ) { case eEventCheckCommandState: { EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if ((cmd->id == CmdAction) && (cmd->menu_id == MenuContact)){ Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); if (contact == NULL) return false; PropertyHubPtr data = contact->getUserData("action"); if (!data || data->value("NMenu").toInt() == 0) return false; CommandDef *cmds = new CommandDef[data->value("NMenu").toInt() + 1]; unsigned n = 0; for (int i = 0; i < data->value("NMenu").toInt(); i++){ QString str = data->stringMapValue("Menu", i +1); QString item = getToken(str, ';'); int pos = item.indexOf("&IP;"); if (pos >= 0) { EventGetContactIP e(contact); if (!e.process()) continue; } pos = item.indexOf("&Mail;"); if (pos >= 0) { if (contact->getEMails().isEmpty()) continue; } pos = item.indexOf("&Phone;"); if (pos >= 0) { if (contact->getPhones().isEmpty()) continue; } cmds[n].id = CmdAction + i; cmds[n].text = "_"; cmds[n].text_wrk = item; n++; } if (n == 0) { delete[] cmds; return false; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; return true; } break; } case eEventCommandExec: { EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if ((cmd->menu_id == MenuContact) && (cmd->id >= CmdAction)){ unsigned n = cmd->id - CmdAction; Contact *contact = getContacts()->contact((unsigned long)(cmd->param)); PropertyHubPtr data = contact->getUserData("action"); if (!contact || !data || n >= data->value("NMenu").toLongLong()) return false; QString str = data->stringMapValue("Menu", n +1); getToken(str, ';'); EventTemplate::TemplateExpand t; t.tmpl = str; t.contact = contact; t.receiver = this; t.param = NULL; EventTemplateExpand(&t).process(); return true; } break; } case eEventContact: { EventContact *ec = static_cast<EventContact*>(e); if(ec->action() != EventContact::eOnline) break; Contact *contact = ec->contact(); if (contact == NULL) return false; PropertyHubPtr data = contact->getUserData("action"); if (!data || data->value("OnLine").toString().isEmpty()) return false; EventTemplate::TemplateExpand t; t.tmpl = data->value("OnLine").toString(); t.contact = contact; t.receiver = this; t.param = NULL; EventTemplateExpand(&t).process(); return true; } case eEventMessageReceived: { EventMessage *em = static_cast<EventMessage*>(e); Message *msg = em->msg(); Contact *contact = getContacts()->contact(msg->contact()); if (contact == NULL) return false; PropertyHubPtr data = contact->getUserData("action"); if (!data) return false; if (msg->type() == MessageStatus){ if (data->value("Status").toString().isEmpty()) return false; EventTemplate::TemplateExpand t; t.tmpl = data->value("Status").toString(); t.contact = contact; t.receiver = this; t.param = NULL; EventTemplateExpand(&t).process(); return false; } QString cmd = data->stringMapValue("Message",msg->baseType()); if (cmd.isEmpty()) return false; EventTemplate::TemplateExpand t; t.tmpl = cmd; t.contact = contact; t.receiver = this; t.param = msg; EventTemplateExpand(&t).process(); return true; } case eEventTemplateExpanded: { EventTemplate *et = static_cast<EventTemplate*>(e); EventTemplate::TemplateExpand *t = et->templateExpand(); Message *msg = (Message*)(t->param); QProcess *proc; if (msg){ QString text = t->tmpl + unquoteText(msg->presentation()); proc = new MsgProcess(msg, this); connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(msg_ready(int, QProcess::ExitStatus))); proc->start(text); }else{ proc = new QProcess(this); connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(ready(int, QProcess::ExitStatus))); proc->start(t->tmpl); } break; } default: break; }
bool MsgFile::processEvent(Event *e) { if (e->type() == eEventCheckCommandState){ EventCheckCommandState *ecs = static_cast<EventCheckCommandState*>(e); CommandDef *cmd = ecs->cmd(); if (cmd->param == m_edit){ unsigned id = cmd->bar_grp; if ((id >= MIN_INPUT_BAR_ID) && (id < MAX_INPUT_BAR_ID)){ cmd->flags |= BTN_HIDE; if (cmd->id == CmdFileName) cmd->flags &= ~BTN_HIDE; return true; } switch (cmd->id){ case CmdTranslit: case CmdSmile: case CmdSend: case CmdSendClose: e->process(this); cmd->flags &= ~BTN_HIDE; return true; case CmdNextMessage: case CmdMsgAnswer: e->process(this); cmd->flags |= BTN_HIDE; return true; } } } else if (e->type() == eEventCommandExec){ EventCommandExec *ece = static_cast<EventCommandExec*>(e); CommandDef *cmd = ece->cmd(); if (cmd->param == m_edit){ if (cmd->id == CmdSend){ Command cmd; cmd->id = CmdFileName; cmd->param = m_edit; EventCommandWidget eWidget(cmd); eWidget.process(); CToolEdit *edtName = qobject_cast<CToolEdit*>(eWidget.widget()); if (edtName == NULL) return false; QString msgText = m_edit->m_edit->toPlainText(); QString file = edtName->text(); QStringList files; QString f; for (int i = 0; i < (int)file.length(); i++){ if (file[i] == '\"'){ f = f.trimmed(); if (!f.isEmpty()) files.append(f); f = QString::null; for (i++; i < (int)file.length(); i++){ if (file[i] == '\"') break; f += file[i]; } f = f.trimmed(); if (!f.isEmpty()) files.append(f); f = QString::null; continue; } f += file[i]; } f = f.trimmed(); if (!f.isEmpty()) files.append(f); file = QString::null; for (QStringList::Iterator it = files.begin(); it != files.end(); ++it){ if (!file.isEmpty()) file += ';'; file += quoteChars(*it, ";"); } if (!file.isEmpty()){ FileMessage *msg = new FileMessage; msg->setText(msgText); msg->setFile(file); msg->setContact(m_edit->m_userWnd->id()); msg->setClient(m_client); m_edit->sendMessage(msg); } return true; } if (cmd->id == CmdFileName){ selectFile(); return true; } } } return false; }