| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2019 Ericsson Telecom AB // |
| // // |
| // All rights reserved. This program and the accompanying materials // |
| // are made available under the terms of the Eclipse Public License v2.0 // |
| // which accompanies this distribution, and is available at // |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_CLL_UIHandler_BrowserFunctions |
| // |
| // Purpose: |
| // This module contains browser functions of EPTF_UIHandler_CT. |
| // |
| // Module Parameters: |
| // - |
| // |
| // Module depends on: |
| // <EPTF_CLL_UIHandler_Definitions> |
| // <EPTF_CLL_UIHandler_WidgetFunctions> |
| // <EPTF_CLL_Variable_Definitions> |
| // <EPTF_CLL_Variable_Functions> |
| // <EPTF_CLL_HashMapStr2Int_Functions> |
| // <TCCFileIO_Functions> |
| // <TCCConversion_Functions> |
| // <Socket_API_Definitions> |
| // <ttcn_ericsson_se_protocolModules_xtdp_xtdl> |
| // <IPL4asp_Types> |
| // <IPL4asp_PortType> |
| // <HTTPmsg_Types> |
| // |
| // Current Owner: |
| // EJNOSVN |
| // |
| // Last Review Date: |
| // 2012-xx-xx |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_CLL_UIHandler_BrowserFunctions |
| // [.objid{ itu_t(0) identified_organization(4) etsi(0) |
| // identified_organization(127) ericsson(5) testing(0) |
| // <put further nodes here if needed>}] |
| { |
| |
| //========================================================================= |
| // Import Part |
| //========================================================================= |
| import from EPTF_CLL_UIHandler_Definitions all; |
| import from EPTF_CLL_UIHandler_WidgetFunctions all; |
| import from EPTF_CLL_Variable_Definitions all; |
| import from EPTF_CLL_Variable_Functions all; |
| import from EPTF_CLL_HashMapStr2Int_Functions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from TCCFileIO_Functions all; |
| import from TCCConversion_Functions all; |
| import from Socket_API_Definitions all |
| |
| import from ttcn_ericsson_se_protocolModules_xtdp_xtdl all; |
| import from IPL4asp_Types all; |
| import from IPL4asp_PortType all; |
| import from HTTPmsg_Types all; |
| import from HTTPmsg_MessageLen all; |
| import from EPTF_CLL_Common_Definitions all; |
| import from EPTF_CLL_Common_Functions all; |
| import from EPTF_CLL_HashMapInt2Int_Functions all; |
| import from EPTF_CLL_FBQ_Functions all; |
| import from EPTF_CLL_DataSource_Definitions all; |
| import from EPTF_CLL_DataSource_Functions all; |
| |
| |
| modulepar charstring tsp_EPTF_UIHandler_Browser_RemoteAddress := "127.0.0.1"; |
| modulepar integer tsp_EPTF_UIHandler_Browser_RemotePort := 4000; |
| modulepar charstring tsp_EPTF_UIHandler_Browser_xsl2send := "EPTF_LoadMain.xsl"; |
| modulepar charstring tsp_EPTF_UIHandler_Browser_xsl4Tabpage := "EPTF_LoadMain.xsl"; |
| modulepar charstring tsp_EPTF_UIHandler_Browser_favicon2send := "favicon.ico"; |
| modulepar charstring tsp_EPTF_UIHandler_Browser_welcomeScreen := "welcome.html"; |
| modulepar charstring tsp_EPTF_UIHandler_Browser_directory := "../BrowserGUI/"; |
| |
| friend module EPTF_CLL_UIHandler_WidgetFunctions; |
| //========================================================================= |
| // Public functions |
| //========================================================================= |
| group PublicFunctions { |
| |
| //========================================================================= |
| // Functions |
| //========================================================================= |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_init_CT |
| // |
| // Purpose: |
| // Initialize the host information to browser GUI |
| // |
| // Parameters: |
| // pl_hosts - *in* *EPTF_UIHandler_Browser_Responder_HostInformationList* - incomming host information |
| // |
| // Return Value: |
| // boolean - true, if the init was sucsessful |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_init_CT( in EPTF_UIHandler_Browser_Responder_HostInformationList pl_hosts := { { tsp_EPTF_UIHandler_Browser_RemoteAddress, tsp_EPTF_UIHandler_Browser_RemotePort } }) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| map(self:v_IPL4_PCO, system:v_IPL4_PCO); |
| f_EPTF_int2int_HashMap_Init(f_EPTF_Base_selfName()); |
| v_EPTF_UIHandler_Browser_chunk_FromConnId_Hash := f_EPTF_int2int_HashMap_New(c_EPTF_UIHandler_Browser_chunk_FromConnId_HashMapName); |
| f_EPTF_FBQ_initFreeBusyQueue(v_EPTF_UIHandler_Browser_chunk_FromConnId_Queue); |
| |
| v_EPTF_UIHandler_Browser_activeTabs_Hash := f_EPTF_str2int_HashMap_New(c_EPTF_UIHandler_Browser_activeTabs_HashMapName); |
| f_EPTF_FBQ_initFreeBusyQueue(v_EPTF_UIHandler_Browser_activeTabs_Queue); |
| |
| var IPL4asp_Types.f_getMsgLen vl_funct := refers(f_EPTF_UIHandler_Browser_getMessageLength); |
| f_IPL4_setGetMsgLen(v_IPL4_PCO, -1, vl_funct , {}); |
| |
| var boolean vl_return := f_EPTF_UIHandler_Browser_addRemoteHosts(pl_hosts); |
| v_EPTF_UIHandler_Browser_directory := tsp_EPTF_UIHandler_Browser_directory; |
| v_UIHandler_Browser_defAltStep := activate(as_UIHandler_handleHTTPRequest()); |
| f_EPTF_Base_registerCleanup(refers(f_EPTF_UIHandler_Browser_cleanup_CT)); |
| return vl_return; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_enableWelcomeScreen |
| // |
| // Purpose: |
| // Enable welcome screen, when the application starts by setting the v_EPTF_UIHandler_Browser_enableWelcomeScreen |
| // component variable to true. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_enableWelcomeScreen() runs on EPTF_UIHandler_Private_CT{ |
| v_EPTF_UIHandler_Browser_enableWelcomeScreen := true; |
| v_EPTF_UIHandler_BrowserGUI_WidgetToVariables := {}; |
| v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := true; |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_disableWelcomeScreen |
| // |
| // Purpose: |
| // Disable welcome screen, when the application starts by setting the v_EPTF_UIHandler_Browser_enableWelcomeScreen |
| // component variable to false. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_disableWelcomeScreen() runs on EPTF_UIHandler_Private_CT{ |
| v_EPTF_UIHandler_Browser_enableWelcomeScreen := false; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_getRemoteHosts |
| // |
| // Purpose: |
| // This function returns the Host names and ports on which the BrowserGUI |
| // is activated. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // *EPTF_UIHandler_Browser_Responder_HostInformationList* - the host name and port pairs |
| // |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_getRemoteHosts() runs on EPTF_UIHandler_Private_CT return EPTF_UIHandler_Browser_Responder_HostInformationList{ |
| var EPTF_UIHandler_Browser_Responder_HostInformationList vl_EPTF_Browser_remoteHosts := {}; |
| for (var integer vl_i := 0; vl_i < sizeof(v_EPTF_Browser_remoteHosts); vl_i := vl_i + 1) |
| { |
| vl_EPTF_Browser_remoteHosts[vl_i].hostIPAddress := v_EPTF_Browser_remoteHosts[vl_i].hostIPAddress; |
| vl_EPTF_Browser_remoteHosts[vl_i].hostPort := v_EPTF_Browser_remoteHosts[vl_i].hostPort; |
| } |
| return vl_EPTF_Browser_remoteHosts; |
| |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_addRemoteHosts |
| // |
| // Purpose: |
| // This function adds the given Host name and port pairs to the list |
| // on which the BrowserGUI is activated and activates them as well. |
| // |
| // Parameters: |
| // pl_hosts - *in* <EPTF_UIHandler_Browser_Responder_HostInformationList> - the host name and port pairs |
| // |
| // Return Value: |
| // *boolean* - true, if process was successful |
| // |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_addRemoteHosts(in EPTF_UIHandler_Browser_Responder_HostInformationList pl_hosts) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| var Socket_API_Definitions.Result vl_result; |
| var boolean vl_returnVal := true; |
| for (var integer vl_i := 0; vl_i < sizeof(pl_hosts); vl_i := vl_i + 1) |
| { |
| var integer vl_remoteHostPos := sizeof(v_EPTF_Browser_remoteHosts); |
| for (var integer vl_findPlace := 0; vl_findPlace < vl_remoteHostPos; vl_findPlace := vl_findPlace + 1){ |
| if(v_EPTF_Browser_remoteHosts[vl_findPlace].connIdPos == -1){ |
| //it has been deleted, use this one |
| vl_remoteHostPos := vl_findPlace; // we are leaving this for cycl because of vl_findPlace < vl_remoteHostPos; |
| } |
| } |
| |
| vl_result := f_IPL4_listen(v_IPL4_PCO, pl_hosts[vl_i].hostIPAddress, pl_hosts[vl_i].hostPort, { tcp := {} }, { {reuseAddress := { enable := true } } }); |
| |
| if (vl_result.errorCode == omit) { |
| v_connIds[vl_i] := vl_result.connId; |
| v_EPTF_Browser_remoteHosts[vl_remoteHostPos].hostIPAddress := pl_hosts[vl_i].hostIPAddress; |
| v_EPTF_Browser_remoteHosts[vl_remoteHostPos].hostPort := pl_hosts[vl_i].hostPort; |
| v_EPTF_Browser_remoteHosts[vl_remoteHostPos].connId := vl_result.connId; |
| v_EPTF_Browser_remoteHosts[vl_remoteHostPos].connIdPos := vl_i; |
| } else { |
| f_EPTF_UIHandler_warning(%definitionId&log2str(": BrowserGUI listening failed on: ", pl_hosts[vl_i], " (", vl_result, "). This does not effect the application, only the BrowserGUI functionality. If you dont want to use this feature, set the tsp_EPTF_UIHandler_enableBrowserGUI to false. If you do want to watch your application in a browser, set the host name and port number with the tsp_EPTF_UIHandler_Browser_RemoteAddress (default: 127.0.0.1) and the tsp_EPTF_UIHandler_Browser_RemotePort (default: 4000) ")); |
| vl_returnVal := false; |
| } |
| } |
| return vl_returnVal; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_setRemoteHosts |
| // |
| // Purpose: |
| // This function sets and activates the given Host name and port pairs |
| // on which the BrowserGUI is listening. |
| // |
| // Parameters: |
| // pl_hosts - *in* <EPTF_UIHandler_Browser_Responder_HostInformationList> - the host name and port pairs |
| // |
| // Return Value: |
| // *boolean* - true, if process was successful |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_setRemoteHosts(in EPTF_UIHandler_Browser_Responder_HostInformationList pl_hosts) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| f_EPTF_UIHandler_Browser_clearRemoteHosts( ); |
| return f_EPTF_UIHandler_Browser_addRemoteHosts( pl_hosts ); |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_clearRemoteHosts |
| // |
| // Purpose: |
| // This function clears the host name and ports |
| // on which the BrowserGUI is listening. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_clearRemoteHosts() |
| runs on EPTF_UIHandler_Private_CT{ |
| var Socket_API_Definitions.Result vl_result; |
| for (var integer vl_i := 0; vl_i < sizeof(v_connIds); vl_i := vl_i + 1) |
| { |
| vl_result := f_IPL4_close(v_IPL4_PCO, v_connIds[vl_i], { tcp := {} }); |
| } |
| v_connIds := {}; |
| v_EPTF_Browser_remoteHosts := {}; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_removeRemoteHosts |
| // |
| // Purpose: |
| // This function removes and deactivates the given Host name and port pairs |
| // on which the BrowserGUI is listening. |
| // |
| // Parameters: |
| // pl_hosts - *in* <EPTF_UIHandler_Browser_Responder_HostInformationList> - the host name and port pairs |
| // |
| // Return Value: |
| // *boolean* - true, if process was successful |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_removeRemoteHosts(in EPTF_UIHandler_Browser_Responder_HostInformationList pl_hosts) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| var boolean vl_returnVal := true; |
| var Socket_API_Definitions.Result vl_result; |
| for (var integer vl_j := 0; vl_j < sizeof(pl_hosts); vl_j := vl_j + 1) |
| { |
| var boolean vl_found := false; |
| for (var integer vl_i := 0; vl_i < sizeof(v_EPTF_Browser_remoteHosts); vl_i := vl_i + 1) |
| { |
| if(v_EPTF_Browser_remoteHosts[vl_i].hostIPAddress == pl_hosts[vl_j].hostIPAddress and |
| v_EPTF_Browser_remoteHosts[vl_i].hostPort == pl_hosts[vl_j].hostPort ){ |
| vl_result := f_IPL4_close(v_IPL4_PCO, v_EPTF_Browser_remoteHosts[vl_i].connId, { tcp := {} }); |
| |
| v_connIds[v_EPTF_Browser_remoteHosts[vl_i].connIdPos] := -1; |
| v_EPTF_Browser_remoteHosts[vl_i] := {"",-1,-1, -1}; |
| vl_found := true; |
| } |
| } |
| if(vl_found == false){vl_returnVal := false;} |
| } |
| return vl_returnVal; |
| } |
| |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_getCustomStyle |
| // |
| // Purpose: |
| // This function returns the active custom CSS style of the BrowserGUI. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // *charstring* - the custom style string |
| // |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_getCustomStyle() runs on EPTF_UIHandler_Private_CT return charstring{ |
| |
| return v_EPTF_Browser_customStyleCache; |
| |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_addCustomStyle |
| // |
| // Purpose: |
| // This function adds the given CSS Style to the main.css from file. |
| // |
| // Parameters: |
| // pl_styleFilename - *in* <charstring> - custom CSS file name |
| // |
| // Return Value: |
| // *boolean* - true, if process was successful |
| // |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_addCustomStyle(in charstring pl_styleFilename) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| var boolean vl_returnVal := true; |
| var integer vl_size := sizeof(v_EPTF_Browser_customStyleDescriptor); |
| var charstring vl_nextStr := f_EPTF_createFromFile(pl_styleFilename); |
| if(vl_nextStr != ""){ |
| v_EPTF_Browser_customStyleCache := v_EPTF_Browser_customStyleCache & vl_nextStr; |
| v_EPTF_Browser_customStyleDescriptor[vl_size] := { styleFilename := pl_styleFilename, styleStr := vl_nextStr }; |
| v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := true; // Refresh |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| } else { |
| vl_returnVal := false; |
| } |
| return vl_returnVal; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_setCustomStyle |
| // |
| // Purpose: |
| // This function sets the custom style (CSS) from file. |
| // |
| // Parameters: |
| // pl_styleFilename - *in* <charstring> - custom CSS file name. |
| // |
| // Return Value: |
| // *boolean* - true, if process was successful |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_setCustomStyle(in charstring pl_styleFilename) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| f_EPTF_UIHandler_Browser_clearCustomStyle( ); |
| return f_EPTF_UIHandler_Browser_addCustomStyle( pl_styleFilename ); |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_clearCustomStyle |
| // |
| // Purpose: |
| // This function clears the custom style CSS elements. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_clearCustomStyle() |
| runs on EPTF_UIHandler_Private_CT{ |
| v_EPTF_Browser_customStyleCache := ""; |
| v_EPTF_Browser_customStyleDescriptor := {}; |
| v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := true; // Refresh |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_removeCustomStyle |
| // |
| // Purpose: |
| // This function removes the custom style (CSS) based on filename. |
| // |
| // Parameters: |
| // pl_styleFilename - *in* <charstring> - custom CSS file name. |
| // |
| // Return Value: |
| // *boolean* - true, if process was successful |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_removeCustomStyle(in charstring pl_styleFilename) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| var boolean vl_returnVal := false; |
| var EPTF_UIhandler_Browser_CustomStyle_InformationList vl_Act_customFiles := {}; |
| var integer vl_idx := 0; |
| v_EPTF_Browser_customStyleCache := ""; |
| for (var integer vl_i := 0; vl_i < sizeof(v_EPTF_Browser_customStyleDescriptor); vl_i := vl_i + 1) |
| { |
| if(v_EPTF_Browser_customStyleDescriptor[vl_i].styleFilename!= "" and pl_styleFilename == v_EPTF_Browser_customStyleDescriptor[vl_i].styleFilename){ |
| vl_returnVal := true; |
| } else { |
| // From string |
| var charstring vl_nextStr := v_EPTF_Browser_customStyleDescriptor[vl_i].styleStr; |
| if(v_EPTF_Browser_customStyleDescriptor[vl_i].styleFilename != "" and vl_nextStr == ""){ |
| // From file |
| vl_nextStr := f_EPTF_createFromFile(v_EPTF_Browser_customStyleDescriptor[vl_i].styleFilename); |
| } |
| if(vl_nextStr != ""){ |
| v_EPTF_Browser_customStyleCache := v_EPTF_Browser_customStyleCache & vl_nextStr; |
| vl_Act_customFiles[vl_idx] := v_EPTF_Browser_customStyleDescriptor[vl_i]; |
| vl_idx := vl_idx + 1; |
| } |
| } |
| } |
| v_EPTF_Browser_customStyleDescriptor := vl_Act_customFiles; |
| if(vl_returnVal == true){ |
| v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := true; // Refresh |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| } |
| return vl_returnVal; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_addCustomStyleStr |
| // |
| // Purpose: |
| // This function adds the given CSS Style to the main.css from string. |
| // |
| // Parameters: |
| // pl_styleStr - *in* <charstring> - custom CSS string |
| // |
| // Return Value: |
| // *boolean* - true, if process was successful |
| // |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_addCustomStyleStr(in charstring pl_styleStr) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| var boolean vl_returnVal := true; |
| var integer vl_size := sizeof(v_EPTF_Browser_customStyleDescriptor); |
| if(pl_styleStr != ""){ |
| v_EPTF_Browser_customStyleCache := v_EPTF_Browser_customStyleCache & pl_styleStr; |
| v_EPTF_Browser_customStyleDescriptor[vl_size] := { styleFilename := "", styleStr := pl_styleStr }; |
| v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := true; // Refresh |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| } else { |
| vl_returnVal := false; |
| } |
| return vl_returnVal; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_setCustomStyleStr |
| // |
| // Purpose: |
| // This function sets the custom style (CSS) from string. |
| // |
| // Parameters: |
| // pl_styleStr - *in* <charstring> - custom CSS string. |
| // |
| // Return Value: |
| // *boolean* - true, if process was successful |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_setCustomStyleStr(in charstring pl_styleStr) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| f_EPTF_UIHandler_Browser_clearCustomStyle( ); |
| return f_EPTF_UIHandler_Browser_addCustomStyleStr( pl_styleStr ); |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_removeCustomStyle |
| // |
| // Purpose: |
| // This function removes the custom style string (CSS) based in string. |
| // |
| // Parameters: |
| // pl_styleStr - *in* <charstring> - custom CSS string. |
| // |
| // Return Value: |
| // *boolean* - true, if process was successful |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_removeCustomStyleStr(in charstring pl_styleStr) |
| runs on EPTF_UIHandler_Private_CT return boolean{ |
| var boolean vl_returnVal := false; |
| var EPTF_UIhandler_Browser_CustomStyle_InformationList vl_Act_customFiles := {}; |
| var integer vl_idx := 0; |
| v_EPTF_Browser_customStyleCache := ""; |
| for (var integer vl_i := 0; vl_i < sizeof(v_EPTF_Browser_customStyleDescriptor); vl_i := vl_i + 1) |
| { |
| if(v_EPTF_Browser_customStyleDescriptor[vl_i].styleFilename == "" and pl_styleStr == v_EPTF_Browser_customStyleDescriptor[vl_i].styleStr){ |
| vl_returnVal := true; |
| } else { |
| // From string |
| var charstring vl_nextStr := v_EPTF_Browser_customStyleDescriptor[vl_i].styleStr; |
| if(v_EPTF_Browser_customStyleDescriptor[vl_i].styleFilename != "" and vl_nextStr == ""){ |
| // From file |
| vl_nextStr := f_EPTF_createFromFile(v_EPTF_Browser_customStyleDescriptor[vl_i].styleFilename); |
| } |
| } |
| } |
| v_EPTF_Browser_customStyleDescriptor := vl_Act_customFiles; |
| if(vl_returnVal == true){ |
| v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := true; // Refresh |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| } |
| return vl_returnVal; |
| } |
| |
| } |
| |
| group PrivateFunctions { |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_cleanup_CT |
| // |
| // Purpose: |
| // Uninitialize the browser GUI |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| private function f_EPTF_UIHandler_Browser_cleanup_CT() |
| runs on EPTF_UIHandler_Private_CT{ |
| deactivate(v_UIHandler_Browser_defAltStep); |
| f_EPTF_UIHandler_Browser_clearRemoteHosts(); |
| |
| if (v_EPTF_UIHandler_Browser_chunk_FromConnId_Hash != c_UIHandler_Browser_invalidIdx) { |
| f_EPTF_int2int_HashMap_Delete(c_EPTF_UIHandler_Browser_chunk_FromConnId_HashMapName); |
| v_EPTF_UIHandler_Browser_chunk_FromConnId_Hash := c_UIHandler_Browser_invalidIdx; |
| } |
| |
| if (v_EPTF_UIHandler_Browser_activeTabs_Hash != c_UIHandler_Browser_invalidIdx) { |
| f_EPTF_str2int_HashMap_Delete(c_EPTF_UIHandler_Browser_activeTabs_HashMapName); |
| v_EPTF_UIHandler_Browser_activeTabs_Hash := c_UIHandler_Browser_invalidIdx; |
| } |
| |
| |
| unmap(self:v_IPL4_PCO, system:v_IPL4_PCO); |
| } |
| |
| /////////////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_getMessageLength |
| // |
| // Purpose: |
| // Function to get the message length of a stream |
| // |
| // Parameters: |
| // stream - *in* *octetstring* - stream |
| // args - *inout* - arguments |
| // |
| // Return Value: |
| // *integer* - message length of stream |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////////////////////////// |
| private function f_EPTF_UIHandler_Browser_getMessageLength ( |
| in octetstring stream, |
| inout IPL4asp_Types.ro_integer args) |
| return integer |
| { |
| return f_HTTPMessage_len(stream); |
| } |
| |
| private function f_EPTF_UIHandler_Browser_getXmlPrelude(in boolean pl_tabpage:= false) |
| runs on EPTF_UIHandler_Private_CT return charstring{ |
| if(v_EPTF_UIHandler_Browser_enableWelcomeScreen){ |
| return "<?xml version=\"1.0\"?><?xml-stylesheet type=\"text/xsl\" href=\" "&tsp_EPTF_UIHandler_Browser_xsl2send&".welcome"&"\"?>"; |
| } |
| if(pl_tabpage == false){ |
| return "<?xml version=\"1.0\"?><?xml-stylesheet type=\"text/xsl\" href=\" "&tsp_EPTF_UIHandler_Browser_xsl2send&"\"?>"; |
| } else { |
| return "<?xml version=\"1.0\"?><?xml-stylesheet type=\"text/xsl\" href=\" "&tsp_EPTF_UIHandler_Browser_xsl4Tabpage&"\"?>"; |
| } |
| } |
| |
| |
| private function f_EPTF_UIHandler_Browser_getErrorPage(in charstring pl_errorStr:= "") |
| runs on EPTF_UIHandler_Private_CT return charstring{ |
| |
| var Widgets vl_widgets := { window := { |
| about := omit, height := omit, help := omit, id := "EPTF_Main_Window", orientation := vertical, title := "ERROR", width := omit, image_list := {}, |
| embeddedwidgets := {{ |
| { hbox := { |
| /* customclass */ omit, |
| /* disabled */ omit, |
| /* disabledongui */ omit , |
| /* fixedposition */ omit, |
| /* flex */ omit, |
| /* id */ "UIHandler_widgetId_1", |
| /* orientation */ horizontal, |
| /* scrollable */ omit, |
| /* embeddedwidgets */ {{ |
| { label_ := { |
| /* customclass */ omit, |
| /* disabled */ true, |
| /* disabledongui */ omit, |
| /* flex */ omit, |
| /* id */ "UIHandler_widgetId_error", |
| /* style */ omit, |
| /* tooltiptext */ omit, |
| /* value_ */ pl_errorStr, |
| /* externaldata */ omit |
| }} |
| }} |
| }} |
| }} |
| }}; |
| return oct2char(enc_Widgets(vl_widgets)); |
| } |
| |
| |
| private function f_EPTF_UIHandler_Browser_getErrorTab(in charstring pl_errorStr:= "") |
| runs on EPTF_UIHandler_Private_CT return charstring { |
| var Widgets vl_widgets := { hbox := { |
| /* customclass */ omit, |
| /* disabled */ omit, |
| /* disabledongui */ omit , |
| /* fixedposition */ omit, |
| /* flex */ omit, |
| /* id */ "UIHandler_widgetId_1", |
| /* orientation */ horizontal, |
| /* scrollable */ omit, |
| /* embeddedwidgets */ {{ |
| { label_ := { |
| /* customclass */ omit, |
| /* disabled */ true, |
| /* disabledongui */ omit, |
| /* flex */ omit, |
| /* id */ "UIHandler_widgetId_error", |
| /* style */ omit, |
| /* tooltiptext */ omit, |
| /* value_ */ pl_errorStr, |
| /* externaldata */ omit |
| }} |
| }} |
| }}; |
| return oct2char(enc_Widgets(vl_widgets)); |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_TabpageFilter |
| // |
| // Purpose: |
| // Filter the inactive tabpages in XML. Only the active tabpage's children should appear in the outgoing message. |
| // |
| // Parameters: |
| // pl_widgets - *in* *Widgets* - incomming widgets to filter |
| // |
| // Return Value: |
| // charstring - the xml string with the active tabpage(s) only |
| ///////////////////////////////////////////////////////////////////////// |
| private function f_EPTF_UIHandler_Browser_TabpageFilter(in Widgets pl_widgets) |
| runs on EPTF_UIHandler_Private_CT return charstring{ |
| var Widgets vl_widgets := pl_widgets; |
| if(ischosen(vl_widgets.window)){ |
| for ( var integer vl_i := 0; vl_i < sizeof(vl_widgets.window.embeddedwidgets.embeddedwidget_list) ; vl_i := vl_i+1 ) |
| { |
| f_EPTF_UIHandler_Browser_TabpageChildrenFilter(vl_widgets.window.embeddedwidgets.embeddedwidget_list[vl_i]); |
| } |
| } else { |
| f_EPTF_UIHandler_warning(%definitionId&": Message does not start with window."); |
| } |
| return oct2char(enc_Widgets(vl_widgets)); |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_TabpageChildrenFilter |
| // |
| // Purpose: |
| // Filter the inactive tabpages in the embededwidgets. Only the active tabpage's children should appear in the embedded widgets. |
| // |
| // Parameters: |
| // pl_xul - *inout* *Embeddedwidget* - incomming Embeddedwidget to filter |
| // |
| // Return Value: |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| private function f_EPTF_UIHandler_Browser_TabpageChildrenFilter( inout Embeddedwidget pl_xul) |
| runs on EPTF_UIHandler_Private_CT{ |
| if(ischosen(pl_xul.tabpages)){ |
| var integer vl_sizeOfTabpages := sizeof(pl_xul.tabpages.tabpagegroups.tabpagegroup_list); |
| if(0 < vl_sizeOfTabpages){ |
| var integer vl_tabpagesId := -1; |
| if(f_EPTF_str2int_HashMap_Find(v_EPTF_UIHandler_Browser_activeTabs_Hash, f_EPTF_UIHandler_unichar2charstring(pl_xul.tabpages.id) , vl_tabpagesId)) { |
| //The tabpage with this id shouldnt be erased only : v_EPTF_UIHandler_Browser_activeTabs.activeTabs[[vl_tabpagesId] |
| for ( var integer vl_i := 0; vl_i < vl_sizeOfTabpages ; vl_i := vl_i+1 ){ |
| if( pl_xul.tabpages.tabpagegroups.tabpagegroup_list[vl_i].tabpage.id != v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].widgetId ){ |
| pl_xul.tabpages.tabpagegroups.tabpagegroup_list[vl_i].tabpage.embeddedwidgets.embeddedwidget_list := {}; |
| } else { |
| for ( var integer vl_j := 0; vl_j < sizeof(pl_xul.tabpages.tabpagegroups.tabpagegroup_list[vl_i].tabpage.embeddedwidgets.embeddedwidget_list) ; vl_j := vl_j+1 ) |
| { |
| f_EPTF_UIHandler_Browser_TabpageChildrenFilter(pl_xul.tabpages.tabpagegroups.tabpagegroup_list[vl_i].tabpage.embeddedwidgets.embeddedwidget_list[vl_j]); |
| } |
| } |
| } |
| } else { |
| if(1 < vl_sizeOfTabpages){ |
| for ( var integer vl_i := 1; vl_i < vl_sizeOfTabpages ; vl_i := vl_i+1 ){ |
| pl_xul.tabpages.tabpagegroups.tabpagegroup_list[vl_i].tabpage.embeddedwidgets.embeddedwidget_list := {}; |
| } |
| } |
| //Put the first tab into the hashmap and to the database |
| vl_tabpagesId := f_EPTF_FBQ_getOrCreateFreeSlot(v_EPTF_UIHandler_Browser_activeTabs_Queue); |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].widgetId := f_EPTF_UIHandler_unichar2charstring(pl_xul.tabpages.tabpagegroups.tabpagegroup_list[0].tabpage.id); |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].needToRefresh := false; |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].versionTabRefreshCount := 1; |
| f_EPTF_FBQ_moveFromFreeHeadToBusyTail(v_EPTF_UIHandler_Browser_activeTabs_Queue); |
| f_EPTF_str2int_HashMap_Insert(v_EPTF_UIHandler_Browser_activeTabs_Hash, f_EPTF_UIHandler_unichar2charstring(pl_xul.tabpages.id), vl_tabpagesId); |
| |
| for ( var integer vl_j := 0; vl_j < sizeof(pl_xul.tabpages.tabpagegroups.tabpagegroup_list[0].tabpage.embeddedwidgets.embeddedwidget_list) ; vl_j := vl_j+1 ) |
| { |
| f_EPTF_UIHandler_Browser_TabpageChildrenFilter(pl_xul.tabpages.tabpagegroups.tabpagegroup_list[0].tabpage.embeddedwidgets.embeddedwidget_list[vl_j]); |
| } |
| } |
| } |
| } |
| else if(ischosen(pl_xul.hbox)){ |
| // Process flex revision if no flex value set setup the average value |
| var integer vl_flexitems := 0; |
| var float vl_flexitemsweight := 0.0; |
| var integer vl_embededwidgetlistlength := sizeof(pl_xul.hbox.embeddedwidgets.embeddedwidget_list); |
| // Zero flex are set to 1.0 |
| if(0.0 == f_EPTF_UIHandler_Browser_GetItemFlex(pl_xul)){ |
| f_EPTF_UIHandler_Browser_SetItemFlex(pl_xul, 1.0); |
| } |
| for ( var integer i := 0; i < vl_embededwidgetlistlength; i := i+1 ) |
| { |
| var float vl_actflex := f_EPTF_UIHandler_Browser_GetItemFlex(pl_xul.hbox.embeddedwidgets.embeddedwidget_list[i]); |
| f_EPTF_UIHandler_Browser_TabpageChildrenFilter(pl_xul.hbox.embeddedwidgets.embeddedwidget_list[i]); |
| if(ischosen(pl_xul.hbox.embeddedwidgets.embeddedwidget_list[i].spacer)==false and 0.0 < vl_actflex){ |
| vl_flexitems := vl_flexitems+1; |
| vl_flexitemsweight := vl_flexitemsweight + vl_actflex; |
| } |
| } |
| // If not all flex items are set up or there are zero flex items |
| if(vl_embededwidgetlistlength != vl_flexitems){ |
| var float vl_flexaverage := 1.0; // default averadge |
| // valid flex items set the averadge |
| if(0 < vl_flexitems and 0.0 < vl_flexitemsweight){ |
| vl_flexaverage := (vl_flexitemsweight / int2float(vl_flexitems)); |
| } |
| if(vl_flexaverage < 1.0) { vl_flexaverage := 1.0; } |
| |
| for ( var integer i := 0; i < vl_embededwidgetlistlength; i := i+1 ){ |
| var float vl_actflex := f_EPTF_UIHandler_Browser_GetItemFlex(pl_xul.hbox.embeddedwidgets.embeddedwidget_list[i]); |
| if(ischosen(pl_xul.hbox.embeddedwidgets.embeddedwidget_list[i].spacer)){ |
| f_EPTF_UIHandler_Browser_SetItemFlex(pl_xul.hbox.embeddedwidgets.embeddedwidget_list[i], 0.0); |
| } else if(vl_actflex <= 0.0 ){ |
| f_EPTF_UIHandler_Browser_SetItemFlex(pl_xul.hbox.embeddedwidgets.embeddedwidget_list[i], vl_flexaverage); |
| } |
| } |
| } |
| } |
| else if(ischosen(pl_xul.tree)){ |
| // Process flex revision if no flex value set setup the average value |
| var integer vl_flexitems := 0; |
| var float vl_flexitemsweight := 0.0; |
| var integer vl_colslength := sizeof(pl_xul.tree.treecols.treecolgroups.treecolgroup_list); |
| // Zero flex are set to 1.0 |
| if(0.0 == pl_xul.tree.flex){ |
| pl_xul.tree.flex := 1.0; |
| } |
| for ( var integer i := 0; i < vl_colslength; i := i+1 ) |
| { |
| var float vl_actflex := 0.0; |
| if(ispresent(pl_xul.tree.treecols.treecolgroups.treecolgroup_list[i].treecol.flex)==true){ |
| vl_actflex := pl_xul.tree.treecols.treecolgroups.treecolgroup_list[i].treecol.flex; |
| } |
| if( 0.0 < vl_actflex){ |
| vl_flexitems := vl_flexitems+1; |
| vl_flexitemsweight := vl_flexitemsweight + vl_actflex; |
| } |
| } |
| // If not all flex items are set up or there are zero flex items |
| if(vl_colslength != vl_flexitems){ |
| var float vl_flexaverage := 1.0; // default averadge |
| // valid flex items set the averadge |
| if(0 < vl_flexitems and 0.0 < vl_flexitemsweight){ |
| vl_flexaverage := (vl_flexitemsweight / int2float(vl_flexitems)); |
| } |
| if(vl_flexaverage < 1.0) { vl_flexaverage := 1.0; } |
| |
| for ( var integer i := 0; i < vl_colslength; i := i+1 ){ |
| if( (ispresent(pl_xul.tree.treecols.treecolgroups.treecolgroup_list[i].treecol.flex)==false) or |
| pl_xul.tree.treecols.treecolgroups.treecolgroup_list[i].treecol.flex <= 0.0 ){ |
| pl_xul.tree.treecols.treecolgroups.treecolgroup_list[i].treecol.flex := vl_flexaverage; |
| } |
| } |
| } |
| } |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_GetItemFlex |
| // |
| // Purpose: |
| // Get the embedded widgets flex value. |
| // |
| // Parameters: |
| // pl_xul - *in* *Embeddedwidget* - incomming Embeddedwidget |
| // |
| // Return Value: |
| // float - flex value |
| ///////////////////////////////////////////////////////////////////////// |
| private function f_EPTF_UIHandler_Browser_GetItemFlex( in Embeddedwidget pl_xul) |
| runs on EPTF_UIHandler_Private_CT return float { |
| var float vl_flex := 0.0; |
| if(ischosen(pl_xul.tabpages)){ |
| if(ispresent(pl_xul.tabpages.flex) == true){ |
| vl_flex := pl_xul.tabpages.flex; |
| } |
| } |
| else if(ischosen(pl_xul.tree)){ |
| if(ispresent(pl_xul.tree.flex) == true){ |
| vl_flex := pl_xul.tree.flex; |
| } |
| } |
| else if(ischosen(pl_xul.hbox)){ |
| if(ispresent(pl_xul.hbox.flex) == true){ |
| vl_flex := pl_xul.hbox.flex; |
| } |
| } |
| else if(ischosen(pl_xul.label_)){ |
| if(ispresent(pl_xul.label_.flex) == true){ |
| vl_flex := pl_xul.label_.flex; |
| } |
| } |
| else if(ischosen(pl_xul.spacer)){ |
| if(ispresent(pl_xul.spacer.flex) == true){ |
| vl_flex := pl_xul.spacer.flex; |
| } |
| } |
| else if(ischosen(pl_xul.button)){ |
| if(ispresent(pl_xul.button.flex) == true){ |
| vl_flex := pl_xul.button.flex; |
| } |
| } |
| else if(ischosen(pl_xul.textbox)){ |
| if(ispresent(pl_xul.textbox.flex) == true){ |
| vl_flex := pl_xul.textbox.flex; |
| } |
| } |
| else if(ischosen(pl_xul.numericalwidget)){ |
| if(ispresent(pl_xul.numericalwidget.flex) == true){ |
| vl_flex := pl_xul.numericalwidget.flex; |
| } |
| } |
| else if(ischosen(pl_xul.chart)){ |
| if(ispresent(pl_xul.chart.flex) == true){ |
| vl_flex := pl_xul.chart.flex; |
| } |
| } |
| else if(ischosen(pl_xul.distributionchart)){ |
| if(ispresent(pl_xul.distributionchart.flex) == true){ |
| vl_flex := pl_xul.distributionchart.flex; |
| } |
| } |
| else if(ischosen(pl_xul.listbox)){ |
| if(ispresent(pl_xul.listbox.flex) == true){ |
| vl_flex := pl_xul.listbox.flex; |
| } |
| } |
| else if(ischosen(pl_xul.menulist)){ |
| if(ispresent(pl_xul.menulist.flex) == true){ |
| vl_flex := pl_xul.menulist.flex; |
| } |
| } |
| else if(ischosen(pl_xul.pushbutton)){ |
| if(ispresent(pl_xul.pushbutton.flex) == true){ |
| vl_flex := pl_xul.pushbutton.flex; |
| } |
| } |
| else if(ischosen(pl_xul.togglebutton)){ |
| if(ispresent(pl_xul.togglebutton.flex) == true){ |
| vl_flex := pl_xul.togglebutton.flex; |
| } |
| } |
| else if(ischosen(pl_xul.htmlcode)){ |
| if(ispresent(pl_xul.htmlcode.flex) == true){ |
| vl_flex := pl_xul.htmlcode.flex; |
| } |
| } |
| return(vl_flex); |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_SetItemFlex |
| // |
| // Purpose: |
| // Set the embedded widgets flex value. |
| // |
| // Parameters: |
| // pl_xul - *inout* *Embeddedwidget* - incomming Embeddedwidget |
| // pl_flex - *in* *float* - flex value |
| // |
| // Return Value: |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| private function f_EPTF_UIHandler_Browser_SetItemFlex( inout Embeddedwidget pl_xul, in float pl_flex) |
| runs on EPTF_UIHandler_Private_CT { |
| if(ischosen(pl_xul.tabpages)){ |
| pl_xul.tabpages.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.tree)){ |
| pl_xul.tree.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.hbox)){ |
| pl_xul.hbox.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.label_)){ |
| pl_xul.label_.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.spacer)){ |
| pl_xul.spacer.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.button)){ |
| pl_xul.button.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.textbox)){ |
| pl_xul.textbox.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.numericalwidget)){ |
| pl_xul.numericalwidget.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.chart)){ |
| pl_xul.chart.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.distributionchart)){ |
| pl_xul.distributionchart.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.listbox)){ |
| pl_xul.listbox.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.menulist)){ |
| pl_xul.menulist.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.pushbutton)){ |
| pl_xul.pushbutton.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.togglebutton)){ |
| pl_xul.togglebutton.flex := pl_flex; |
| } |
| else if(ischosen(pl_xul.htmlcode)){ |
| pl_xul.htmlcode.flex := pl_flex; |
| } |
| return; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_directory |
| // |
| // Purpose: |
| // Create valid directory charstring from v_EPTF_UIHandler_Browser_directory. |
| // |
| // Parameters: |
| // pl_fileName - *in* *charstring* - filename |
| // |
| // Return Value: |
| // charstring - the content of the file |
| ///////////////////////////////////////////////////////////////////////// |
| private function f_EPTF_UIHandler_Browser_directory( ) |
| runs on EPTF_UIHandler_Private_CT return charstring { |
| if(lengthof(v_EPTF_UIHandler_Browser_directory) > 0){ |
| if(substr(v_EPTF_UIHandler_Browser_directory, lengthof(v_EPTF_UIHandler_Browser_directory)-1 ,1) != "/"){ |
| if( not f_FIO_fileOrDirExists(v_EPTF_UIHandler_Browser_directory & "/") ) { |
| f_EPTF_UIHandler_warning(%definitionId&": Directory does not exist: "&v_EPTF_UIHandler_Browser_directory & "/. Trying working directory."); |
| return ""; |
| } |
| return v_EPTF_UIHandler_Browser_directory & "/"; |
| } else { |
| if( not f_FIO_fileOrDirExists(v_EPTF_UIHandler_Browser_directory) ) { |
| f_EPTF_UIHandler_warning(%definitionId&": Directory does not exist: "&v_EPTF_UIHandler_Browser_directory&". Trying working directory."); |
| return ""; |
| } |
| return v_EPTF_UIHandler_Browser_directory; |
| } |
| } |
| return ""; |
| } |
| |
| |
| |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_createFromFile |
| // |
| // Purpose: |
| // Create charstring from the content of the file. |
| // |
| // Parameters: |
| // pl_fileName - *in* *charstring* - filename |
| // |
| // Return Value: |
| // charstring - the content of the file |
| ///////////////////////////////////////////////////////////////////////// |
| private function f_EPTF_createFromFile( in charstring pl_fileName) |
| runs on EPTF_UIHandler_Private_CT return charstring { |
| var charstring vl_GUI := ""; |
| var integer vl_file := f_FIO_open_rdonly(pl_fileName); |
| var integer vl_retval:=-1; |
| if(vl_file==-1){ |
| f_EPTF_UIHandler_warning(%definitionId&": Couldn't open the file "&pl_fileName&"."); |
| return ""; |
| } |
| var integer vl_from:=f_FIO_seek_home(vl_file); |
| var integer vl_to:=f_FIO_seek_end(vl_file); |
| if( f_FIO_seek_home(vl_file)==-1) { |
| f_EPTF_UIHandler_warning(%definitionId&": File seek error in file "&pl_fileName&"."); |
| return ""; |
| } |
| vl_retval:=f_FIO_read_text(vl_file, vl_GUI, vl_to-vl_from) |
| if(-1 == vl_retval){ |
| f_EPTF_UIHandler_warning(%definitionId&": Couldn't read the file "&pl_fileName&"."); |
| return ""; |
| } |
| if( f_FIO_close(vl_file)==-1) { |
| f_EPTF_UIHandler_warning(%definitionId&": Could not close the file "&pl_fileName&"."); |
| return ""; |
| } |
| return vl_GUI; |
| } |
| |
| private function f_EPTF_UIHandler_Browser_xmlHTTPResponse(in charstring pl_body) |
| return octetstring{ |
| var HTTPMessage vl_outgoingMessage := { |
| response := { |
| client_id := omit, |
| version_major := 1, |
| version_minor := 1, |
| statuscode := 200, |
| statustext := "OK", |
| header:= { |
| {"Content-Length", int2str(lengthof(pl_body))}, |
| {"Content-Type", "application/xml" } |
| }, |
| body:= pl_body |
| } |
| } |
| return enc_HTTPMessage(vl_outgoingMessage); |
| } |
| |
| private function f_EPTF_UIHandler_Browser_xmlHTTPResponse_as_file(in charstring pl_body, in charstring pl_file_name) |
| return octetstring{ |
| var HTTPMessage vl_outgoingMessage := { |
| response := { |
| client_id := omit, |
| version_major := 1, |
| version_minor := 1, |
| statuscode := 200, |
| statustext := "OK", |
| header:= { |
| {"Content-Length", int2str(lengthof(pl_body))}, |
| {"Content-Type", "application/xml" }, |
| {"Content-disposition", "attachment; filename=\"" & pl_file_name & "\""} |
| }, |
| body:= pl_body |
| } |
| } |
| return enc_HTTPMessage(vl_outgoingMessage); |
| } |
| |
| private function f_EPTF_UIHandler_Browser_imageHTTPResponse( in charstring pl_body, in charstring pl_file) |
| return octetstring{ |
| var charstring vl_mime := "gif"; |
| // gif/png/jpg |
| if(0<f_strstr(pl_file,".jpg")){ |
| vl_mime := "jpeg"; |
| } else if (0<f_strstr(pl_file,".png")) { |
| vl_mime := "png"; |
| } |
| var HTTPMessage vl_outgoingMessage := { |
| response := { |
| client_id := omit, |
| version_major := 1, |
| version_minor := 1, |
| statuscode := 200, |
| statustext := "OK", |
| header:= { |
| {"Content-Length", int2str(lengthof(pl_body))}, |
| {"Content-Type", "image/" & vl_mime } |
| }, |
| body:= pl_body |
| } |
| } |
| return enc_HTTPMessage(vl_outgoingMessage); |
| } |
| |
| private function f_EPTF_UIHandler_Browser_HTTPResponse_404(in charstring pl_requesteduri) |
| return octetstring{ |
| var charstring vl_errormsg_html := |
| "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"> |
| <html> |
| <head> |
| <meta http-equiv=\"pragma\" content=\"no-cache\" /> |
| <title>404 - Not Found: [" & pl_requesteduri & "]</title> |
| </head> |
| <body topmargin=0 leftmargin=0 bottommargin=0 rightmargin=0 style=\"font-family: Verdana; font-size: 14px;\"> |
| <P>404 - [" & pl_requesteduri & "] Not Found!</P> |
| </body> |
| </html>"; |
| |
| var HTTPMessage vl_outgoingMessageHtml := { |
| response := { |
| client_id := omit, |
| version_major := 1, |
| version_minor := 1, |
| statuscode := 404, |
| statustext := "Not Found", |
| header:= { |
| {"Content-Length", int2str(lengthof(vl_errormsg_html))}, |
| {"Content-Type", "text/html" } |
| }, |
| |
| body:= vl_errormsg_html |
| } |
| |
| } |
| return enc_HTTPMessage(vl_outgoingMessageHtml); |
| } |
| |
| private function f_EPTF_UIHandler_Browser_cssHTTPResponse(in charstring pl_body) |
| return octetstring{ |
| var HTTPMessage vl_outgoingMessage := { |
| response := { |
| client_id := omit, |
| version_major := 1, |
| version_minor := 1, |
| statuscode := 200, |
| statustext := "OK", |
| header:= { |
| {"Content-Length", int2str(lengthof(pl_body))}, |
| {"Content-Type", "text/css" } |
| }, |
| body:= pl_body |
| } |
| } |
| return enc_HTTPMessage(vl_outgoingMessage); |
| } |
| |
| private function f_EPTF_UIHandler_Browser_jsHTTPResponse(in charstring pl_body) |
| return octetstring{ |
| var HTTPMessage vl_outgoingMessage := { |
| response := { |
| client_id := omit, |
| version_major := 1, |
| version_minor := 1, |
| statuscode := 200, |
| statustext := "OK", |
| header:= { |
| {"Content-Length", int2str(lengthof(pl_body))}, |
| {"Content-Type", "text/javascript" } |
| }, |
| body:= pl_body |
| } |
| } |
| return enc_HTTPMessage(vl_outgoingMessage); |
| } |
| |
| private function f_EPTF_UIHandler_Browser_htmlHTTPResponse(in charstring pl_body) |
| return octetstring{ |
| var HTTPMessage vl_outgoingMessage := { |
| response := { |
| client_id := omit, |
| version_major := 1, |
| version_minor := 1, |
| statuscode := 200, |
| statustext := "OK", |
| header:= { |
| {"Content-Length", int2str(lengthof(pl_body))}, |
| {"Content-Type", "text/html" } |
| }, |
| body:= pl_body |
| } |
| } |
| return enc_HTTPMessage(vl_outgoingMessage); |
| } |
| |
| private function f_EPTF_UIHandler_Browser_binaryHTTPResponse(in charstring pl_body) |
| return octetstring{ |
| var HTTPMessage vl_outgoingMessage := { |
| response := { |
| client_id := omit, |
| version_major := 1, |
| version_minor := 1, |
| statuscode := 200, |
| statustext := "OK", |
| header:= { |
| {"Content-Length", int2str(lengthof(pl_body))}, |
| {"Content-Type", "application/octet-stream" } |
| }, |
| body:= pl_body |
| } |
| } |
| return enc_HTTPMessage(vl_outgoingMessage); |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_getCurrentLayoutOnHTTP |
| // |
| // Purpose: |
| // Creating the layout to send to browser from snapshot |
| // |
| // Parameters: |
| // pl_send - *out* *ASP_Send* - the message to send with HTTP |
| // |
| // Return Value: |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| private function f_EPTF_UIHandler_getCurrentLayoutOnHTTP(in integer pl_connId, out ASP_Send pl_send) |
| runs on EPTF_UIHandler_Private_CT{ |
| var Widgets vl_widgets; |
| if (0 < sizeof(v_UIHandler_guiItemList)){ |
| f_EPTF_UIHandler_buildXUL(vl_widgets, false); |
| /*var octetstring vl_oct := char2oct(f_EPTF_UIHandler_snapshot()); |
| dec_Widgets(vl_oct, vl_widgets);*/ |
| var charstring vl_msg := f_EPTF_UIHandler_Browser_TabpageFilter(vl_widgets); |
| pl_send := { pl_connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_xmlHTTPResponse( f_EPTF_UIHandler_Browser_getXmlPrelude() & vl_msg ) }; |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Sending current layout" & log2str(pl_send)); |
| } |
| } else { |
| var charstring vl_msg := "Unhandled Request from Browser[empty GUI]!"; |
| f_EPTF_UIHandler_warning(vl_msg); |
| vl_msg := f_EPTF_UIHandler_Browser_getErrorPage(vl_msg); |
| pl_send := { |
| pl_connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_xmlHTTPResponse( f_EPTF_UIHandler_Browser_getXmlPrelude() & vl_msg ) |
| }; |
| } |
| } |
| |
| private function f_EPTF_UIHandler_Browser_parseJSON(in charstring pl_requestToFind, out EPTF_WidgetValuePairs pl_widgetValuePairs) runs on EPTF_UIHandler_Private_CT { |
| var charstring vl_widgetId := "", vl_value := ""; |
| pl_widgetValuePairs := {}; |
| pl_requestToFind := f_replaceEveryOccurenceOfSubstring(pl_requestToFind, "%22", "\""); |
| pl_requestToFind := f_replaceEveryOccurenceOfSubstring(pl_requestToFind, "%20", " "); |
| var integer vl_from := f_strstr(pl_requestToFind,"\"", 0) + 1, vl_to:= vl_from, vl_temp:= 0; |
| while(vl_to > -1){ |
| vl_temp := vl_from; |
| vl_to := f_strstr(pl_requestToFind,"\"", vl_from); |
| if(vl_to > 0){ |
| while(vl_to > 0 and "\\" == substr(pl_requestToFind,vl_to-1, 1)){ |
| vl_temp := vl_to; |
| vl_to := f_strstr(pl_requestToFind,"\"", vl_temp + 1); |
| } |
| |
| if(vl_to-vl_from > 0){ |
| vl_widgetId := substr(pl_requestToFind, vl_from, vl_to-vl_from); |
| } else { |
| f_EPTF_UIHandler_warning("Wrong JSON request(widgetId):" & pl_requestToFind); |
| } |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("WidgetId: " & vl_widgetId); |
| } |
| var integer vl_colon := f_strstr(pl_requestToFind,":", vl_to); |
| vl_from := f_strstr(pl_requestToFind,"\"", vl_colon) + 1; |
| vl_temp := vl_from; |
| vl_to := f_strstr(pl_requestToFind,"\"", vl_from ); |
| if(vl_to > 0){ |
| while(vl_to > 0 and "\\" == substr(pl_requestToFind,vl_to-1, 1)){ |
| vl_temp := vl_to; |
| vl_to := f_strstr(pl_requestToFind,"\"", vl_temp + 1); |
| } |
| if(vl_to-vl_from >= 0){ |
| vl_value := f_EPTF_Common_decodeEscapeSequence(substr(pl_requestToFind, vl_from, vl_to-vl_from)); |
| } else { |
| f_EPTF_UIHandler_warning("Wrong JSON request(val):" & pl_requestToFind); |
| } |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Value: " & vl_value); |
| } |
| |
| pl_widgetValuePairs[sizeof(pl_widgetValuePairs)] := {vl_widgetId,vl_value} |
| } |
| } |
| vl_from := f_strstr(pl_requestToFind,"\"", vl_to + 1) + 1; |
| vl_to := f_strstr(pl_requestToFind,"\"", vl_to + 1); |
| } // end of while |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_reportGUIChanged |
| // |
| // Purpose: |
| // Report that there has been some changes on the GUI. |
| // During the next refresh the browser will get the information |
| // and it will reload the related page. |
| // |
| // Parameters: |
| // pl_widgetIdThatHasBeenChanged - *in* *ASP_Send* - the id of the changed widget |
| // pl_widgetIdx - *in* *integer* the same widget represented by the idx in the database |
| // |
| // Return Value: |
| // - |
| ///////////////////////////////////////////////////////////////////////// |
| friend function f_EPTF_UIHandler_Browser_reportGUIChanged(in charstring pl_widgetIdThatHasBeenChanged, in integer pl_widgetIdx := -1) |
| runs on EPTF_UIHandler_Private_CT{ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": GUI changed by the widget: " & pl_widgetIdThatHasBeenChanged); |
| } |
| var integer vl_widgetIdx := -1; |
| var integer vl_childWidgetIdx := -1; |
| var charstring vl_widgetId; |
| var charstring vl_childWidgetId; |
| var boolean vl_haveRefresh := false; |
| if( (pl_widgetIdx > -1) or (f_EPTF_str2int_HashMap_Find(v_UIHandler_widgetHashMapId, pl_widgetIdThatHasBeenChanged, vl_widgetIdx)) ){ |
| if(pl_widgetIdx > -1){ |
| vl_widgetIdx := pl_widgetIdx; |
| } |
| |
| if(v_UIHandler_guiItemList[vl_widgetIdx].widgetType == wtImage){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": Image: no action"); |
| } |
| return; |
| } |
| |
| if(f_EPTF_UIHandler_getNonEmptyParentId(v_UIHandler_guiItemList[vl_widgetIdx].parentIdx, vl_widgetId) > -1){ |
| vl_childWidgetId := pl_widgetIdThatHasBeenChanged; |
| vl_childWidgetIdx := vl_widgetIdx; |
| } else { |
| vl_widgetIdx := -1; |
| v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := true; |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| vl_haveRefresh := true; |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": Window has to be refreshed"); |
| } |
| } |
| } else { |
| f_EPTF_UIHandler_warning("No widget found with this ID :" & pl_widgetIdThatHasBeenChanged); |
| } |
| var integer vl_tabpagesId; |
| while(vl_widgetIdx > -1){ |
| // Get parent - vl_widgetIdx |
| if(f_EPTF_str2int_HashMap_Find(v_UIHandler_widgetHashMapId, vl_widgetId, vl_widgetIdx)){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": Parent of the element: "& vl_widgetId); |
| } |
| |
| if(v_UIHandler_guiItemList[vl_widgetIdx].widgetType == wtWindow ){ |
| v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := true; |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| vl_haveRefresh := true; |
| vl_widgetIdx := -1; |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": Window has to be refreshed"); |
| } |
| } else { |
| if(v_UIHandler_guiItemList[vl_widgetIdx].widgetType == wtTabpages ){ |
| //This ancestor is a tabpages |
| if(f_EPTF_str2int_HashMap_Find(v_EPTF_UIHandler_Browser_activeTabs_Hash, vl_widgetId , vl_tabpagesId)) { |
| // This tabpages has the tabpage that changed. We need to refresh only, when the vl_childWidgetId, |
| // where we came from equals the selected tabpage on the BrowserGUI |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": This tabpages could be refreshed: " & vl_widgetId); |
| } |
| if(v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].widgetId == vl_childWidgetId){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": This tabpage should be refreshed: " & vl_childWidgetId); |
| } |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].needToRefresh := true; |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].versionTabRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].versionTabRefreshCount + 1; |
| vl_haveRefresh := true; |
| vl_widgetIdx := -1; |
| } else if(0<vl_childWidgetIdx and v_UIHandler_guiItemList[vl_childWidgetIdx].widgetType == wtTabpage){ |
| // If sibling -> get parent tabpages |
| if(f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(v_UIHandler_guiItemList[vl_widgetIdx].parentIdx) > -1){ |
| vl_childWidgetId := vl_widgetId; |
| vl_widgetId := v_UIHandler_guiItemList[f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(v_UIHandler_guiItemList[vl_widgetIdx].parentIdx)].id; |
| vl_widgetIdx := f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(v_UIHandler_guiItemList[vl_widgetIdx].parentIdx); |
| vl_childWidgetIdx := vl_widgetIdx; |
| } else { |
| vl_widgetIdx := -1; |
| } |
| } else { |
| vl_widgetIdx := -1; |
| } |
| |
| } else { |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": Element not on the BrowserGUI yet, no action"); |
| } |
| vl_widgetIdx := -1; |
| } |
| |
| } else { |
| //Go to his ancestor in the next iteration |
| if(f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(v_UIHandler_guiItemList[vl_widgetIdx].parentIdx) > -1){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": Go to ancestor in the next iteration"); |
| } |
| vl_childWidgetId := vl_widgetId; |
| vl_widgetId := v_UIHandler_guiItemList[f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(v_UIHandler_guiItemList[vl_widgetIdx].parentIdx)].id; |
| vl_widgetIdx := f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(v_UIHandler_guiItemList[vl_widgetIdx].parentIdx); |
| vl_childWidgetIdx := vl_widgetIdx; |
| } else { |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": No ancestor : no action"); |
| } |
| vl_widgetIdx := -1; |
| } |
| } |
| } |
| } else { |
| f_EPTF_UIHandler_warning("No widget found with this ID :" & vl_widgetId); |
| vl_widgetIdx := -1; |
| } |
| } |
| if(vl_haveRefresh == false){ |
| } |
| } |
| |
| private function f_EPTF_UIHandler_Browser_getValuesForWidgets(in integer pl_connId, charstring pl_requestToFind) runs on EPTF_UIHandler_Private_CT { |
| var charstring vl_msg := ""; |
| var EPTF_WidgetValuePairs vl_widgetValuePairs; |
| f_EPTF_UIHandler_Browser_parseJSON(pl_requestToFind,vl_widgetValuePairs); |
| for(var integer vl_widgetNo := 0; vl_widgetNo < sizeof(vl_widgetValuePairs); vl_widgetNo := vl_widgetNo + 1){ |
| var integer vl_subsIdx := f_EPTF_UIHandler_getSubscriptionIdxByWidgetId(vl_widgetValuePairs[vl_widgetNo].widgetID); |
| if(vl_subsIdx < 0){ |
| for(var integer vl_i := 0; vl_i < sizeof(v_EPTF_UIHandler_BrowserGUI_WidgetToVariables); vl_i := vl_i + 1 ){ |
| if(v_EPTF_UIHandler_BrowserGUI_WidgetToVariables[vl_i].widgetId == vl_widgetValuePairs[vl_widgetNo].widgetID){ |
| var EPTF_Var_DirectContent vl_content; |
| f_EPTF_Var_getContent(v_EPTF_UIHandler_BrowserGUI_WidgetToVariables[vl_i].varId, vl_content); |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(" Variable content" & log2str(vl_content)); |
| } |
| var charstring vl_writeable := ""; |
| var integer vl_widgetIdx; |
| |
| if(v_EPTF_UIHandler_BrowserGUI_WidgetToVariables[vl_i].readonly == true){ |
| vl_writeable := "1"; //it is writeable |
| } else { |
| vl_writeable := "0"; //it is readonly |
| } |
| |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| |
| if(ischosen(vl_content.charstringVal)){ |
| vl_msg := vl_msg & "\"" & vl_widgetValuePairs[vl_widgetNo].widgetID & "\": \"" & vl_writeable & f_EPTF_Common_encodeEscapeSequence(vl_content.charstringVal) & "\""; |
| } |
| else if(ischosen(vl_content.charstringlistVal)){ |
| var charstring vl_result := "{ "; |
| for (var integer i:=0; i<sizeof(vl_content.charstringlistVal); i:=i+1) { |
| if (i>0) { |
| vl_result := vl_result & ", "; |
| } |
| vl_result := vl_result & log2str(vl_content.charstringlistVal[i]); |
| } |
| vl_result := vl_result & " }"; |
| vl_msg := vl_msg & "\"" & vl_widgetValuePairs[vl_widgetNo].widgetID & "\": \"" & vl_writeable & f_EPTF_Common_encodeEscapeSequence(vl_result)& "\""; |
| } else { |
| vl_msg := vl_msg & "\"" & vl_widgetValuePairs[vl_widgetNo].widgetID & "\": \"" & vl_writeable & f_EPTF_Var_directContent2str(vl_content)& "\""; |
| } |
| break; |
| |
| } |
| } |
| } |
| if(vl_subsIdx > -1){ |
| var EPTF_UIHandler_OpenSubscriptions vl_openSubs := f_EPTF_UIHandler_openSubscriptions(); |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(" Variable Idx: " & log2str(vl_openSubs[vl_subsIdx].varIdx)); |
| } |
| var EPTF_Var_DirectContent vl_content; |
| |
| if(vl_openSubs[vl_subsIdx].widgetType == wtTrace){ |
| if(vl_widgetValuePairs[vl_widgetNo].widgetVal == "chartInit"){ |
| f_EPTF_UIHandler_getHistoryOfTrace(vl_widgetValuePairs[vl_widgetNo].widgetID, vl_content); |
| } |
| else{ |
| f_EPTF_UIHandler_getLatestValueOfTrace(vl_widgetValuePairs[vl_widgetNo].widgetID, vl_content); |
| } |
| }else{ |
| f_EPTF_Var_getContent(vl_openSubs[vl_subsIdx].varIdx, vl_content); |
| } |
| |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(" Variable content" & log2str(vl_content)); |
| } |
| var charstring vl_writeable := ""; |
| var integer vl_widgetIdx; |
| if(true == f_EPTF_str2int_HashMap_Find(v_UIHandler_widgetHashMapId, vl_widgetValuePairs[vl_widgetNo].widgetID, vl_widgetIdx)){ |
| if(f_EPTF_UIHandler_isWidgetEnabled(vl_widgetIdx) and f_EPTF_Var_getSubsCanAdjust(vl_openSubs[vl_subsIdx].varIdx)){ |
| vl_writeable := "1"; //it is writeable |
| } else { |
| vl_writeable := "0"; //it is readonly |
| } |
| } else { |
| f_EPTF_UIHandler_warning("No widget found with this ID :" & vl_widgetValuePairs[vl_widgetNo].widgetID); |
| } |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| |
| if(ischosen(vl_content.charstringVal)){ |
| vl_msg := vl_msg & "\"" & vl_widgetValuePairs[vl_widgetNo].widgetID & "\": \"" & vl_writeable & f_EPTF_Common_encodeEscapeSequence(vl_content.charstringVal) & "\""; |
| } |
| else if(ischosen(vl_content.charstringlistVal)){ |
| var charstring vl_result := "{ "; |
| for (var integer i:=0; i<sizeof(vl_content.charstringlistVal); i:=i+1) { |
| if (i>0) { |
| vl_result := vl_result & ", "; |
| } |
| vl_result := vl_result & log2str(vl_content.charstringlistVal[i]); |
| } |
| vl_result := vl_result & " }"; |
| vl_msg := vl_msg & "\"" & vl_widgetValuePairs[vl_widgetNo].widgetID & "\": \"" & vl_writeable & f_EPTF_Common_encodeEscapeSequence(vl_result)& "\""; |
| } else { |
| vl_msg := vl_msg & "\"" & vl_widgetValuePairs[vl_widgetNo].widgetID & "\": \"" & vl_writeable & f_EPTF_Var_directContent2str(vl_content)& "\""; |
| } |
| } else { |
| //TODO Olyan widget lekeres jott, amihez nincs content : uihandler kuldje le az infot, hogy mely widgeteket lehet modositani(mihez van variable) |
| //Ehhez XTDL protmod modositas kell. |
| //f_EPTF_UIHandler_warning("No variable found to retrieve value to this widget :" & vl_widgetId); |
| } |
| |
| if (vl_widgetValuePairs[vl_widgetNo].widgetID=="ajaxReloadVersionCount"){ |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| vl_msg := vl_msg & "\"ajaxReloadVersionCount\": \"" & int2str(v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount) & "\""; |
| } |
| |
| if (lengthof(vl_widgetValuePairs[vl_widgetNo].widgetID)>20 and substr(vl_widgetValuePairs[vl_widgetNo].widgetID, 0, 20) == "ajaxTabVersionCount_"){ |
| var charstring vl_widgetID := substr(vl_widgetValuePairs[vl_widgetNo].widgetID, 20,(lengthof(vl_widgetValuePairs[vl_widgetNo].widgetID)-20)); |
| var integer vl_versionCount := -1; |
| for(var integer vl_tabid := 0;vl_tabid < sizeof(v_EPTF_UIHandler_Browser_activeTabs.activeTabs) and vl_versionCount == -1; vl_tabid := vl_tabid + 1){ |
| if(v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].widgetId == vl_widgetID){ |
| vl_versionCount := v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].versionTabRefreshCount; |
| } |
| } |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| vl_msg := vl_msg & "\"" & vl_widgetValuePairs[vl_widgetNo].widgetID &"\": \"" & int2str(vl_versionCount) & "\""; |
| } |
| |
| } |
| |
| //This code adds a JSON id:value pair to the message, where the server tells the browser, which tabpage is |
| //activated from code, please set the given tabpage active ( download it from server and make it visible) |
| if(v_EPTF_UIHandler_Browser_activateWidgetIds != ""){ |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| vl_msg := vl_msg & "\"ajaxActivate\": \"" & v_EPTF_UIHandler_Browser_activateWidgetIds & "\""; |
| v_EPTF_UIHandler_Browser_activateWidgetIds := ""; |
| } |
| |
| var charstring vl_activeTabs := ""; |
| |
| if(v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": Window needs to be refreshed"); |
| } |
| |
| v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := false; |
| //Remove all needToRefresh, because we have just sent all the window to the Browser |
| for(var integer vl_tabid := 0;vl_tabid < sizeof(v_EPTF_UIHandler_Browser_activeTabs.activeTabs); vl_tabid := vl_tabid + 1){ |
| if(v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].needToRefresh == true){ |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].needToRefresh := false; |
| } |
| } |
| |
| // This code adds a JSON id:value pair to the message, where the server tells the browser, |
| // the whole window needs to be reloaded. |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| vl_msg := vl_msg & "\"ajaxReload\": \"" & int2str(v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount) & "_\""; |
| } else { |
| //Remove all needToRefresh, because we have just sent them to the Browser |
| for(var integer vl_tabid := 0;vl_tabid < sizeof(v_EPTF_UIHandler_Browser_activeTabs.activeTabs); vl_tabid := vl_tabid + 1){ |
| if(v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].needToRefresh == true){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": The following tab needs to be refreshed: " & log2str(v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid])); |
| } |
| if(vl_activeTabs == ""){ |
| vl_activeTabs := vl_activeTabs & v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].widgetId; |
| } else { |
| vl_activeTabs := vl_activeTabs & "," & v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].widgetId; |
| } |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].needToRefresh := false; |
| } |
| } |
| |
| // This code adds a JSON id:value pair to the message, where the server tells the browser, |
| // which tab(s) to be reloaded. |
| if(vl_activeTabs != ""){ |
| v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount := v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount+1; |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| vl_msg := vl_msg & "\"ajaxReload\": \""& int2str(v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount) & "_" & vl_activeTabs & "\""; |
| } |
| } |
| |
| if(vl_msg != ""){vl_msg := vl_msg & "}";} |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&" Refresh happens: "& vl_msg); |
| } |
| timer T_waitForContentArrive := 0.1; |
| T_waitForContentArrive.start; |
| T_waitForContentArrive.timeout; |
| var ASP_Send vl_send; |
| vl_send := { pl_connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_htmlHTTPResponse( vl_msg ) }; |
| v_IPL4_PCO.send(vl_send); |
| } |
| |
| |
| private function f_EPTF_UIHandler_Browser_getValuesForVersions(in integer pl_connId, charstring pl_requestToFind) runs on EPTF_UIHandler_Private_CT { |
| var charstring vl_msg := ""; |
| var EPTF_WidgetValuePairs vl_widgetValuePairs; |
| f_EPTF_UIHandler_Browser_parseJSON(pl_requestToFind,vl_widgetValuePairs); |
| var integer vl_WidgetsLength := sizeof(vl_widgetValuePairs); |
| |
| // If have requested items |
| if(pl_requestToFind!="{}" and 0 < vl_WidgetsLength){ |
| for(var integer vl_widgetNo := 0; vl_widgetNo < vl_WidgetsLength ; vl_widgetNo := vl_widgetNo + 1){ |
| if (vl_widgetValuePairs[vl_widgetNo].widgetID=="ajaxReloadVersionCount"){ |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| vl_msg := vl_msg & "\"ajaxReloadVersionCount\": \"" & int2str(v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount) & "\""; |
| } else if (lengthof(vl_widgetValuePairs[vl_widgetNo].widgetID)>20 and substr(vl_widgetValuePairs[vl_widgetNo].widgetID, 0, 20) == "ajaxTabVersionCount_"){ |
| var charstring vl_widgetID := substr(vl_widgetValuePairs[vl_widgetNo].widgetID, 20,(lengthof(vl_widgetValuePairs[vl_widgetNo].widgetID)-20)); |
| var integer vl_versionCount := -1; |
| var integer vl_tabLength := sizeof(v_EPTF_UIHandler_Browser_activeTabs.activeTabs); |
| for(var integer vl_tabid := 0;vl_tabid < vl_tabLength and vl_versionCount == -1; vl_tabid := vl_tabid + 1){ |
| if(v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].widgetId == vl_widgetID){ |
| vl_versionCount := v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].versionTabRefreshCount; |
| } |
| } |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| vl_msg := vl_msg & "\"" & vl_widgetValuePairs[vl_widgetNo].widgetID &"\": \"" & int2str(vl_versionCount) & "\""; |
| } |
| } |
| } else { |
| // All versions |
| vl_msg := vl_msg & "{"; |
| vl_msg := vl_msg & "\"ajaxReloadVersionCount\": \"" & int2str(v_EPTF_UIHandler_Browser_activeTabs.versionRefreshCount) & "\""; |
| var integer vl_tabLength := sizeof(v_EPTF_UIHandler_Browser_activeTabs.activeTabs); |
| for(var integer vl_tabid := 0;vl_tabid < vl_tabLength ; vl_tabid := vl_tabid + 1){ |
| if(vl_msg == ""){vl_msg := vl_msg & "{";} |
| else {vl_msg := vl_msg & ",";} |
| vl_msg := vl_msg & "\"" & "ajaxTabVersionCount_" & v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].widgetId &"\": \"" & int2str(v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabid].versionTabRefreshCount) & "\""; |
| } |
| } |
| |
| if(vl_msg != ""){vl_msg := vl_msg & "}";} |
| |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&" Version Refresh happens: "& vl_msg); |
| } |
| timer T_waitForContentArrive := 0.1; |
| T_waitForContentArrive.start; |
| T_waitForContentArrive.timeout; |
| var ASP_Send vl_send; |
| vl_send := { pl_connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_htmlHTTPResponse( vl_msg ) }; |
| v_IPL4_PCO.send(vl_send); |
| } |
| |
| |
| private function f_EPTF_UIHandler_Browser_updateValueForWidget(in integer pl_connId, charstring pl_requestToFind) runs on EPTF_UIHandler_Private_CT { |
| var charstring vl_msg := ""; |
| var EPTF_WidgetValuePairs vl_widgetValuePairs; |
| f_EPTF_UIHandler_Browser_parseJSON(pl_requestToFind,vl_widgetValuePairs); |
| for(var integer vl_widgetNo := 0; vl_widgetNo < sizeof(vl_widgetValuePairs); vl_widgetNo := vl_widgetNo + 1){ |
| var integer vl_subsIdx := f_EPTF_UIHandler_getSubscriptionIdxByWidgetId(vl_widgetValuePairs[vl_widgetNo].widgetID); |
| if(vl_subsIdx > -1){ |
| var EPTF_UIHandler_OpenSubscriptions vl_openSubs := f_EPTF_UIHandler_openSubscriptions(); |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(" Variable Idx: " & log2str(vl_openSubs[vl_subsIdx].varIdx)); |
| } |
| |
| var EPTF_Var_DirectContent vl_content, vl_oldContent; |
| f_EPTF_Var_getContent(vl_openSubs[vl_subsIdx].varIdx, vl_content); |
| vl_oldContent := vl_content; |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(" Variable original Content" & log2str(vl_content)); |
| } |
| |
| var integer vl_fromdxNow := -1; |
| //button or regular integer value |
| if(ischosen(vl_content.intVal) and f_EPTF_str2int_HashMap_Find(v_UIHandler_widgetHashMapId, vl_widgetValuePairs[vl_widgetNo].widgetID, vl_fromdxNow)){ |
| // TR: HQ50988 |
| if(v_UIHandler_guiItemList[vl_fromdxNow].widgetType == wtButton or |
| (v_UIHandler_guiItemList[vl_fromdxNow].widgetType == wtTreecell and |
| ispresent(v_UIHandler_guiItemList[vl_fromdxNow].widgetDataType) and |
| v_UIHandler_guiItemList[vl_fromdxNow].widgetDataType == pushButton) ){ |
| //increase the value, if button |
| vl_content.intVal := vl_content.intVal + 1; |
| } else { |
| //no button, set intval |
| var charstring vl_currentValueStr := regexp(vl_widgetValuePairs[vl_widgetNo].widgetVal,c_EPTF_Var_whitespace&c_EPTF_Var_integerNumber&c_EPTF_Var_whitespace,0); |
| if (vl_currentValueStr!="") { |
| vl_content.intVal := str2int(vl_currentValueStr); |
| } else { |
| vl_msg := "ajaxupdate_NOK_WRONG_VALUE_GIVEN"; |
| f_EPTF_UIHandler_warning("Wrong value given to update this widget :" & vl_widgetValuePairs[vl_widgetNo].widgetID); |
| } |
| } |
| if (vl_oldContent != vl_content){ |
| f_EPTF_Var_adjustContent(vl_openSubs[vl_subsIdx].varIdx, vl_content, {refers(f_EPTF_UIHandler_adjustContentResponseHandler), {}}); |
| f_EPTF_Var_setContent(vl_openSubs[vl_subsIdx].varIdx, vl_content); |
| } |
| } else { |
| if(f_EPTF_Var_str2directContent(vl_widgetValuePairs[vl_widgetNo].widgetVal, vl_content) == 0){ |
| vl_msg := "ajaxupdate_OK"; |
| if (vl_oldContent != vl_content){ |
| f_EPTF_Var_adjustContent(vl_openSubs[vl_subsIdx].varIdx, vl_content, {refers(f_EPTF_UIHandler_adjustContentResponseHandler), {}}); |
| f_EPTF_Var_setContent(vl_openSubs[vl_subsIdx].varIdx, vl_content); |
| } |
| } else { |
| vl_msg := "ajaxupdate_NOK_WRONG_VALUE_GIVEN"; |
| f_EPTF_UIHandler_warning("Wrong value given to update this widget :" & vl_widgetValuePairs[vl_widgetNo].widgetID); |
| } |
| } |
| |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(" Variable content changed to : " & log2str(vl_content)); |
| } |
| if(vl_msg == "") { |
| vl_msg := "ajaxupdate_OK"; |
| } |
| } else { |
| f_EPTF_UIHandler_warning("No variable found to update this widget :" & vl_widgetValuePairs[vl_widgetNo].widgetID); |
| vl_msg := "ajaxupdate_ERROR_NOVAR"; |
| } |
| } |
| |
| timer T_waitForContentArrive := 0.1; |
| T_waitForContentArrive.start; |
| T_waitForContentArrive.timeout; |
| |
| var ASP_Send vl_send; |
| //action(" Updatere a valasz : ", vl_msg); |
| vl_send := { pl_connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_htmlHTTPResponse( vl_msg ) }; |
| v_IPL4_PCO.send(vl_send); |
| } |
| |
| private function f_EPTF_UIHandler_Browser_changeTabpage(in charstring pl_widgetId, in integer pl_connId, in boolean pl_tabPageXsl) runs on EPTF_UIHandler_Private_CT { |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Sending out tab children xml"); |
| } |
| var charstring vl_msg; |
| var charstring vl_tabid := ""; |
| var charstring vl_tabtitle := ""; |
| var integer vl_widgetIdx := f_EPTF_UIHandler_widgetRecIndex(pl_widgetId); |
| if(vl_widgetIdx > -1) { |
| if(v_UIHandler_guiItemList[vl_widgetIdx].widgetType == wtTabpage ){ |
| vl_tabid := f_EPTF_UIHandler_unichar2charstring(v_UIHandler_guiItemList[vl_widgetIdx].XULformat.tabpage.id); |
| vl_tabtitle := f_EPTF_UIHandler_unichar2charstring(v_UIHandler_guiItemList[vl_widgetIdx].XULformat.tabpage.label_); |
| var Widgets vl_tabpage; |
| f_EPTF_UIHandler_buildchildrenXUL(vl_widgetIdx, vl_tabpage); |
| //To save the tabpage that is requested in order to give back when next / request arrives. |
| var integer vl_tabpagesId := -1; |
| var charstring vl_widgetsTabpagesId := v_UIHandler_guiItemList[f_EPTF_UIHAndler_getNotMetaiteratorParentIdx(v_UIHandler_guiItemList[vl_widgetIdx].parentIdx)].id; |
| if(f_EPTF_str2int_HashMap_Find(v_EPTF_UIHandler_Browser_activeTabs_Hash, vl_widgetsTabpagesId , vl_tabpagesId)) { |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].widgetId := pl_widgetId; |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].needToRefresh := false; |
| } else { |
| vl_tabpagesId := f_EPTF_FBQ_getOrCreateFreeSlot(v_EPTF_UIHandler_Browser_activeTabs_Queue); |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].widgetId := pl_widgetId; |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].needToRefresh := false; |
| v_EPTF_UIHandler_Browser_activeTabs.activeTabs[vl_tabpagesId].versionTabRefreshCount := 1; |
| f_EPTF_FBQ_moveFromFreeHeadToBusyTail(v_EPTF_UIHandler_Browser_activeTabs_Queue); |
| f_EPTF_str2int_HashMap_Insert(v_EPTF_UIHandler_Browser_activeTabs_Hash, vl_widgetsTabpagesId, vl_tabpagesId); |
| } |
| for(var integer vl_i := 0 ; vl_i < sizeof(vl_tabpage.tabpage.embeddedwidgets.embeddedwidget_list); vl_i := vl_i + 1){ |
| f_EPTF_UIHandler_Browser_TabpageChildrenFilter(vl_tabpage.tabpage.embeddedwidgets.embeddedwidget_list[vl_i]); |
| } |
| vl_msg := oct2char(enc_Widgets(vl_tabpage)); |
| } else { |
| vl_msg := "Invalid request received! WidgetId should be a valid tabpage: " & pl_widgetId; |
| f_EPTF_UIHandler_warning(vl_msg); |
| vl_msg := f_EPTF_UIHandler_Browser_getErrorTab(vl_msg); |
| } |
| } else { |
| vl_msg := "Invalid WidgetId: " & pl_widgetId; |
| f_EPTF_UIHandler_warning(vl_msg); |
| vl_msg := f_EPTF_UIHandler_Browser_getErrorTab(vl_msg); |
| } |
| // If required the html header (css & js) |
| if(pl_tabPageXsl==false){ |
| if(f_strstr(vl_msg,"<window")<0){ |
| //CR_TR00019826 : Tabpage title should be windowtitle : tabtitle |
| var charstring vl_windowtitle := ""; |
| if(v_UIHandler_windowIndex > -1){ |
| if(ischosen(v_UIHandler_guiItemList[v_UIHandler_windowIndex].XULformat.window)){ |
| vl_windowtitle := f_EPTF_UIHandler_unichar2charstring(v_UIHandler_guiItemList[v_UIHandler_windowIndex].XULformat.window.title); |
| } |
| } |
| if(vl_windowtitle != ""){ |
| vl_msg := "<window id=\""& vl_tabid &"\" title=\""& vl_windowtitle & " : " & vl_tabtitle &"\">" & vl_msg & "</window>"; |
| } else { |
| vl_msg := "<window id=\""& vl_tabid &"\" title=\""& vl_tabtitle &"\">" & vl_msg & "</window>"; |
| } |
| } |
| } |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(" Answer message: " & f_EPTF_UIHandler_Browser_getXmlPrelude(pl_tabPageXsl) & vl_msg); |
| } |
| var ASP_Send vl_responseMsg := { |
| pl_connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_xmlHTTPResponse( f_EPTF_UIHandler_Browser_getXmlPrelude(pl_tabPageXsl) & vl_msg ) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| |
| } |
| |
| private function f_EPTF_UIHandler_Browser_getErrorMsg(in charstring pl_missingFile) runs on EPTF_UIHandler_Private_CT |
| return charstring { |
| var charstring vl_msg := v_EPTF_UIHandler_Browser_errorMsg; |
| vl_msg := f_replaceEveryOccurenceOfSubstring(vl_msg, c_missingFileName, pl_missingFile); |
| vl_msg := f_replaceEveryOccurenceOfSubstring(vl_msg, "$tsp_EPTF_UIHandler_Browser_directory", "tsp_EPTF_UIHandler_Browser_directory: \"" & v_EPTF_UIHandler_Browser_directory & "\""); |
| return vl_msg; |
| } |
| |
| |
| //Widget - externaldata osszekotest teremti meg ez az fg |
| private function f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreen(inout Widgets pl_xul) runs on EPTF_UIHandler_Private_CT |
| { |
| if(ischosen(pl_xul.window )) { |
| f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreenInner(pl_xul.window.embeddedwidgets); |
| } |
| else if(ischosen(pl_xul.tabpages )) { |
| for(var integer vl_i := 0; vl_i < sizeof(pl_xul.tabpages.tabpagegroups.tabpagegroup_list); vl_i := vl_i + 1){ |
| //TODO nem kezelunk condition, if, iterator elemeket. |
| f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreenInner(pl_xul.tabpages.tabpagegroups.tabpagegroup_list[vl_i].tabpage.embeddedwidgets); |
| } |
| } |
| else if(ischosen(pl_xul.hbox )) { |
| f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreenInner(pl_xul.hbox.embeddedwidgets); |
| } |
| else if(ischosen(pl_xul.label_ )) { |
| if(ispresent(pl_xul.label_.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.label_.disabledongui) and pl_xul.label_.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.label_.id), pl_xul.label_.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.spacer )) { |
| //ok |
| } |
| else if(ischosen(pl_xul.button )) { |
| if(ispresent(pl_xul.button.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.button.disabledongui) and pl_xul.button.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.button.id), pl_xul.button.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.textbox )) { |
| if(ispresent(pl_xul.textbox.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.textbox.disabledongui) and pl_xul.textbox.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.textbox.id), pl_xul.textbox.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.tabpage )) { |
| f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreenInner(pl_xul.tabpage.embeddedwidgets); |
| } |
| else if(ischosen(pl_xul.listbox )) { |
| if(ispresent(pl_xul.listbox.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.listbox.disabledongui) and pl_xul.listbox.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.listbox.id), pl_xul.listbox.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.menulist )) { |
| if(ispresent(pl_xul.menulist.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.menulist.disabledongui) and pl_xul.menulist.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.menulist.id), pl_xul.menulist.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.menuitem )) { |
| if(ispresent(pl_xul.menuitem.externaldata)){ |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.menuitem.id), pl_xul.menuitem.externaldata, false); |
| } |
| } |
| else if(ischosen(pl_xul.pushbutton )) { |
| if(ispresent(pl_xul.pushbutton.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.pushbutton.disabledongui) and pl_xul.pushbutton.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.pushbutton.id), pl_xul.pushbutton.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.togglebutton )) { |
| if(ispresent(pl_xul.togglebutton.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.togglebutton.disabledongui) and pl_xul.togglebutton.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.togglebutton.id), pl_xul.togglebutton.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.htmlcode )) { |
| //ok |
| } else { |
| f_EPTF_UIHandler_warning("Unhandled widget type in "&%definitionId&": "&log2str(pl_xul)); |
| } |
| } |
| |
| private function f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreenInner(inout Embeddedwidgets pl_embededwidgets) runs on EPTF_UIHandler_Private_CT |
| { |
| for(var integer vl_i := 0; vl_i < sizeof(pl_embededwidgets.embeddedwidget_list); vl_i := vl_i + 1){ |
| f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreenInner2(pl_embededwidgets.embeddedwidget_list[vl_i]); |
| } |
| } |
| |
| private function f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreenInner2(inout Embeddedwidget pl_xul) runs on EPTF_UIHandler_Private_CT |
| { |
| if(ischosen(pl_xul.tabpages )) { |
| for(var integer vl_i := 0; vl_i < sizeof(pl_xul.tabpages.tabpagegroups.tabpagegroup_list); vl_i := vl_i + 1){ |
| //TODO nem kezelunk condition, if, iterator elemeket. |
| f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreenInner(pl_xul.tabpages.tabpagegroups.tabpagegroup_list[vl_i].tabpage.embeddedwidgets); |
| } |
| } |
| else if(ischosen(pl_xul.hbox )) { |
| f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreenInner(pl_xul.hbox.embeddedwidgets); |
| } |
| else if(ischosen(pl_xul.label_ )) { |
| if(ispresent(pl_xul.label_.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.label_.disabledongui) and pl_xul.label_.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.label_.id), pl_xul.label_.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.spacer )) { |
| //ok |
| } |
| else if(ischosen(pl_xul.button )) { |
| if(ispresent(pl_xul.button.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.button.disabledongui) and pl_xul.button.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.button.id), pl_xul.button.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.textbox )) { |
| if(ispresent(pl_xul.textbox.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.textbox.disabledongui) and pl_xul.textbox.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.textbox.id), pl_xul.textbox.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.listbox )) { |
| if(ispresent(pl_xul.listbox.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.listbox.disabledongui) and pl_xul.listbox.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.listbox.id), pl_xul.listbox.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.menulist )) { |
| if(ispresent(pl_xul.menulist.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.menulist.disabledongui) and pl_xul.menulist.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.menulist.id), pl_xul.menulist.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.pushbutton )) { |
| if(ispresent(pl_xul.pushbutton.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.pushbutton.disabledongui) and pl_xul.pushbutton.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.pushbutton.id), pl_xul.pushbutton.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.togglebutton )) { |
| if(ispresent(pl_xul.togglebutton.externaldata)){ |
| var boolean vl_disabledongui := false; |
| if(ispresent(pl_xul.togglebutton.disabledongui) and pl_xul.togglebutton.disabledongui == true) { |
| vl_disabledongui := true; |
| } |
| f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(f_EPTF_UIHandler_unichar2charstring(pl_xul.togglebutton.id), pl_xul.togglebutton.externaldata, vl_disabledongui); |
| } |
| } |
| else if(ischosen(pl_xul.htmlcode )) { |
| //ok |
| } else { |
| f_EPTF_UIHandler_warning("Unhandled widget type in "&%definitionId&": "&log2str(pl_xul)); |
| } |
| } |
| |
| private function f_EPTF_UIHandler_Browser_addExternalDataToWidgetId(in charstring pl_widgetId, in Datadescription pl_datadescription, in boolean pl_readonly := false) runs on EPTF_UIHandler_Private_CT |
| { |
| //action("Connect widget : ", pl_widgetId ," to variable from externaldata: " , pl_datadescription.element); |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": Started on : " & log2str(pl_datadescription)); |
| } |
| // Ask the UIHandler about the datasource, then send him the question. |
| var EPTF_DataSource_Params vl_dataparamList:= {}; |
| var charstring vl_varName := ""; |
| if(ispresent(pl_datadescription.params)){ |
| for(var integer i := 0; i < sizeof(pl_datadescription.params.dataparam_list); i := i + 1 ){ |
| var integer vl_dataParamsSize := sizeof(vl_dataparamList); |
| vl_dataparamList[vl_dataParamsSize].paramName := f_unichar2charstr(pl_datadescription.params.dataparam_list[i].name); // FIXME |
| vl_dataparamList[vl_dataParamsSize].paramValue := f_unichar2charstr(pl_datadescription.params.dataparam_list[i].value_); |
| } |
| } |
| var charstring vl_source := f_unichar2charstr(pl_datadescription.source); |
| |
| var charstring vl_ptcname := ""; |
| if(ispresent(pl_datadescription.ptcname)){ vl_ptcname := f_unichar2charstr(pl_datadescription.ptcname)} |
| |
| var charstring vl_element := f_unichar2charstr(pl_datadescription.element); |
| |
| var EPTF_UIHandler_GuiItemRec vl_widgetRec; |
| var EPTF_Var_DirectContent vl_defaultValue; |
| |
| if(f_EPTF_DataSource_getData(vl_varName, vl_source, vl_ptcname, vl_element, vl_dataparamList) == 0 ){ |
| var integer vl_varId := f_EPTF_Var_getId(vl_varName); |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug(%definitionId&": widgetId: " & log2str(pl_widgetId) & " varId: " & log2str(vl_varId)); |
| } |
| var integer vl_size := sizeof(v_EPTF_UIHandler_BrowserGUI_WidgetToVariables); |
| v_EPTF_UIHandler_BrowserGUI_WidgetToVariables[vl_size].widgetId := pl_widgetId; |
| v_EPTF_UIHandler_BrowserGUI_WidgetToVariables[vl_size].varId := vl_varId; |
| v_EPTF_UIHandler_BrowserGUI_WidgetToVariables[vl_size].readonly := pl_readonly; |
| } else { |
| f_EPTF_UIHandler_error(%definitionId&": Configuration error : Invalid dataSource parameters: \n"& |
| "\nSource: "&vl_source& |
| "\nPTC : "&vl_ptcname & |
| "\nData Name : " &vl_element& |
| "\nParams:" & log2str(vl_dataparamList)& |
| "\nCheck the warnings above for more info."); |
| } |
| } |
| |
| |
| // returns true if the end of the pl_inputStr is pl_eofStr |
| private function f_UIHandler_checkEofStr( |
| in charstring pl_inputStr, |
| in charstring pl_eofStr |
| ) return boolean { |
| return (lengthof(pl_eofStr)<=lengthof(pl_inputStr)) and (substr(pl_inputStr,lengthof(pl_inputStr)-lengthof(pl_eofStr),lengthof(pl_eofStr))==pl_eofStr); |
| } |
| |
| //========================================================================= |
| // Altsteps |
| //========================================================================= |
| /////////////////////////////////////////////////////////// |
| // Altstep: as_UIHandler_handleHTTPRequest |
| // |
| // Purpose: Handle the incomming HTTP Requests |
| // |
| /////////////////////////////////////////////////////////// |
| private altstep as_UIHandler_handleHTTPRequest() runs on EPTF_UIHandler_Private_CT { |
| var ASP_Send vl_responseMsg; |
| var ASP_RecvFrom v_ASP_RecvFrom; |
| var ASP_Event v_ASP_Event; |
| var HTTPMessage v_HTTP_msg; |
| var integer vl_chunkId := -1; |
| [] v_IPL4_PCO.receive(ASP_RecvFrom:?) -> value v_ASP_RecvFrom { |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("ASP receive from: " & log2str(v_ASP_RecvFrom)); |
| } |
| |
| vl_chunkId := -1; |
| v_intNoWarn := dec_HTTPMessage(v_ASP_RecvFrom.msg, v_HTTP_msg, false); |
| if(v_intNoWarn != 0 or not ischosen(v_HTTP_msg.request)){ |
| if(f_EPTF_int2int_HashMap_Find(v_EPTF_UIHandler_Browser_chunk_FromConnId_Hash, v_ASP_RecvFrom.connId, vl_chunkId)) { |
| v_intNoWarn := dec_HTTPMessage(v_EPTF_UIHandler_Browser_chunk[vl_chunkId] & v_ASP_RecvFrom.msg, v_HTTP_msg, false); |
| } |
| } |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("HTTP payload: " & log2str(v_HTTP_msg)); |
| } |
| |
| if(v_intNoWarn == 0 and ischosen(v_HTTP_msg.request)){ |
| if(vl_chunkId > -1){v_EPTF_UIHandler_Browser_chunk[vl_chunkId] := ''O;} |
| var charstring vl_requestToFind := v_HTTP_msg.request.uri; |
| vl_requestToFind := f_replaceEveryOccurenceOfSubstring( vl_requestToFind, "/", "") |
| vl_requestToFind := f_replaceEveryOccurenceOfSubstring( vl_requestToFind, "%22", "") |
| vl_requestToFind := f_replaceEveryOccurenceOfSubstring( vl_requestToFind, "%20", " ") |
| vl_requestToFind := f_replaceEveryOccurenceOfSubstring( vl_requestToFind, "%2B", "+") |
| if(v_HTTP_msg.request.uri == "/"){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Page loaded first time"); |
| } |
| |
| v_tabsNb := 0; |
| var ASP_Send vl_send; |
| if(v_EPTF_UIHandler_Browser_enableWelcomeScreen){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("GUI not ready, send welcome screen"); |
| } |
| var charstring vl_msg2 := f_EPTF_createFromFile(f_EPTF_UIHandler_Browser_directory() & tsp_EPTF_UIHandler_Browser_welcomeScreen); |
| if(0<f_strstr(tsp_EPTF_UIHandler_Browser_welcomeScreen,".xml")){ |
| var Widgets vl_messageInXMLFormat := f_EPTF_UIHandler_XSD_decodeXUL(vl_msg2); |
| f_EPTF_UIHandler_Browser_handleExternalDataOnWelcomeScreen(vl_messageInXMLFormat); |
| vl_msg2 := f_EPTF_UIHandler_XSD_encodeXUL(vl_messageInXMLFormat); |
| vl_responseMsg := { v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_xmlHTTPResponse( f_EPTF_UIHandler_Browser_getXmlPrelude() & vl_msg2 ) }; |
| |
| } else { |
| vl_responseMsg := { v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_htmlHTTPResponse( vl_msg2 ) }; |
| } |
| |
| v_IPL4_PCO.send(vl_responseMsg); |
| } |
| else { |
| f_EPTF_UIHandler_getCurrentLayoutOnHTTP(v_ASP_RecvFrom.connId,vl_send); |
| v_IPL4_PCO.send(vl_send); |
| } |
| } |
| else if(f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".html") or |
| f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".htm") or |
| f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".lng") or |
| f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".txt") or |
| (f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".xml") and v_HTTP_msg.request.uri != "/complete_gui.xml") |
| ){ |
| |
| var charstring vl_msg2 := f_EPTF_createFromFile(f_EPTF_UIHandler_Browser_directory() & v_HTTP_msg.request.uri); |
| if(vl_msg2 != "") { |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_htmlHTTPResponse( vl_msg2 ) |
| }; |
| } else { |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_HTTPResponse_404(v_HTTP_msg.request.uri) |
| }; |
| } |
| v_IPL4_PCO.send(vl_responseMsg); |
| } |
| else if(f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".pcap") or |
| f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".zip") or |
| f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".gz") or |
| f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".tar") |
| ){ |
| var charstring vl_msg2 := f_EPTF_createFromFile(f_EPTF_UIHandler_Browser_directory() & v_HTTP_msg.request.uri); |
| if(vl_msg2 != "") { |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_binaryHTTPResponse( vl_msg2 ) |
| }; |
| } else { |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_HTTPResponse_404(v_HTTP_msg.request.uri) |
| }; |
| } |
| v_IPL4_PCO.send(vl_responseMsg); |
| } |
| else if((f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".xsl") or f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".xsl.welcome")) and f_strstr(v_HTTP_msg.request.uri,"error") == -1){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Sending out XSL"); |
| } |
| |
| var charstring vl_ifile := substr(v_HTTP_msg.request.uri, 1, lengthof(v_HTTP_msg.request.uri)-1); |
| var charstring vl_msg2; |
| //TODO This is a temporary solution, v_EPTF_UIHandler_Browser_activeTabs.needToRefreshWholeWindow := true; should be handled, |
| //but this does not work for me. |
| if(0<f_strstr(vl_ifile,".xsl.welcome")){ |
| vl_ifile := substr(vl_ifile, 0, lengthof(vl_ifile)-8); |
| vl_msg2 := f_EPTF_createFromFile(f_EPTF_UIHandler_Browser_directory() & vl_ifile); |
| //Replace </head> tag to <meta http-equiv="refresh" content="10"/></head> string, if the xsl is reload |
| vl_msg2 := f_replaceEveryOccurenceOfSubstring( vl_msg2, "</head>","<meta http-equiv='refresh' content='10'/></head>"); |
| } else { |
| vl_msg2 := f_EPTF_createFromFile(f_EPTF_UIHandler_Browser_directory() & vl_ifile); |
| } |
| if(vl_msg2 != ""){ |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_xmlHTTPResponse( vl_msg2 ) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| } else { |
| vl_msg2 := "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> |
| <xsl:stylesheet version=\"2.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" xmlns:fo=\"http://www.w3.org/1999/XSL/Format\"> |
| <xsl:template match=\"/\"> |
| <html> |
| <head> |
| <script type=\"text/javascript\">window.location = \"./?error_" & vl_ifile & "\"</script> |
| </head> |
| </html> |
| </xsl:template> |
| </xsl:stylesheet>"; |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_xmlHTTPResponse( vl_msg2 ) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| f_EPTF_UIHandler_warning("GET XSL - WARNING: " & v_HTTP_msg.request.uri); |
| } |
| } |
| else if(v_HTTP_msg.request.uri == "/complete_gui.xml"){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Sending out saved.xml"); |
| } |
| var charstring vl_msg2 := f_EPTF_UIHandler_snapshot(); |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_xmlHTTPResponse_as_file( vl_msg2, "complete_gui.xml" ) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| } |
| else if(v_HTTP_msg.request.uri == "/favicon.ico"){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Sending out favicon.ico"); |
| } |
| var charstring vl_msg2 := f_EPTF_createFromFile(f_EPTF_UIHandler_Browser_directory() & tsp_EPTF_UIHandler_Browser_favicon2send); |
| if(vl_msg2 != "") { |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_xmlHTTPResponse( vl_msg2 ) |
| }; |
| } else { |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_HTTPResponse_404(v_HTTP_msg.request.uri) |
| }; |
| } |
| v_IPL4_PCO.send(vl_responseMsg); |
| } |
| else if(f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".gif") or f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".jpg") or |
| f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".png") or f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".ico") ){ |
| var charstring vl_ifile := substr(v_HTTP_msg.request.uri, 1, lengthof(v_HTTP_msg.request.uri)-1); |
| vl_ifile := f_replaceEveryOccurenceOfSubstring( vl_ifile, "%22", "") |
| var charstring vl_msg2 := f_EPTF_createFromFile(f_EPTF_UIHandler_Browser_directory() & vl_ifile); |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("GET Image: " & vl_ifile); |
| } |
| if(vl_msg2 != ""){ |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_imageHTTPResponse( vl_msg2, vl_ifile ) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| } else { |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_HTTPResponse_404(v_HTTP_msg.request.uri) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| f_EPTF_UIHandler_warning("GET Image - WARNING: " & v_HTTP_msg.request.uri); |
| } |
| } |
| else if (f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".css") and f_strstr(v_HTTP_msg.request.uri,"error") == -1){ |
| var charstring vl_cssfile := substr(v_HTTP_msg.request.uri, 1, lengthof(v_HTTP_msg.request.uri)-1); |
| var charstring vl_msg2 := f_EPTF_createFromFile(f_EPTF_UIHandler_Browser_directory() & vl_cssfile); |
| // Custom style |
| if(v_EPTF_Browser_customStyleCache != ""){ |
| vl_msg2 := vl_msg2 & v_EPTF_Browser_customStyleCache; |
| } |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("GET CSS: " & vl_cssfile); |
| } |
| if(vl_msg2 != ""){ |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_cssHTTPResponse( vl_msg2 ) |
| }; |
| } else { |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_HTTPResponse_404(v_HTTP_msg.request.uri) |
| }; |
| f_EPTF_UIHandler_warning("GET CSS - WARNING: " & v_HTTP_msg.request.uri); |
| } |
| v_IPL4_PCO.send(vl_responseMsg); |
| } |
| else if (f_UIHandler_checkEofStr(v_HTTP_msg.request.uri,".js") and f_strstr(v_HTTP_msg.request.uri,"error") == -1){ |
| var charstring vl_jsfile := substr(v_HTTP_msg.request.uri, 1, lengthof(v_HTTP_msg.request.uri)-1); |
| var charstring vl_msg2 := f_EPTF_createFromFile(f_EPTF_UIHandler_Browser_directory() & vl_jsfile); |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("GET JS: " & vl_jsfile); |
| } |
| if(vl_msg2 != ""){ |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_jsHTTPResponse( vl_msg2 ) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| } else { |
| vl_msg2 := "window.location = \"./?error_" & vl_jsfile & "\""; |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_jsHTTPResponse( vl_msg2 ) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| f_EPTF_UIHandler_warning("GET JS - WARNING: " & v_HTTP_msg.request.uri); |
| } |
| } |
| else if(lengthof(v_HTTP_msg.request.uri)>14 and substr(v_HTTP_msg.request.uri, 0, 14) == "/?ajaxversion_"){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Sending out Version values"); |
| } |
| var integer vl_from := f_strstr(v_HTTP_msg.request.uri,"{", 0); // behind no cache[requestSuccess] counter |
| var charstring vl_versionIDs := ""; |
| if(0<vl_from) { |
| vl_versionIDs := substr(v_HTTP_msg.request.uri,vl_from,(lengthof(v_HTTP_msg.request.uri)-vl_from)); |
| |
| } else { |
| vl_versionIDs := substr(v_HTTP_msg.request.uri,14,lengthof(v_HTTP_msg.request.uri)-14); |
| } |
| f_EPTF_UIHandler_Browser_getValuesForVersions(v_ASP_RecvFrom.connId, vl_versionIDs); |
| } |
| else if(lengthof(v_HTTP_msg.request.uri)>14 and substr(v_HTTP_msg.request.uri, 0, 14) == "/?ajaxrefresh_"){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Sending out refreshed values"); |
| } |
| var integer vl_from := f_strstr(v_HTTP_msg.request.uri,"{", 0); // behind no cache[requestSuccess] counter |
| if(0<vl_from) { |
| f_EPTF_UIHandler_Browser_getValuesForWidgets(v_ASP_RecvFrom.connId, substr(v_HTTP_msg.request.uri,vl_from,(lengthof(v_HTTP_msg.request.uri)-vl_from))); |
| } else { |
| f_EPTF_UIHandler_Browser_getValuesForWidgets(v_ASP_RecvFrom.connId, substr(v_HTTP_msg.request.uri,14,lengthof(v_HTTP_msg.request.uri)-14)); |
| } |
| |
| } |
| else if(lengthof(v_HTTP_msg.request.uri)>13 and substr(v_HTTP_msg.request.uri, 0, 13) == "/?ajaxupdate_"){ |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Sending out update value"); |
| } |
| var integer vl_from := f_strstr(v_HTTP_msg.request.uri,"{", 0); // behind no cache[updateSuccess] counter |
| if(0<vl_from) { |
| f_EPTF_UIHandler_Browser_updateValueForWidget(v_ASP_RecvFrom.connId, substr(v_HTTP_msg.request.uri,vl_from,(lengthof(v_HTTP_msg.request.uri)-vl_from))); |
| } else { |
| f_EPTF_UIHandler_Browser_updateValueForWidget(v_ASP_RecvFrom.connId, substr(v_HTTP_msg.request.uri,13,lengthof(v_HTTP_msg.request.uri)-13)); |
| } |
| } |
| else if(lengthof(v_HTTP_msg.request.uri)>22 and substr(v_HTTP_msg.request.uri, 0, 22) == "/?tabrequest_samepage_"){ |
| var charstring vl_widgetId := ""; |
| var integer vl_from := f_strstr(v_HTTP_msg.request.uri,"}", 0); // behind no cache[requestSuccess] counter |
| if(0<vl_from) { |
| vl_widgetId := substr(v_HTTP_msg.request.uri,vl_from+1,(lengthof(v_HTTP_msg.request.uri)-vl_from-1)); |
| } else { |
| vl_widgetId := substr(vl_requestToFind, 21, lengthof(vl_requestToFind)-21); |
| } |
| f_EPTF_UIHandler_Browser_changeTabpage(vl_widgetId, v_ASP_RecvFrom.connId, true); |
| } |
| else if(lengthof(v_HTTP_msg.request.uri)>13 and substr(v_HTTP_msg.request.uri, 0, 13) == "/?tabrequest_"){ |
| var charstring vl_widgetId := ""; |
| var integer vl_from := f_strstr(v_HTTP_msg.request.uri,"}", 0); // behind no cache[requestSuccess] counter |
| if(0<vl_from) { |
| vl_widgetId := substr(v_HTTP_msg.request.uri,vl_from+1,(lengthof(v_HTTP_msg.request.uri)-vl_from-1)); |
| } else { |
| vl_widgetId := substr(vl_requestToFind, 12, lengthof(vl_requestToFind)-12); |
| } |
| f_EPTF_UIHandler_Browser_changeTabpage(vl_widgetId, v_ASP_RecvFrom.connId, false); |
| } |
| else if (lengthof(v_HTTP_msg.request.uri)>8 and substr(v_HTTP_msg.request.uri, 0, 8) == "/?error_"){ |
| var charstring vl_errorFile := substr(vl_requestToFind, 7, lengthof(vl_requestToFind)-7); |
| var charstring vl_msg2 := f_EPTF_UIHandler_Browser_getErrorMsg(vl_errorFile); |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("Sending error message, it contains the problem with the file: " & vl_errorFile); |
| } |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_htmlHTTPResponse( vl_msg2 ) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| } else { |
| var charstring vl_msg := "Unhandled Request from Browser: " & v_HTTP_msg.request.uri; |
| f_EPTF_UIHandler_warning(vl_msg); |
| vl_msg := f_EPTF_UIHandler_Browser_getErrorPage(vl_msg); |
| vl_responseMsg := { |
| v_ASP_RecvFrom.connId, {tcp := {}}, |
| f_EPTF_UIHandler_Browser_xmlHTTPResponse( f_EPTF_UIHandler_Browser_getXmlPrelude() & vl_msg ) |
| }; |
| v_IPL4_PCO.send(vl_responseMsg); |
| } |
| } else { |
| vl_chunkId := -1; |
| if(f_EPTF_int2int_HashMap_Find(v_EPTF_UIHandler_Browser_chunk_FromConnId_Hash, v_ASP_RecvFrom.connId, vl_chunkId)) { |
| v_EPTF_UIHandler_Browser_chunk[vl_chunkId] := v_EPTF_UIHandler_Browser_chunk[vl_chunkId] & v_ASP_RecvFrom.msg; |
| } else { |
| vl_chunkId := f_EPTF_FBQ_getOrCreateFreeSlot(v_EPTF_UIHandler_Browser_chunk_FromConnId_Queue); |
| v_EPTF_UIHandler_Browser_chunk[vl_chunkId] := v_ASP_RecvFrom.msg; |
| f_EPTF_FBQ_moveFromFreeHeadToBusyTail(v_EPTF_UIHandler_Browser_chunk_FromConnId_Queue); |
| f_EPTF_int2int_HashMap_Insert(v_EPTF_UIHandler_Browser_chunk_FromConnId_Hash, v_ASP_RecvFrom.connId, vl_chunkId); |
| } |
| } |
| repeat; |
| } |
| [] v_IPL4_PCO.receive(ASP_Event:?) -> value v_ASP_Event { |
| if(c_EPTF_Common_debugSwitch and f_EPTF_UIHandler_debugEnabled()){ |
| f_EPTF_UIHandler_debug("ASP event: "& log2str(v_ASP_Event)); |
| } |
| if(ischosen(v_ASP_Event.connClosed)){ |
| if(f_EPTF_int2int_HashMap_Find(v_EPTF_UIHandler_Browser_chunk_FromConnId_Hash, v_ASP_Event.connClosed.connId, vl_chunkId)) { |
| f_EPTF_int2int_HashMap_Erase(v_EPTF_UIHandler_Browser_chunk_FromConnId_Hash, v_ASP_Event.connClosed.connId); |
| f_EPTF_FBQ_moveFromBusyToFreeHead(vl_chunkId,v_EPTF_UIHandler_Browser_chunk_FromConnId_Queue); |
| v_EPTF_UIHandler_Browser_chunk[vl_chunkId] := ''O; |
| } |
| } |
| repeat; |
| } |
| [] v_IPL4_PCO.receive { |
| f_EPTF_UIHandler_warning("Invalid message received!"); |
| repeat; |
| } |
| } |
| |
| } |
| |
| |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_setBrowserDirectory |
| // |
| // Purpose: |
| // This function sets the BrowserGUI directory, where the .png, .css, .js |
| // and several other files are, needed by the BrowserGUI feature. |
| // |
| // Parameters: |
| // pl_directory - *in* <charstring> - the directory |
| // |
| // Return Value: |
| // - |
| // |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_setBrowserDirectory(in charstring pl_directory) |
| runs on EPTF_UIHandler_Private_CT{ |
| v_EPTF_UIHandler_Browser_directory := pl_directory; |
| } |
| |
| ///////////////////////////////////////////////////////////////////////// |
| // Function: f_EPTF_UIHandler_Browser_getBrowserDirectory |
| // |
| // Purpose: |
| // This function returns with the BrowserGUI directory string, where the .png, .css, .js |
| // and several other files should be, needed by the BrowserGUI feature. |
| // |
| // Parameters: |
| // - |
| // |
| // Return Value: |
| // *charstring* - the directory |
| // |
| ///////////////////////////////////////////////////////////////////////// |
| public function f_EPTF_UIHandler_Browser_getBrowserDirectory() runs on EPTF_UIHandler_Private_CT return charstring{ |
| |
| return v_EPTF_UIHandler_Browser_directory; |
| |
| } |
| |
| } // end of module |