From dacd393fefeabafd1306533dd6c5a56e0ab347cc Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 27 Feb 2011 18:48:35 +0100 Subject: Initial commit --- TPluginParent.cpp | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 TPluginParent.cpp (limited to 'TPluginParent.cpp') diff --git a/TPluginParent.cpp b/TPluginParent.cpp new file mode 100644 index 0000000..a19f15b --- /dev/null +++ b/TPluginParent.cpp @@ -0,0 +1,101 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +#include "TPluginParent.h" +#include "TConnection.h" + +extern list plugins; + +void TPluginParent::hiddenaddplugincontext(int flags,int csize) +{ + cout << "adding a new plugincontext..." << endl; + + plugincontext temp; + char* cptr; + temp.flags=flags; + + if (csize>0) + try + { + cptr=new char[csize]; + for (int i=0; i (cptr); + + contexts.push_back(temp); //pushen... und fertig :) +} + + +void TPluginParent::removeplugincontext(int x) +{ + cout << "removing " << x << "th plugincontext" << endl; + list::iterator temp; + temp=contexts.begin(); + advance(temp,x); + + list ::iterator it=plugins.begin(); + advance(it,x); + ircmessage curr_msg; + curr_msg.origin=""; curr_msg.content=""; curr_msg.command=""; curr_msg.params=""; + if (temp->flags & PFLAGS_EXEC_ONREMOVE) + (*it)->execute( &(*temp) , curr_msg, this, PFLAGS_EXEC_ONREMOVE); + + if (temp->data) + delete [] static_cast (temp->data); + contexts.erase(temp); +} + +void TPluginParent::zerocurrmsg() +{ + //curr_msg.origin=""; curr_msg.content=""; curr_msg.params=""; curr_msg.command=""; + msg_for_us=false; +} + +TPluginParent::~TPluginParent() +{ + cout << "destroying all contexts for object..." << endl; + list::iterator it2=plugins.begin(); + + for (list::iterator it=contexts.begin(); it!=contexts.end(); it++) + { + if (it->data) + delete [] static_cast (it->data); + + it2++; + } +} + +void TPluginParent::deliver_message(string subject, void *data) +{ + list::iterator it2=plugins.begin(); + for (list::iterator it=contexts.begin(); it!=contexts.end(); it++) + { + if (it->flags & PFLAGS_RECV_MESSAGES) + (*it2)->push_message( &(*it) , subject, data, this); + + it2++; + } +} -- cgit v1.2.1