Subroutine Epi_User_Debug(MsgSent)

/******************************************************************************************************** 

    This program is proprietary and is not to be used by or disclosed to others, nor is it to
    be copied without written permission from SRP Computer Solutions, Inc.

    Name        :   Epi_User_Debug

    Description :   

    Notes       :   

    Parameters  :
		MsgSent		[out] --

    History (Date, Initials, Notes)
    	04/01/06    dmb     Initial new logic																			
		06/30/09    fjt     Updated for use in EPI
		06/30/10    jch     Cloned from debugger_replace in SYSPROG acct	

********************************************************************************************************/

$insert RTI_Debug_Common
$insert Logical
$insert SRPMail_Inserts

Declare subroutine Set_Property
Declare function Get_Property, SRP_Send_Mail, Msg

Process = 0
Loop
    Process += 1
    On Process GoSub Init, Development, Check, Text, Message, Send, Done
Until (Error or Done)
Repeat

Return


!----- PROCESS ROUTINES ---------------------------------------------------------------------------------


Init:
    Done     = No$
    Error    = No$
    If Get_Property('NDW_MAIN', 'VISIBLE') then
        MainWin = 'NDW_MAIN'
    end else
        MainWin = 'LSL_MAIN2'
    end
*    MainWin  = "LSL_MAIN2"
    Program  = Curr_Program@
    MsgSent  = ""
    
    If Program EQ "" then Program = "Debug Intercept Test"
    
    SentFrom = "oinotify@infineon.com"
    SentTo   = "MES-FI-Mesa-Support@infineon.com"
	
	
    ConfigFile    = ""
    ConfigFile<1> = SendUsing_Port$
    ConfigFile<2> = ""
    ConfigFile<3> = 25                    	 	;// Server port
    *ConfigFile<4> = "10.95.1.11"				;// Mail server
    *ConfigFile<4>  = 'smtp.intra.infineon.com'	;// Infineon smtp mail Server_internal recipients only
    *ConfigFile<4> = 'appmail.eu.infineon.com'	;// Infineon smtp mail server_internal and external recipients
    ConfigFile<4> = 'mailrelay-external.infineon.com'
    ConfigFile<5> = Yes$                        ;// Authenticate
    ConfigFile<6> = "oinotify@infineon.com"		;// Username
    ConfigFile<7> = "oinotify1"		            ;// Password
    ConfigFile<8> =	No$						    ;// Use SSL
return


Development:
	NoEmail = "SRP_FRANK"
	Locate @USER4 in NoEmail using "," setting x then
		Done = Yes$
	end
return


Check:
    Debugged = Get_Property(MainWin, "@DEBUGGED")
    Locate Program in Debugged using @FM setting Pos then
        // Email already sent for this program
        Done = Yes$
    end
return


Text:
    Text = ""
    Text<-1> = "App:     "	: @APPID<1>
    Text<-1> = "Window:  "  : @WINDOW
    Text<-1> = "User:    "	: @USER4
    Text<-1> = "Station: "	: @STATION
    Text<-1> = " "
    Text<-1> = "SP Status:    "  : SPStatus@
    Text<-1> = "SP Stat Code: "  : SPStatCode@
    Text<-1> = "Program:      "  : Program
    Text<-1> = "Call Depth:   "  : CallDepth@
    Text<-1> = "Line No:      "  : LineNo@
    Text<-1> = " "
    Text<-1> = "Stack:   "
    Text<-1> = CallStack@
    
    Convert \00\ to "," in Text
    Convert @VM to "-" in Text
    Swap @FM with Char(13):Char(10) in Text
    
    OSWrite Text to Drive():"\logs\debug_log.txt"
return

  
Message:  
    Message = ""
    Message<1> = "Debug Alert - ":Program	; // Subject
    Message<2> = SentFrom		            ; // From (email address)
    Message<3> = SentTo			            ; // Send to (email address)
    Message<5> = ""							; // Blind Carbon Copy (email address)
    Message<6> = ""							; // Reply To (email address)
    Message<7> = "TEXT"						; // Content Type (TEXT or HTML)
    Message<8> = Text						; // Content / Body
    Message<9> = ""							; // Attachment(s) (path to file name(s))
return
    

Send:
    MsgSent = SRP_Send_Mail(Message, ConfigFile)
return


Done:
    Debugged<-1> = Program
	Set_Property(MainWin, "@DEBUGGED", Debugged)
    Done = Yes$
return


