summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/kopetemessageevent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kopete/libkopete/kopetemessageevent.cpp')
-rw-r--r--kopete/libkopete/kopetemessageevent.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/kopete/libkopete/kopetemessageevent.cpp b/kopete/libkopete/kopetemessageevent.cpp
new file mode 100644
index 00000000..fb129837
--- /dev/null
+++ b/kopete/libkopete/kopetemessageevent.cpp
@@ -0,0 +1,105 @@
+/*
+ kopetemessageevent.cpp - Kopete Message Event
+
+ Copyright (c) 2003 by Olivier Goffart <ogoffart @ kde.org>
+ Copyright (c) 2002 by Duncan Mac-Vicar Prett <[email protected]>
+ Copyright (c) 2002 by Hendrik vom Lehn <[email protected]>
+ Copyright (c) 2002-2003 by Martijn Klingens <[email protected]>
+ Copyright (c) 2004 by Richard Smith <[email protected]>
+
+ Kopete (c) 2002-2003 by the Kopete developers <[email protected]>
+
+ *************************************************************************
+ * *
+ * 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 <kdebug.h>
+
+#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, QObject *parent, const char *name )
+ : QObject(parent,name), d( new Private )
+{
+ d->message = m;
+ d->state = Nothing;
+ const Contact *c=m.from();
+ if(c)
+ connect(c,SIGNAL(contactDestroyed( Kopete::Contact* )),this,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"
+
+// vim: set noet ts=4 sts=4 sw=4:
+