Commit fa39d5ae authored by Ziirish's avatar Ziirish
Browse files

cleaning code (part 3)

parent ea63b6e5
......@@ -88,7 +88,8 @@ c . . .KMMMMMMMMM\nMMMMMMMMMMMWo dMMMMMMMWWMMMMMMMMMMMMMMMX\
. . 'NMMMMMMMM\nMMMMMMMMMMMd . ,NMMMMMMMNWMMMMMMMMMMMMMMMW\
' dMMMMMMMM\nMMMMMMMMMN: . dMMMMMMMMNWMMMMMMMMMMMMMMMM\
, :MMMMMMMM\nMMMMMMMMMO ..kMMMMMMMMNWMMMMMMMMMMMMMMMM\
, . :MMMMMMMM\nMMMMMMMMMKloxl;cKMMMMMMMNWMMMMMMMMMMMMMNXK' ...xMMMMMMMM\nMMMMMMMWKddkkkkl':kNMMMMWWMMMMMMMMMMMMM0Ok; ;\
, . :MMMMMMMM\nMMMMMMMMMKloxl;cKMMMMMMMNWMMMMMMMMMMMMMNXK' \
...xMMMMMMMM\nMMMMMMMWKddkkkkl':kNMMMMWWMMMMMMMMMMMMM0Ok; ;\
kOWMMMMMMM\nMMMNXKOdodxkkkkkd. .dXMMMMMMMMMMMMMMMN0kkkl.....\
ckOONMMMMMMM\nMMNkkkkxxkkkkkkkkd' .:XMMMMMMMMMMMMMXOxxkxoloox\
kOOkkKWMMMMM\nMMNxxkkkOOOkkkkkkxxc\
......
......@@ -45,7 +45,8 @@ gboolean
cid_get_xml_file (const gchar *artist,
const gchar *album)
{
if (g_file_test (DEFAULT_DOWNLOADED_IMAGE_LOCATION, G_FILE_TEST_EXISTS))
if (g_file_test (DEFAULT_DOWNLOADED_IMAGE_LOCATION,
G_FILE_TEST_EXISTS))
{
cid_file_remove (DEFAULT_DOWNLOADED_IMAGE_LOCATION);
}
......@@ -128,7 +129,8 @@ cid_download_missing_cover (const gchar *cURL)
fclose(fp);
curl_easy_cleanup(handle);
if (rename (DEFAULT_DOWNLOADED_IMAGE_LOCATION".tmp",DEFAULT_DOWNLOADED_IMAGE_LOCATION) == -1)
if (rename (DEFAULT_DOWNLOADED_IMAGE_LOCATION".tmp",
DEFAULT_DOWNLOADED_IMAGE_LOCATION) == -1)
{
cid_warning ("Cannot rename '%s' to '%s'",
DEFAULT_DOWNLOADED_IMAGE_LOCATION".tmp",
......@@ -174,7 +176,9 @@ cid_search_xml_xpath (const char *filename,
}
// Evaluation de l'expression XPath
//gchar *cXPath = g_strdup_printf (xpath,cid->config->iImageSize == MEDIUM_IMAGE ? "large" : "extralarge"/*TAB_IMAGE_SIZES[cid->config->iImageSize]*/);
//gchar *cXPath = g_strdup_printf (xpath,cid->config->iImageSize ==
//MEDIUM_IMAGE ? "large" :
//"extralarge"/*TAB_IMAGE_SIZES[cid->config->iImageSize]*/);
gchar *cXPath = g_strdup_vprintf (xpath, args);
xmlXPathObjectPtr xpathRes = xmlXPathEvalExpression(cXPath, ctxt);
g_free (cXPath);
......@@ -193,7 +197,8 @@ cid_search_xml_xpath (const char *filename,
for (i = 0; i < xpathRes->nodesetval->nodeNr; i++)
{
xmlNodePtr n = xpathRes->nodesetval->nodeTab[i];
if (n->type == XML_TEXT_NODE || n->type == XML_CDATA_SECTION_NODE)
if (n->type == XML_TEXT_NODE ||
n->type == XML_CDATA_SECTION_NODE)
{
*cValue = g_strdup (n->content);
}
......@@ -242,7 +247,8 @@ cid_db_store_cover (CidMainContainer **pCid,
pKeyFile = g_key_file_new ();
flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
if (!g_file_test (cid->config->cDLPath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE))
if (!g_file_test (cid->config->cDLPath,
G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE))
{
cid_info ("Creating path %s", cid->config->cDLPath);
g_mkdir_with_parents (cid->config->cDLPath, 7*8*8+7*8+5);
......@@ -316,7 +322,10 @@ cid_db_search_cover (CidMainContainer **pCid,
return NULL;
}
gchar *cVal = g_key_file_get_value (pKeyFile, DB_GROUP_DOWNLOAD, cKey, &error);
gchar *cVal = g_key_file_get_value (pKeyFile,
DB_GROUP_DOWNLOAD,
cKey,
&error);
if (error != NULL)
{
cid_warning ("%s",error->message);
......
This diff is collapsed.
......@@ -80,7 +80,9 @@ GtkWidget *cid_get_image_widget(gchar **imageURI);
* @param non utilisé
* @param pointeur de données (non utilisé)
*/
void cid_set_colormap (GtkWidget *widget, GdkScreen *old_screen, gpointer userdata);
void cid_set_colormap (GtkWidget *widget,
GdkScreen *old_screen,
gpointer userdata);
/**
* renvoie une image à partir d'un buffer de pixels
......@@ -96,7 +98,9 @@ cairo_surface_t *cid_get_image_from_pixbuf (GdkPixbuf **pixbuf);
* @param iHeight Hauteur.
* @return image.
*/
cairo_surface_t *cid_get_cairo_image (gchar *cImagePath, gdouble iWidth, gdouble iHeight);
cairo_surface_t *cid_get_cairo_image (gchar *cImagePath,
gdouble iWidth,
gdouble iHeight);
/**
* Fonction appelée pour dessiner la fenêtre
......@@ -104,7 +108,9 @@ cairo_surface_t *cid_get_cairo_image (gchar *cImagePath, gdouble iWidth, gdouble
* @param ?
* @param non utilisé
*/
void cid_draw_window (GtkWidget *widget, GdkEventExpose *event, gpointer *userdata);
void cid_draw_window (GtkWidget *widget,
GdkEventExpose *event,
gpointer *userdata);
/**
* On dessine l'etat du lecteur
......
......@@ -75,7 +75,12 @@ cid_log_location(const GLogLevelFlags loglevel,
if (loglevel > gLogLevel)
return;
fprintf (stdout,"%s",_cid_log_level_to_string(loglevel));
fprintf (stdout,"\033[0;37m(%s:%s:%d) \033[%cm \n ", file, func, line, s_iLogColor);
fprintf (stdout,
"\033[0;37m(%s:%s:%d) \033[%cm \n ",
file,
func,
line,
s_iLogColor);
va_start(args, format);
g_logv(G_LOG_DOMAIN, loglevel, format, args);
va_end(args);
......
......@@ -63,20 +63,40 @@ void cid_log_init(gboolean bBlackTerminal);
*/
void cid_log_set_level(GLogLevelFlags loglevel);
#define cid_error(...) \
cid_log_location(G_LOG_LEVEL_ERROR, __FILE__, __PRETTY_FUNCTION__, __LINE__,__VA_ARGS__)
#define cid_error(...) \
cid_log_location(G_LOG_LEVEL_ERROR, \
__FILE__, \
__PRETTY_FUNCTION__, \
__LINE__, \
__VA_ARGS__)
#define cid_warning(...) \
cid_log_location(G_LOG_LEVEL_WARNING, __FILE__, __PRETTY_FUNCTION__, __LINE__,__VA_ARGS__)
#define cid_warning(...) \
cid_log_location(G_LOG_LEVEL_WARNING, \
__FILE__, \
__PRETTY_FUNCTION__, \
__LINE__, \
__VA_ARGS__)
#define cid_message(...) \
cid_log_location(G_LOG_LEVEL_MESSAGE, __FILE__, __PRETTY_FUNCTION__, __LINE__,__VA_ARGS__)
#define cid_message(...) \
cid_log_location(G_LOG_LEVEL_MESSAGE, \
__FILE__, \
__PRETTY_FUNCTION__, \
__LINE__, \
__VA_ARGS__)
#define cid_debug(...) \
cid_log_location(G_LOG_LEVEL_DEBUG, __FILE__, __PRETTY_FUNCTION__, __LINE__,__VA_ARGS__)
#define cid_debug(...) \
cid_log_location(G_LOG_LEVEL_DEBUG, \
__FILE__, \
__PRETTY_FUNCTION__, \
__LINE__, \
__VA_ARGS__)
#define cid_info(...) \
cid_log_location(G_LOG_LEVEL_INFO, __FILE__, __PRETTY_FUNCTION__, __LINE__,__VA_ARGS__)
cid_log_location(G_LOG_LEVEL_INFO, \
__FILE__, \
__PRETTY_FUNCTION__, \
__LINE__, \
__VA_ARGS__)
/**
* sort du programme avec le code de retour donné
......@@ -84,7 +104,10 @@ void cid_log_set_level(GLogLevelFlags loglevel);
* @param code de retour
* @param message d'erreur à nombre variable de paramètres
*/
void cid_exit (CidMainContainer **pCid, int code, const gchar *mess, ...);
void cid_exit (CidMainContainer **pCid,
int code,
const gchar *mess,
...);
G_END_DECLS
#endif
......@@ -35,30 +35,39 @@ cid_initialize_module_manager (const gchar *cModuleDirPath)
if (s_hModuleTable == NULL)
s_hModuleTable = g_hash_table_new_full (g_str_hash,
g_str_equal,
NULL, // la cle est le nom du module, et pointe directement sur le champ 'cModuleName' du module.
NULL,
(GDestroyNotify) cid_free_module);
// la cle est le nom du module, et pointe directement sur le
// champ 'cModuleName' du module.
if (s_hInternalModuleTable == NULL)
{
s_hInternalModuleTable = g_hash_table_new_full (g_str_hash,
g_str_equal,
NULL, // la cle est le nom du module, et pointe directement sur le champ 'cModuleName' du module.
NULL,
(GDestroyNotify) NULL); // ne sont jamais liberes.
// la cle est le nom du module, et pointe directement sur le
// champ 'cModuleName' du module.
//cid_preload_internal_modules (s_hInternalModuleTable);
}
if (cModuleDirPath != NULL && g_file_test (cModuleDirPath, G_FILE_TEST_IS_DIR))
if (cModuleDirPath != NULL &&
g_file_test (cModuleDirPath, G_FILE_TEST_IS_DIR))
{
GError *erreur = NULL;
cid_preload_module_from_directory (cModuleDirPath, &erreur);
if (erreur != NULL)
{
cid_warning ("%s\n no module will be available", erreur->message);
cid_warning ("%s\n no module will be available",
erreur->message);
g_error_free (erreur);
}
}
/*
//\________________ ceci est un vilain hack ... mais je trouvais ca lourd de compiler un truc qui n'a aucun code, et puis comme ca on a l'aide meme sans les plug-ins.
//\________________ ceci est un vilain hack ... mais je trouvais ca
// lourd de compiler un truc qui n'a aucun code, et puis comme ca
// on a l'aide meme sans les plug-ins.
CairoDockModule *pHelpModule = g_new0 (CairoDockModule, 1);
CairoDockVisitCard *pVisitCard = g_new0 (CairoDockVisitCard, 1);
pHelpModule->pVisitCard = pVisitCard;
......@@ -68,19 +77,28 @@ cid_initialize_module_manager (const gchar *cModuleDirPath)
pVisitCard->iMicroVersionNeeded = 0;
pVisitCard->cPreviewFilePath = NULL;
pVisitCard->cGettextDomain = NULL;
pVisitCard->cDockVersionOnCompilation = g_strdup (CAIRO_DOCK_VERSION);
pVisitCard->cDockVersionOnCompilation =
g_strdup (CAIRO_DOCK_VERSION);
pVisitCard->cUserDataDir = g_strdup ("help");
pVisitCard->cShareDataDir = g_strdup (CAIRO_DOCK_SHARE_DATA_DIR);
pVisitCard->cConfFileName = g_strdup ("help.conf");
pVisitCard->cModuleVersion = g_strdup ("0.0.5");
pVisitCard->iCategory = CAIRO_DOCK_CATEGORY_SYSTEM;
pVisitCard->cIconFilePath = g_strdup_printf ("%s/%s", CAIRO_DOCK_SHARE_DATA_DIR, "help.svg");
pVisitCard->cIconFilePath =
g_strdup_printf ("%s/%s",
CAIRO_DOCK_SHARE_DATA_DIR,
"help.svg");
pVisitCard->iSizeOfConfig = 0;
pVisitCard->iSizeOfData = 0;
pVisitCard->cDescription = N_("A useful FAQ that contains also a lot of hints.\nLet the mouse over a sentence to make the hint dialog popups.");
pVisitCard->cDescription = N_("A useful FAQ that contains also a \
lot of hints.\nLet the mouse over a sentence to make the hint dialog \
popups.");
pHelpModule->pInterface = g_new0 (CairoDockModuleInterface, 1);
g_hash_table_insert (s_hModuleTable, pHelpModule->pVisitCard->cModuleName, pHelpModule);
///pHelpModule->cConfFilePath = cairo_dock_check_module_conf_file (pHelpModule->pVisitCard);
g_hash_table_insert (s_hModuleTable,
pHelpModule->pVisitCard->cModuleName,
pHelpModule);
///pHelpModule->cConfFilePath =
/// cairo_dock_check_module_conf_file (pHelpModule->pVisitCard);
cairo_dock_activate_module (pHelpModule, NULL);
*/
}
......@@ -117,28 +135,45 @@ cid_check_module_conf_file (CidVisitCard *pVisitCard)
return NULL;
int r;
gchar *cUserDataDirPath = g_strdup_printf ("%s/plug-ins/%s", /*g_cCurrentThemePath*/CID_MODULES_DIR, pVisitCard->cUserDataDir);
if (! g_file_test (cUserDataDirPath, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
gchar *cUserDataDirPath = g_strdup_printf("%s/plug-ins/%s",
/*g_cCurrentThemePath*/
CID_MODULES_DIR,
pVisitCard->cUserDataDir);
if (! g_file_test (cUserDataDirPath,
G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
{
cid_message ("directory %s doesn't exist, it will be added.", cUserDataDirPath);
cid_message ("directory %s doesn't exist, it will be added.",
cUserDataDirPath);
gchar *command = g_strdup_printf ("mkdir -p %s", cUserDataDirPath);
gchar *command =
g_strdup_printf ("mkdir -p %s", cUserDataDirPath);
r = system (command);
g_free (command);
}
gchar *cConfFilePath = g_strdup_printf ("%s/%s", cUserDataDirPath, pVisitCard->cConfFileName);
gchar *cConfFilePath = g_strdup_printf ("%s/%s",
cUserDataDirPath,
pVisitCard->cConfFileName);
if (! g_file_test (cConfFilePath, G_FILE_TEST_EXISTS))
{
cid_message ("no conf file %s, we will take the default one", cConfFilePath);
gchar *command = g_strdup_printf ("cp %s/%s %s", pVisitCard->cShareDataDir, pVisitCard->cConfFileName, cConfFilePath);
cid_message ("no conf file %s, we will take the default one",
cConfFilePath);
gchar *command = g_strdup_printf ("cp %s/%s %s",
pVisitCard->cShareDataDir,
pVisitCard->cConfFileName,
cConfFilePath);
r = system (command);
g_free (command);
}
if (! g_file_test (cConfFilePath, G_FILE_TEST_EXISTS)) // la copie ne s'est pas bien passee.
// la copie ne s'est pas bien passee.
if (! g_file_test (cConfFilePath, G_FILE_TEST_EXISTS))
{
cid_warning ("couldn't copy %s/%s in %s; check permissions and file's existence", pVisitCard->cShareDataDir, pVisitCard->cConfFileName, cUserDataDirPath);
cid_warning ("couldn't copy %s/%s in %s; check permissions and \
file's existence",
pVisitCard->cShareDataDir,
pVisitCard->cConfFileName,
cUserDataDirPath);
g_free (cUserDataDirPath);
g_free (cConfFilePath);
return NULL;
......@@ -152,10 +187,16 @@ static void
cid_open_module (CidModule *pCairoDockModule, GError **erreur)
{
//\__________________ On ouvre le .so.
GModule *module = g_module_open (pCairoDockModule->cSoFilePath, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
GModule *module = g_module_open (pCairoDockModule->cSoFilePath,
G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
if (!module)
{
g_set_error (erreur, 1, 1, "while opening module '%s' : (%s)", pCairoDockModule->cSoFilePath, g_module_error ());
g_set_error (erreur,
1,
1,
"while opening module '%s' : (%s)",
pCairoDockModule->cSoFilePath,
g_module_error ());
return ;
}
pCairoDockModule->pModule = module;
......@@ -163,42 +204,77 @@ cid_open_module (CidModule *pCairoDockModule, GError **erreur)
//\__________________ On identifie le module.
gboolean bSymbolFound;
CidModulePreInit function_pre_init = NULL;
bSymbolFound = g_module_symbol (module, "pre_init", (gpointer) &function_pre_init);
bSymbolFound = g_module_symbol (module,
"pre_init",
(gpointer) &function_pre_init);
if (bSymbolFound && function_pre_init != NULL)
{
pCairoDockModule->pVisitCard = g_new0 (CidVisitCard, 1);
pCairoDockModule->pInterface = g_new0 (CidModuleInterface, 1);
gboolean bModuleLoaded = function_pre_init (pCairoDockModule->pVisitCard, pCairoDockModule->pInterface);
gboolean bModuleLoaded =
function_pre_init (pCairoDockModule->pVisitCard,
pCairoDockModule->pInterface);
if (! bModuleLoaded)
{
cid_free_visit_card (pCairoDockModule->pVisitCard);
pCairoDockModule->pVisitCard = NULL;
cid_debug ("module '%s' has not been loaded", pCairoDockModule->cSoFilePath); // peut arriver a xxx-integration.
// peut arriver a xxx-integration.
cid_debug ("module '%s' has not been loaded",
pCairoDockModule->cSoFilePath);
return ;
}
}
else
{
pCairoDockModule->pVisitCard = NULL;
g_set_error (erreur, 1, 1, "this module ('%s') does not have the common entry point 'pre_init', it may be broken or icompatible with cairo-dock", pCairoDockModule->cSoFilePath);
g_set_error (erreur,
1,
1,
"this module ('%s') does not have the common entry"
" point 'pre_init', it may be broken or "
"icompatible with CID",
pCairoDockModule->cSoFilePath);
return ;
}
//\__________________ On verifie sa compatibilite.
CidVisitCard *pVisitCard = pCairoDockModule->pVisitCard;
/*
if (pVisitCard->iMajorVersionNeeded > g_iMajorVersion || (pVisitCard->iMajorVersionNeeded == g_iMajorVersion && pVisitCard->iMinorVersionNeeded > g_iMinorVersion) || (pVisitCard->iMajorVersionNeeded == g_iMajorVersion && pVisitCard->iMinorVersionNeeded == g_iMinorVersion && pVisitCard->iMicroVersionNeeded > g_iMicroVersion))
if (pVisitCard->iMajorVersionNeeded > g_iMajorVersion ||
(pVisitCard->iMajorVersionNeeded == g_iMajorVersion &&
pVisitCard->iMinorVersionNeeded > g_iMinorVersion) ||
(pVisitCard->iMajorVersionNeeded == g_iMajorVersion &&
pVisitCard->iMinorVersionNeeded == g_iMinorVersion &&
pVisitCard->iMicroVersionNeeded > g_iMicroVersion))
{
g_set_error (erreur, 1, 1, "this module ('%s') needs at least Cairo-Dock v%d.%d.%d, but Cairo-Dock is in v%s\n It will be ignored", pCairoDockModule->cSoFilePath, pVisitCard->iMajorVersionNeeded, pVisitCard->iMinorVersionNeeded, pVisitCard->iMicroVersionNeeded, CAIRO_DOCK_VERSION);
g_set_error (erreur,
1,
1,
"this module ('%s') needs at least Cairo-Dock v%d."
"%d.%d, but Cairo-Dock is in v%s\n It will be "
"ignored",
pCairoDockModule->cSoFilePath,
pVisitCard->iMajorVersionNeeded,
pVisitCard->iMinorVersionNeeded,
pVisitCard->iMicroVersionNeeded,
CAIRO_DOCK_VERSION);
cairo_dock_free_visit_card (pCairoDockModule->pVisitCard);
pCairoDockModule->pVisitCard = NULL;
return ;
}
*/
/*
if (pVisitCard->cDockVersionOnCompilation != NULL && strcmp (pVisitCard->cDockVersionOnCompilation, CID_VERSION) != 0)
if (pVisitCard->cDockVersionOnCompilation != NULL &&
strcmp(pVisitCard->cDockVersionOnCompilation, CID_VERSION) != 0)
{
g_set_error (erreur, 1, 1, "this module ('%s') was compiled with C.I.D. v%s, but C.I.D. is in v%s\n It will be ignored", pCairoDockModule->cSoFilePath, pVisitCard->cDockVersionOnCompilation, CAIRO_DOCK_VERSION);
g_set_error (erreur,
1,
1,
"this module ('%s') was compiled with C.I.D. v%s, "
"but C.I.D. is in v%s\n It will be ignored",
pCairoDockModule->cSoFilePath,
pVisitCard->cDockVersionOnCompilation,
CAIRO_DOCK_VERSION);
cid_free_visit_card (pCairoDockModule->pVisitCard);
pCairoDockModule->pVisitCard = NULL;
return ;
......@@ -206,11 +282,17 @@ cid_open_module (CidModule *pCairoDockModule, GError **erreur)
*/
if (pVisitCard->cModuleName == NULL)
pVisitCard->cModuleName = cid_extract_default_module_name_from_path (pCairoDockModule->cSoFilePath);
pVisitCard->cModuleName =
cid_extract_default_module_name_from_path (
pCairoDockModule->cSoFilePath);
if (cid_module_is_auto_loaded (pCairoDockModule)) // c'est un module qui soit ne peut etre activer et/ou desactiver, soit s'est lie a un module interne; on l'activera donc automatiquement.
// c'est un module qui soit ne peut etre activer et/ou desactiver,
// soit s'est lie a un module interne; on l'activera donc
// automatiquement.
if (cid_module_is_auto_loaded (pCairoDockModule))
{
s_AutoLoadedModules = g_list_prepend (s_AutoLoadedModules, pCairoDockModule);
s_AutoLoadedModules = g_list_prepend (s_AutoLoadedModules,
pCairoDockModule);
}
}
......@@ -245,11 +327,14 @@ cid_close_module (CidModule *module)
module->cConfFilePath = NULL;
}
// cSoFilePath vers un fichier de la forme 'libtruc.so'.
// Le module est rajoute dans la table des modules.
CidModule *
cid_load_module (gchar *cSoFilePath, GError **erreur) // cSoFilePath vers un fichier de la forme 'libtruc.so'. Le module est rajoute dans la table des modules.
cid_load_module (gchar *cSoFilePath, GError **erreur)
{
//g_print ("%s (%s)\n", __func__, cSoFilePath);
if (cSoFilePath == NULL) // g_module_open () plante si 'cSoFilePath' est NULL.
// g_module_open () plante si 'cSoFilePath' est NULL.
if (cSoFilePath == NULL)
{
g_set_error (erreur, 1, 1, "%s () : no such module", __func__);
return NULL;
......@@ -268,13 +353,16 @@ cid_load_module (gchar *cSoFilePath, GError **erreur) // cSoFilePath vers un fi
}
if (s_hModuleTable != NULL && pCairoDockModule->pVisitCard != NULL)
g_hash_table_insert (s_hModuleTable, pCairoDockModule->pVisitCard->cModuleName, pCairoDockModule);
g_hash_table_insert (s_hModuleTable,
pCairoDockModule->pVisitCard->cModuleName,
pCairoDockModule);
return pCairoDockModule;
}
void
cid_preload_module_from_directory (const gchar *cModuleDirPath, GError **erreur)
cid_preload_module_from_directory (const gchar *cModuleDirPath,
GError **erreur)
{
cid_message ("%s (%s)", __func__, cModuleDirPath);
GError *tmp_erreur = NULL;
......@@ -296,7 +384,10 @@ cid_preload_module_from_directory (const gchar *cModuleDirPath, GError **erreur)
if (g_str_has_suffix (cFileName, ".so"))
{
g_string_printf (sFilePath, "%s/%s", cModuleDirPath, cFileName);
g_string_printf (sFilePath,
"%s/%s",
cModuleDirPath,
cFileName);
pModule = cid_load_module (sFilePath->str, &tmp_erreur);
if (tmp_erreur != NULL)
{
......@@ -330,7 +421,9 @@ void cid_free_module (CidModule *module)
#define REGISTER_INTERNAL_MODULE(cGroupName) \
pModule = g_new0 (CidInternalModule, 1);\
cid_pre_init_##cGroupName (pModule);\
g_hash_table_insert (pModuleTable, (gpointer)pModule->cModuleName, (gpointer)pModule)
g_hash_table_insert (pModuleTable,
(gpointer)pModule->cModuleName,
(gpointer)pModule)
void
cid_preload_internal_modules (GHashTable *pModuleTable)
......@@ -357,9 +450,16 @@ void
cid_deactivate_module (CidModule *module)
{
g_return_if_fail (module != NULL);
cid_debug ("%s (%s, %s)", __func__, module->pVisitCard->cModuleName, module->cConfFilePath);
g_list_foreach (module->pInstancesList, (GFunc) cid_stop_module_instance, NULL);
g_list_foreach (module->pInstancesList, (GFunc) cid_free_module_instance, NULL);
cid_debug ("%s (%s, %s)",
__func__,
module->pVisitCard->cModuleName,
module->cConfFilePath);
g_list_foreach (module->pInstancesList,
(GFunc) cid_stop_module_instance,
NULL);
g_list_foreach (module->pInstancesList,
(GFunc) cid_free_module_instance,
NULL);
g_list_free (module->pInstancesList);
module->pInstancesList = NULL;
}
......
......@@ -23,12 +23,22 @@ G_BEGIN_DECLS
/**
*@file cairo-dock-modules.h This class defines and handles the external and internal modules of Cairo-Dock.
*@file cairo-dock-modules.h This class defines and handles the external
* and internal modules of Cairo-Dock.
* A module has an interface and a visit card :
* - the visit card allows it to define itself (name, category, default icon, etc)
* - the interface defines the entry points for init, stop, reload, read config, and reset datas.
* Modules can be instanciated several times; each time they are, an instance is created. This instance will hold all the data used by the module's functions : the icon and its container, the config structure and its conf file, the data structure and a slot to plug datas into containers and icons. All these parameters are optionnal; a module that has an icon is also called an applet.
* Internal modules are just simplified version of modules, and are used internally by Cairo-Dock. As a special feature, a module can bind itself to an internal module, if its purpose is to complete it.
* - the visit card allows it to define itself (name, category, default
* icon, etc)
* - the interface defines the entry points for init, stop, reload, read
* config, and reset datas.
* Modules can be instanciated several times; each time they are, an
* instance is created. This instance will hold all the data used by the
* module's functions : the icon and its container, the config structure
* and its conf file, the data structure and a slot to plug datas into
* containers and icons. All these parameters are optionnal; a module
* that has an icon is also called an applet.
* Internal modules are just simplified version of modules, and are used
* internally by Cairo-Dock. As a special feature, a module can bind
* itself to an internal module, if its purpose is to complete it.
*/
......@@ -56,22 +66,29 @@ struct _CidVisitCard {
gchar *cDescription;
/// auteur/pseudo
gchar *cAuthor;
/// nom d'un module interne auquel ce module se rattache, ou NULL si aucun.
/// nom d'un module interne auquel ce module se rattache,
/// ou NULL si aucun.
const gchar *cInternalModule;
/// octets reserves pour preserver la compatibilite binaire lors de futurs ajouts sur l'interface entre plug-ins et dock.
/// octets reserves pour preserver la compatibilite binaire lors de
/// futurs ajouts sur l'interface entre plug-ins et dock.
char reserved[8];
};
/// Definition of the interface of a module.
struct _CidModuleInterface {
void (* initModule) (CidModuleInstance *pInstance, GKeyFile *pKeyFile);
void (* initModule) (CidModuleInstance *pInstance,
GKeyFile *pKeyFile);
void (* stopModule) (CidModuleInstance *pInstance);
gboolean (* reloadModule) (CidModuleInstance *pInstance, GKeyFile *pKeyFile);
gboolean (* read_conf_file) (CidModuleInstance *pInstance, GKeyFile *pKeyFile);
gboolean (* reloadModule) (CidModuleInstance *pInstance,
GKeyFile *pKeyFile);
gboolean (* read_conf_file) (CidModuleInstance *pInstance,
GKeyFile *pKeyFile);
void (* reset_config) (CidModuleInstance *pInstance);
void (* reset_data) (CidModuleInstance *pInstance);
void (* load_custom_widget) (CidModuleInstance *pInstance, GKeyFile *pKeyFile);
void (* save_custom_widget) (CidModuleInstance *pInstance, GKeyFile *pKeyFile);
void (* load_custom_widget) (CidModuleInstance *pInstance,
GKeyFile *pKeyFile);
void (* save_custom_widget) (CidModuleInstance *pInstance,
GKeyFile *pKeyFile);
};
/// Definition of an instance of a module.
......@@ -84,13 +101,15 @@ struct _CidModuleInstance {
};
/// Fill the visit card and the interface of a module.
typedef gboolean (* CidModulePreInit) (CidVisitCard *pVisitCard, CidModuleInterface *pInterface);
typedef gboolean (* CidModulePreInit) (CidVisitCard *pVisitCard,
CidModuleInterface *pInterface);
/// Definition of an external module.
struct _CidModule {
/// chemin du .so
gchar *cSoFilePath;
/// structure du module, contenant les pointeurs vers les fonctions du module.
/// structure du module, contenant les pointeurs vers les fonctions
/// du module.
GModule *pModule;
/// fonctions d'interface du module.
CidModuleInterface *pInterface;
......@@ -107,10 +126,16 @@ struct _CidModule {
typedef gpointer CidInternalModuleConfigPtr;
typedef gpointer CidInternalModuleDataPtr;
typedef void (* CidInternalModuleReloadFunc) (CidInternalModuleConfigPtr *pPrevConfig, CidInternalModuleConfigPtr *pNewConfig);
typedef gboolean (* CidInternalModuleGetConfigFunc) (GKeyFile *pKeyFile, CidInternalModuleConfigPtr *pConfig);
typedef void (* CidInternalModuleResetConfigFunc) (CidInternalModuleConfigPtr *pConfig);
typedef void (* CidInternalModuleResetDataFunc) (CidInternalModuleDataPtr *pData);
typedef void (* CidInternalModuleReloadFunc)
(CidInternalModuleConfigPtr *pPrevConfig,
CidInternalModuleConfigPtr *pNewConfig);
typedef gboolean (* CidInternalModuleGetConfigFunc)
(GKeyFile *pKeyFile,
CidInternalModuleConfigPtr *pConfig);
typedef void (* CidInternalModuleResetConfigFunc)
(CidInternalModuleConfigPtr *pConfig);
typedef void (* CidInternalModuleResetDataFunc)
(CidInternalModuleDataPtr *pData);
/// Definition of an internal module.
struct _CidInternalModule {
......@@ -135,76 +160,98 @@ struct _CidInternalModule {
void cid_initialize_module_manager (const gchar *cModuleDirPath);
/*
*Verifie que le fichier de conf d'un plug-in est bien present dans le repertoire utilisateur du plug-in, sinon le copie a partir du fichier de conf fournit lors de l'installation. Cree au besoin le repertoire utilisateur du plug-in.
*@param pVisitCard la carte de visite du module.
*@return Le chemin du fichier de conf en espace utilisateur, ou NULL si le fichier n'a pu etre ni trouve, ni cree.
*/
/**