2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_chat.c: chat
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Copyright (C) 1999-2023 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/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2015-10-16 02:24:29 +02:00
|
|
|
|
#include <stdbool.h> // For boolean type
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2022-10-19 18:07:49 +02:00
|
|
|
|
#include "swad_alert.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_chat.h"
|
2021-05-19 15:07:24 +02:00
|
|
|
|
#include "swad_chat_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_config.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_course_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#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"
|
2023-09-22 14:47:56 +02:00
|
|
|
|
#include "swad_hierarchy_type.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"
|
2015-01-17 20:06:25 +01:00
|
|
|
|
#include "swad_logo.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
#include "swad_string.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define Cht_CHAT_MAX_LEVELS 3
|
|
|
|
|
|
2017-03-09 21:24:06 +01:00
|
|
|
|
#define Cht_MAX_CHARS_ROOM_CODE 16 // 16, maximum number of chars of the code of a chat room
|
|
|
|
|
#define Cht_MAX_BYTES_ROOM_CODE Cht_MAX_CHARS_ROOM_CODE // 16
|
2017-03-07 11:03:05 +01:00
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define Cht_MAX_CHARS_ROOM_SHRT_NAME (128 - 1) // 127, maximum number of chars of the short name of a chat room
|
|
|
|
|
#define Cht_MAX_BYTES_ROOM_SHRT_NAME ((Cht_MAX_CHARS_ROOM_SHRT_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
2017-03-07 11:03:05 +01:00
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define Cht_MAX_CHARS_ROOM_FULL_NAME (256 - 1) // 255, maximum number of chars of the full name of a chat room
|
|
|
|
|
#define Cht_MAX_BYTES_ROOM_FULL_NAME ((Cht_MAX_CHARS_ROOM_FULL_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 4095
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-07 11:03:05 +01:00
|
|
|
|
static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShrtName,const char *RoomFullName,
|
2023-11-07 19:06:18 +01:00
|
|
|
|
unsigned Level,Lay_LastItem_t IsLastItemInLevel[1 + Cht_CHAT_MAX_LEVELS]);
|
2015-01-17 19:31:21 +01:00
|
|
|
|
static void Cht_WriteLinkToChat2 (const char *RoomCode,const char *RoomFullName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** List available whiteboard/chat rooms *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cht_ShowChatRooms (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_To_use_chat_you_must_have_installed_the_software_X_and_add_Y_;
|
2017-04-21 14:39:21 +02:00
|
|
|
|
extern const char *Txt_Unfortunately_Firefox_and_Chrome_no_longer_allow_Java_to_run_;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Help message about software needed to use the whiteboard/chat *****/
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_To_use_chat_you_must_have_installed_the_software_X_and_add_Y_,
|
2019-02-16 00:03:58 +01:00
|
|
|
|
Cfg_JAVA_URL,Cfg_JAVA_NAME,
|
|
|
|
|
Cfg_PLATFORM_SERVER);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** List available chat rooms *****/
|
|
|
|
|
Cht_ShowListOfAvailableChatRooms ();
|
|
|
|
|
|
2019-02-16 14:37:34 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_Unfortunately_Firefox_and_Chrome_no_longer_allow_Java_to_run_);
|
2017-04-21 14:39:21 +02: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
|
|
|
|
Cht_ShowListOfChatRoomsWithUsrs ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Show list of available chat rooms *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cht_ShowListOfAvailableChatRooms (void)
|
|
|
|
|
{
|
2023-12-06 20:59:19 +01:00
|
|
|
|
extern bool (*Hie_GetDataByCod[Hie_NUM_LEVELS]) (struct Hie_Node *Node);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Chat_rooms;
|
|
|
|
|
extern const char *Txt_General;
|
|
|
|
|
extern const char *Txt_SEX_PLURAL_Abc[Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_SEX_PLURAL_abc[Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
2017-05-30 21:43:05 +02:00
|
|
|
|
extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
|
2023-11-06 12:36:05 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_SINGUL_Abc[Hie_NUM_LEVELS];
|
2023-11-07 19:06:18 +01:00
|
|
|
|
Lay_LastItem_t IsLastItemInLevel[1 + Cht_CHAT_MAX_LEVELS];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumMyDeg;
|
2023-09-18 15:15:29 +02:00
|
|
|
|
struct Hie_Node Deg;
|
|
|
|
|
struct Hie_Node Crs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-04-16 13:51:12 +02:00
|
|
|
|
unsigned NumCrss;
|
|
|
|
|
unsigned NumCrs;
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char ThisRoomCode [Cht_MAX_BYTES_ROOM_CODE + 1];
|
|
|
|
|
char ThisRoomShrtName[Cht_MAX_BYTES_ROOM_SHRT_NAME + 1];
|
|
|
|
|
char ThisRoomFullName[Cht_MAX_BYTES_ROOM_FULL_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Fill the list with the degrees I belong to *****/
|
2023-10-03 14:32:22 +02:00
|
|
|
|
Hie_GetMyHierarchy (Hie_DEG);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Chat_rooms,
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-19 15:07:24 +02:00
|
|
|
|
/***** Begin list *****/
|
|
|
|
|
HTM_UL_Begin ("class=\"LIST_TREE\"");
|
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Link to chat available for all users *****/
|
2023-11-07 19:06:18 +01:00
|
|
|
|
IsLastItemInLevel[1] = (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS] ||
|
|
|
|
|
Gbl.Usrs.Me.Hierarchy[Hie_DEG].Num) ? Lay_NO_LAST_ITEM :
|
|
|
|
|
Lay_LAST_ITEM;
|
2021-05-19 15:07:24 +02:00
|
|
|
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
|
|
|
|
|
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);
|
2023-11-07 19:06:18 +01:00
|
|
|
|
Cht_WriteLinkToChat1 ("GBL_USR",Txt_SEX_PLURAL_Abc[Usr_SEX_ALL],
|
|
|
|
|
ThisRoomFullName,1,IsLastItemInLevel);
|
2021-12-22 00:20:06 +01:00
|
|
|
|
Ico_PutIcon ("comments.svg",Ico_BLACK,ThisRoomFullName,"ICO16x16");
|
2021-05-19 15:07:24 +02:00
|
|
|
|
Cht_WriteLinkToChat2 ("GBL_USR",ThisRoomFullName);
|
|
|
|
|
|
2023-11-07 19:06:18 +01:00
|
|
|
|
IsLastItemInLevel[1] = Gbl.Usrs.Me.Hierarchy[Hie_DEG].Num ? Lay_NO_LAST_ITEM :
|
|
|
|
|
Lay_LAST_ITEM;
|
2021-05-19 15:07:24 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-05-19 15:07:24 +02:00
|
|
|
|
case Rol_STD:
|
|
|
|
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
|
|
|
|
|
Txt_General,Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_ALL]);
|
|
|
|
|
Cht_WriteLinkToChat1 ("GBL_STD",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD],
|
|
|
|
|
ThisRoomFullName,1,IsLastItemInLevel);
|
2021-12-22 00:20:06 +01:00
|
|
|
|
Ico_PutIcon ("comments.svg",Ico_BLACK,ThisRoomFullName,"ICO16x16");
|
2021-05-19 15:07:24 +02:00
|
|
|
|
Cht_WriteLinkToChat2 ("GBL_STD",ThisRoomFullName);
|
|
|
|
|
break;
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s (%s)",
|
|
|
|
|
Txt_General,Txt_ROLES_PLURAL_abc[Rol_TCH][Usr_SEX_ALL]);
|
|
|
|
|
Cht_WriteLinkToChat1 ("GBL_TCH",Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH],
|
|
|
|
|
ThisRoomFullName,1,IsLastItemInLevel);
|
2021-12-22 00:20:06 +01:00
|
|
|
|
Ico_PutIcon ("comments.svg",Ico_BLACK,ThisRoomFullName,"ICO16x16");
|
2021-05-19 15:07:24 +02:00
|
|
|
|
Cht_WriteLinkToChat2 ("GBL_TCH",ThisRoomFullName);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-04-16 13:51:12 +02:00
|
|
|
|
|
2021-05-19 15:07:24 +02:00
|
|
|
|
/***** Link to chat of users from my degrees *****/
|
|
|
|
|
for (NumMyDeg = 0;
|
2023-10-03 14:32:22 +02:00
|
|
|
|
NumMyDeg < Gbl.Usrs.Me.Hierarchy[Hie_DEG].Num;
|
2021-05-19 15:07:24 +02:00
|
|
|
|
NumMyDeg++)
|
|
|
|
|
{
|
|
|
|
|
/* Get data of this degree */
|
2023-10-03 14:32:22 +02:00
|
|
|
|
Deg.HieCod = Gbl.Usrs.Me.Hierarchy[Hie_DEG].Nodes[NumMyDeg].HieCod;
|
2023-12-06 20:59:19 +01:00
|
|
|
|
if (!Hie_GetDataByCod[Hie_DEG] (&Deg))
|
2021-05-19 15:07:24 +02:00
|
|
|
|
Err_WrongDegreeExit ();
|
|
|
|
|
|
|
|
|
|
/* Link to the room of this degree */
|
2023-11-07 19:06:18 +01:00
|
|
|
|
IsLastItemInLevel[1] = (NumMyDeg == Gbl.Usrs.Me.Hierarchy[Hie_DEG].Num - 1) ? Lay_LAST_ITEM :
|
|
|
|
|
Lay_NO_LAST_ITEM;
|
2023-09-20 10:36:07 +02:00
|
|
|
|
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"DEG_%ld",Deg.HieCod);
|
2021-04-16 13:51:12 +02:00
|
|
|
|
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),"%s",
|
2021-05-19 15:07:24 +02:00
|
|
|
|
Deg.ShrtName);
|
2021-04-16 13:51:12 +02:00
|
|
|
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
2023-11-06 12:36:05 +01:00
|
|
|
|
Txt_HIERARCHY_SINGUL_Abc[Hie_DEG],Deg.ShrtName);
|
2023-11-07 19:06:18 +01:00
|
|
|
|
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,
|
|
|
|
|
ThisRoomFullName,1,IsLastItemInLevel);
|
2023-11-28 01:44:05 +01:00
|
|
|
|
Lgo_DrawLogo (Hie_DEG,&Deg,"ICO16x16");
|
2021-04-16 13:51:12 +02:00
|
|
|
|
Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName);
|
2021-05-19 15:07:24 +02:00
|
|
|
|
|
|
|
|
|
/* Get my courses in this degree from database */
|
2021-11-03 11:35:21 +01:00
|
|
|
|
NumCrss = Crs_DB_GetCrssFromUsr (&mysql_res,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
2023-09-20 10:36:07 +02:00
|
|
|
|
Deg.HieCod);
|
2021-05-19 15:07:24 +02:00
|
|
|
|
for (NumCrs = 0;
|
|
|
|
|
NumCrs < NumCrss;
|
|
|
|
|
NumCrs++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next course */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get course code */
|
2023-09-20 10:36:07 +02:00
|
|
|
|
if ((Crs.HieCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
2021-05-19 15:07:24 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get data of this course */
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Hie_GetDataByCod[Hie_CRS] (&Crs);
|
2021-05-19 15:07:24 +02:00
|
|
|
|
|
|
|
|
|
/* Link to the room of this course */
|
2023-11-07 19:06:18 +01:00
|
|
|
|
IsLastItemInLevel[2] = (NumCrs == NumCrss - 1) ? Lay_LAST_ITEM :
|
|
|
|
|
Lay_NO_LAST_ITEM;
|
2021-05-19 15:07:24 +02:00
|
|
|
|
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"CRS_%ld",
|
2023-09-20 10:36:07 +02:00
|
|
|
|
Crs.HieCod);
|
2021-05-19 15:07:24 +02:00
|
|
|
|
snprintf (ThisRoomShrtName,sizeof (ThisRoomShrtName),"%s",
|
|
|
|
|
Crs.ShrtName);
|
|
|
|
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
2023-11-06 12:36:05 +01:00
|
|
|
|
Txt_HIERARCHY_SINGUL_Abc[Hie_CRS],Crs.ShrtName);
|
2023-11-07 19:06:18 +01:00
|
|
|
|
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,
|
|
|
|
|
ThisRoomFullName,2,IsLastItemInLevel);
|
2023-11-28 01:44:05 +01:00
|
|
|
|
Lgo_DrawLogo (Hie_CRS,&Crs,"ICO16x16");
|
2021-05-19 15:07:24 +02:00
|
|
|
|
Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-19 15:07:24 +02:00
|
|
|
|
/***** End list *****/
|
|
|
|
|
HTM_UL_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Show list of chat rooms with users *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Cht_ShowListOfChatRoomsWithUsrs (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Rooms_with_users;
|
|
|
|
|
extern const char *Txt_CHAT_Room_code;
|
2020-05-07 14:15:39 +02:00
|
|
|
|
extern const char *Txt_Number_of_users;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-04-16 13:51:12 +02:00
|
|
|
|
unsigned NumRooms;
|
|
|
|
|
unsigned NumRoom;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get chat rooms with connected users from database *****/
|
2021-05-19 15:07:24 +02:00
|
|
|
|
NumRooms = Cht_DB_GetListOfChatRoomsWithUsrs (&mysql_res);
|
2021-04-16 13:51:12 +02:00
|
|
|
|
if (NumRooms) // If not empty chat rooms found
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxTableBegin (NULL,Txt_Rooms_with_users,
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE,2);
|
2017-06-12 14:16:33 +02:00
|
|
|
|
|
2021-05-19 15:07:24 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH (Txt_CHAT_Room_code ,HTM_HEAD_CENTER);
|
|
|
|
|
HTM_TH (Txt_Number_of_users,HTM_HEAD_LEFT );
|
2021-05-19 15:07:24 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-05-19 15:07:24 +02:00
|
|
|
|
/***** Loop over chat rooms *****/
|
|
|
|
|
for (NumRoom = 0;
|
|
|
|
|
NumRoom < NumRooms;
|
|
|
|
|
NumRoom++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next chat room */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2019-10-06 12:00:55 +02:00
|
|
|
|
|
2021-05-19 15:07:24 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2023-10-14 21:36:39 +02:00
|
|
|
|
HTM_TD_Txt_Left (row[0]);
|
|
|
|
|
HTM_TD_Txt_Right (row[1]);
|
2021-05-19 15:07:24 +02:00
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +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 structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write title and link to a chat room ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-07 11:03:05 +01:00
|
|
|
|
static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShrtName,const char *RoomFullName,
|
2023-11-07 19:06:18 +01:00
|
|
|
|
unsigned Level,Lay_LastItem_t IsLastItemInLevel[1 + Cht_CHAT_MAX_LEVELS])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-05-19 15:07:24 +02:00
|
|
|
|
/***** Begin list item *****/
|
2019-10-26 22:49:13 +02:00
|
|
|
|
HTM_LI_Begin (NULL);
|
2019-11-18 09:59:00 +01:00
|
|
|
|
|
2023-11-07 19:06:18 +01:00
|
|
|
|
Lay_IndentDependingOnLevel (Level,IsLastItemInLevel,Lay_HORIZONTAL_LINE_AT_RIGHT);
|
2021-05-19 15:07:24 +02:00
|
|
|
|
|
|
|
|
|
/***** Begin form *****/
|
|
|
|
|
Frm_BeginForm (ActCht);
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Cht_WriteParsRoomCodeAndNames (RoomCode,RoomShrtName,RoomFullName);
|
2021-05-19 15:07:24 +02:00
|
|
|
|
|
|
|
|
|
/* Begin button */
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (RoomFullName,
|
|
|
|
|
"class=\"BT_LINK FORM_IN_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2015-01-17 19:31:21 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Cht_WriteLinkToChat2 (const char *RoomCode,const char *RoomFullName)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_connected_PLURAL;
|
|
|
|
|
extern const char *Txt_connected_SINGULAR;
|
2021-05-19 15:07:24 +02:00
|
|
|
|
unsigned NumUsrsInRoom = Cht_DB_GetNumUsrsInChatRoom (RoomCode);
|
|
|
|
|
|
|
|
|
|
/* Begin strong if room has users */
|
|
|
|
|
if (NumUsrsInRoom)
|
|
|
|
|
HTM_STRONG_Begin ();
|
|
|
|
|
|
|
|
|
|
/* Room name and users */
|
|
|
|
|
HTM_TxtF (" %s",RoomFullName);
|
|
|
|
|
if (NumUsrsInRoom > 1)
|
|
|
|
|
HTM_TxtF (" [%d %s]",NumUsrsInRoom,Txt_connected_PLURAL);
|
|
|
|
|
else if (NumUsrsInRoom == 1)
|
|
|
|
|
HTM_TxtF (" [1 %s]",Txt_connected_SINGULAR);
|
|
|
|
|
|
|
|
|
|
/* End strong if room has users */
|
|
|
|
|
if (NumUsrsInRoom)
|
|
|
|
|
HTM_STRONG_End ();
|
|
|
|
|
|
|
|
|
|
/* End button */
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
/***** End list item *****/
|
2019-10-26 22:49:13 +02:00
|
|
|
|
HTM_LI_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*** Write parameters with code and names (short and full) of a chat room ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
void Cht_WriteParsRoomCodeAndNames (const char *RoomCode,const char *RoomShrtName,const char *RoomFullName)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_PutParString (NULL,"RoomCode",RoomCode);
|
|
|
|
|
Par_PutParString (NULL,"RoomShrtName",RoomShrtName);
|
|
|
|
|
Par_PutParString (NULL,"RoomFullName",RoomFullName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Enter a chat room ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-10-03 00:25:57 +02:00
|
|
|
|
// TODO: Max. bytes should be allocated dinamycally depending on number of degrees and courses
|
|
|
|
|
#define Cht_MAX_BYTES_ROOM_CODES (100 * Cht_MAX_BYTES_ROOM_CODE)
|
|
|
|
|
#define Cht_MAX_BYTES_ROOM_SHRT_NAMES (100 * Cht_MAX_BYTES_ROOM_SHRT_NAME)
|
|
|
|
|
#define Cht_MAX_BYTES_ROOM_FULL_NAMES (100 * Cht_MAX_BYTES_ROOM_FULL_NAME)
|
2017-01-17 03:10:43 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Cht_OpenChatWindow (void)
|
|
|
|
|
{
|
2023-12-06 20:59:19 +01:00
|
|
|
|
extern bool (*Hie_GetDataByCod[Hie_NUM_LEVELS]) (struct Hie_Node *Node);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_SEX_PLURAL_Abc[Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_SEX_PLURAL_abc[Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_General;
|
|
|
|
|
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
2017-05-30 21:43:05 +02:00
|
|
|
|
extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
|
2023-11-06 12:36:05 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_SINGUL_Abc[Hie_NUM_LEVELS];
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char RoomCode[Cht_MAX_BYTES_ROOM_CODE + 1];
|
|
|
|
|
char RoomShrtName[Cht_MAX_BYTES_ROOM_SHRT_NAME + 1];
|
|
|
|
|
char RoomFullName [Cht_MAX_BYTES_ROOM_FULL_NAME + 1];
|
2017-01-13 01:51:23 +01:00
|
|
|
|
char UsrName[Usr_MAX_BYTES_FULL_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumMyDeg;
|
|
|
|
|
unsigned NumMyCrs;
|
2023-09-18 15:15:29 +02:00
|
|
|
|
struct Hie_Node Deg;
|
|
|
|
|
struct Hie_Node Crs;
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char ThisRoomCode[Cht_MAX_BYTES_ROOM_CODE + 1];
|
|
|
|
|
char ThisRoomShortName[Cht_MAX_BYTES_ROOM_SHRT_NAME + 1];
|
|
|
|
|
char ThisRoomFullName [Cht_MAX_BYTES_ROOM_FULL_NAME + 1];
|
2023-10-03 00:25:57 +02:00
|
|
|
|
char ListRoomCodes [Cht_MAX_BYTES_ROOM_CODES + 1];
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char ListRoomShrtNames[Cht_MAX_BYTES_ROOM_SHRT_NAMES + 1];
|
2023-10-03 00:25:57 +02:00
|
|
|
|
char ListRoomFullNames[Cht_MAX_BYTES_ROOM_FULL_NAMES + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
FILE *FileChat;
|
2022-10-27 22:09:44 +02:00
|
|
|
|
FILE *FileOut = Fil_GetOutputFile ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the code and the nombre of the room *****/
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParText ("RoomCode",RoomCode,Cht_MAX_BYTES_ROOM_CODE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParText ("RoomShrtName",RoomShrtName,Cht_MAX_BYTES_ROOM_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-03-07 09:55:39 +01:00
|
|
|
|
Par_GetParText ("RoomFullName",RoomFullName,Cht_MAX_BYTES_ROOM_FULL_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-03-07 11:03:05 +01:00
|
|
|
|
if (!RoomCode[0] || !RoomShrtName[0] || !RoomFullName[0])
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Wrong code or name of chat room.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (strcspn (RoomCode," \t\n\r") != strlen (RoomCode)) // If RoomCode contiene espacios
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Wrong code of chat room.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Fill the lists with the degrees and courses I belong to *****/
|
2023-10-03 14:32:22 +02:00
|
|
|
|
Hie_GetMyHierarchy (Hie_DEG);
|
|
|
|
|
Hie_GetMyHierarchy (Hie_CRS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Build my user's name *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,sizeof (UsrName) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Usrs.Me.UsrDat.Surname2[0])
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (UsrName," ",sizeof (UsrName) - 1);
|
|
|
|
|
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2,sizeof (UsrName) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (UsrName,", ",sizeof (UsrName) - 1);
|
|
|
|
|
Str_Concat (UsrName,Gbl.Usrs.Me.UsrDat.FrstName,sizeof (UsrName) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Build the lists of available rooms *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ListRoomCodes,sizeof (ListRoomCodes),"#%s",RoomCode);
|
|
|
|
|
Str_Copy (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
|
|
|
|
|
Str_Copy (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (strcmp (RoomCode,"GBL_USR"))
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomCodes,"|#GBL_USR",sizeof (ListRoomCodes) - 1);
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (RoomShrtName,sizeof (RoomShrtName),"|%s",
|
2018-10-17 10:32:18 +02:00
|
|
|
|
Txt_SEX_PLURAL_Abc[Usr_SEX_ALL]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (RoomFullName,sizeof (RoomFullName),"|%s (%s)",
|
2018-10-17 10:32:18 +02:00
|
|
|
|
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (strcmp (RoomCode,"GBL_STD"))
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomCodes,"|#GBL_STD",sizeof (ListRoomCodes) - 1);
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (RoomShrtName,sizeof (RoomShrtName),"|%s",
|
2018-10-17 10:32:18 +02:00
|
|
|
|
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (RoomFullName,sizeof (RoomFullName),"|%s (%s)",
|
2018-10-17 10:32:18 +02:00
|
|
|
|
Txt_General,Txt_ROLES_PLURAL_abc[Rol_STD][Usr_SEX_ALL]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_NET ||
|
|
|
|
|
Gbl.Usrs.Me.Role.Logged == Rol_TCH)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (strcmp (RoomCode,"GBL_TCH"))
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomCodes,"|#GBL_TCH",sizeof (ListRoomCodes) - 1);
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (RoomShrtName,sizeof (RoomShrtName),"|%s",
|
2018-10-17 10:32:18 +02:00
|
|
|
|
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomShrtNames,RoomShrtName,sizeof (ListRoomShrtNames) - 1);
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (RoomFullName,sizeof (RoomFullName),"|%s (%s)",
|
2018-10-17 10:32:18 +02:00
|
|
|
|
Txt_General,Txt_ROLES_PLURAL_abc[Rol_TCH][Usr_SEX_ALL]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomFullNames,RoomFullName,sizeof (ListRoomFullNames) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (NumMyDeg = 0;
|
2023-10-03 14:32:22 +02:00
|
|
|
|
NumMyDeg < Gbl.Usrs.Me.Hierarchy[Hie_DEG].Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumMyDeg++)
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"DEG_%ld",
|
2023-10-03 14:32:22 +02:00
|
|
|
|
Gbl.Usrs.Me.Hierarchy[Hie_DEG].Nodes[NumMyDeg].HieCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (strcmp (RoomCode,ThisRoomCode))
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomCodes,"|#",sizeof (ListRoomCodes) - 1);
|
|
|
|
|
Str_Concat (ListRoomCodes,ThisRoomCode,sizeof (ListRoomCodes) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get data of this degree */
|
2023-10-03 14:32:22 +02:00
|
|
|
|
Deg.HieCod = Gbl.Usrs.Me.Hierarchy[Hie_DEG].Nodes[NumMyDeg].HieCod;
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Hie_GetDataByCod[Hie_DEG] (&Deg);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ThisRoomShortName,sizeof (ThisRoomShortName),"%s",
|
2018-10-17 10:32:18 +02:00
|
|
|
|
Deg.ShrtName);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomShrtNames,"|",sizeof (ListRoomShrtNames) - 1);
|
|
|
|
|
Str_Concat (ListRoomShrtNames,ThisRoomShortName,sizeof (ListRoomShrtNames) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
2023-11-06 12:36:05 +01:00
|
|
|
|
Txt_HIERARCHY_SINGUL_Abc[Hie_DEG],Deg.ShrtName);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomFullNames,"|",sizeof (ListRoomFullNames) - 1);
|
|
|
|
|
Str_Concat (ListRoomFullNames,ThisRoomFullName,sizeof (ListRoomFullNames) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-01-13 01:51:23 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (NumMyCrs = 0;
|
2023-10-03 14:32:22 +02:00
|
|
|
|
NumMyCrs < Gbl.Usrs.Me.Hierarchy[Hie_CRS].Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumMyCrs++)
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ThisRoomCode,sizeof (ThisRoomCode),"CRS_%ld",
|
2023-10-03 14:32:22 +02:00
|
|
|
|
Gbl.Usrs.Me.Hierarchy[Hie_CRS].Nodes[NumMyCrs].HieCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (strcmp (RoomCode,ThisRoomCode))
|
|
|
|
|
{
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomCodes,"|#",sizeof (ListRoomCodes) - 1);
|
|
|
|
|
Str_Concat (ListRoomCodes,ThisRoomCode,sizeof (ListRoomCodes) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get data of this course */
|
2023-10-03 14:32:22 +02:00
|
|
|
|
Crs.HieCod = Gbl.Usrs.Me.Hierarchy[Hie_CRS].Nodes[NumMyCrs].HieCod;
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Hie_GetDataByCod[Hie_CRS] (&Crs);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-10-17 10:32:18 +02:00
|
|
|
|
snprintf (ThisRoomShortName,sizeof (ThisRoomShortName),
|
|
|
|
|
"%s",
|
|
|
|
|
Crs.ShrtName);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomShrtNames,"|",sizeof (ListRoomShrtNames) - 1);
|
|
|
|
|
Str_Concat (ListRoomShrtNames,ThisRoomShortName,sizeof (ListRoomShrtNames) - 1);
|
2017-01-15 02:05:24 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ThisRoomFullName,sizeof (ThisRoomFullName),"%s %s",
|
2023-11-06 12:36:05 +01:00
|
|
|
|
Txt_HIERARCHY_SINGUL_Abc[Hie_CRS],Crs.ShrtName);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Concat (ListRoomFullNames,"|",sizeof (ListRoomFullNames) - 1);
|
|
|
|
|
Str_Concat (ListRoomFullNames,ThisRoomFullName,sizeof (ListRoomFullNames) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Open index.html file with the HTML page for the chat *****/
|
|
|
|
|
if ((FileChat = fopen (Cfg_PATH_AND_FILE_REL_CHAT_PRIVATE,"rb")) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Can not open chat.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin writing the index.html file to the output *****/
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Txt ("Content-type: text/html; charset=windows-1252\n\n"); // Two carriage returns at the end of the line are mandatory!
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
Gbl.Layout.HTMLStartWritten = true;
|
|
|
|
|
|
|
|
|
|
/***** Copy index.html file until the end of the applet code *****/
|
2022-10-27 22:09:44 +02:00
|
|
|
|
Str_WriteUntilStrFoundInFileIncludingStr (FileOut,FileChat,"<applet",
|
2016-09-19 17:49:25 +02:00
|
|
|
|
Str_NO_SKIP_HTML_COMMENTS);
|
2022-10-27 22:09:44 +02:00
|
|
|
|
Str_WriteUntilStrFoundInFileIncludingStr (FileOut,FileChat,">",
|
2016-09-19 17:49:25 +02:00
|
|
|
|
Str_NO_SKIP_HTML_COMMENTS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write parameters *****/
|
2019-11-09 20:26:13 +01:00
|
|
|
|
HTM_PARAM ("nick","N%s",Gbl.Session.Id);
|
|
|
|
|
HTM_PARAM ("realname","%s",UsrName);
|
2022-10-27 22:09:44 +02:00
|
|
|
|
HTM_PARAM ("host","%s",Par_GetIP ());
|
2019-11-09 20:26:13 +01:00
|
|
|
|
HTM_PARAM ("server_name","%s",Cfg_PLATFORM_SERVER);
|
|
|
|
|
HTM_PARAM ("port","%u",5000);
|
|
|
|
|
HTM_PARAM ("image_bl","%s/usr_bl.jpg",Cfg_URL_ICON_PUBLIC);
|
|
|
|
|
HTM_PARAM ("image_url","%s/%s.jpg",Cfg_URL_PHOTO_PUBLIC,Gbl.Usrs.Me.UsrDat.Photo);
|
|
|
|
|
HTM_PARAM ("channel_name","%s",ListRoomCodes);
|
|
|
|
|
HTM_PARAM ("tab","%s",ListRoomShrtNames);
|
|
|
|
|
HTM_PARAM ("topic","%s",ListRoomFullNames);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Copy index.html file until the end *****/
|
2022-10-27 22:09:44 +02:00
|
|
|
|
Str_WriteUntilStrFoundInFileIncludingStr (FileOut,FileChat,"</html>",
|
2016-09-19 17:49:25 +02:00
|
|
|
|
Str_NO_SKIP_HTML_COMMENTS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Close index.html file *****/
|
|
|
|
|
fclose (FileChat);
|
|
|
|
|
|
2015-11-27 21:24:24 +01:00
|
|
|
|
Gbl.Layout.DivsEndWritten = Gbl.Layout.HTMLEndWritten = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|