def _on_contact_attr_changed(self, account, change_type, old_value, do_notify=True): """callback called when an attribute of a contact changed""" contact = self.session.contacts.get(account) if not contact: dbg("account " + account + " not found on contacts", "mainwindow", 1) if change_type == "online" and do_notify: if self.session.config.b_notify_contact_online: gui.notify(contact.display_name, "is now online") if self.session.config.b_play_contact_online: gui.play(self.session, gui.theme.sound_online) elif change_type == "offline": if self.session.config.b_notify_contact_offline: gui.notify(contact.display_name, "is now offline") if self.session.config.b_play_contact_offline: gui.play(self.session, gui.theme.sound_offline)
def _on_contact_attr_changed(self, account, change_type, old_value, do_notify=True): '''callback called when an attribute of a contact changed''' contact = self.session.contacts.get(account) if not contact: log.debug('account %s not found on contacts' % account) if change_type == 'online' and do_notify: if self.session.config.b_notify_contact_online: gui.notify(contact.display_name, "is now online") if self.session.config.b_play_contact_online: gui.play(self.session, gui.theme.sound_online) elif change_type == 'offline': if self.session.config.b_notify_contact_offline: gui.notify(contact.display_name, "is now offline") if self.session.config.b_play_contact_offline: gui.play(self.session, gui.theme.sound_offline)
def request(data, type): print 'request starts!' if (type == 'db_add_or_update'): print "type: db_add_or_update" db.add_or_update_no_push(data) gtk.gdk.threads_enter() gui.notify(data) gtk.gdk.threads_leave() # elif (type == 'textMessage'): # print "type: textMessage" # msg = TextMessage(data.src, data.dst, data.msg) # db.add_or_update(msg) # msg.src_object = db.get_one_by_id(Employee, msg.src) # msg.dst_object = db.get_one_by_id(Employee, msg.dst) # db.commit() # gtk.gdk.threads_enter() # gui.notify(msg) # gtk.gdk.threads_leave() elif (type == 'pong'): """ Recieves a list with ID """ print 'type: pong' onlineLista = data """ Updates whos online in db """ print 'dbupdate to false' for mongo in db.get_all(Employee): mongo.online=False print 'dbupdate to true from list' for id in onlineLista: user = db.get_one_by_id(Employee, id) user.online = True db.commit()