diff --git a/src/psiaccount.cpp b/src/psiaccount.cpp index 98aa922..945d411 100644 --- a/src/psiaccount.cpp +++ b/src/psiaccount.cpp @@ -1286,6 +1286,10 @@ void PsiAccount::login() // disconnect or stop reconnecting void PsiAccount::logout(bool fast, const Status &s) { +#ifdef PSI_PLUGINS + PluginManager::instance()->logout(this); +#endif + if(!isActive()) return; @@ -1887,6 +1891,10 @@ void PsiAccount::client_resourceAvailable(const Jid &j, const Resource &r) UserResourceList::Iterator rit = u->userResourceList().find(j.resource()); bool found = (rit == u->userResourceList().end()) ? false: true; if(!found) { +#ifdef PSI_PLUGINS + PluginManager::instance()->contactOnline(this, j.node() + "@" + j.domain()); +#endif + popupType = PopupOnline; UserResource ur(r); @@ -2043,6 +2051,10 @@ void PsiAccount::client_resourceUnavailable(const Jid &j, const Resource &r) PsiGrowlNotifier::instance()->popup(this, PsiPopup::AlertOffline, j, r, u); #endif } +#ifdef PSI_PLUGINS + PluginManager::instance()->contactOffline(this, j.node() + "@" + j.domain()); +#endif + } void PsiAccount::client_presenceError(const Jid &j, int, const QString &str) @@ -3001,7 +3013,6 @@ ChatDlg *PsiAccount::ensureChatDlg(const Jid &j) if(!pp.isNull()) p = pp; #ifdef __GNUC__ -#warning "Removed reparenting call from qwextend" #endif //reparent_good(window, 0, false); if(!p.isNull()) @@ -3638,6 +3649,25 @@ void PsiAccount::dj_sendMessage(const Message &m, bool log) } } +#ifdef PSI_PLUGINS + if (nm.type() != "groupchat" && !nm.body().isEmpty()) + { + QString body = nm.body(); + QString subject = nm.subject(); + + PluginManager::instance()->processOutgoingMessage(this, nm.to().full(), + body, subject); + if (body != nm.body()) + { + nm.setBody(body); + } + if (subject != nm.subject()) + { + nm.setSubject(subject); + } + } +#endif + d->client->sendMessage(nm); // only toggle if not an invite or body is not empty @@ -3913,6 +3943,53 @@ void PsiAccount::handleEvent(PsiEvent* e, ActivationType activationType) } //FIXME(KIS): must now cause the event to be recreated from this xml or such. Horrid. #endif + +#ifdef PSI_PLUGINS + if(e->type() == PsiEvent::Message) + { + MessageEvent* messageEvent = (MessageEvent*) e; + Message message = messageEvent->message(); + + if (message.type() != "groupchat") + { + + bool discard = false; + if (message.containsHTML() && !message.html().text().isEmpty()) + { + HTMLElement htmlElement = message.html(); + QDomElement htmlBody = htmlElement.body(); + QString subject = message.subject(); + + discard = PluginManager::instance()->processMessage(this, e->from().full(), + htmlBody, subject); + htmlElement.setBody(htmlBody); + message.setHTML(htmlElement, message.lang()); + message.setBody(htmlElement.text()); + message.setSubject(subject); + } + else if (!message.body().isEmpty()) + { + QString body = message.body(); + QString subject = message.subject(); + + discard = PluginManager::instance()->processMessage(this, e->from().full(), + body, subject); + message.setBody(body); + message.setSubject(subject); + } + + if (discard) + { + delete e; + return; + } + + messageEvent->setMessage(message); + } + } +#endif + + if(d->acc.opt_log && activationType != FromXml) { if(e->type() == PsiEvent::Message || e->type() == PsiEvent::Auth) { @@ -3926,20 +4003,6 @@ void PsiAccount::handleEvent(PsiEvent* e, ActivationType activationType) MessageEvent *me = (MessageEvent *)e; const Message &m = me->message(); -#ifdef PSI_PLUGINS - //TODO(mck): clean up - //UserListItem *ulItem=NULL; - //if ( !ul.isEmpty() ) - // ulItem=ul.first(); - if (PluginManager::instance()->processMessage(this, e->from().full(), m.body(), m.subject())) { - delete e; - return; - } - //PluginManager::instance()->message(this,e->from(),ulItem,((MessageEvent*)e)->message().body()); -#endif - - - // Pass message events to chat window if ((m.containsEvents() || m.chatState() != StateNone) && m.body().isEmpty()) { if (PsiOptions::instance()->getOption("options.messages.send-composing-events").toBool()) {