0001 ### BITPIM 0002 ### 0003 ### Copyright (C) 2003-2004 Roger Binns <rogerb@rogerbinns.com> 0004 ### 0005 ### This program is free software; you can redistribute it and/or modify 0006 ### it under the terms of the BitPim license as detailed in the LICENSE file. 0007 ### 0008 ### $Id: pubsub.py 4412 2007-09-28 01:28:56Z djpham $ 0009 0010 0011 """The publish subscribe mechanism used to maintain lists of stuff. 0012 0013 This helps different pieces of code maintain lists of things (eg 0014 wallpapers, categories) and other to express and interest and be 0015 notified when it changes (eg field editors). The wxPython pubsub 0016 module is the base. The enhancements are a list of standard topics in 0017 this file. 0018 0019 This code also used to be larger as the wxPython pubsub didn't use 0020 weak references. It does now, so a whole bunch of code could be 0021 deleted. 0022 """ 0023 0024 from wx.lib.pubsub import Publisher 0025 0026 0027 ### 0028 ### A list of topics 0029 ### 0030 0031 0032 # Maintain the list of categories 0033 REQUEST_CATEGORIES=( 'request', 'categories' ) # no data 0034 ALL_CATEGORIES=( 'response', 'categories') # data is list of strings 0035 SET_CATEGORIES=( 'request', 'setcategories') # data is list of strings 0036 ADD_CATEGORY=( 'request', 'addcategory') # data is list of strings 0037 MERGE_CATEGORIES=( 'request', 'mergecategories') # data is list of strings 0038 ALL_WALLPAPERS=( 'response', 'wallpapers') # data is list of strings 0039 REQUEST_WALLPAPERS=( 'request', 'wallpapers') # no data 0040 ALL_RINGTONES=( 'response', 'ringtones' ) # data is list of strings 0041 REQUEST_RINGTONES=( 'request', 'ringtones') # no data 0042 PHONE_MODEL_CHANGED=( 'notification', 'phonemodelchanged') # data is phone module 0043 REQUEST_RINGTONE_INDEX=('request', 'ringtone-index') # no data 0044 ALL_RINGTONE_INDEX=('response', 'ringtone-index') # data is the ringtone-index dict 0045 REQUEST_PB_LOOKUP=('request', 'phonebook') # Request to lookup a number 0046 RESPONSE_PB_LOOKUP=('response', 'phonebook') # Response to the request 0047 MEDIA_NAME_CHANGED=('notificaion', 'medianamechanged') # notify if name changed 0048 REQUEST_TAB_CHANGED=('notification', 'tabchanges') # request to change the main tab 0049 TODAY_ITEM_SELECTED=('notification', 'todayitemselected') # a Today item was selected 0050 REQUEST_TODAY_DATA=('request', 'todaydata') # request data for Today page 0051 RESPONSE_TODAY_DATA=('response', 'todaydata') # reponse data for Today page 0052 NEW_DATA_AVAILABLE=('notification', 'dataavailable') # new data available 0053 MIDNIGHT=('notification', 'midnight') # midnight had passed 0054 DR_RECORD=('notification', 'recorddata') # DR On 0055 DR_PLAY=('notification', 'playdata') # DR Playback 0056 DR_STOP=('notification', 'stop') # DR stop 0057 REQUEST_MEDIA_INFO=('request', 'mediainfo') # Request media item description 0058 RESPONSE_MEDIA_INFO=('response', 'mediainfo') # Response: list of strings (lines) 0059 REQUEST_MEDIA_OPEN=('request', 'mediaopen') # Request to open/launch a media item 0060 0061 # MEDIA_NAME_CHANGED keys & types 0062 media_change_type='type' 0063 wallpaper_type='wallpaper' 0064 ringtone_type='ringtone' 0065 media_old_name='old_name' 0066 media_new_name='new_name' 0067 0068 def subscribe(listener, topic): 0069 Publisher.subscribe(listener, topic) 0070 0071 def unsubscribe(listener): 0072 Publisher.unsubscribe(listener) 0073 0074 def publish(topic, data=None): 0075 Publisher.sendMessage(topic, data) 0076
Generated by PyXR 0.9.4