2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_plugin.c: plugins called from SWAD using web services
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
TODO: Check if web service is called from an authorized IP.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-10-16 02:24:29 +02:00
|
|
|
|
#include <stdbool.h> // For boolean type
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For calloc, free
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2019-05-16 14:02:06 +02:00
|
|
|
|
#include "swad_API.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_config.h"
|
|
|
|
|
#include "swad_constant.h"
|
|
|
|
|
#include "swad_cryptography.h"
|
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2018-12-08 16:43:13 +01:00
|
|
|
|
#include "swad_language.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#include "swad_plugin.h"
|
2021-10-06 21:38:15 +02:00
|
|
|
|
#include "swad_plugin_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_session.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static struct Plugin *Plg_EditingPlg = NULL; // Static variable to keep the plugin being edited
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 22:09:35 +02:00
|
|
|
|
static void Plg_PutIconToEditPlugins (__attribute__((unused)) void *Args);
|
2019-04-09 18:46:13 +02:00
|
|
|
|
static void Plg_EditPluginsInternal (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Plg_ListPluginsForEdition (void);
|
2020-10-13 22:34:31 +02:00
|
|
|
|
static void Plg_PutParamPlgCod (void *PlgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Plg_GetListPlugins (void);
|
|
|
|
|
static void Plg_PutFormToCreatePlugin (void);
|
|
|
|
|
static void Plg_PutHeadPlugins (void);
|
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
static void Plg_EditingPluginConstructor (void);
|
|
|
|
|
static void Plg_EditingPluginDestructor (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** List available plugins ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_ListPlugins (void)
|
|
|
|
|
{
|
2021-12-15 00:47:29 +01:00
|
|
|
|
extern const char *The_ClassDat[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Option_under_development;
|
|
|
|
|
extern const char *Txt_Plugins;
|
|
|
|
|
extern const char *Txt_Plugin;
|
|
|
|
|
unsigned NumPlg;
|
|
|
|
|
struct Plugin *Plg;
|
2018-10-17 01:08:42 +02:00
|
|
|
|
char URL[Cns_MAX_BYTES_WWW + Cns_BYTES_SESSION_ID + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-02-16 18:11:52 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_Option_under_development);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get list of plugins *****/
|
|
|
|
|
Plg_GetListPlugins ();
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
|
|
|
|
|
Box_BoxTableBegin (NULL,Txt_Plugins,
|
2020-04-08 22:09:35 +02:00
|
|
|
|
Plg_PutIconToEditPlugins,NULL,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
|
|
|
|
else
|
|
|
|
|
Box_BoxTableBegin (NULL,Txt_Plugins,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write table heading *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Plugin);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Write all plugins *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (NumPlg = 0;
|
|
|
|
|
NumPlg < Gbl.Plugins.Num;
|
|
|
|
|
NumPlg++)
|
|
|
|
|
{
|
|
|
|
|
Plg = &(Gbl.Plugins.Lst[NumPlg]);
|
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (URL,sizeof (URL),"%s%s",Plg->URL,Gbl.Session.Id);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Plugin logo */
|
2015-09-05 19:19:39 +02:00
|
|
|
|
// TODO: Change plugin icons to 32x32
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LM\" style=\"width:45px;\"",
|
|
|
|
|
The_ClassDat[Gbl.Prefs.Theme]);
|
|
|
|
|
HTM_A_Begin ("href=\"%s\" title=\"%s\" class=\"%s\" target=\"_blank\"",
|
|
|
|
|
URL,Plg->Name,The_ClassDat[Gbl.Prefs.Theme]);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_IMG (Cfg_URL_ICON_PLUGINS_PUBLIC,
|
2021-12-15 14:02:49 +01:00
|
|
|
|
Str_BuildString ("%s24x24.gif",Gbl.Plugins.Lst[NumPlg].Logo),
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Plg->Name,
|
|
|
|
|
"class=\"ICO40x40\"");
|
2021-12-15 00:47:29 +01:00
|
|
|
|
Str_FreeStrings ();
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_A_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LM\"",The_ClassDat[Gbl.Prefs.Theme]);
|
|
|
|
|
HTM_A_Begin ("href=\"%s\" title=\"%s\" class=\"%s\" target=\"_blank\"",
|
|
|
|
|
URL,Plg->Name,The_ClassDat[Gbl.Prefs.Theme]);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_Txt (Plg->Name);
|
|
|
|
|
HTM_A_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 20:17:29 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-11 22:26:40 +02:00
|
|
|
|
/***** End table and box *****/
|
2019-11-25 23:18:08 +01:00
|
|
|
|
Box_BoxTableEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free list of plugins *****/
|
|
|
|
|
Plg_FreeListPlugins ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-03-19 00:48:58 +01:00
|
|
|
|
/*************************** Put icon to edit plugins ************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 22:09:35 +02:00
|
|
|
|
static void Plg_PutIconToEditPlugins (__attribute__((unused)) void *Args)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-08 22:09:35 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiPlg,NULL,
|
|
|
|
|
NULL,NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Put forms to edit plugins ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_EditPlugins (void)
|
|
|
|
|
{
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Plugin constructor *****/
|
|
|
|
|
Plg_EditingPluginConstructor ();
|
|
|
|
|
|
|
|
|
|
/***** Edit plugins *****/
|
|
|
|
|
Plg_EditPluginsInternal ();
|
|
|
|
|
|
|
|
|
|
/***** Plugin destructor *****/
|
|
|
|
|
Plg_EditingPluginDestructor ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Plg_EditPluginsInternal (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Plugins;
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get list of plugins *****/
|
|
|
|
|
Plg_GetListPlugins ();
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Plugins,
|
|
|
|
|
NULL,NULL,
|
2019-04-09 18:46:13 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Put a form to create a new plugin *****/
|
|
|
|
|
Plg_PutFormToCreatePlugin ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** List current plugins *****/
|
|
|
|
|
if (Gbl.Plugins.Num)
|
|
|
|
|
Plg_ListPluginsForEdition ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2019-04-09 18:46:13 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free list of plugins *****/
|
|
|
|
|
Plg_FreeListPlugins ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Get list of current plugins ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Plg_GetListPlugins (void)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumPlg;
|
|
|
|
|
struct Plugin *Plg;
|
|
|
|
|
|
|
|
|
|
/***** Get plugins from database *****/
|
2021-10-06 21:38:15 +02:00
|
|
|
|
if ((Gbl.Plugins.Num = Plg_DB_GetListPlugins (&mysql_res))) // Plugins found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create list with plugins *****/
|
2021-04-17 01:08:48 +02:00
|
|
|
|
if ((Gbl.Plugins.Lst = calloc ((size_t) Gbl.Plugins.Num,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (*Gbl.Plugins.Lst))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the plugins *****/
|
|
|
|
|
for (NumPlg = 0;
|
|
|
|
|
NumPlg < Gbl.Plugins.Num;
|
|
|
|
|
NumPlg++)
|
|
|
|
|
{
|
|
|
|
|
Plg = &(Gbl.Plugins.Lst[NumPlg]);
|
|
|
|
|
|
|
|
|
|
/* Get next plugin */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get plugin code (row[0]) */
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Plg->PlgCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPluginExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
/* Get name (row[1]), description (row[2), logo (row[3]),
|
|
|
|
|
* application key (row[4]), URL (row[5]) and IP (row[6]) of the plugin */
|
|
|
|
|
Str_Copy (Plg->Name ,row[1],sizeof (Plg->Name ) - 1);
|
|
|
|
|
Str_Copy (Plg->Description,row[2],sizeof (Plg->Description) - 1);
|
|
|
|
|
Str_Copy (Plg->Logo ,row[3],sizeof (Plg->Logo ) - 1);
|
|
|
|
|
Str_Copy (Plg->AppKey ,row[4],sizeof (Plg->AppKey ) - 1);
|
|
|
|
|
Str_Copy (Plg->URL ,row[5],sizeof (Plg->URL ) - 1);
|
|
|
|
|
Str_Copy (Plg->IP ,row[6],sizeof (Plg->IP ) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Get data of a plugin ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
bool Plg_GetDataOfPluginByCod (struct Plugin *Plg)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
bool PluginFound;
|
|
|
|
|
|
|
|
|
|
/***** Clear data *****/
|
2017-03-13 13:43:37 +01:00
|
|
|
|
Plg->Name[0] =
|
|
|
|
|
Plg->Description[0] =
|
|
|
|
|
Plg->Logo[0] =
|
|
|
|
|
Plg->URL[0] =
|
|
|
|
|
Plg->IP[0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if plugin code is correct *****/
|
|
|
|
|
if (Plg->PlgCod <= 0)
|
|
|
|
|
return false;
|
|
|
|
|
// Plg->PlgCod > 0
|
|
|
|
|
|
|
|
|
|
/***** Get data of a plugin from database *****/
|
2021-10-06 21:38:15 +02:00
|
|
|
|
if (Plg_DB_GetDataOfPluginByCod (&mysql_res,Plg->PlgCod)) // Plugin found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
PluginFound = true;
|
|
|
|
|
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
/* Get name (row[0]), description (row[1]), logo (row[2]),
|
|
|
|
|
application key (row[3]), URL (row[4]) and IP (row[5]) of the plugin */
|
|
|
|
|
Str_Copy (Plg->Name ,row[0],sizeof (Plg->Name ) - 1);
|
|
|
|
|
Str_Copy (Plg->Description,row[1],sizeof (Plg->Description) - 1);
|
|
|
|
|
Str_Copy (Plg->Logo ,row[2],sizeof (Plg->Logo ) - 1);
|
|
|
|
|
Str_Copy (Plg->AppKey ,row[3],sizeof (Plg->AppKey ) - 1);
|
|
|
|
|
Str_Copy (Plg->URL ,row[4],sizeof (Plg->URL ) - 1);
|
|
|
|
|
Str_Copy (Plg->IP ,row[5],sizeof (Plg->IP ) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
PluginFound = false;
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return PluginFound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Free list of plugins ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_FreeListPlugins (void)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Plugins.Lst)
|
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of plugins *****/
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Gbl.Plugins.Lst);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Plugins.Lst = NULL;
|
|
|
|
|
Gbl.Plugins.Num = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/****************************** List all plugins *****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Plg_ListPluginsForEdition (void)
|
|
|
|
|
{
|
2021-12-15 00:47:29 +01:00
|
|
|
|
extern const char *The_ClassDat[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumPlg;
|
|
|
|
|
struct Plugin *Plg;
|
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Plg_PutHeadPlugins ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Write all plugins *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
for (NumPlg = 0;
|
|
|
|
|
NumPlg < Gbl.Plugins.Num;
|
|
|
|
|
NumPlg++)
|
|
|
|
|
{
|
|
|
|
|
Plg = &Gbl.Plugins.Lst[NumPlg];
|
|
|
|
|
|
|
|
|
|
/* Row begin */
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Put icon to remove plugin */
|
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
Ico_PutContextualIconToRemove (ActRemPlg,NULL,
|
|
|
|
|
Plg_PutParamPlgCod,&Plg->PlgCod);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Plugin code */
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RM\"",The_ClassDat[Gbl.Prefs.Theme]);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_Long (Plg->PlgCod);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Plugin logo */
|
|
|
|
|
// TODO: Change plugin icons to 32x32
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\" style=\"width:45px;\"");
|
|
|
|
|
HTM_IMG (Cfg_URL_ICON_PLUGINS_PUBLIC,
|
2021-12-15 14:02:49 +01:00
|
|
|
|
Str_BuildString ("%s24x24.gif",Gbl.Plugins.Lst[NumPlg].Logo),
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Gbl.Plugins.Lst[NumPlg].Name,
|
|
|
|
|
"class=\"ICO40x40\"");
|
2021-12-15 00:47:29 +01:00
|
|
|
|
Str_FreeStrings ();
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Plugin name */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActRenPlg);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Plg_PutParamPlgCod (&Plg->PlgCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_INPUT_TEXT ("Name",Plg_MAX_CHARS_PLUGIN_NAME,Plg->Name,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"10\"");
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Plugin description */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgPlgDes);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Plg_PutParamPlgCod (&Plg->PlgCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_INPUT_TEXT ("Description",Plg_MAX_CHARS_PLUGIN_DESCRIPTION,Plg->Description,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"30\"");
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Plugin logo */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgPlgLog);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Plg_PutParamPlgCod (&Plg->PlgCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_INPUT_TEXT ("Logo",Plg_MAX_CHARS_PLUGIN_LOGO,Plg->Logo,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"4\"");
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Plugin application key */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgPlgAppKey);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Plg_PutParamPlgCod (&Plg->PlgCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_INPUT_TEXT ("AppKey",Plg_MAX_CHARS_PLUGIN_APP_KEY,Plg->AppKey,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"16\"");
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Plugin URL */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgPlgURL);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Plg_PutParamPlgCod (&Plg->PlgCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_INPUT_URL ("URL",Plg->URL,HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"15\"");
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Plugin IP */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgPlgIP);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Plg_PutParamPlgCod (&Plg->PlgCod);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_INPUT_TEXT ("IP",Cns_MAX_CHARS_IP,Plg->IP,HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"10\"");
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Row end */
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Write parameter with code of plugin *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-10-13 22:34:31 +02:00
|
|
|
|
static void Plg_PutParamPlgCod (void *PlgCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-10-13 22:34:31 +02:00
|
|
|
|
if (PlgCod)
|
|
|
|
|
Par_PutHiddenParamLong (NULL,"PlgCod",*((long *) PlgCod));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get parameter with code of plugin *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
long Plg_GetParamPlgCod (void)
|
|
|
|
|
{
|
2017-01-28 20:32:50 +01:00
|
|
|
|
/***** Get code of plugin *****/
|
|
|
|
|
return Par_GetParToLong ("PlgCod");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Remove a plugin *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_RemovePlugin (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Plugin_X_removed;
|
2019-04-09 18:46:13 +02:00
|
|
|
|
|
|
|
|
|
/***** Plugin constructor *****/
|
|
|
|
|
Plg_EditingPluginConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get plugin code *****/
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPluginExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the plugin from database *****/
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove plugin *****/
|
2021-10-06 21:38:15 +02:00
|
|
|
|
Plg_DB_RemovePlugin (Plg_EditingPlg->PlgCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_Plugin_X_removed,
|
|
|
|
|
Plg_EditingPlg->Name);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Change the name of a plugin ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_RenamePlugin (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_plugin_X_already_exists;
|
|
|
|
|
extern const char *Txt_The_plugin_X_has_been_renamed_as_Y;
|
|
|
|
|
extern const char *Txt_The_name_of_the_plugin_X_has_not_changed;
|
2017-03-08 01:21:21 +01:00
|
|
|
|
char NewPlgName[Plg_MAX_BYTES_PLUGIN_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Plugin constructor *****/
|
|
|
|
|
Plg_EditingPluginConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the plugin */
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPluginExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new name for the plugin */
|
2017-03-08 01:21:21 +01:00
|
|
|
|
Par_GetParToText ("Name",NewPlgName,Plg_MAX_BYTES_PLUGIN_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Get plugin data from the database *****/
|
|
|
|
|
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if new name is empty *****/
|
2019-12-20 00:30:54 +01:00
|
|
|
|
if (NewPlgName[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-01-02 15:10:51 +01:00
|
|
|
|
/***** Check if old and new names are the same
|
|
|
|
|
(this happens when return is pressed without changes) *****/
|
2019-04-09 18:46:13 +02:00
|
|
|
|
if (strcmp (Plg_EditingPlg->Name,NewPlgName)) // Different names
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** If plugin was in database... *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Plg_DB_CheckIfPluginNameExists (NewPlgName,Plg_EditingPlg->PlgCod))
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_The_plugin_X_already_exists,
|
|
|
|
|
NewPlgName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old name by new name */
|
2021-10-06 21:38:15 +02:00
|
|
|
|
Plg_DB_ChangeName (Plg_EditingPlg->PlgCod,NewPlgName);
|
|
|
|
|
|
|
|
|
|
/* Write message to show the change made */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_plugin_X_has_been_renamed_as_Y,
|
|
|
|
|
Plg_EditingPlg->Name,NewPlgName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // The same name
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_INFO,NULL,
|
|
|
|
|
Txt_The_name_of_the_plugin_X_has_not_changed,
|
|
|
|
|
Plg_EditingPlg->Name);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-12-20 00:30:54 +01:00
|
|
|
|
else
|
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Update name *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Plg_EditingPlg->Name,NewPlgName,sizeof (Plg_EditingPlg->Name) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Change the description of a plugin **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_ChangePlgDescription (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_new_description_is_X;
|
2017-03-08 01:21:21 +01:00
|
|
|
|
char NewDescription[Plg_MAX_BYTES_PLUGIN_DESCRIPTION + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Plugin constructor *****/
|
|
|
|
|
Plg_EditingPluginConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the plugin */
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPluginExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new description for the plugin */
|
2017-03-08 01:21:21 +01:00
|
|
|
|
Par_GetParToText ("Description",NewDescription,Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Get plugin data from the database *****/
|
|
|
|
|
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Check if new description is empty *****/
|
|
|
|
|
if (NewDescription[0])
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old description by new description */
|
2021-10-06 21:38:15 +02:00
|
|
|
|
Plg_DB_ChangeDescription (Plg_EditingPlg->PlgCod,NewDescription);
|
|
|
|
|
|
|
|
|
|
/* Write message to show the change made */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_new_description_is_X,
|
|
|
|
|
NewDescription);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-12-20 00:30:54 +01:00
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Update description *****/
|
|
|
|
|
Str_Copy (Plg_EditingPlg->Description,NewDescription,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (Plg_EditingPlg->Description) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Change the logo of a plugin ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_ChangePlgLogo (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_new_logo_is_X;
|
2017-03-08 01:21:21 +01:00
|
|
|
|
char NewLogo[Plg_MAX_BYTES_PLUGIN_LOGO + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Plugin constructor *****/
|
|
|
|
|
Plg_EditingPluginConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the plugin */
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPluginExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new logo for the plugin */
|
2017-03-08 01:21:21 +01:00
|
|
|
|
Par_GetParToText ("Logo",NewLogo,Plg_MAX_BYTES_PLUGIN_LOGO);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Get plugin data from the database *****/
|
|
|
|
|
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Check if new logo is empty *****/
|
|
|
|
|
if (NewLogo[0])
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old logo by new logo */
|
2021-10-06 21:38:15 +02:00
|
|
|
|
Plg_DB_ChangeLogo (Plg_EditingPlg->PlgCod,NewLogo);
|
|
|
|
|
|
|
|
|
|
/* Write message to show the change made */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_new_logo_is_X,
|
|
|
|
|
NewLogo);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-12-20 00:30:54 +01:00
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Update logo *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Plg_EditingPlg->Logo,NewLogo,sizeof (Plg_EditingPlg->Logo) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Change the application key of a plugin *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_ChangePlgAppKey (void)
|
|
|
|
|
{
|
2021-10-06 21:38:15 +02:00
|
|
|
|
extern const char *Txt_The_new_application_key_is_X;
|
2017-03-08 01:21:21 +01:00
|
|
|
|
char NewAppKey[Plg_MAX_BYTES_PLUGIN_APP_KEY + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Plugin constructor *****/
|
|
|
|
|
Plg_EditingPluginConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the plugin */
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPluginExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new logo for the plugin */
|
2017-03-08 01:21:21 +01:00
|
|
|
|
Par_GetParToText ("AppKey",NewAppKey,Plg_MAX_BYTES_PLUGIN_APP_KEY);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Get plugin data from the database *****/
|
|
|
|
|
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Check if new logo is empty *****/
|
|
|
|
|
if (NewAppKey[0])
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old application key by new application key */
|
2021-10-06 21:38:15 +02:00
|
|
|
|
Plg_DB_ChangeAppKey (Plg_EditingPlg->PlgCod,NewAppKey);
|
|
|
|
|
|
|
|
|
|
/* Write message to show the change made */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
2021-10-06 21:38:15 +02:00
|
|
|
|
Txt_The_new_application_key_is_X,
|
2019-04-09 18:46:13 +02:00
|
|
|
|
NewAppKey);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-12-20 00:30:54 +01:00
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Update app key *****/
|
2021-02-15 22:49:44 +01:00
|
|
|
|
Str_Copy (Plg_EditingPlg->AppKey,NewAppKey,sizeof (Plg_EditingPlg->AppKey) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Change the URL of a plugin *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_ChangePlgURL (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_new_URL_is_X;
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char NewURL[Cns_MAX_BYTES_WWW + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Plugin constructor *****/
|
|
|
|
|
Plg_EditingPluginConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the plugin */
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPluginExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new URL for the plugin */
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Par_GetParToText ("URL",NewURL,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Get plugin data from the database *****/
|
|
|
|
|
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Check if new URL is empty *****/
|
|
|
|
|
if (NewURL[0])
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old WWW by new WWW */
|
2021-10-06 21:38:15 +02:00
|
|
|
|
Plg_DB_ChangeURL (Plg_EditingPlg->PlgCod,NewURL);
|
|
|
|
|
|
|
|
|
|
/* Write message to show the change made */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_new_URL_is_X,
|
|
|
|
|
NewURL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-12-20 00:30:54 +01:00
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Update URL *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Plg_EditingPlg->URL,NewURL,sizeof (Plg_EditingPlg->URL) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Change the IP of a plugin *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_ChangePlgIP (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_new_IP_address_is_X;
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char NewIP[Cns_MAX_BYTES_IP + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Plugin constructor *****/
|
|
|
|
|
Plg_EditingPluginConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the plugin */
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPluginExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new IP for the plugin */
|
2017-03-07 11:03:05 +01:00
|
|
|
|
Par_GetParToText ("IP",NewIP,Cns_MAX_BYTES_IP);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Get plugin data from the database *****/
|
|
|
|
|
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Check if new IP is empty *****/
|
|
|
|
|
if (NewIP[0])
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old IP by new IP */
|
2021-10-06 21:38:15 +02:00
|
|
|
|
Plg_DB_ChangeIP (Plg_EditingPlg->PlgCod,NewIP);
|
|
|
|
|
|
|
|
|
|
/* Write message to show the change made */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_new_IP_address_is_X,
|
|
|
|
|
NewIP);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-12-20 00:30:54 +01:00
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Update IP *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Plg_EditingPlg->IP,NewIP,sizeof (Plg_EditingPlg->IP) - 1);
|
2019-04-09 18:46:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Show alerts after changing a plugin and continue editing **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Plg_ContEditAfterChgPlg (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Write message to show the change made *****/
|
|
|
|
|
Ale_ShowAlerts (NULL);
|
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
|
|
|
|
Plg_EditPluginsInternal ();
|
|
|
|
|
|
|
|
|
|
/***** Plugin destructor *****/
|
|
|
|
|
Plg_EditingPluginDestructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put a form to create a new plugin *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Plg_PutFormToCreatePlugin (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_plugin;
|
|
|
|
|
extern const char *Txt_Name;
|
|
|
|
|
extern const char *Txt_Description;
|
|
|
|
|
extern const char *Txt_Logo;
|
|
|
|
|
extern const char *Txt_Application_key;
|
|
|
|
|
extern const char *Txt_URL;
|
|
|
|
|
extern const char *Txt_IP;
|
|
|
|
|
extern const char *Txt_Create_plugin;
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActNewPlg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin box and table *****/
|
|
|
|
|
Box_BoxTableBegin (NULL,Txt_New_plugin,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Name);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Description);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Logo);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Application_key);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_URL);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_IP);
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Row begin *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/***** Plugin name *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("Name",Plg_MAX_CHARS_PLUGIN_NAME,Plg_EditingPlg->Name,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"10\" required=\"required\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Plugin description *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("Description",Plg_MAX_CHARS_PLUGIN_DESCRIPTION,
|
|
|
|
|
Plg_EditingPlg->Description,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"30\" required=\"required\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Plugin logo *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("Logo",Plg_MAX_CHARS_PLUGIN_LOGO,Plg_EditingPlg->Logo,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"4\" required=\"required\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Plugin application key *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("AppKey",Plg_MAX_CHARS_PLUGIN_APP_KEY,Plg_EditingPlg->AppKey,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"16\" required=\"required\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Plugin URL *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_URL ("URL",Plg_EditingPlg->URL,HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"15\" required=\"required\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Plugin IP address *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("IP",Cns_MAX_CHARS_IP,Plg_EditingPlg->IP,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"size=\"10\" required=\"required\"");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Row end *****/
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** End table, send button and end box *****/
|
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_plugin);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-04-11 23:46:21 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write header with fields of a plugin *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Plg_PutHeadPlugins (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Code;
|
|
|
|
|
extern const char *Txt_Name;
|
|
|
|
|
extern const char *Txt_Description;
|
|
|
|
|
extern const char *Txt_Logo;
|
|
|
|
|
extern const char *Txt_Application_key;
|
|
|
|
|
extern const char *Txt_URL;
|
|
|
|
|
extern const char *Txt_IP;
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Code);
|
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Name);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Description);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Logo);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_Application_key);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_URL);
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_IP);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Receive form to create a new plugin **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Plg_ReceiveFormNewPlg (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_plugin_X_already_exists;
|
2019-04-09 18:46:13 +02:00
|
|
|
|
extern const char *Txt_Created_new_plugin_X;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_You_must_specify_the_logo_the_application_key_the_URL_and_the_IP_address_of_the_new_plugin;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_name_and_the_description_of_the_new_plugin;
|
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/***** Plugin constructor *****/
|
|
|
|
|
Plg_EditingPluginConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get plugin name */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Par_GetParToText ("Name",Plg_EditingPlg->Name,Plg_MAX_BYTES_PLUGIN_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get plugin description */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Par_GetParToText ("Description",Plg_EditingPlg->Description,Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get plugin logo */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Par_GetParToText ("Logo",Plg_EditingPlg->Logo,Plg_MAX_BYTES_PLUGIN_LOGO);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get plugin application key */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Par_GetParToText ("AppKey",Plg_EditingPlg->AppKey,Plg_MAX_BYTES_PLUGIN_APP_KEY);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get plugin URL */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Par_GetParToText ("URL",Plg_EditingPlg->URL,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get plugin IP address */
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Par_GetParToText ("IP",Plg_EditingPlg->IP,Cns_MAX_BYTES_IP);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 18:46:13 +02:00
|
|
|
|
if (Plg_EditingPlg->Name[0]) // If there's a plugin name
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-04-09 18:46:13 +02:00
|
|
|
|
if (Plg_EditingPlg->Logo[0] &&
|
|
|
|
|
Plg_EditingPlg->AppKey[0] &&
|
|
|
|
|
Plg_EditingPlg->URL[0] &&
|
|
|
|
|
Plg_EditingPlg->IP[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** If name of plugin was in database... *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
if (Plg_DB_CheckIfPluginNameExists (Plg_EditingPlg->Name,-1L))
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_The_plugin_X_already_exists,
|
|
|
|
|
Plg_EditingPlg->Name);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // Add new plugin to database
|
2019-04-09 18:46:13 +02:00
|
|
|
|
{
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Plg_DB_CreatePlugin (Plg_EditingPlg);
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_Created_new_plugin_X,
|
|
|
|
|
Plg_EditingPlg->Name);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // If there is not a logo, a URL or a IP
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_You_must_specify_the_logo_the_application_key_the_URL_and_the_IP_address_of_the_new_plugin);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // If there is not a plugin name
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_You_must_specify_the_name_and_the_description_of_the_new_plugin);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-04-09 18:46:13 +02:00
|
|
|
|
/************************ Plugin constructor/destructor **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Plg_EditingPluginConstructor (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Pointer must be NULL *****/
|
|
|
|
|
if (Plg_EditingPlg != NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPluginExit ();
|
2019-04-09 18:46:13 +02:00
|
|
|
|
|
|
|
|
|
/***** Allocate memory for plugin *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Plg_EditingPlg = malloc (sizeof (*Plg_EditingPlg))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2019-04-09 18:46:13 +02:00
|
|
|
|
|
|
|
|
|
/***** Reset plugin *****/
|
|
|
|
|
Plg_EditingPlg->PlgCod = -1L;
|
|
|
|
|
Plg_EditingPlg->Name[0] = '\0';
|
|
|
|
|
Plg_EditingPlg->Description[0] = '\0';
|
|
|
|
|
Plg_EditingPlg->Logo[0] = '\0';
|
|
|
|
|
Plg_EditingPlg->AppKey[0] = '\0';
|
|
|
|
|
Plg_EditingPlg->URL[0] = '\0';
|
|
|
|
|
Plg_EditingPlg->IP[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Plg_EditingPluginDestructor (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Free memory used for plugin *****/
|
|
|
|
|
if (Plg_EditingPlg != NULL)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Plg_EditingPlg);
|
2019-04-09 18:46:13 +02:00
|
|
|
|
Plg_EditingPlg = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|