blob: 81f42476088495e0f1ad3489a1e6162802e9b113 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#include <ctime>
#include <list>
#include <string>
#include <fstream>
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <netdb.h>
#include <cstring>
#include <dlfcn.h>
using namespace std;
#include "TPluginParent.h"
#include "TConnection.h"
#include "myfuncs.h"
extern list<TPlugin*> 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<csize; i++) cptr[i]=0; //context nullen
}
catch (...)
{
cout << "PANIC: unable to create context data!" << endl;
cout << "HINT: this should N E V E R happen! you don't have even "<<csize<<"bytes of RAM free!" << endl;
cout << " consider rebooting your machine as soon as possible!" << endl;
panic();
cptr=NULL;
}
else
cptr=NULL;
temp.data=static_cast<void*> (cptr);
contexts.push_back(temp); //pushen... und fertig :)
}
void TPluginParent::removeplugincontext(int x)
{
cout << "removing " << x << "th plugincontext" << endl;
list<plugincontext>::iterator temp;
temp=contexts.begin();
advance(temp,x);
list <TPlugin*>::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<char*> (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<TPlugin*>::iterator it2=plugins.begin();
for (list<plugincontext>::iterator it=contexts.begin(); it!=contexts.end(); it++)
{
if (it->data)
delete [] static_cast<char*> (it->data);
it2++;
}
}
void TPluginParent::deliver_message(string subject, void *data)
{
list<TPlugin*>::iterator it2=plugins.begin();
for (list<plugincontext>::iterator it=contexts.begin(); it!=contexts.end(); it++)
{
if (it->flags & PFLAGS_RECV_MESSAGES)
(*it2)->push_message( &(*it) , subject, data, this);
it2++;
}
}
|