File: popconplugincontainer.cpp

package info (click to toggle)
packagesearch 2.10.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,704 kB
  • sloc: cpp: 9,176; perl: 248; makefile: 15; sh: 11
file content (132 lines) | stat: -rw-r--r-- 2,815 bytes parent folder | download | duplicates (6)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <cassert>

#include <qmessagebox.h>
#include <qaction.h>
#include <QMainWindow>
#include <QMutex>

#include <unistd.h>		// for getuid and geteuid
#include <sys/types.h>	//

#include <wibble/operators.h>

#include "popconplugincontainer.h"

// NUtil
#include "helpers.h"

// NApplication
#include "applicationfactory.h"
#include "runcommand.h"

// NPlugin
#include <iprovider.h>
#include <plugincontainer.h>
#include <iprogressobserver.h>
#include "popconplugin.h"
#include "popconpluginfactory.h"


#include <globals.h>

extern "C" 
{ 
	NPlugin::PluginContainer* new_popconplugin() 
	{
		return new NPlugin::PopconPluginContainer;
	} 

	NPlugin::PluginInformation get_pluginInformation()
	{
		return NPlugin::PluginInformation("popconplugin", toString(NPackageSearch::VERSION), "Benjamin Mesing");
	} 
}

/** Initialize the plugin. */
__attribute__ ((constructor)) void init() 
{
}
      
      
// __attribute__ ((destructor)) void fini() 
// {
//   /* code here is executed just before dlclose() unloads the module */
// } 


namespace NPlugin
{

PopconPluginContainer::PopconPluginContainer()
{
	// this assumes, that only one instance of the PopconPluginContainer is created
	// (no two versions of libapt-front may be opened at any time)
	// This is ok for our purpose - though usually there should be a singleton ensuring
	// this constraint...
	PopconPluginFactory::getInstance()->setContainer(this);
	_pPopconPlugin = 0;
	addPlugin("PopconPlugin");
	
	_popconEnabled=false;
}
 
PopconPluginContainer::~PopconPluginContainer()
{
	unloadAllPlugins();
}

/////////////////////////////////////////////////////
// PluginContainer Interface
/////////////////////////////////////////////////////


bool PopconPluginContainer::init(IProvider* pProvider)
{
	BasePluginContainer::init(pProvider, PopconPluginFactory::getInstance());
	
	if (popconEnabled())
	{
		// use dynamic cast here because of the virtual base class 
		// (static_cast is not allowed there)
		_pPopconPlugin = dynamic_cast<PopconPlugin*>(requestPlugin("PopconPlugin"));
	}
	else
	{
		provider()->reportError(
			tr("Popcon data not available" ),
			tr(
				"<p>There is no popcon data available!</p>"
				"<p>"
				"The popcon plugin has been disabled."
				"</p>")
		);
		return false;
	}
	return popconEnabled();
}


/////////////////////////////////////////////////////
// BasePluginContainer Interface
/////////////////////////////////////////////////////

vector< pair<QString, QAction*> > PopconPluginContainer::actions()
{
	vector< pair<QString, QAction*> > result;
	return result;
}



/////////////////////////////////////////////////////
// Helper Methods
/////////////////////////////////////////////////////

void PopconPluginContainer::setPopconEnabled(bool enabled)
{
	_popconEnabled = enabled;
}


}	// namespace NPlugin