91 lines
2.9 KiB
Python
91 lines
2.9 KiB
Python
"""
|
|
@file OGPLogin.py
|
|
@date 2008-09-16
|
|
Contributors can be viewed at:
|
|
http://svn.secondlife.com/svn/linden/projects/2008/pyogp/CONTRIBUTORS.txt
|
|
|
|
$LicenseInfo:firstyear=2008&license=apachev2$
|
|
|
|
Copyright 2008, Linden Research, Inc.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License").
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
or in
|
|
http://svn.secondlife.com/svn/linden/projects/2008/pyogp/LICENSE.txt
|
|
|
|
$/LicenseInfo$
|
|
"""
|
|
|
|
from pyogp.lib.base.credentials import PlainPasswordCredential
|
|
from pyogp.lib.base.agentdomain import AgentDomain
|
|
from pyogp.lib.base.regiondomain import Region
|
|
|
|
from pyogp.lib.base.interfaces import IPlaceAvatar
|
|
|
|
import getpass, sys
|
|
from optparse import OptionParser
|
|
|
|
import pprint
|
|
|
|
class OGPLogin(object):
|
|
""" This class can be used to log in to an agent domain and start communicating with a region domain """
|
|
|
|
def __init__(self, credents, loginuri, regionuri):
|
|
self.credentials = credents #PlainPasswordCredential(credents.firstname, credents.lastname, credents.password)
|
|
self.loginuri = loginuri
|
|
self.regionuri = regionuri
|
|
|
|
def login(self):
|
|
|
|
print "login to the agent domain: " + self.loginuri
|
|
agentd, agent = self.loginToAgentD()
|
|
print "logged in, we now have an agent: ", agent
|
|
print "and a domain: ", agentd
|
|
|
|
print "now we try to place the avatar on a region"
|
|
avatar = self.placeAvatarCap()
|
|
print "placed avatar cap, got back: ", avatar
|
|
|
|
#avatar.establish_presence()
|
|
|
|
def loginToAgentD(self):
|
|
""" Logs into the agent domain, getting the agentd seed cap """
|
|
self.agentdomain = AgentDomain(self.loginuri)
|
|
self.agent = self.agentdomain.login(self.credentials)
|
|
return self.agentdomain, self.agent
|
|
|
|
def getCapabilities(self, seed_cap, caps):
|
|
""" This is the method that SHOULD be used (but isn't) to get capabilities from the seedcap """
|
|
pass
|
|
|
|
def placeAvatarCap(self):
|
|
""" actually gets the place_avatar cap and posts to it """
|
|
region = Region(self.regionuri)
|
|
place = IPlaceAvatar(self.agentdomain)
|
|
self.avatar = place(region)
|
|
return self.avatar
|
|
|
|
def main():
|
|
parser = OptionParser()
|
|
|
|
parser.add_option("-a", "--agentdomain", dest="loginuri", default="https://login1.aditi.lindenlab.com/cgi-bin/auth.cgi",
|
|
help="URI of Agent Domain")
|
|
parser.add_option("-r", "--region", dest="regionuri", default="http://sim1.vaak.lindenlab.com:13000",
|
|
help="URI of Region to connect to")
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
options.firstname = args[0]
|
|
options.lastname = args[1]
|
|
options.password = getpass.getpass()
|
|
|
|
pprint.pprint(options)
|
|
credents = PlainPasswordCredential(options.firstname, options.lastname, options.password)
|
|
|
|
return OGPLogin(credents, options.loginuri, options.regionuri).login()
|
|
|
|
if __name__=="__main__":
|
|
main()
|