Exemple #1
0
    def test_loop(self):
        while True:
            #Types, hah
            next_url = random.randrange(len(urls))
            next_url = domain + urls[next_url]

            m = msg.create_req_uri_follow(next_url)
            tlog("Writing message: %s" % str(m))
            msg.write_message_soc(m, self.soc)

            m = msg.read_message_soc(self.soc)
            tlog("Received message: %s" % str(m))
            #tlog(m.content)

            time.sleep(5)

            if (random.randrange(10) == 0):
                m = msg.create_display_shm(self.shm_obj.shmid, 0)
                tlog("display_shm(%d, %d)" % (self.shm_obj.shmid, 0))
                tlog("Writing message: %s" % str(m))
                msg.write_message_soc(m, self.soc)

            c = Cookie.SimpleCookie()
            c.load("Set-Cookie: Foo=Bar; Domain="+domain+"; Path=/; HttpOnly")
            m = msg.create_set_cookie(c)
            tlog("Writing message: %s" % str(m))
            msg.write_message_soc(m, self.soc)

            time.sleep(5)
Exemple #2
0
    def test_loop(self):
        while True:
            #Types, hah
            next_url = random.randrange(len(urls))
            next_url = domain + urls[next_url]

            m = msg.create_req_uri_follow(next_url)
            tlog("Writing message: %s" % str(m))
            msg.write_message_soc(m, self.soc)

            m = msg.read_message_soc(self.soc)
            tlog("Received message: %s" % str(m))
            #tlog(m.content)

            time.sleep(5)

            if (random.randrange(10) == 0):
                m = msg.create_display_shm(self.shm_obj.shmid, 0)
                tlog("display_shm(%d, %d)" % (self.shm_obj.shmid, 0))
                tlog("Writing message: %s" % str(m))
                msg.write_message_soc(m, self.soc)

            c = Cookie.SimpleCookie()
            c.load("Set-Cookie: Foo=Bar; Domain=" + domain +
                   "; Path=/; HttpOnly")
            m = msg.create_set_cookie(c)
            tlog("Writing message: %s" % str(m))
            msg.write_message_soc(m, self.soc)

            time.sleep(5)
Exemple #3
0
    def main(self):
        #tlog("tab is initiated")
        #fstat = os.stat(sys.argv[0])
        #os.seteuid(fstat[stat.ST_UID])
        #opt.parse_options(sys.argv[4:])

        # opt.parse_options(["-l","-m","-k"])
        # tlog("tab argv:" + str(sys.argv))
	
	libsoup.soup_set_t2k_raw_socket(int(sys.argv[1]))
	#if  opt.options.use_kcookies:
        # cookie cache is always on.
        libsoup.soup_set_kcookies_flag(1)

        self.soc = socket.fromfd(int(sys.argv[1]), msg.FAMILY, msg.TYPE)
        self.soc.setblocking(1)

        self.shm_obj = create_memory(5000000)
        self.shm_obj.attach()
        self.sem_obj = shm.create_semaphore(self.shm_obj.shmid, 1)
        self.sem_obj.setperm(0600)
        self.sem_obj.setuid(quarkexec.quark_output_uid)
        self.sem_obj.setblocking(True)

        self.escaped = None
        
        gobject.io_add_watch(self.soc.fileno(), gobject.IO_IN, self.handle_input)
        gobject.io_add_watch(self.soc.fileno(), gobject.IO_HUP, self.handle_hup)

        self.view = webkit.WebView()
        self.view.connect('expose-event', self.expose)
        self.view.connect('resource-request-starting', self.resource_cb)
        self.view.connect('notify::progress', self.progress_cb)
        self.view.connect('navigation-policy-decision-requested', 
                          self.navigation_cb)
        self.view.connect('create-web-view', 
                          self.create_web_view_cb)
        
        #self.view.connect('notify::load-status', self.load_status_cb)

        settings = self.view.get_settings()
        settings.set_property("enable-plugins", False)

        self.frames = {}
        win = gtk.OffscreenWindow()
        win.set_default_size(1100,700)
        win.add(self.view)
        win.connect('damage-event', self.damage)
        win.show_all()
        self.win = win
        (x,y,width,height,depth) = self.view.get_window().get_geometry()
        self.pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,width,height)


        self.tab_origin = sys.argv[2]

        m = msg.create_display_shm(self.shm_obj.shmid, 0)
        self.write_message(m)
        self.view.open(self.add_http(self.tab_origin))

        #gtk.timeout_add(50, self.iterated_render)

        #self.rthread = threading.Thread(target=self.drawing_thread, args=())
        #self.rthread.start()

        #t_thread = threading.Thread(target=self.input_thread, args=())
        #t_thread.start()
        gtk.main()
Exemple #4
0
 def process_escaped(self, s):
     if s[0] == "g":
         self.view.open(self.add_http(s[2:]))
         m = msg.create_display_shm(self.shm_obj.shmid, 0)
         self.write_message(m)
Exemple #5
0
    def process_message(self, m):
        if m.type == msg.mtypes.GO:
            self.view.open(m.uri)
        elif m.type == msg.mtypes.RENDER:
            #gtk.timeout_add(0, self.delayed_render)
            #self.render()
            m = msg.create_display_shm(self.shm_obj.shmid, 0)
            self.write_message(m)
            # this is a render msg triggered by tab switching.
            # so we have to render the entire screen again.
            if self.renderred:
                gtk.timeout_add(50, self.delayed_render)
        elif m.type == msg.mtypes.K2T_SET_COOKIE:
            #tlog("<< K2T_SET_COOKIE msg is received:" + m.cookie)
            libsoup.soup_add_invalidated_cookie(ctypes.c_char_p(m.cookie));
            #libsoup.soup_add_invalidated_cookie(ctypes.create_string_buffer(m.cookie));
        elif m.type == msg.mtypes.MOUSE_CLICK:
            e = gtk.gdk.Event(gtk.gdk.BUTTON_PRESS)
            e.button = 1
            e.x = float(m.x)
            e.y = float(m.y)
            e.window = self.view.get_window()
            self.view.emit("button_press_event", e)
            gtk.timeout_add(5, self.delayed_mouse_release, m)

        # elif m.type == msg.mtypes.MOUSE_PRESSED: e =
        #     gtk.gdk.Event(gtk.gdk.BUTTON_PRESS) e.button = m.button
        #     e.x = m.x - 100 e.y = m.y - 100 e.window =
        #     self.view.get_window()
        #     self.view.emit("button_press_event", e) elif m.type ==
        #     msg.mtypes.MOUSE_RELEASED: e =
        #     gtk.gdk.Event(gtk.gdk.BUTTON_RELEASE) e.button =
        #     m.button e.x = m.x - 100 e.y = m.y - 100 e.window =
        #     self.view.get_window()
        #     self.view.emit("button_release_event", e)
        #     gtk.timeout_add(500, self.delayed_render) keycode:
        #     http://rachel-codebook.googlecode.com/svn-history/r130/trunk/Graphics/GraphicsA1/src/appwindow.cpp
        # http://www.pberndt.com/Programme/Linux/pqiv/_download/pqiv.py?ct=raw
        elif m.type == msg.mtypes.KEY_PRESS:
            #tlog("pressed key:" + str(m.key) + "\n")
            if self.escaped == None:
                if m.key == "\\":
                    self.escaped = ""
                else:
                    e = gtk.gdk.Event(gtk.gdk.KEY_PRESS)
                    e.window = self.view.get_window()
                    #tlog("pressed key:" + str(ord(m.key)) + "\n")

                    if ord(m.key) == 19:
                        e.keyval = int(keysyms.Page_Up)
                        e.hardware_keycode = gtk.gdk.keymap_get_default().get_entries_for_keyval(int(keysyms.Page_Up))[0][0]
                    elif ord(m.key) == 20:
                        e.keyval = int(keysyms.Page_Down)
                        e.hardware_keycode = gtk.gdk.keymap_get_default().get_entries_for_keyval(int(keysyms.Page_Down))[0][0]
                    elif ord(m.key) == 8:
                        e.keyval = int(keysyms.BackSpace)
                        e.hardware_keycode = gtk.gdk.keymap_get_default().get_entries_for_keyval(int(keysyms.BackSpace))[0][0]
                    elif ord(m.key) == 9:
                        e.keyval = int(keysyms.Tab)
                        e.hardware_keycode = gtk.gdk.keymap_get_default().get_entries_for_keyval(int(keysyms.Tab))[0][0]
                    elif ord(m.key) == 10:
                        e.keyval = int(keysyms.Return)
                        e.hardware_keycode = gtk.gdk.keymap_get_default().get_entries_for_keyval(int(keysyms.Return))[0][0]
                    else :
                        e.keyval = ord(m.key)
                    
                    self.view.emit("key_press_event", e)
                    #gtk.timeout_add(200, self.delayed_render)
            else:
                if m.key == "\n":
                    self.process_escaped(self.escaped)
                    self.escaped = None
                else:
                    self.escaped += m.key
        elif m.type == msg.mtypes.EXIT:
            gtk.main_quit()
Exemple #6
0
 def render(self,x,y,width,height):
     #stime = time.time()
     self.write_webkit_as_png(x,y,width,height)
     m = msg.create_display_shm(self.shm_obj.shmid, self.shm_size)
     self.write_message(m)
     self.renderred = True