1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  * anjuta-plugin-handle.c
4  * Copyright (C) Naba Kumar  <naba@gnome.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 
21 /**
22  * SECTION:anjuta-plugin-handle
23  * @short_description: Handle used by plugin manager to keep track of plugins.
24  * @see_also: #AnjutaPluginManager, #AnjutaPluginDescription, #AnjutaPlugin
25  * @stability: Unstable
26  * @include: libanjuta/anjuta-plugin-handle.h
27  *
28  * Plugin handle is wrapper for installed plugins. For each installed plugin
29  * there will be one corresponding plugin handle. It is mainly used by
30  * plugin manager to keep track of loading and unloading of plugins.
31  */
32 
33 #include <string.h>
34 #include <glib/gi18n.h>
35 #include "anjuta-plugin-handle.h"
36 #include "resources.h"
37 #include "anjuta-debug.h"
38 
39 enum
40 {
41 	PROP_0,
42 
43 	PROP_ID,
44 	PROP_NAME,
45 	PROP_ABOUT,
46 	PROP_ICON_PATH,
47 	PROP_USER_ACTIVATABLE,
48 	PROP_RESIDENT,
49 	PROP_LANGUAGE,
50 	PROP_DESCRIPTION,
51 	PROP_DEPENDENCY_NAMES,
52 	PROP_DEPENDENCIES,
53 	PROP_DEPENDENTS,
54 	PROP_INTERFACES,
55 	PROP_CAN_LOAD,
56 	PROP_CAN_UNLOAD,
57 	PROP_CHECKED,
58 	PROP_RESOLVE_PASS,
59 	PROP_PATH
60 };
61 
62 struct _AnjutaPluginHandlePriv
63 {
64 	char *id;
65 	char *name;
66 	char *about;
67 	char *icon_path;
68 	char *path;
69 	gboolean user_activatable;
70 	gboolean resident;
71 	char *language;
72 
73 	AnjutaPluginDescription *description;
74 
75 	/* The dependencies listed in the oaf file */
76 	GList *dependency_names;
77 
78 	/* Interfaces exported by this plugin */
79 	GList *interfaces;
80 
81 	/* Attributes defined for this plugin */
82 	/* GHashTable *attributes; */
83 
84 	/* The keys of these tables represent the dependencies and dependents
85 	 * of the module.  The values point back at the plugins */
86 	GHashTable *dependencies;
87 	GHashTable *dependents;
88 
89 	gboolean can_load;
90 	gboolean can_unload;
91 	gboolean checked;
92 
93 	/* The pass on which the module was resolved, or -1 if
94 	 * unresolved */
95 	int resolve_pass;
96 };
97 
98 static GObjectClass* parent_class = NULL;
99 
100 static void
anjuta_plugin_handle_init(AnjutaPluginHandle * object)101 anjuta_plugin_handle_init (AnjutaPluginHandle *object)
102 {
103 	object->priv = g_new0 (AnjutaPluginHandlePriv, 1);
104 
105 	object->priv->resolve_pass = -1;
106 	object->priv->can_unload = TRUE;
107 
108 	object->priv->dependencies = g_hash_table_new (g_direct_hash,
109 												   g_direct_equal);
110 	object->priv->dependents = g_hash_table_new (g_direct_hash,
111 												 g_direct_equal);
112 }
113 
114 static void
anjuta_plugin_handle_finalize(GObject * object)115 anjuta_plugin_handle_finalize (GObject *object)
116 {
117 	AnjutaPluginHandlePriv *priv;
118 
119 	priv = ANJUTA_PLUGIN_HANDLE (object)->priv;
120 
121 	g_free (priv->id);
122 	priv->id = NULL;
123 	g_free (priv->name);
124 	priv->name = NULL;
125 	g_free (priv->icon_path);
126 	priv->icon_path = NULL;
127 	g_free (priv->path);
128 	priv->path = NULL;
129 	g_free (priv->language);
130 	priv->language = NULL;
131 
132 	g_list_foreach (priv->dependency_names, (GFunc)g_free, NULL);
133 	g_list_free (priv->dependency_names);
134 	priv->dependency_names = NULL;
135 
136 	g_list_foreach (priv->interfaces, (GFunc)g_free, NULL);
137 	g_list_free (priv->dependency_names);
138 	priv->dependency_names = NULL;
139 
140 	g_hash_table_destroy (priv->dependencies);
141 	priv->dependencies = NULL;
142 	g_hash_table_destroy (priv->dependents);
143 	priv->dependents = NULL;
144 
145 	g_free (priv);
146 
147 	G_OBJECT_CLASS (parent_class)->finalize (object);
148 }
149 
150 static void
anjuta_plugin_handle_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)151 anjuta_plugin_handle_set_property (GObject *object, guint prop_id,
152 								   const GValue *value, GParamSpec *pspec)
153 {
154 	g_return_if_fail (ANJUTA_IS_PLUGIN_HANDLE (object));
155 
156 	switch (prop_id)
157 	{
158 #if 0
159 	case PROP_ID:
160 		/* TODO: Add setter for "id" property here */
161 		break;
162 	case PROP_NAME:
163 		/* TODO: Add setter for "name" property here */
164 		break;
165 	case PROP_ABOUT:
166 		/* TODO: Add setter for "about" property here */
167 		break;
168 	case PROP_ICON_PATH:
169 		/* TODO: Add setter for "icon-path" property here */
170 		break;
171 	case PROP_PATH:
172 		/* TODO: Add setter for "path" property here */
173 		break;
174 	case PROP_USER_ACTIVATABLE:
175 		/* TODO: Add setter for "user-activatable" property here */
176 		break;
177 	case PROP_RESIDENT:
178 		/* TODO: Add setter for "resident" property here */
179 		break;
180 	case PROP_LANGUAGE:
181 		/* TODO: Add setter for "language" property here */
182 		break;
183 	case PROP_DESCRIPTION:
184 		/* TODO: Add setter for "description" property here */
185 		break;
186 	case PROP_DEPENDENCY_NAMES:
187 		/* TODO: Add setter for "dependency-names" property here */
188 		break;
189 	case PROP_DEPENDENCIES:
190 		/* TODO: Add setter for "dependencies" property here */
191 		break;
192 	case PROP_DEPENDENTS:
193 		/* TODO: Add setter for "dependents" property here */
194 		break;
195 	case PROP_INTERFACES:
196 		/* TODO: Add setter for "interfaces" property here */
197 		break;
198 	case PROP_CAN_LOAD:
199 		/* TODO: Add setter for "can-load" property here */
200 		break;
201 	case PROP_CAN_UNLOAD:
202 		/* TODO: Add setter for "can-unload" property here */
203 		break;
204 	case PROP_CHECKED:
205 		/* TODO: Add setter for "checked" property here */
206 		break;
207 	case PROP_RESOLVE_PASS:
208 		/* TODO: Add setter for "resolve-pass" property here */
209 		break;
210 #endif
211 	default:
212 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
213 		break;
214 	}
215 }
216 
217 static void
anjuta_plugin_handle_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)218 anjuta_plugin_handle_get_property (GObject *object, guint prop_id,
219 								   GValue *value, GParamSpec *pspec)
220 {
221 	AnjutaPluginHandlePriv *priv;
222 
223 	g_return_if_fail (ANJUTA_IS_PLUGIN_HANDLE (object));
224 	priv = ANJUTA_PLUGIN_HANDLE (object)->priv;
225 	switch (prop_id)
226 	{
227 	case PROP_ID:
228 		g_value_set_string (value, priv->id);
229 		break;
230 	case PROP_NAME:
231 		g_value_set_string (value, priv->name);
232 		break;
233 	case PROP_ABOUT:
234 		g_value_set_string (value, priv->about);
235 		break;
236 	case PROP_ICON_PATH:
237 		g_value_set_string (value, priv->icon_path);
238 		break;
239 	case PROP_PATH:
240 		g_value_set_string (value, priv->path);
241 		break;
242 	case PROP_USER_ACTIVATABLE:
243 		g_value_set_boolean (value, priv->user_activatable);
244 		break;
245 	case PROP_RESIDENT:
246 		g_value_set_boolean (value, priv->resident);
247 		break;
248 	case PROP_LANGUAGE:
249 		g_value_set_string (value, priv->language);
250 		break;
251 	case PROP_DESCRIPTION:
252 		g_value_set_pointer (value, priv->description);
253 		break;
254 	case PROP_DEPENDENCY_NAMES:
255 		g_value_set_pointer (value, priv->dependency_names);
256 		break;
257 	case PROP_DEPENDENCIES:
258 		g_value_set_pointer (value, priv->dependencies);
259 		break;
260 	case PROP_DEPENDENTS:
261 		g_value_set_pointer (value, priv->dependents);
262 		break;
263 	case PROP_INTERFACES:
264 		g_value_set_pointer (value, priv->interfaces);
265 		break;
266 	case PROP_CAN_LOAD:
267 		g_value_set_boolean (value, priv->can_load);
268 		break;
269 	case PROP_CAN_UNLOAD:
270 		g_value_set_boolean (value, priv->can_unload);
271 		break;
272 	case PROP_CHECKED:
273 		g_value_set_boolean (value, priv->checked);
274 		break;
275 	case PROP_RESOLVE_PASS:
276 		g_value_set_int (value, priv->resolve_pass);
277 		break;
278 	default:
279 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
280 		break;
281 	}
282 }
283 
284 static void
anjuta_plugin_handle_class_init(AnjutaPluginHandleClass * klass)285 anjuta_plugin_handle_class_init (AnjutaPluginHandleClass *klass)
286 {
287 	GObjectClass* object_class = G_OBJECT_CLASS (klass);
288 	parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
289 
290 	object_class->finalize = anjuta_plugin_handle_finalize;
291 	object_class->set_property = anjuta_plugin_handle_set_property;
292 	object_class->get_property = anjuta_plugin_handle_get_property;
293 
294 	g_object_class_install_property (object_class,
295 	                                 PROP_ID,
296 	                                 g_param_spec_string ("id",
297 	                                                      "ID",
298 	                                                      "Unique plugin ID",
299 	                                                      NULL,
300 	                                                      G_PARAM_READABLE));
301 
302 	g_object_class_install_property (object_class,
303 	                                 PROP_NAME,
304 	                                 g_param_spec_string ("name",
305 	                                                      "Name",
306 	                                                      "Plugin name",
307 	                                                      NULL,
308 	                                                      G_PARAM_READABLE));
309 
310 	g_object_class_install_property (object_class,
311 	                                 PROP_ABOUT,
312 	                                 g_param_spec_string ("about",
313 	                                                      "About Plugin",
314 	                                                      "About description of the plugin",
315 	                                                      NULL,
316 	                                                      G_PARAM_READABLE));
317 
318 	g_object_class_install_property (object_class,
319 	                                 PROP_ICON_PATH,
320 	                                 g_param_spec_string ("icon-path",
321 	                                                      "Icon Path",
322 	                                                      "Icon path of the plugin",
323 	                                                      NULL,
324 	                                                      G_PARAM_READABLE));
325 
326 	g_object_class_install_property (object_class,
327 	                                 PROP_PATH,
328 	                                 g_param_spec_string ("path",
329 	                                                      "Path",
330 	                                                      "Path of the plugin",
331 	                                                      NULL,
332 	                                                      G_PARAM_READABLE));
333 
334 	g_object_class_install_property (object_class,
335 	                                 PROP_USER_ACTIVATABLE,
336 	                                 g_param_spec_boolean ("user-activatable",
337 	                                                       "User Activatable",
338 	                                                       "If the plugin is user activatable",
339 	                                                       FALSE,
340 	                                                       G_PARAM_READABLE));
341 
342 	g_object_class_install_property (object_class,
343 	                                 PROP_RESIDENT,
344 	                                 g_param_spec_boolean ("resident",
345 	                                                       "Resident",
346 	                                                       "If the plugin cannot be unloaded",
347 	                                                       FALSE,
348 	                                                       G_PARAM_READABLE));
349 
350 	g_object_class_install_property (object_class,
351 	                                 PROP_LANGUAGE,
352 	                                 g_param_spec_string ("language",
353 	                                                      "Language",
354 	                                                      "Language used to write the plugin",
355 	                                                      NULL,
356 	                                                      G_PARAM_READABLE));
357 
358 	g_object_class_install_property (object_class,
359 	                                 PROP_DESCRIPTION,
360 	                                 g_param_spec_pointer ("description",
361 	                                                       "Description",
362 	                                                       "Plugin description",
363 	                                                       G_PARAM_READABLE));
364 
365 	g_object_class_install_property (object_class,
366 	                                 PROP_DEPENDENCY_NAMES,
367 	                                 g_param_spec_pointer ("dependency-names",
368 	                                                       "Dependency names",
369 	                                                       "Plugin dependency names listed in oaf file",
370 	                                                       G_PARAM_READABLE));
371 
372 	g_object_class_install_property (object_class,
373 	                                 PROP_DEPENDENCIES,
374 	                                 g_param_spec_pointer ("dependencies",
375 	                                                       "Dependencies",
376 	                                                       "Plugin dependencies",
377 	                                                       G_PARAM_READABLE));
378 
379 	g_object_class_install_property (object_class,
380 	                                 PROP_DEPENDENTS,
381 	                                 g_param_spec_pointer ("dependents",
382 	                                                       "Dependents",
383 	                                                       "Plugin dependents",
384 	                                                       G_PARAM_READABLE));
385 
386 	g_object_class_install_property (object_class,
387 	                                 PROP_INTERFACES,
388 	                                 g_param_spec_pointer ("interfaces",
389 	                                                       "Interfaces",
390 	                                                       "Interfaces exported by the plugin",
391 	                                                       G_PARAM_READABLE));
392 
393 	g_object_class_install_property (object_class,
394 	                                 PROP_CAN_LOAD,
395 	                                 g_param_spec_boolean ("can-load",
396 	                                                       "Can Load",
397 	                                                       "If the plugin can be loaded",
398 	                                                       FALSE,
399 	                                                       G_PARAM_READABLE));
400 
401 	g_object_class_install_property (object_class,
402 	                                 PROP_CAN_UNLOAD,
403 	                                 g_param_spec_boolean ("can-unload",
404 	                                                       "Can UnLoad",
405 	                                                       "If the plugin can be unloaded",
406 	                                                       TRUE,
407 	                                                       G_PARAM_READABLE));
408 
409 	g_object_class_install_property (object_class,
410 	                                 PROP_CHECKED,
411 	                                 g_param_spec_boolean ("checked",
412 	                                                       "Checked",
413 	                                                       "If the plugin is checked in UI",
414 	                                                       FALSE,
415 	                                                       G_PARAM_READABLE));
416 
417 	g_object_class_install_property (object_class,
418 	                                 PROP_RESOLVE_PASS,
419 	                                 g_param_spec_int ("resolve-pass",
420 	                                                   "Resolve Pass",
421 	                                                   "Dependency resolution pass",
422 	                                                   G_MININT, /* TODO: Adjust minimum property value */
423 	                                                   G_MAXINT, /* TODO: Adjust maximum property value */
424 	                                                   0,
425 	                                                   G_PARAM_READABLE));
426 }
427 
428 GType
anjuta_plugin_handle_get_type(void)429 anjuta_plugin_handle_get_type (void)
430 {
431 	static GType our_type = 0;
432 
433 	if(our_type == 0)
434 	{
435 		static const GTypeInfo our_info =
436 		{
437 			sizeof (AnjutaPluginHandleClass), /* class_size */
438 			(GBaseInitFunc) NULL, /* base_init */
439 			(GBaseFinalizeFunc) NULL, /* base_finalize */
440 			(GClassInitFunc) anjuta_plugin_handle_class_init, /* class_init */
441 			(GClassFinalizeFunc) NULL, /* class_finalize */
442 			NULL /* class_data */,
443 			sizeof (AnjutaPluginHandle), /* instance_size */
444 			0, /* n_preallocs */
445 			(GInstanceInitFunc) anjuta_plugin_handle_init, /* instance_init */
446 			NULL /* value_table */
447 		};
448 
449 		our_type = g_type_register_static (G_TYPE_OBJECT, "AnjutaPluginHandle",
450 		                                   &our_info, 0);
451 	}
452 
453 	return our_type;
454 }
455 
456 
457 static char *
get_icon_path(char * icon_name)458 get_icon_path (char *icon_name)
459 {
460 	char *ret;
461 
462 	if (g_path_is_absolute (icon_name)) {
463 		ret = g_strdup (icon_name);
464 	} else {
465 		ret = anjuta_res_get_pixmap_file (icon_name);
466 	}
467 
468 	return ret;
469 }
470 
471 static GList *
property_to_list(const char * value)472 property_to_list (const char *value)
473 {
474 	GList *l = NULL;
475 	char **split_str;
476 	char **p;
477 
478 	split_str = g_strsplit (value, ",", -1);
479 	for (p = split_str; *p != NULL; p++) {
480 		l = g_list_prepend (l, g_strdup (g_strstrip (*p)));
481 	}
482 	g_strfreev (split_str);
483 	return l;
484 }
485 
486 AnjutaPluginHandle*
anjuta_plugin_handle_new(const gchar * plugin_desc_path)487 anjuta_plugin_handle_new (const gchar *plugin_desc_path)
488 {
489 	AnjutaPluginHandle *plugin_handle;
490 	AnjutaPluginDescription *desc;
491 	char *str;
492 	gboolean enable;
493 	gchar *contents = NULL;
494 	gboolean success = TRUE;
495 
496 	/* Load file content */
497 	if (g_file_get_contents (plugin_desc_path, &contents, NULL, NULL)) {
498 
499 		desc = anjuta_plugin_description_new_from_string (contents, NULL);
500 		g_free (contents);
501 		if (!desc) {
502 			g_warning ("Bad plugin file: %s\n", plugin_desc_path);
503 			return NULL;
504 		}
505 	}
506 	else
507 	{
508 		return NULL;
509 	}
510 
511 	plugin_handle = g_object_new (ANJUTA_TYPE_PLUGIN_HANDLE, NULL);
512 
513 	/* Initialize plugin handle */
514 	plugin_handle->priv->description = desc;
515 	plugin_handle->priv->user_activatable = TRUE;
516 	plugin_handle->priv->resident = TRUE;
517 	plugin_handle->priv->path = g_path_get_dirname (plugin_desc_path);
518 
519 	if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
520 											  "Location", &str)) {
521 		plugin_handle->priv->id = str;
522 	} else {
523 		g_warning ("Couldn't find 'Location'");
524 		success = FALSE;
525 	}
526 
527 	if (anjuta_plugin_description_get_locale_string (desc, "Anjuta Plugin",
528 													 "Name", &str)) {
529 		plugin_handle->priv->name = str;
530 	} else {
531 		g_warning ("couldn't find 'Name' attribute.");
532 		success = FALSE;
533 	}
534 
535 	if (anjuta_plugin_description_get_locale_string (desc, "Anjuta Plugin",
536 													 "Description", &str)) {
537 		plugin_handle->priv->about = str;
538 	} else {
539 		g_warning ("Couldn't find 'Description' attribute.");
540 		success = FALSE;
541 	}
542 
543 	if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
544 									   "Icon", &str)) {
545 		plugin_handle->priv->icon_path = get_icon_path (str);
546 		g_free (str);
547 	}
548 
549 	if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
550 											  "Dependencies",
551 											  &str)) {
552 		plugin_handle->priv->dependency_names = property_to_list (str);
553 		g_free (str);
554 	}
555 
556 	if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
557 											  "Interfaces",
558 											  &str)) {
559 		plugin_handle->priv->interfaces = property_to_list (str);
560 		g_free (str);
561 	}
562 
563 	if (anjuta_plugin_description_get_boolean (desc, "Anjuta Plugin",
564 											  "UserActivatable", &enable)) {
565 		plugin_handle->priv->user_activatable = enable;
566 		/*
567 		DEBUG_PRINT ("Plugin '%s' is not user activatable",
568 					 plugin_handle->priv->name?
569 					 plugin_handle->priv->name : "Unknown");
570 		*/
571 	}
572 
573 	if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
574 											  "Resident", &str)) {
575 		if (str && strcasecmp (str, "no") == 0)
576 		{
577 			plugin_handle->priv->resident = FALSE;
578 		}
579 		g_free (str);
580 	}
581 
582 	if (anjuta_plugin_description_get_string (desc, "Anjuta Plugin",
583 											  "Language", &str)) {
584 		plugin_handle->priv->language = str;
585 	}
586 
587 	if (!success) {
588 		g_object_unref (plugin_handle);
589 		plugin_handle = NULL;
590 	}
591 
592 	return plugin_handle;
593 }
594 
595 const char*
anjuta_plugin_handle_get_id(AnjutaPluginHandle * plugin_handle)596 anjuta_plugin_handle_get_id (AnjutaPluginHandle *plugin_handle)
597 {
598 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
599 	return plugin_handle->priv->id;
600 }
601 
602 const char*
anjuta_plugin_handle_get_name(AnjutaPluginHandle * plugin_handle)603 anjuta_plugin_handle_get_name (AnjutaPluginHandle *plugin_handle)
604 {
605 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
606 	return plugin_handle->priv->name;
607 }
608 
609 const char*
anjuta_plugin_handle_get_about(AnjutaPluginHandle * plugin_handle)610 anjuta_plugin_handle_get_about (AnjutaPluginHandle *plugin_handle)
611 {
612 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
613 	return _(plugin_handle->priv->about);
614 }
615 
616 const char*
anjuta_plugin_handle_get_icon_path(AnjutaPluginHandle * plugin_handle)617 anjuta_plugin_handle_get_icon_path (AnjutaPluginHandle *plugin_handle)
618 {
619 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
620 	return plugin_handle->priv->icon_path;
621 }
622 
623 const char*
anjuta_plugin_handle_get_path(AnjutaPluginHandle * plugin_handle)624 anjuta_plugin_handle_get_path (AnjutaPluginHandle *plugin_handle)
625 {
626 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
627 	return plugin_handle->priv->path;
628 }
629 
630 gboolean
anjuta_plugin_handle_get_user_activatable(AnjutaPluginHandle * plugin_handle)631 anjuta_plugin_handle_get_user_activatable (AnjutaPluginHandle *plugin_handle)
632 {
633 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), FALSE);
634 	return plugin_handle->priv->user_activatable;
635 }
636 
637 gboolean
anjuta_plugin_handle_get_resident(AnjutaPluginHandle * plugin_handle)638 anjuta_plugin_handle_get_resident (AnjutaPluginHandle *plugin_handle)
639 {
640 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), FALSE);
641 	return plugin_handle->priv->resident;
642 }
643 
644 const char*
anjuta_plugin_handle_get_language(AnjutaPluginHandle * plugin_handle)645 anjuta_plugin_handle_get_language (AnjutaPluginHandle *plugin_handle)
646 {
647 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
648 	return plugin_handle->priv->language;
649 }
650 
651 AnjutaPluginDescription*
anjuta_plugin_handle_get_description(AnjutaPluginHandle * plugin_handle)652 anjuta_plugin_handle_get_description (AnjutaPluginHandle *plugin_handle)
653 {
654 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
655 	return plugin_handle->priv->description;
656 }
657 
658 GList*
anjuta_plugin_handle_get_dependency_names(AnjutaPluginHandle * plugin_handle)659 anjuta_plugin_handle_get_dependency_names (AnjutaPluginHandle *plugin_handle)
660 {
661 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
662 	return plugin_handle->priv->dependency_names;
663 }
664 
665 GHashTable*
anjuta_plugin_handle_get_dependencies(AnjutaPluginHandle * plugin_handle)666 anjuta_plugin_handle_get_dependencies (AnjutaPluginHandle *plugin_handle)
667 {
668 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
669 	return plugin_handle->priv->dependencies;
670 }
671 
672 GHashTable*
anjuta_plugin_handle_get_dependents(AnjutaPluginHandle * plugin_handle)673 anjuta_plugin_handle_get_dependents (AnjutaPluginHandle *plugin_handle)
674 {
675 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
676 	return plugin_handle->priv->dependents;
677 }
678 
679 GList*
anjuta_plugin_handle_get_interfaces(AnjutaPluginHandle * plugin_handle)680 anjuta_plugin_handle_get_interfaces (AnjutaPluginHandle *plugin_handle)
681 {
682 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), NULL);
683 	return plugin_handle->priv->interfaces;
684 }
685 
686 gboolean
anjuta_plugin_handle_get_can_load(AnjutaPluginHandle * plugin_handle)687 anjuta_plugin_handle_get_can_load (AnjutaPluginHandle *plugin_handle)
688 {
689 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), FALSE);
690 	return plugin_handle->priv->can_load;
691 }
692 
693 gboolean
anjuta_plugin_handle_get_can_unload(AnjutaPluginHandle * plugin_handle)694 anjuta_plugin_handle_get_can_unload (AnjutaPluginHandle *plugin_handle)
695 {
696 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), FALSE);
697 	return plugin_handle->priv->can_unload;
698 }
699 
700 gboolean
anjuta_plugin_handle_get_checked(AnjutaPluginHandle * plugin_handle)701 anjuta_plugin_handle_get_checked (AnjutaPluginHandle *plugin_handle)
702 {
703 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), FALSE);
704 	return plugin_handle->priv->checked;
705 }
706 
707 gint
anjuta_plugin_handle_get_resolve_pass(AnjutaPluginHandle * plugin_handle)708 anjuta_plugin_handle_get_resolve_pass (AnjutaPluginHandle *plugin_handle)
709 {
710 	g_return_val_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle), 0);
711 	return plugin_handle->priv->resolve_pass;
712 }
713 
714 void
anjuta_plugin_handle_set_can_load(AnjutaPluginHandle * plugin_handle,gboolean can_load)715 anjuta_plugin_handle_set_can_load (AnjutaPluginHandle *plugin_handle,
716 								   gboolean can_load)
717 {
718 	g_return_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle));
719 	plugin_handle->priv->can_load = can_load;
720 }
721 
722 void
anjuta_plugin_handle_set_can_unload(AnjutaPluginHandle * plugin_handle,gboolean can_unload)723 anjuta_plugin_handle_set_can_unload (AnjutaPluginHandle *plugin_handle,
724 								   gboolean can_unload)
725 {
726 	g_return_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle));
727 	plugin_handle->priv->can_unload = can_unload;
728 }
729 
730 void
anjuta_plugin_handle_set_checked(AnjutaPluginHandle * plugin_handle,gboolean checked)731 anjuta_plugin_handle_set_checked (AnjutaPluginHandle *plugin_handle,
732 								  gboolean checked)
733 {
734 	g_return_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle));
735 	plugin_handle->priv->checked = checked;
736 }
737 
738 void
anjuta_plugin_handle_set_resolve_pass(AnjutaPluginHandle * plugin_handle,gboolean resolve_pass)739 anjuta_plugin_handle_set_resolve_pass (AnjutaPluginHandle *plugin_handle,
740 									   gboolean resolve_pass)
741 {
742 	g_return_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle));
743 	plugin_handle->priv->resolve_pass = resolve_pass;
744 }
745 
746 void
anjuta_plugin_handle_unresolve_dependencies(AnjutaPluginHandle * plugin_handle)747 anjuta_plugin_handle_unresolve_dependencies (AnjutaPluginHandle *plugin_handle)
748 {
749 	AnjutaPluginHandlePriv *priv;
750 
751 	g_return_if_fail (ANJUTA_IS_PLUGIN_HANDLE (plugin_handle));
752 	priv = plugin_handle->priv;
753 
754 	g_hash_table_remove_all (priv->dependencies);
755 	g_hash_table_remove_all (priv->dependents);
756 
757 	priv->can_load = TRUE;
758 	priv->resolve_pass = -1;
759 }
760