Exemplo n.º 1
0
 def sTracks(self, source, ref, list_dic):
     """
     DBus signal handler - /Tracks/Tracks
     """
     #if source=="__heart__":
     #    print "MB Heart: "+str(list_dic)
     
     try:    ours=(ref.split(":")[0])=="musync"
     except: ours=False
     if ours:
         #print "sTracks: source(%s) ref(%s) list_dic: %s" % (source, ref, list_dic)
         mswitch.publish(self.agent, "mb_tracks", source, ref, list_dic)
     self.mb_detected_count+=1
Exemplo n.º 2
0
 def sQTrack(self, ref, artist_name, track_name, priority):
     """
     DBus signal handler - /Tracks/qTrack
     
     @param ref: string - an opaque "reference"
     @param artist_name: string
     @param track_name:  string
     @param priority:    string [low|high]
     
     @todo: better error handling
     """
     try:    artist=str(artist_name)
     except: artist=None
     try:    track=str(track_name)
     except: track=None
     
     mswitch.publish(self.agent, "track?", ref, artist, track, priority)
Exemplo n.º 3
0
    def tick(self, *_):
        """
        Performs message dispatch
        """
        
        tick_second = (self.tick_count % self.ticks_seconds) == 0 
        self.tick_count += 1
        
        #print "tick! ", tick_second
        
        mswitch.publish("__main__", "tick", self.ticks_seconds, tick_second)
        
        while True:
            try:     
                envelope=self.isq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.isq))
                if quit:
                    self.on_destroy()
                    
            except Empty:
                break
            continue            
        
        burst=5
        
        while True:
            try:     
                envelope=self.iq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.iq))
                if quit:
                    self.on_destroy()
                    
                burst -= 1
                if burst == 0:
                    break
            except Empty:
                break
            
            continue

        return True
    def tick(self):
        #print "tick (%s)" % time.time()
        self._manageUserMessage()
        
        while True:
            try:
                envelope=self.isq.get(block=False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.isq)) 
                if quit:
                    self.on_destroy()
            except Empty:
                break
            
        burst=5
        while True:
            try:
                envelope=self.iq.get(block=False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.iq))
                if quit:
                    self.on_destroy()                    
                burst -= 1
                if burst==0:
                    break
            except Empty:
                break

        self.count += 1
        mswitch.publish("__main__", "tick", self.count)
        
        if self.quitting:
            self.quit()
            self.loop.quit()
Exemplo n.º 5
0
 def show(self, *_):
     print "menu: show"
     mswitch.publish(self, "__show__")
Exemplo n.º 6
0
 def exit(self, *p):
     print "menu: exit"
     mswitch.publish(self, "__quit__")
Exemplo n.º 7
0
 def _chAuthorize(self, *_):
     """ Starts the authorization phase
     """  
     mswitch.publish(self, "start_authorize")
Exemplo n.º 8
0
    def tick(self, *_):
        """
        Performs message dispatch
        """
        tick_min=False
        tick_hour=False
        tick_day=False
        tick_second = (self.tick_count % self.ticks_second) == 0 
        self.tick_count += 1
        
        if tick_second:
            self.sec_count += 1

            if (self.sec_count % self.REFRESH_TIMEOUT)==0:
                self.refreshUi()

            tick_min=(self.sec_count % 60)==0
            if tick_min:
                self.min_count += 1
                
                tick_hour=(self.min_count % 60)==0
                if tick_hour:
                    self.hour_count += 1
                    
                    tick_day=(self.hour_count % 24)==0
                    if tick_day:
                        self.day_count += 1
        
        #print "tick! ", tick_second
        mswitch.publish("__main__", "__tick__", self.ticks_second, 
                        tick_second, tick_min, tick_hour, tick_day, 
                        self.sec_count, self.min_count, self.hour_count, self.day_count)
        
        #(src_agent, agent_name, agent_id, 
        #  interest_map, responsesInterestList, 
        #  iq, isq, processor, low_priority_burst_size=5)
        quit=process_queues(self, "__main__", "__main__", 
                       self.interests, self.responsesInterests,
                       self.iq, self.isq, message_processor 
                       )
        if quit:
            self.on_destroy()
            
        """
        while True:
            try:     
                envelope=self.isq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.isq))
                if quit:
                    self.on_destroy()
                    break
                
            except Empty:
                break
            continue            
        
        burst=self.LOW_PRIORITY_MESSAGE_BURST_SIZE
        
        while True:
            try:     
                envelope=self.iq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.iq))
                if quit:
                    self.on_destroy()
                    break
                    
                burst -= 1
                if burst == 0:
                    break
            except Empty:
                break
            
            continue
        """
        ## for gobject... just in case
        return True
Exemplo n.º 9
0
 def do_destroy(self, *_):
     mswitch.publish(self, "app_close")
Exemplo n.º 10
0
 def _chVerify(self, *_):
     """ Starts the verification phase
     """
     vc=self.eVerificationCode.get_text()
     mswitch.publish(self, "start_verify", vc)
Exemplo n.º 11
0
 def show(self, *_):
     mswitch.publish(self, "app_show")
Exemplo n.º 12
0
 def exit(self, *p):
     mswitch.publish(self, "__quit__")
Exemplo n.º 13
0
 def do_destroy(self, *_):
     print "ui.window: destroy"
     mswitch.publish(self, "__destroy__")
Exemplo n.º 14
0
 def on_destroy(self):
     mswitch.publish(None, "__quit__", None)
     self.quitting=True
Exemplo n.º 15
0
 def rx_rating(self, source, timestamp, artist_name, album_name, track_name, rating):
     mswitch.publish(self, "rating", source, timestamp, artist_name, album_name, track_name, rating)
Exemplo n.º 16
0
 def sTracks(self, source, ref, list_dic):
     """
     DBus signal handler - /Tracks/Tracks
     """
     mswitch.publish(self.agent, "mb_tracks", source, ref, list_dic)
Exemplo n.º 17
0
 def rx_qrating(self, artist_name, album_name, track_name):
     mswitch.publish(self, "qrating", artist_name, album_name, track_name)