Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Login
- --Component
- --v.0.5
- --| public:
- --| construct
- --| deconstruct
- --| initA
- --| initB
- --| connect
- --| disconnect
- --| isOkToLogin
- property pOkToLogin
- -- Public methods: -- -- -- -- -- -- -- -- -- -- --//
- -- Constructor.
- on construct(me)
- pOkToLogin = FALSE
- if(variableExists("stats.tracking.url")) then
- createObject(#statsBroker, "Statistics Broker Class")
- end if
- -- Create Figure System object...
- if(not objectExists("Figure_System")) then
- if(createObject("Figure_System",["Figure System Class"]) <> FALSE) then
- tUrl = getVariable("external.figurepartlist.txt")
- getObject("Figure_System").define(["type":"url", "source":tUrl])
- end if
- end if
- -- Create Figure Preview object...
- if(not objectExists("Figure_Preview")) then
- createObject("Figure_Preview",["Figure Preview Class"])
- end if
- -- Prepare user rights list...
- getObject(#session).set("user_rights", [])
- -- Skip over login dialogs if quick login is enabled...
- if(not variableExists("quickLogin")) then
- setVariable("quickLogin", FALSE)
- end if
- if(getIntVariable("quickLogin", FALSE)) and (the runMode contains "Author") then
- if(not voidP(getPref(getVariable("fuse.project.id", "fusepref")))) then
- tTemp = value(getPref(getVariable("fuse.project.id","fusepref")))
- getObject(#session).set(#username, tTemp[1])
- getObject(#session).set(#password, tTemp[2])
- pOkToLogin = TRUE
- return(me.connect())
- end if
- end if
- registerMessage(#initialize, me.getID(), #initA)
- -- Initialize help tooltip
- if(not objectExists("Help_Tooltip_Manager")) then
- createObject("Help_Tooltip_Manager", "Help Tooltip Manager Class")
- end if
- -- Initialize game ticket window manager.
- if(not objectExists("Ticket_Window_Manager")) then
- createObject("Ticket_Window_Manager", "Ticket Window Manager Class")
- end if
- return(TRUE)
- end
- -- Deconstruct.
- on deconstruct(me)
- pOkToLogin = FALSE
- if(objectExists("Figure_System")) then
- removeObject("Figure_System")
- end if
- if(objectExists("Figure_Preview")) then
- removeObject("Figure_Preview")
- end if
- if(objectExists("nav_problem_obj")) then
- removeObject("nav_problem_obj")
- end if
- if(objectExists(#statsBroker)) then
- removeObject(#statsBroker)
- end if
- if(objectExists(#getServerDate)) then
- removeObject(#getServerDate)
- end if
- if(objectExists("Help_Tooltip_Manager")) then
- removeObject("Help_Tooltip_Manager")
- end if
- if(connectionExists(getVariable("connection.info.id", #info))) then
- return(me.disconnect())
- else
- return(TRUE)
- end if
- end
- -- Everything should be ready for some action.
- on initA(me)
- -- Figure definition list _must_ be loaded...
- if(getIntVariable("figurepartlist.loaded", TRUE) = FALSE) then
- return(me.delay(250, #initA))
- end if
- return(me.delay(1000, #initB))
- end
- on initB(me)
- return(me.getInterface().showLogin())
- end
- -- Starts connection/login process.
- on connect(me)
- tHost = getVariable("connection.info.host")
- tPort = getIntVariable("connection.info.port")
- tConn = getVariable("connection.info.id", #info)
- -- Validate parameters...
- if(voidP(tHost) or voidP(tPort)) then
- return(error(me, "Server port/host data not found!", #connect))
- end if
- -- Create connection...
- if(not createConnection(tConn, tHost, tPort)) then
- return(error(me, "Failed to create connection!", #connect))
- end if
- -- Create object witch retrieves date from server...
- if(not objectExists(#getServerDate)) then
- createObject(#getServerDate, "Server Date Class")
- end if
- -- Create object which helps user if login fails...
- if(not objectExists("nav_problem_obj")) then
- createObject("nav_problem_obj", "Connection Problem Class")
- end if
- -- Construct hobba thread...
- if(not threadExists(#hobba)) then
- initThread("thread.hobba")
- end if
- return(TRUE)
- end
- -- Disconnects current connection.
- on disconnect(me)
- tConn = getVariable("connection.info.id", #info)
- if(connectionExists(tConn)) then
- return(removeConnection(tConn))
- else
- return(error(me, "Connection not found!", #disconnect))
- end if
- end
- on isOkToLogin(me)
- return(me.pOkToLogin)
- end
- -- End of file. -- -- -- -- -- -- -- -- -- -- -- --//
- --Login Component Class
- --Antti Kaseva
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement