Esempio n. 1
0
    def __init__(self, parent=None):
	self.account='login'
	self.password='******'
	
	self.profile = IRCProfile(self.account, self.password)
	self.profile.onLoginSuccess = self.onLoginSuccess
	
	self.camconn = CamProfile(self.account)
	self.camconn.onLoginSuccess = self.onCamLoginSuccess
	self.camconn.onImgRecv = self.onCamImgRecv
	self.camconn.onSubscribeDenied = self.onSubscribeDenied
	self.camconn.onNoSuchUser = self.onNoSuchUser
	self.camconn.onUserGone = self.onUserGone
        self.camconn.onUserCountUpdate = self.onUserCountUpdate
        self.camconn.onUserList = self.onUserList

        self.watching = False
        self.watched_nick = None
        
        self.screen = aalib.AsciiScreen(width=320, height=240)
	
	factory = IRCClientFactory(self.profile)
	reactor.connectTCP('213.180.130.192', 5015, factory)
Esempio n. 2
0
    def __init__(self, parent=None):
        gtk.Window.__init__(self)

        self.account = "login"
        self.password = "******"

        self.profile = IRCProfile(self.account, self.password)
        self.profile.onLoginSuccess = self.onLoginSuccess

        self.camconn = CamProfile(self.account)
        self.camconn.onLoginSuccess = self.onCamLoginSuccess
        self.camconn.onImgRecv = self.onCamImgRecv
        self.camconn.onSubscribeDenied = self.onSubscribeDenied
        self.camconn.onNoSuchUser = self.onNoSuchUser
        self.camconn.onUserGone = self.onUserGone
        self.camconn.onUserCountUpdate = self.onUserCountUpdate
        self.camconn.onUserList = self.onUserList

        self.watching = False
        self.watched_nick = None

        factory = IRCClientFactory(self.profile)
        reactor.connectTCP("213.180.130.192", 5015, factory)

        try:
            self.set_screen(parent.get_screen())
        except AttributeError:
            self.connect("destroy", lambda *w: gtk.main_quit())
        self.connect("destroy", self.cleanup_callback)
        self.set_title("OnetCzat Kamerki")
        self.set_default_size(400, 400)
        self.set_border_width(8)

        vbox = gtk.VBox(False, 8)
        vbox.set_border_width(8)
        # self.add(vbox)

        self.label = gtk.Label()
        self.label.set_markup("Logging in")
        vbox.pack_start(self.label, False, False, 0)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)

        # The alignment keeps the frame from growing when users resize
        # the window
        align = gtk.Alignment(0.5, 0.5, 0, 0)
        align.add(frame)
        vbox.pack_start(align, False, False, 0)

        self.image = gtk.Image()
        self.image.set_from_pixbuf(None)
        frame.add(self.image)

        hpaned = gtk.HPaned()
        hpaned.add1(vbox)

        vbox2 = gtk.VBox(False, 8)
        vbox2.set_border_width(8)

        slider = gtk.VScale()
        slider.set_inverted(True)
        slider.set_range(0, 100)
        slider.set_increments(1, 10)
        slider.set_digits(0)
        slider.set_size_request(34, 160)
        slider.set_value_pos(gtk.POS_BOTTOM)
        slider.set_value(5)

        # Events
        slider.connect("value-changed", self.updateRefreshFrequency)

        vbox2.pack_start(slider, False, False, 0)

        button = gtk.Button("Quit")
        button.connect_object("clicked", gtk.mainquit, self)
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()

        vbox2.pack_start(button, False, False, 0)
        hpaned.add2(vbox2)

        # Sensitivity control
        self.add(hpaned)
        self.show_all()
Esempio n. 3
0
class ImagesDemo(gtk.Window):
    pixbuf_loader = None
    load_timeout = None
    image_stream = None

    def __init__(self, parent=None):
        gtk.Window.__init__(self)

        self.account = "login"
        self.password = "******"

        self.profile = IRCProfile(self.account, self.password)
        self.profile.onLoginSuccess = self.onLoginSuccess

        self.camconn = CamProfile(self.account)
        self.camconn.onLoginSuccess = self.onCamLoginSuccess
        self.camconn.onImgRecv = self.onCamImgRecv
        self.camconn.onSubscribeDenied = self.onSubscribeDenied
        self.camconn.onNoSuchUser = self.onNoSuchUser
        self.camconn.onUserGone = self.onUserGone
        self.camconn.onUserCountUpdate = self.onUserCountUpdate
        self.camconn.onUserList = self.onUserList

        self.watching = False
        self.watched_nick = None

        factory = IRCClientFactory(self.profile)
        reactor.connectTCP("213.180.130.192", 5015, factory)

        try:
            self.set_screen(parent.get_screen())
        except AttributeError:
            self.connect("destroy", lambda *w: gtk.main_quit())
        self.connect("destroy", self.cleanup_callback)
        self.set_title("OnetCzat Kamerki")
        self.set_default_size(400, 400)
        self.set_border_width(8)

        vbox = gtk.VBox(False, 8)
        vbox.set_border_width(8)
        # self.add(vbox)

        self.label = gtk.Label()
        self.label.set_markup("Logging in")
        vbox.pack_start(self.label, False, False, 0)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)

        # The alignment keeps the frame from growing when users resize
        # the window
        align = gtk.Alignment(0.5, 0.5, 0, 0)
        align.add(frame)
        vbox.pack_start(align, False, False, 0)

        self.image = gtk.Image()
        self.image.set_from_pixbuf(None)
        frame.add(self.image)

        hpaned = gtk.HPaned()
        hpaned.add1(vbox)

        vbox2 = gtk.VBox(False, 8)
        vbox2.set_border_width(8)

        slider = gtk.VScale()
        slider.set_inverted(True)
        slider.set_range(0, 100)
        slider.set_increments(1, 10)
        slider.set_digits(0)
        slider.set_size_request(34, 160)
        slider.set_value_pos(gtk.POS_BOTTOM)
        slider.set_value(5)

        # Events
        slider.connect("value-changed", self.updateRefreshFrequency)

        vbox2.pack_start(slider, False, False, 0)

        button = gtk.Button("Quit")
        button.connect_object("clicked", gtk.mainquit, self)
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()

        vbox2.pack_start(button, False, False, 0)
        hpaned.add2(vbox2)

        # Sensitivity control
        self.add(hpaned)
        self.show_all()

    def onLoginSuccess(self):
        print "Zalogowano!"
        self.updateLabel("Logged into OnetCzat. Logging to OnetCams...")
        # profile.getChannelList()
        self.profile.join("#scc")
        uokey = self.profile.getUOKEY()
        camfactory = CamClientFactory(self.camconn, self.account, uokey)
        reactor.connectTCP("212.244.48.54", 5008, camfactory)

    def onCamLoginSuccess(self):
        self.updateLabel("Logged into OnetCams. Choose a nick and double click on it!")
        print "Zalogowano i mozemy pobierac pakiety z protokolu kamerek."
        # self.camconn.subscribeCamera('cora6')

    def onCamImgRecv(self, nick, data):
        self.updateLabel("Receiving stream from %s" % (nick))
        self.updateImage(data)
        print "pobrano obraz!"

    def onSubscribeDenied(self, nick):
        self.updateLabel("Canoot connect to user %s stream." % (nick))

    def onNoSuchUser(self, nick):
        self.updateLabel("User %s is not logged in." % (nick))

    def onUserGone(self, nick):
        self.updateLabel("User %s gone." % (nick))

    def onUserList(self, data):
        pass
        # print data

    def onUserCountUpdate(self, data):
        data = data.split("\n")
        self.liststore.clear()
        for user in data:
            try:
                nick, watchers, unknown = user.split(" ")
                # print 'a:', user.split(' ')
                # print nick
                self.liststore.append([int(watchers), int(unknown), str(nick)])
            except:
                print "Not possible for data: ", user

    def updateRefreshFrequency(self, widget):

        val = widget.get_value()

        print val

    def nickClicked(self, treeview, iter, tvc, foo):
        model = treeview.get_model()
        iter = model.get_iter(iter)
        nickname = model.get_value(iter, 2)
        if nickname:
            self.updateLabel("Fetching stream. Please wait a moment.")
            if self.watching == True:
                self.camconn.stopPing(self.watched_nick)
                self.camconn.unsubscribeCamera(self.watched_nick)
            self.camconn.subscribeCamera(nickname)
            self.camconn.startPing(nickname)
            self.watched_nick = nickname
            self.watching = True
        print nickname

    def updateLabel(self, text):
        self.label.set_markup(text)

    def updateImage(self, data):
        loader = gtk.gdk.PixbufLoader("jpeg")
        loader.write(data)
        pixbuf = loader.get_pixbuf()
        loader.close()
        self.image.set_from_pixbuf(pixbuf)

    def cleanup_callback(self, win):
        #        if self.load_timeout != 0:
        #            gtk.timeout_remove(self.load_timeout)
        #            self.load_timeout = 0

        if self.pixbuf_loader is not None:
            self.pixbuf_loader.close()
            self.pixbuf_loader = None

        if self.image_stream is not None:
            self.image_stream.close()
            self.image_stream = None

        self.camconn.stopPing(self.watched_nick)
        self.camconn.unsubscribeCamera(self.watched_nick)
        gtk.main_quit()
        reactor.stop()
        sys.exit(1)
Esempio n. 4
0
    reactor.connectTCP("212.244.48.54", 5008, camfactory)


def onCamLoginSuccess():
    print "Zalogowano i mozemy pobierac pakiety z protokolu kamerek."
    camconn.subscribeCamera("LenCia")


def onCamImgRecv(nick, data):
    print "pobrano obraz!"


account = "kkszysiu"
password = "******"

profile = IRCProfile(account, password)
profile.onLoginSuccess = onLoginSuccess

camconn = CamProfile(account)
camconn.onLoginSuccess = onCamLoginSuccess
camconn.onImgRecv = onCamImgRecv


factory = IRCClientFactory(profile)
reactor.connectTCP("213.180.130.192", 5015, factory)
# camfactory = CamClientFactory(camconn, account, 'mTtJbwM7bmtQmEQN017nMFFLmfxh6ZNK')
# reactor.connectTCP('212.244.48.54', 5008, camfactory)
reactor.run()
#
# profile.onLoginSuccess = self.on_loginSuccess
# profile.onLoginFailure = self.on_loginFailed
Esempio n. 5
0
    def __init__(self, nick):
        self.window = gtk.Window()

        self.nick = nick

	self.account='login'
	self.password='******'
	
	self.profile = IRCProfile(self.account, self.password)
	self.profile.onLoginSuccess = self.onLoginSuccess
	
	self.camconn = CamProfile(self.account)
	self.camconn.onLoginSuccess = self.onCamLoginSuccess
	self.camconn.onImgRecv = self.onCamImgRecv
	self.camconn.onSubscribeDenied = self.onSubscribeDenied
	self.camconn.onNoSuchUser = self.onNoSuchUser
	self.camconn.onUserGone = self.onUserGone
        self.camconn.onUserCountUpdate = self.onUserCountUpdate
        self.camconn.onUserList = self.onUserList

        self.watching = False
        self.watched_nick = None
	
	factory = IRCClientFactory(self.profile)
	reactor.connectTCP('213.180.130.192', 5015, factory)
	
        self.window.connect("destroy", self.cleanup_callback)
        self.window.set_title("OnetCzat Kamerka - %s" % (nick))
        self.window.set_default_size(400, 260)
        self.window.set_border_width(8)

        vbox = gtk.VBox()
        vbox.set_border_width(8)

        self.label = gtk.Label()
        self.label.set_padding(2, 2)
        self.label.set_markup("Logging in into WebCams")
        vbox.pack_start(self.label, False, False, 0)

        frame = gtk.Frame()

        align = gtk.Alignment()
        align.add(frame)
        vbox.pack_start(align, False, False, 0)
        
        self.image = gtk.Image()
        self.image.set_size_request(320, 240)
        self.image.set_from_pixbuf(None)
        frame.add(self.image)
        
        hpaned = gtk.HPaned()
        hpaned.add1(vbox)

        vbox2 = gtk.VBox()
        vbox2.set_border_width(10)

        slider = gtk.VScale()
        slider.set_inverted(True)
        slider.set_range(0, 30)
        slider.set_increments(1, 10)
        slider.set_digits(0)
        slider.set_size_request(34, 160)
        slider.set_value(5)

        # Events
        slider.connect('value-changed', self.updateRefreshFrequency)
        
        vbox2.pack_start(slider, True, True, 0)

        button = gtk.Button()
        button.set_label("Quit")
        button.connect('button-press-event', self.cleanup_callback)

        vbox2.pack_start(button, False, False, 0)
        hpaned.add2(vbox2)

        # Sensitivity control
        self.window.add(hpaned)
        self.window.show_all()
Esempio n. 6
0
class InitialiseWebCamWindow(object):
    pixbuf_loader = None 
    load_timeout = None
    image_stream = None

    def __init__(self, nick):
        self.window = gtk.Window()

        self.nick = nick

	self.account='login'
	self.password='******'
	
	self.profile = IRCProfile(self.account, self.password)
	self.profile.onLoginSuccess = self.onLoginSuccess
	
	self.camconn = CamProfile(self.account)
	self.camconn.onLoginSuccess = self.onCamLoginSuccess
	self.camconn.onImgRecv = self.onCamImgRecv
	self.camconn.onSubscribeDenied = self.onSubscribeDenied
	self.camconn.onNoSuchUser = self.onNoSuchUser
	self.camconn.onUserGone = self.onUserGone
        self.camconn.onUserCountUpdate = self.onUserCountUpdate
        self.camconn.onUserList = self.onUserList

        self.watching = False
        self.watched_nick = None
	
	factory = IRCClientFactory(self.profile)
	reactor.connectTCP('213.180.130.192', 5015, factory)
	
        self.window.connect("destroy", self.cleanup_callback)
        self.window.set_title("OnetCzat Kamerka - %s" % (nick))
        self.window.set_default_size(400, 260)
        self.window.set_border_width(8)

        vbox = gtk.VBox()
        vbox.set_border_width(8)

        self.label = gtk.Label()
        self.label.set_padding(2, 2)
        self.label.set_markup("Logging in into WebCams")
        vbox.pack_start(self.label, False, False, 0)

        frame = gtk.Frame()

        align = gtk.Alignment()
        align.add(frame)
        vbox.pack_start(align, False, False, 0)
        
        self.image = gtk.Image()
        self.image.set_size_request(320, 240)
        self.image.set_from_pixbuf(None)
        frame.add(self.image)
        
        hpaned = gtk.HPaned()
        hpaned.add1(vbox)

        vbox2 = gtk.VBox()
        vbox2.set_border_width(10)

        slider = gtk.VScale()
        slider.set_inverted(True)
        slider.set_range(0, 30)
        slider.set_increments(1, 10)
        slider.set_digits(0)
        slider.set_size_request(34, 160)
        slider.set_value(5)

        # Events
        slider.connect('value-changed', self.updateRefreshFrequency)
        
        vbox2.pack_start(slider, True, True, 0)

        button = gtk.Button()
        button.set_label("Quit")
        button.connect('button-press-event', self.cleanup_callback)

        vbox2.pack_start(button, False, False, 0)
        hpaned.add2(vbox2)

        # Sensitivity control
        self.window.add(hpaned)
        self.window.show_all()

    def onLoginSuccess(self):
	print 'Zalogowano!'
	self.updateLabel('Logged into OnetCzat. Logging to OnetCams...')
	#profile.getChannelList()
	self.profile.join('#scc')
	uokey = self.profile.getUOKEY()
	camfactory = CamClientFactory(self.camconn, self.account, uokey)
	reactor.connectTCP('212.244.48.54', 5008, camfactory)
    
    def onCamLoginSuccess(self):
	self.updateLabel('Logged into OnetCams. Waiting for stream.')
        self.camconn.subscribeCamera(self.nick)
        self.camconn.startPing(self.nick)
    
    def onCamImgRecv(self, nick, data):
	self.updateLabel('Receiving stream from %s' % (nick))
	self.updateImage(data)
	print 'pobrano obraz!'

    def onSubscribeDenied(self, nick):
	self.updateLabel('Canoot connect to user %s stream.' % (nick))

    def onNoSuchUser(self, nick):
	self.updateLabel('User %s is not logged in.' % (nick))

    def onUserGone(self, nick):
	self.updateLabel('User %s gone.' % (nick))

    def onUserList(self, data):
        pass
        #print data

    def onUserCountUpdate(self, data):
        data = data.split('\n')
        for user in data:
            try:
                nick, watchers, unknown = user.split(' ')
                #print 'a:', user.split(' ')
                #print nick
            except:
                print 'Not possible for data: ', user

    def updateRefreshFrequency(self, widget):

        val = widget.get_value()

        if self.camconn.__connection.loop:
            self.camconn.__connection.loop.stop()
            self.camconn.__connection.loop.start(val)
        else:
            print 'KeepAlive loop is not ready yet.'

    def nickClicked(self, treeview, iter, tvc, foo):
        model=treeview.get_model()
        iter = model.get_iter(iter)
        nickname = model.get_value(iter, 2)
        if nickname:
            self.updateLabel('Fetching stream. Please wait a moment.')
            if self.watching == True:
                self.camconn.stopPing(self.watched_nick)
                self.camconn.unsubscribeCamera(self.watched_nick)
            self.camconn.subscribeCamera(nickname)
            self.camconn.startPing(nickname)
            self.watched_nick = nickname
            self.watching = True
        print nickname

    def updateLabel(self, text):
	self.label.set_markup(text)

    def updateImage(self, data):
	loader = gtk.gdk.PixbufLoader("jpeg")
	loader.write(data)
	pixbuf = loader.get_pixbuf()
	loader.close()
	self.image.set_from_pixbuf(pixbuf)

    def cleanup_callback(self, win, smth=None):
        if self.pixbuf_loader is not None:
            self.pixbuf_loader.close()
            self.pixbuf_loader = None

        if self.image_stream is not None:
            self.image_stream.close()
            self.image_stream = None

        try:
            if self.nick != None:
                self.camconn.stopPing(self.nick)
                self.camconn.unsubscribeCamera(self.nick)
            self.camconn.disconnect()
        except:
            self.camconn.disconnect()
        self.window.destroy()
Esempio n. 7
0
    def __init__(self, parent=None, user=None, password=None):
        gtk.Window.__init__(self)
	
	self.account=user
	self.password=password
	
	self.profile = IRCProfile(self.account, self.password)
	self.profile.onLoginSuccess = self.onLoginSuccess
	
	self.camconn = CamProfile(self.account)
	self.camconn.onLoginSuccess = self.onCamLoginSuccess
	self.camconn.onImgRecv = self.onCamImgRecv
	self.camconn.onSubscribeDenied = self.onSubscribeDenied
	self.camconn.onNoSuchUser = self.onNoSuchUser
	self.camconn.onUserGone = self.onUserGone
        self.camconn.onUserCountUpdate = self.onUserCountUpdate
        self.camconn.onUserList = self.onUserList

        self.watching = False
        self.watched_nick = None
	
	factory = IRCClientFactory(self.profile)
	reactor.connectTCP('213.180.130.192', 5015, factory)
	
        try:
            self.set_screen(parent.get_screen())
        except AttributeError:
            self.connect('destroy', lambda *w: gtk.main_quit())
        self.connect("destroy", self.cleanup_callback)
        self.set_title("OnetCzat Kamerki")
        self.set_default_size(400, 400)
        self.set_border_width(8)

        vbox = gtk.VBox(False, 8)
        vbox.set_border_width(8)
        self.add(vbox)

        self.label = gtk.Label();
        self.label.set_markup("<u>Logging in</u>")
        vbox.pack_start(self.label, False, False, 0)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)

        # The alignment keeps the frame from growing when users resize
        # the window
        align = gtk.Alignment(0.5, 0.5, 0, 0)
        align.add(frame)
        vbox.pack_start(align, False, False, 0)

        # Create an empty image for now; the progressive loader
        # will create the pixbuf and fill it in.
	#img = open('aa.jpg')
	#data = img.read()
	#img.close()
	#loader = gtk.gdk.PixbufLoader("jpeg")
	#loader.write(data)
	#loader.close()
	#pixbuf = loader.get_pixbuf()
	
        self.image = gtk.Image()
        self.image.set_from_pixbuf(None)
        frame.add(self.image)

        self.liststore = gtk.ListStore(int, int, str)
        self.tree = gtk.TreeView(model=self.liststore)
        self.tree.connect("row-activated", self.nickClicked, None)

        column_w = gtk.TreeViewColumn('Watchers')
        column_w.set_clickable(True)
        column_w.set_sort_column_id(0)
        column_w.set_resizable(True)


        column_u = gtk.TreeViewColumn('Unknown')
        column_n = gtk.TreeViewColumn('Nick')

        self.tree.append_column(column_w)
        self.tree.append_column(column_u)
        self.tree.append_column(column_n)

        cell_w = gtk.CellRendererText()
        cell_u = gtk.CellRendererText()
        cell_n = gtk.CellRendererText()

        column_w.pack_start(cell_w)
        column_u.pack_start(cell_u)
        column_n.pack_start(cell_n)

        column_w.add_attribute(cell_w, 'text', 0)
        column_u.add_attribute(cell_u, 'text', 1)
        column_n.add_attribute(cell_n, 'text', 2)

        sw = gtk.ScrolledWindow()
        sw.add(self.tree)
        vbox.add(sw)

        # Sensitivity control

        self.show_all()
Esempio n. 8
0
class CameraWindow(gtk.Window):
    pixbuf_loader = None
    load_timeout = None
    image_stream = None

    def __init__(self, parent=None, user=None, password=None):
        gtk.Window.__init__(self)
	
	self.account=user
	self.password=password
	
	self.profile = IRCProfile(self.account, self.password)
	self.profile.onLoginSuccess = self.onLoginSuccess
	
	self.camconn = CamProfile(self.account)
	self.camconn.onLoginSuccess = self.onCamLoginSuccess
	self.camconn.onImgRecv = self.onCamImgRecv
	self.camconn.onSubscribeDenied = self.onSubscribeDenied
	self.camconn.onNoSuchUser = self.onNoSuchUser
	self.camconn.onUserGone = self.onUserGone
        self.camconn.onUserCountUpdate = self.onUserCountUpdate
        self.camconn.onUserList = self.onUserList

        self.watching = False
        self.watched_nick = None
	
	factory = IRCClientFactory(self.profile)
	reactor.connectTCP('213.180.130.192', 5015, factory)
	
        try:
            self.set_screen(parent.get_screen())
        except AttributeError:
            self.connect('destroy', lambda *w: gtk.main_quit())
        self.connect("destroy", self.cleanup_callback)
        self.set_title("OnetCzat Kamerki")
        self.set_default_size(400, 400)
        self.set_border_width(8)

        vbox = gtk.VBox(False, 8)
        vbox.set_border_width(8)
        self.add(vbox)

        self.label = gtk.Label();
        self.label.set_markup("<u>Logging in</u>")
        vbox.pack_start(self.label, False, False, 0)

        frame = gtk.Frame()
        frame.set_shadow_type(gtk.SHADOW_IN)

        # The alignment keeps the frame from growing when users resize
        # the window
        align = gtk.Alignment(0.5, 0.5, 0, 0)
        align.add(frame)
        vbox.pack_start(align, False, False, 0)

        # Create an empty image for now; the progressive loader
        # will create the pixbuf and fill it in.
	#img = open('aa.jpg')
	#data = img.read()
	#img.close()
	#loader = gtk.gdk.PixbufLoader("jpeg")
	#loader.write(data)
	#loader.close()
	#pixbuf = loader.get_pixbuf()
	
        self.image = gtk.Image()
        self.image.set_from_pixbuf(None)
        frame.add(self.image)

        self.liststore = gtk.ListStore(int, int, str)
        self.tree = gtk.TreeView(model=self.liststore)
        self.tree.connect("row-activated", self.nickClicked, None)

        column_w = gtk.TreeViewColumn('Watchers')
        column_w.set_clickable(True)
        column_w.set_sort_column_id(0)
        column_w.set_resizable(True)


        column_u = gtk.TreeViewColumn('Unknown')
        column_n = gtk.TreeViewColumn('Nick')

        self.tree.append_column(column_w)
        self.tree.append_column(column_u)
        self.tree.append_column(column_n)

        cell_w = gtk.CellRendererText()
        cell_u = gtk.CellRendererText()
        cell_n = gtk.CellRendererText()

        column_w.pack_start(cell_w)
        column_u.pack_start(cell_u)
        column_n.pack_start(cell_n)

        column_w.add_attribute(cell_w, 'text', 0)
        column_u.add_attribute(cell_u, 'text', 1)
        column_n.add_attribute(cell_n, 'text', 2)

        sw = gtk.ScrolledWindow()
        sw.add(self.tree)
        vbox.add(sw)

        # Sensitivity control

        self.show_all()

    def onLoginSuccess(self):
	print 'Zalogowano!'
	self.updateLabel('Logged into OnetCzat. Logging to OnetCams...')
	#profile.getChannelList()
	self.profile.join('#scc')
	uokey = self.profile.getUOKEY()
	camfactory = CamClientFactory(self.camconn, self.account, uokey)
	reactor.connectTCP('212.244.48.54', 5008, camfactory)
    
    def onCamLoginSuccess(self):
	self.updateLabel('Logged into OnetCams. Choose a nick and double click on it!')
	print 'Zalogowano i mozemy pobierac pakiety z protokolu kamerek.'
	#self.camconn.subscribeCamera('cora6')
    
    def onCamImgRecv(self, nick, data):
	self.updateLabel('Receiving stream from %s' % (nick))
	self.updateImage(data)
	print 'pobrano obraz!'

    def onSubscribeDenied(self, nick):
	self.updateLabel('Canoot connect to user %s stream.' % (nick))

    def onNoSuchUser(self, nick):
	self.updateLabel('User %s is not logged in.' % (nick))

    def onUserGone(self, nick):
	self.updateLabel('User %s gone.' % (nick))

    def onUserList(self, data):
        pass
        
    def onUserCountUpdate(self, data):
        data = data.split('\n')
        self.liststore.clear()
        for user in data:
            try:
                nick, watchers, unknown = user.split(' ')
                self.liststore.append([int(watchers), int(unknown), str(nick)])
            except:
                print 'Not possible for data: ', user


    def nickClicked(self, treeview, iter, tvc, foo):
        model=treeview.get_model()
        iter = model.get_iter(iter)
        nickname = model.get_value(iter, 2)
        if nickname:
            self.updateLabel('Fetching stream. Please wait a moment.')
            if self.watching == True:
                self.camconn.stopPing(self.watched_nick)
                self.camconn.unsubscribeCamera(self.watched_nick)
            self.camconn.subscribeCamera(nickname)
            self.camconn.startPing(nickname)
            self.watched_nick = nickname
            self.watching = True
        print nickname

    def updateLabel(self, text):
	self.label.set_markup(text)

    def updateImage(self, data):
	loader = gtk.gdk.PixbufLoader("jpeg")
	loader.write(data)
	pixbuf = loader.get_pixbuf()
	loader.close()
	self.image.set_from_pixbuf(pixbuf)

    def cleanup_callback(self, win):
        if self.pixbuf_loader is not None:
            self.pixbuf_loader.close()
            self.pixbuf_loader = None

        if self.image_stream is not None:
            self.image_stream.close()
            self.image_stream = None

        self.camconn.stopPing(self.watched_nick)
        self.camconn.unsubscribeCamera(self.watched_nick)
        gtk.main_quit()
	reactor.stop()
        sys.exit(1)
Esempio n. 9
0
class ImagesDemo(object):
    def __init__(self, parent=None):
	self.account='login'
	self.password='******'
	
	self.profile = IRCProfile(self.account, self.password)
	self.profile.onLoginSuccess = self.onLoginSuccess
	
	self.camconn = CamProfile(self.account)
	self.camconn.onLoginSuccess = self.onCamLoginSuccess
	self.camconn.onImgRecv = self.onCamImgRecv
	self.camconn.onSubscribeDenied = self.onSubscribeDenied
	self.camconn.onNoSuchUser = self.onNoSuchUser
	self.camconn.onUserGone = self.onUserGone
        self.camconn.onUserCountUpdate = self.onUserCountUpdate
        self.camconn.onUserList = self.onUserList

        self.watching = False
        self.watched_nick = None
        
        self.screen = aalib.AsciiScreen(width=320, height=240)
	
	factory = IRCClientFactory(self.profile)
	reactor.connectTCP('213.180.130.192', 5015, factory)

    def onLoginSuccess(self):
	print 'Zalogowano!'
	print ('Logged into OnetCzat. Logging to OnetCams...')
	#profile.getChannelList()
	self.profile.join('#scc')
	uokey = self.profile.getUOKEY()
	camfactory = CamClientFactory(self.camconn, self.account, uokey)
	reactor.connectTCP('212.244.48.54', 5008, camfactory)
    
    def onCamLoginSuccess(self):
	print ('Logged into OnetCams. Choose a nick and double click on it!')
	print 'Zalogowano i mozemy pobierac pakiety z protokolu kamerek.'
	#self.camconn.subscribeCamera('cora6')
        self.camconn.subscribeCamera('kocica35')
        self.camconn.startPing('kocica35')
    
    def onCamImgRecv(self, nick, data):
	print ('Receiving stream from %s' % (nick))
	self.updateImage(data)
	print 'pobrano obraz!'

    def onSubscribeDenied(self, nick):
	print ('Canoot connect to user %s stream.' % (nick))

    def onNoSuchUser(self, nick):
	print ('User %s is not logged in.' % (nick))

    def onUserGone(self, nick):
	print ('User %s gone.' % (nick))

    def onUserList(self, data):
        pass
        #print data

    def onUserCountUpdate(self, data):
        data = data.split('\n')
        for user in data:
            try:
                nick, watchers, unknown = user.split(' ')
                #print 'a:', user.split(' ')
                #print nick
            except:
                print 'Not possible for data: ', user


    def nickClicked(self, treeview, iter, tvc, foo):
        model=treeview.get_model()
        iter = model.get_iter(iter)
        nickname = model.get_value(iter, 2)
        if nickname:
            print ('Fetching stream. Please wait a moment.')
            if self.watching == True:
                self.camconn.stopPing(self.watched_nick)
                self.camconn.unsubscribeCamera(self.watched_nick)
            self.camconn.subscribeCamera(nickname)
            self.camconn.startPing(nickname)
            self.watched_nick = nickname
            self.watching = True
        print nickname

    def updateImage(self, data):
        self.fp = StringIO(data)
        self.image = Image.open(fp).convert('L').resize(self.screen.virtual_size)
        self.screen.put_image((0, 0), image)
        print self.screen.render()