
# Wrapper to enable the microscope client to be run inside the Matisse
# session client.


from PyClient import PyClient
import SessionApplication

class MatisseMicroscope(SessionApplication):

    __revision__ = "$Id: MatisseMicroscope.py,v 1.6.2.2 2002/02/26 20:32:20 akuchlin Exp $"
    
    def __init__ (self):
        self.client = None

    def getAppName (self):
        return "microscope"

    def addAppService (self, name, ref):
        # This implementation is copied from multiplayfe/DisplayFrame.java
        # in the Matisse distribution.  I don't think I actually
        # need to care about this method.
        print "Service '" + name + "' added" 
        return 1

    def startApp (self):
        # The applet parameters are currently hard-wired (even including the
        # authorization token!) to the Supernet address of the Berkeley
        # microscope.
	self.hostname = "169.229.50.130"
	self.port = 19000
	self.authtoken = "eJxFjTFrwzAQhXf9imzJUAedpLvTZWqHDgVTCl29CHPYIpZi7Dj059cU2o7v433vnU6tiGUMwbP3HjgEJIsoQCFi3GF0VpiJgw9WkJBb04KNESEKo4tENjI4dEBCXkhQmBx4ibCXfWBszX225vP4nopeDum69eOUa1c/lvzIkw66Xg7bqs3a32Z9Kqmm4Tf84a6+lpSnf/25aFkb/erHVAc935ahqy9LP+aHNm8l/Yzel02PZob935nzN+MuRMQ="
        self.client = client = PyClient(self.hostname, 19000,
                                        self.authtoken, 'akuchlin',
                                        applet=1)
        client.init(0)
	client.make_connection()
        self.showApp()
        return 1
        
    def showApp (self):
        print 'Show app called'
	self.client.get_frame().pack()
	self.client.get_frame().validate()
	self.client.get_frame().setVisible(1)
        return 1
    
    def stopApp (self):
        print 'Stop app called'
        self.client.get_frame().setVisible(0)
        return 1

