NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

notificationDevUI.py (10451B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\notifications\client\development\notificationDevUI.py
      2 from __future__ import print_function
      3 from notifications.common.notification import SimpleNotification
      4 from carbonui.control.window import Window
      5 from carbonui.control.button import Button
      6 from carbonui.primitives.container import Container
      7 from notifications.client.generator.notificationGenerator import NotificationGenerator
      8 from notifications.client.controls.notificationSettingsWindow import NotificationSettingsWindow
      9 from notifications.client.development.skillHistoryProvider import SkillHistoryProvider
     10 import carbonui.const as uiconst
     11 
     12 class NotificationDevWindow(Window):
     13     default_caption = 'Notification Debug window'
     14     default_windowID = 'NotificationDevWindow2'
     15     default_width = 300
     16     default_height = 300
     17     default_minSize = (250, 350)
     18 
     19     def ApplyAttributes(self, attributes):
     20         Window.ApplyAttributes(self, attributes)
     21         self.mainContainer = NotificationDevMainContainer(name='mainContainer', align=uiconst.TOALL, parent=self.GetMainArea())
     22 
     23 
     24 class NotificationDevMainContainer(Container):
     25 
     26     def ApplyAttributes(self, attributes):
     27         Container.ApplyAttributes(self, attributes=attributes)
     28         self.generateButton = Button(name='generationStartButton', align=uiconst.TOTOP, label='start Generating', func=self.OnGenerateButtonClicked, pos=(0, 20, 100, 20), parent=self)
     29         self.fillSkillHistoryBtn = Button(name='fillSkillHistory', align=uiconst.TOTOP, label='skillHistory()', func=self.OnSkillDevClick, pos=(0, 5, 100, 20), parent=self)
     30         self.makeAllNotificationsBtn = Button(name='MakeAllNotifications', align=uiconst.TOTOP, label='MakeAllNotifications()', func=self.OnMakeAllNotificationClick, pos=(0, 5, 100, 20), parent=self)
     31         self.displayNotificationSettingBtn = Button(name='NotificationSettingsWindowButton', align=uiconst.TOTOP, label='Notification Settings window', func=self.OnDisplayNotificationSettingClick, pos=(0, 5, 100, 20), parent=self)
     32         self.toggleEnabledFlagBtn = Button(name='NotificationSettingsWindowButton', align=uiconst.TOTOP, label='Toggle enabled', func=self.OnToggleEnabledClick, pos=(0, 5, 100, 20), parent=self)
     33         self.toggleEnabledDevModeFlagBtn = Button(name='DevToggleButton', align=uiconst.TOTOP, label='Toggle developermode', func=self.OnDevToggleButtonClick, pos=(0, 5, 100, 20), parent=self)
     34         self.testTransactionFun = Button(name='TransactioFun', align=uiconst.TOTOP, label='Generate random fake transaction', func=self.OnTransactionFun, pos=(0, 5, 100, 20), parent=self)
     35         self.isGenerating = False
     36         self.MakeNewGenerator()
     37 
     38     def OnTransactionFun(self, *args):
     39         import random
     40         aRandom = random.Random()
     41         startValue = 1000000
     42         transaction = aRandom.randint(-1000000, 1000000)
     43         sm.ScatterEvent('OnPersonalAccountChangedClient', startValue, transaction)
     44 
     45     def OnDevToggleButtonClick(self, *args):
     46         service = sm.GetService('notificationUIService')
     47         service.ToggleDeveloperMode()
     48         service.ToggleEnabledFlag()
     49         service.ToggleEnabledFlag()
     50 
     51     def OnToggleEnabledClick(self, *args):
     52         service = sm.GetService('notificationUIService')
     53         service.ToggleEnabledFlag()
     54 
     55     def OnDisplayNotificationSettingClick(self, *args):
     56         NotificationSettingsWindow.ToggleOpenClose()
     57 
     58     def OnMakeAllNotificationClick(self, *args):
     59         notificationMaker = FakeNotificationMaker()
     60         notificationMaker.MakeAndScatterAllClassicNotifications()
     61 
     62     def fakeNotification(self, typeID):
     63         newNotification = Notification(notificationID=1345)
     64 
     65     def OnSkillDevClick(self, *args):
     66         provider = SkillHistoryProvider()
     67         provider.provide()
     68 
     69     def OnMakeNewGeneratorClicked(self, *args):
     70         if self.notificationGenerator:
     71             self.notificationGenerator.Stop()
     72         self.MakeNewGenerator()
     73 
     74     def adjustLabel(self):
     75         if self.isGenerating:
     76             self.generateButton.SetLabel('Stop generating')
     77         else:
     78             self.generateButton.SetLabel('Start generating')
     79 
     80     def MakeNewGenerator(self):
     81         self.notificationGenerator = NotificationGenerator()
     82 
     83     def OnGenerateButtonClicked(self, *args):
     84         self.isGenerating = not self.isGenerating
     85         if self.isGenerating:
     86             sm.GetService('notificationUIService').SpawnFakeNotifications()
     87         else:
     88             sm.GetService('notificationUIService').notificationGenerator.Stop()
     89         self.adjustLabel()
     90 
     91 
     92 import eve.common.script.util.notificationUtil as notificationUtil
     93 import eve.common.script.util.notificationconst as notificationConst
     94 import blue
     95 import sys
     96 from eve.client.script.ui.services.mail.notificationSvc import Notification
     97 
     98 class FakeNotificationMaker:
     99 
    100     @staticmethod
    101     def MakeFakeData(senderID = 98000002):
    102         data = {'addCloneInfo': 1,
    103          'againstID': 98000002,
    104          'agentLocation': {3: 10000037,
    105                            4: 20000443,
    106                            5: 30003029,
    107                            15: 60011125},
    108          'aggressorCorpID': 98000002,
    109          'aggressorID': 98000001,
    110          'allianceID': 99000002,
    111          'allyID': 98000001,
    112          'amount': 6666,
    113          'armorValue': 0.2,
    114          'attackerID': 90000002,
    115          'billTypeID': 1,
    116          'body': 'This Is a body',
    117          'bounty': 666,
    118          'bountyPlacerID': 98000001,
    119          'celestialIndex': 1,
    120          'characterID': 90000001,
    121          'charID': 90000001,
    122          'charRefID': 90000001,
    123          'charsInCorpID': [90000001],
    124          'cloneStationID': 60012415,
    125          'corpID': senderID,
    126          'corporationID': senderID,
    127          'corpsPresent': '',
    128          'corpStationID': 60012415,
    129          'cost': 12456,
    130          'creditorID': 98000001,
    131          'debtorID': 90000003,
    132          'declaredByID': senderID,
    133          'defenderID': 98000001,
    134          'disqualificationType': 9,
    135          'districtIndex': 1,
    136          'enemyID': 90000001,
    137          'entityID': 90000001,
    138          'errorText': 'THIS IS AN ERROR TEXT',
    139          'event': 373,
    140          'factionID': 500001,
    141          'header': 'THIS IS A BULLSHIT HEADER',
    142          'hours': 667,
    143          'iskValue': 666,
    144          'itemRefID': 1,
    145          'level': 5,
    146          'locationID': 60012415,
    147          'locationOwnerID': 30005031,
    148          'lostList': None,
    149          'medalID': 132919,
    150          'mercID': 90000001,
    151          'messageIndex': 1,
    152          'myIsk': 668,
    153          'newOwnerID': 90000004,
    154          'newRank': 'Your New rank',
    155          'offeredID': 90000001,
    156          'offeringID': 90000001,
    157          'oldOwnerID': 90000001,
    158          'ownerID': 90000001,
    159          'ownerID1': 90000001,
    160          'parameter': 98000001,
    161          'password': 'thisIsPassword',
    162          'payout': 1231313,
    163          'planetID': 40318731,
    164          'planetTypeID': 1,
    165          'price': 45646456,
    166          'reason': 'This is a bullshit reason',
    167          'reinforceExitTime': blue.os.GetWallclockTime() + 100000,
    168          'security': 3,
    169          'shieldValue': 0.8,
    170          'skillPointsLost': 669,
    171          'solarSystemID': 30005031,
    172          'standingsChange': 0.2,
    173          'startDate': blue.os.GetWallclockTime(),
    174          'startTime': blue.os.GetWallclockTime(),
    175          'state': 1,
    176          'stationID': 60012415,
    177          'subject': 'This is a subject',
    178          'systemBids': (90000001, 1234),
    179          'teamNameInfo': (1000144, 17740, 3767636),
    180          'time': blue.os.GetWallclockTime(),
    181          'timeFinished': blue.os.GetWallclockTime(),
    182          'toEntityID': 90000001,
    183          'topTen': None,
    184          'totalIsk': 45646,
    185          'typeID': 17740,
    186          'typeIDs': None,
    187          'victimID': 90000001,
    188          'voteType': 1,
    189          'wants': None,
    190          'yourAmount': 6667,
    191          'hullValue': 0.9,
    192          'aggressorAllianceID': 99000002,
    193          'delayHours': 24,
    194          'hostileState': 1,
    195          'targetLocation': {3: 10000037,
    196                             4: 20000443,
    197                             5: 30003029,
    198                             15: 60011125},
    199          'requiredStanding': 0.5,
    200          'corpList': [98000001],
    201          'warHQ': 100000123,
    202          'currentStanding': 0.5,
    203          'warNegotiationID': 123}
    204         return data
    205 
    206     def ScatterSingleNotification(self, counter, notificationId, senderID, someAgentID, someCorp):
    207         data = self.MakeFakeData(someCorp)
    208         aNotification = Notification(notificationID=counter + 10000000, typeID=notificationId, senderID=senderID, receiverID=90000001, processed=False, created=blue.os.GetWallclockTime() - counter * 10000, data=data)
    209         fsubject, fbody = notificationUtil.Format(aNotification)
    210         try:
    211             characterID = None
    212             corporationId = None
    213             if notificationId in notificationConst.groupTypes[notificationConst.groupAgents]:
    214                 senderID = someAgentID
    215             if notificationId in notificationConst.groupTypes[notificationConst.groupCorp]:
    216                 senderID = someCorp
    217             newNotification = SimpleNotification(subject=fsubject, created=blue.os.GetWallclockTime() - counter * 10000, notificationID=counter + 1000000, notificationTypeID=notificationId, senderID=senderID, body=fbody)
    218             sm.ScatterEvent('OnNewNotificationReceived', newNotification)
    219         except:
    220             print('exception')
    221             print(sys.exc_info()[0])
    222 
    223     def MakeAndScatterAllClassicNotifications(self):
    224         counter = 0
    225         onlyOneGroup = False
    226         whitelistedGroups = [notificationConst.groupAgents, notificationConst.groupCorp]
    227         useWhiteLists = False
    228         for notificationId, dict in notificationUtil.formatters.iteritems():
    229             if useWhiteLists:
    230                 foundSomething = False
    231                 for group in whitelistedGroups:
    232                     if notificationId in notificationConst.groupTypes[group]:
    233                         foundSomething = True
    234 
    235                 if not foundSomething:
    236                     continue
    237             agentStartID = 3008416
    238             someAgentID = agentStartID + counter
    239             senderID = 98000001
    240             corpStartID = 1000089
    241             someCorp = corpStartID + counter
    242             self.ScatterSingleNotification(counter, notificationId, senderID, someAgentID, someCorp)
    243             counter = counter + 1
    244             blue.synchro.Yield()