/* kopetemessageevent.cpp - Kopete Message Event Copyright (c) 2003 by Olivier Goffart Copyright (c) 2002 by Duncan Mac-Vicar Prett Copyright (c) 2002 by Hendrik vom Lehn Copyright (c) 2002-2003 by Martijn Klingens Copyright (c) 2004 by Richard Smith Kopete (c) 2002-2003 by the Kopete developers ************************************************************************* * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * ************************************************************************* */ #include #include "kopetemessageevent.h" #include "kopetemetacontact.h" #include "kopetecontactlist.h" #include "kopetecontact.h" #include "kopeteprefs.h" namespace Kopete { class MessageEvent::Private { public: Kopete::Message message; EventState state; }; MessageEvent::MessageEvent( const Message& m, TQObject *parent, const char *name ) : TQObject(parent,name), d( new Private ) { d->message = m; d->state = Nothing; const Contact *c=m.from(); if(c) connect(c,TQT_SIGNAL(contactDestroyed( Kopete::Contact* )),this,TQT_SLOT(discard())); } MessageEvent::~MessageEvent() { kdDebug(14010) << k_funcinfo << endl; emit done(this); delete d; } Kopete::Message MessageEvent::message() { return d->message; } void MessageEvent::setMessage( const Kopete::Message &message ) { d->message = message; } MessageEvent::EventState MessageEvent::state() { return d->state; } void MessageEvent::apply() { kdDebug(14010) << k_funcinfo << endl; d->state = Applied; deleteLater(); } void MessageEvent::ignore() { // FIXME: this should be done by the contact list for itself. if( d->message.from()->metaContact() && d->message.from()->metaContact()->isTemporary() && KopetePrefs::prefs()->balloonNotifyIgnoreClosesChatView() ) ContactList::self()->removeMetaContact( d->message.from()->metaContact() ); d->state = Ignored; deleteLater(); } void MessageEvent::accept() { emit accepted(this); } void MessageEvent::discard() { emit discarded(this); delete this; } } #include "kopetemessageevent.moc"