msimn.py
5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#appModules/msimn.py - Outlook Express appModule
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2006-2012 NVDA Contributors
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
import winUser
import controlTypes
import displayModel
import textInfos
import api
import appModuleHandler
from keyboardHandler import KeyboardInputGesture
from NVDAObjects.window import Window
from NVDAObjects.IAccessible import IAccessible, sysListView32
import watchdog
from NVDAObjects.behaviors import _FakeTableCell
messageListImageLabels={
# Translators: This Outlook Express message has an attachment
8:_("has attachment"),
# Translators: this Outlook Express message is flagged
34:_("flagged"),
}
#Labels for the header fields of an email, by control ID
envelopeNames={
# Translators: This is presented in outlook or live mail to indicate email attachments.
1000:_("Attachments"),
# Translators: This is presented in outlook or live mail when creating a new email 'to:' or 'recipient:'
1001:_("To:"),
# Translators: This is presented in outlook or live mail when sending an email to a newsgroup
1002:_("Newsgroup:"),
# Translators: This is presented in outlook or live mail, email carbon copy
1003:_("CC:"),
# Translators: This is presented in outlook or live mail, email subject
1004:_("Subject:"),
# Translators: This is presented in outlook or live mail, email sender
1005:_("From:"),
# Translators: This is presented in outlook or live mail, date of email
1016:_("Date:"),
# Translators: This is presented in outlook or live mail
1018:_("Forward to:"),
# Translators: This is presented in outlook or live mail
1019:_("Answer to:"),
# Translators: This is presented in outlook or live mail
1020:_("Organisation:"),
# Translators: This is presented in outlook or live mail
1021:_("Distribution:"),
# Translators: This is presented in outlook or live mail
1022:_("Key words:"),
# Translators: This is presented in outlook or live mail, email blind carbon copy
1026:_("BCC:"),
# Translators: This is presented in outlook or live mail, email sender
1037:_("From:"),
}
class AppModule(appModuleHandler.AppModule):
def event_NVDAObject_init(self,obj):
if not isinstance(obj,Window): return
controlID=obj.windowControlID
windowHandle=obj.windowHandle
parentWindow=winUser.getAncestor(windowHandle,winUser.GA_PARENT)
parentClassName=winUser.getClassName(parentWindow)
#If this object is an email header field, and we have a custom label for it,
#Then set the object's name to the label
if parentClassName=="OE_Envelope" and isinstance(obj,IAccessible) and obj.IAccessibleChildID==0 and envelopeNames.has_key(controlID):
obj.name=envelopeNames[controlID]
obj.useITextDocumentSupport=True
obj.editValueUnit=textInfos.UNIT_STORY
def chooseNVDAObjectOverlayClasses(self,obj,clsList):
if obj.windowClassName=="SysListView32" and obj.windowControlID in (128,129,130) and obj.role==controlTypes.ROLE_LISTITEM:
clsList.insert(0,MessageRuleListItem)
elif "SysListView32" in obj.windowClassName and obj.role==controlTypes.ROLE_LISTITEM and obj.parent.name=="Outlook Express Message List":
clsList.insert(0,MessageListItem)
def event_gainFocus(self,obj,nextHandler):
nextHandler()
#Force focus to move to something sane when landing on an outlook express message window
if obj.windowClassName=="ATH_Note" and obj.event_objectID==winUser.OBJID_CLIENT and obj.IAccessibleChildID==0:
api.processPendingEvents()
if obj==api.getFocusObject() and controlTypes.STATE_FOCUSED in obj.states:
return KeyboardInputGesture.fromName("shift+tab").send()
class MessageRuleListItem(sysListView32.ListItem):
"""Used for the checkbox list items used to select message rule types in in message filters"""
role=controlTypes.ROLE_CHECKBOX
def _get_states(self):
states=super(MessageRuleListItem,self).states
if (watchdog.cancellableSendMessage(self.windowHandle,sysListView32.LVM_GETITEMSTATE,self.IAccessibleChildID-1,sysListView32.LVIS_STATEIMAGEMASK)>>12)==8:
states.add(controlTypes.STATE_CHECKED)
return states
class MessageListItem(sysListView32.ListItem):
def _getColumnContent(self,column):
content=super(MessageListItem,self)._getColumnContent(column)
if not content:
imageID=self._getColumnImageID(column)
if imageID>0:
content=messageListImageLabels.get(imageID,"")
return content
def _get_isUnread(self):
info=displayModel.DisplayModelTextInfo(self,textInfos.POSITION_FIRST)
info.expand(textInfos.UNIT_CHARACTER)
fields=info.getTextWithFields()
try:
isUnread=fields[0].field['bold']
except:
isUnread=False
return isUnread
def _get_name(self):
nameList=[]
imageState=watchdog.cancellableSendMessage(self.windowHandle,sysListView32.LVM_GETITEMSTATE,self.IAccessibleChildID-1,sysListView32.LVIS_STATEIMAGEMASK)>>12
if imageState==5:
nameList.append(controlTypes.stateLabels[controlTypes.STATE_COLLAPSED])
elif imageState==6:
nameList.append(controlTypes.stateLabels[controlTypes.STATE_EXPANDED])
if self.isUnread:
# Translators: Displayed in outlook or live mail to indicate an email is unread
nameList.append(_("unread"))
name=super(MessageListItem,self).name
if name:
nameList.append(name)
return " ".join(nameList)