def GetUnreadNotifications(self): self.LogInfo('Getting unread notifications') if self.unreadNotifications is None: unreadNotifications = [] newNotifications = self.notificationMgr.GetUnprocessed() newSenders = [] for newNotification in newNotifications: unreadNotifications.append( util.KeyVal(notificationID=newNotification.notificationID, typeID=newNotification.typeID, senderID=newNotification.senderID, receiverID=newNotification.receiverID, processed=newNotification.processed, created=newNotification.created, data=newNotification.data, deleted=False)) newSenders.append(newNotification.senderID) groupID = notificationUtil.GetTypeGroup(newNotification.typeID) if groupID in self.unreadCount: self.unreadCount[groupID] = self.unreadCount[groupID] + 1 else: self.unreadCount[groupID] = 1 self.unreadNotifications = unreadNotifications sm.GetService('mailSvc').PrimeOwners(newSenders) return self.unreadNotifications
def OnNotificationReceived(self, notificationID, typeID, senderID, created, data={}): self.SetBlinkTabState(True) notification = util.KeyVal(notificationID=notificationID, typeID=typeID, senderID=senderID, receiverID=session.charid, processed=False, created=created, data=data, deleted=False) groupID = notificationUtil.GetTypeGroup(typeID) if groupID is None: log.LogException('No group for typeID = %s' % typeID) else: if groupID in self.notifications: self.notifications[groupID].insert(0, notification) if self.unreadNotifications is not None: if groupID in self.unreadCount: self.unreadCount[groupID] = self.unreadCount[groupID] + 1 else: self.unreadCount[groupID] = 1 self.unreadNotifications.insert(0, notification) self.ScatterNotificationEvent(notification) if settings.user.ui.Get('notification_showNotification', 1): self.GetNotificationNotification(notification) if settings.user.ui.Get('notification_blinkNecom', 1): sm.GetService('neocom').Blink('mail')
def OnNotificationDeleted(self, notificationIDs): toclear = copy.copy(notificationIDs) if self.unreadNotifications is not None: for deletedID in notificationIDs: for unread in self.unreadNotifications: if unread.notificationID == deletedID: groupID = notificationUtil.GetTypeGroup( self.unreadNotifications[deletedID].typeID) self.unreadNotifications.remove(unread) if groupID in self.unreadCount: self.unreadCount[ groupID] = self.unreadCount[groupID] - 1 if groupID in self.notifications: for grouped in self.notifications[groupID]: if grouped.notificationID == deletedID: self.notifications[groupID].remove(grouped) break toclear.remove(deletedID) break if len(toclear) > 0: for groupID in self.notifications: for deletedID in copy.copy(toclear): for grouped in self.notifications[groupID]: if grouped.notificationID == deletedID: self.notifications[groupID].remove(grouped) toclear.remove(deletedID) break sm.ScatterEvent('OnNotificationsRefresh')
def UpdateCacheAfterDeleting(self, notificationIDs): toclear = copy.copy(notificationIDs) if self.unreadNotifications is not None: for deletedID in notificationIDs: for unread in self.unreadNotifications: if unread.notificationID == deletedID: groupID = notificationUtil.GetTypeGroup(unread.typeID) self.unreadNotifications.remove(unread) if groupID in self.unreadCount: self.unreadCount[ groupID] = self.unreadCount[groupID] - 1 if groupID in self.notifications: for grouped in self.notifications[groupID]: if grouped.notificationID == deletedID: self.notifications[groupID].remove(grouped) break toclear.remove(deletedID) break if len(toclear) > 0: for groupID in self.notifications: for deletedID in copy.copy(toclear): for grouped in self.notifications[groupID]: if grouped.notificationID == deletedID: self.notifications[groupID].remove(grouped) toclear.remove(deletedID) break
def UpdateCacheAfterMarkingRead(self, notificationIDs): for readID in notificationIDs: wasUnread = False typeID = None for unread in self.unreadNotifications: if unread.notificationID == readID: typeID = unread.typeID self.unreadNotifications.remove(unread) wasUnread = True break if not wasUnread: continue groupID = notificationUtil.GetTypeGroup(typeID) if groupID in self.notifications: for grouped in self.notifications[groupID]: if grouped.notificationID == readID: grouped.processed = True break if groupID in self.unreadCount: self.unreadCount[groupID] = self.unreadCount[groupID] - 1
def LoadGroupFromNode(self, node, refreshing = 0, selectedIDs = [], *args): group = node settings.char.ui.Set('mail_lastnotification', group.groupID) notifications = [] if group.groupID == const.notificationGroupUnread: notifications = sm.GetService('notificationSvc').GetFormattedUnreadNotifications() senders = [ value.senderID for value in sm.GetService('notificationSvc').GetUnreadNotifications() ] else: notifications = sm.GetService('notificationSvc').GetFormattedNotifications(group.groupID) senders = [ value.senderID for value in sm.GetService('notificationSvc').GetNotificationsByGroupID(group.groupID) ] sm.GetService('mailSvc').PrimeOwners(senders) if not self or self.destroyed: return pos = self.sr.msgScroll.GetScrollProportion() scrolllist = [] for each in notifications: senderName = '' if each.senderID is not None: senderName = cfg.eveowners.Get(each.senderID).ownerName label = '<t>' + senderName + '<t>' + each.subject + '<t>' + util.FmtDate(each.created, 'ls') if group.groupID == const.notificationGroupUnread: typeGroup = notificationUtil.GetTypeGroup(each.typeID) labelPath = notificationUtil.groupNamePaths.get(typeGroup, None) if labelPath is None: typeName = '' else: typeName = localization.GetByLabel(labelPath) label += '<t>' + typeName hint = each.body.replace('<br>', '') hint = uiutil.TruncateStringTo(hint, HINTCUTOFF, localization.GetByLabel('UI/Common/MoreTrail')) data = util.KeyVal() data.cleanLabel = label data.parentNode = node data.label = label data.hint = hint data.id = each.notificationID data.typeID = each.typeID data.senderID = each.senderID data.data = util.KeyVal(read=each.processed) data.info = each data.OnClick = self.LoadReadingPaneFromEntry data.OnDblClick = self.DblClickNotificationEntry data.GetMenu = self.GetEntryMenu data.ignoreRightClick = 1 data.isSelected = each.notificationID in selectedIDs data.Draggable_blockDrag = 1 scrolllist.append(listentry.Get('MailEntry', data=data)) scrollHeaders = [localization.GetByLabel('UI/Mail/Status'), localization.GetByLabel('UI/Mail/Sender'), localization.GetByLabel('UI/Mail/Subject'), localization.GetByLabel('UI/Mail/Received')] if group.groupID == const.notificationGroupUnread: scrollHeaders.append(localization.GetByLabel('UI/Mail/Notifications/GroupName')) if not self or self.destroyed: return self.sr.msgScroll.Load(contentList=scrolllist, headers=scrollHeaders, noContentHint=localization.GetByLabel('UI/Mail/Notifications/NoNotifications')) if not refreshing: self.ClearReadingPane() else: self.sr.msgScroll.ScrollToProportion(pos) self.UpdateCounters()