; ============================================================================
; General Module - Application Entry Point
; ============================================================================

Module General
	EnableExplicit
	
	Procedure BlueSky_Integration()
		Protected i
		
		ForEach DataModel::Language()
			If BlueSky(i)\Handle <> "" And BlueSky(i)\Password <> ""
				If BlueskyAPI::Initialize(@BlueSky(i)\Session, BlueSky(i)\Handle, BlueSky(i)\Password)
					BlueSky(i)\Enabled = #True
					PrintN("[General] BlueSky integration enabled for " + MapKey(DataModel::Language())) 
				EndIf
			EndIf
			i + 1
		Next
	EndProcedure
	
	; -- Public procedures --
	Procedure Init()
		OpenConsole("SelfHost")
		PrintN("[General] Starting SelfHost...")
		
		DataModel::Init()
		
		BlueSky_Integration()
		
		If Not FCGI::Init()
			PrintN("[Error] Couldn't initialize FastCGI network.")
			End
		EndIf
		
		PrintN("[General] Ready and listening on port " + Str(General::#FCGIPort))
		
		FCGI::MainLoop()
	EndProcedure
EndModule
; IDE Options = PureBasic 6.30 beta 5 (Linux - x64)
; CursorPosition = 36
; Folding = 0
; EnableXP
; DPIAware