home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / mail / hotmail / ajax.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  47.0 KB  |  1,229 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import logging
  5. import digsbysite
  6. import common.asynchttp as asynchttp
  7. import re
  8. import util
  9. import weakref
  10. log = logging.getLogger('hotmail.ajax')
  11.  
  12. def FlagsCreate(*args):
  13.     return util.Storage(zip(args[::2], args[1::2]))
  14.  
  15. XMLPost = 0
  16. null = None
  17.  
  18. class FppParamType(object):
  19.     String = ('_string',)
  20.     Date = ('_date',)
  21.     Array = ('_array',)
  22.     oArray = ('_oArray',)
  23.     Primitive = ('_primitive',)
  24.     Object = ('_object',)
  25.     Enum = ('_enum',)
  26.     Custom = '_custom'
  27.  
  28.  
  29. class TypeSystem(object):
  30.     _isFppObject = True
  31.     
  32.     def __init__(self, name_or_type, name = None, val = None):
  33.         if name is not None:
  34.             type = name_or_type
  35.             name = name
  36.         else:
  37.             type = FppParamType.Custom
  38.             name = name_or_type
  39.         self.name = name
  40.         self.type = type
  41.         self.value = val
  42.  
  43.     
  44.     def escape(instance):
  45.         f = {
  46.             '_string': FppProxy.escape,
  47.             '_date': (lambda a: a),
  48.             '_array': FppProxy.arrayToString,
  49.             '_oArray': FppProxy.objToStringImpl,
  50.             '_object': FppProxy.objToStringImpl,
  51.             '_primitive': (lambda a: str(a).lower()),
  52.             '_enum': (lambda a: str(a)) }.get(util.get(instance, 'type', None), FppProxy.objToString)
  53.         escaped_val = f(util.get(instance, 'value', None))
  54.         if escaped_val is None:
  55.             return 'null'
  56.         
  57.         return escaped_val
  58.  
  59.     escape = staticmethod(escape)
  60.     
  61.     def __str__(self):
  62.         return '<TypeSystem %r>' % self.name
  63.  
  64.     
  65.     def toString(self):
  66.         return TypeSystem.escape(self)
  67.  
  68.     
  69.     def default(cls):
  70.         x = cls('')
  71.         x.value = type(cls._default)(cls._default)
  72.         return x
  73.  
  74.     default = classmethod(default)
  75.  
  76.  
  77. class _string(TypeSystem):
  78.     _default = ''
  79.     
  80.     def __init__(self, name):
  81.         TypeSystem.__init__(self, '_string', name)
  82.  
  83.  
  84.  
  85. class _array(TypeSystem):
  86.     _default = []
  87.     
  88.     def __init__(self, name):
  89.         TypeSystem.__init__(self, '_array', name)
  90.  
  91.  
  92.  
  93. class _enum(TypeSystem):
  94.     _default = 0
  95.     
  96.     def __init__(self, name):
  97.         TypeSystem.__init__(self, '_enum', name)
  98.  
  99.  
  100.  
  101. class _primitive(TypeSystem):
  102.     _default = False
  103.     
  104.     def __init__(self, name):
  105.         TypeSystem.__init__(self, '_primitive', name)
  106.  
  107.  
  108.  
  109. class _oArray(TypeSystem):
  110.     _default = { }
  111.     
  112.     def __init__(self, name):
  113.         TypeSystem.__init__(self, '_oArray', name)
  114.  
  115.  
  116.  
  117. class _object(TypeSystem):
  118.     _default = { }
  119.     
  120.     def __init__(self, name):
  121.         TypeSystem.__init__(self, '_object', name)
  122.  
  123.  
  124. _custom = TypeSystem
  125.  
  126. class FppProperty(object):
  127.     
  128.     def __init__(self, name, typ):
  129.         self._name = name
  130.         self._type = typ
  131.  
  132.     
  133.     def __get__(self, obj, objtype):
  134.         if not hasattr(obj, '_field_%s' % self._name):
  135.             setattr(obj, '_field_%s' % self._name, FppMetaclass._classes[self._type].default())
  136.         
  137.         val = getattr(obj, '_field_%s' % self._name)
  138.         if getattr(val, 'type', None) != self._type:
  139.             if val is None or val._isFppObject:
  140.                 return val
  141.             
  142.             raise ValueError('%r has an invalid %r (with type = %r, value = %r)', obj, self._name, val.type, val.value)
  143.         
  144.         return val
  145.  
  146.     
  147.     def __set__(self, obj, val):
  148.         if val is not None and hasattr(val, 'type'):
  149.             if val.type != self._type:
  150.                 raise TypeError('%r must have type %r for the %r field. Got %r (value = %r) instead.', obj, self._type, self._name, val.type, val.value)
  151.             
  152.         elif val is None or getattr(val, '_isFppObject', False):
  153.             pass
  154.         else:
  155.             x = FppMetaclass._classes[self._type].default()
  156.             x.value = val
  157.             val = x
  158.         setattr(obj, '_field_%s' % self._name, val)
  159.  
  160.  
  161.  
  162. class FppMetaclass(type):
  163.     _classes = {
  164.         '_enum': _enum,
  165.         '_string': _string,
  166.         '_array': _array,
  167.         '_primitive': _primitive,
  168.         '_object': _object,
  169.         '_oArray': _oArray }
  170.     
  171.     def __init__(cls, name, bases, dict):
  172.         for _name, typ in cls._fields_:
  173.             setattr(cls, _name, FppProperty(_name, typ))
  174.         
  175.         
  176.         def default(_cls):
  177.             i = cls()
  178.             for _name, typ in i._fields_:
  179.                 setattr(i, _name, FppMetaclass._classes[typ].default())
  180.             
  181.             return i
  182.  
  183.         default = (classmethod,)(default)
  184.         dict['default'] = default
  185.         FppMetaclass._classes[name] = cls
  186.         cls.default = default
  187.         cls._isFppObject = True
  188.         type.__init__(cls, name, bases, dict)
  189.  
  190.  
  191.  
  192. class FppClass(object):
  193.     _fields_ = []
  194.     __metaclass__ = FppMetaclass
  195.     
  196.     def __init__(self, *args, **kwds):
  197.         fieldnames = (lambda .0: for x in .0:
  198. x[0])(self._fields_)
  199.         for i in range(len(args)):
  200.             setattr(self, self._fields_[i][0], args[i])
  201.         
  202.         for key in kwds:
  203.             setattr(self, key, kwds[key])
  204.         
  205.  
  206.     
  207.     def __str__(self):
  208.         res = [
  209.             '{']
  210.         for name, typ in self._fields_:
  211.             cls = FppMetaclass._classes[typ]
  212.             val = getattr(self, name)
  213.             if val is None:
  214.                 res.append('null')
  215.             else:
  216.                 res.append(cls.escape(val))
  217.             res.append(',')
  218.         
  219.         if res[-1] == ',':
  220.             res.pop(-1)
  221.         
  222.         res.append('}')
  223.         return ''.join(res)
  224.  
  225.     toString = escape = __str__
  226.     
  227.     def __repr__(self):
  228.         return '<%s %s>' % (type(self).__name__, (' '.join,)((lambda .0: for entry in .0:
  229. '%s=%r' % (entry[0], getattr(self, entry[0], None)))(self._fields_)))
  230.  
  231.  
  232.  
  233. class FppError(FppClass):
  234.     _fields_ = [
  235.         ('ErrorCode', '_string'),
  236.         ('Message', '_string'),
  237.         ('ErrorObj', '_object'),
  238.         ('StackTrace', '_string')]
  239.  
  240.  
  241. class FppReturnPackage(FppClass):
  242.     _fields_ = [
  243.         ('Status', '_enum'),
  244.         ('Value', '_object'),
  245.         ('OutRefParams', '_oArray'),
  246.         ('Error', 'FppError'),
  247.         ('ProfilingInfo', '_object')]
  248.  
  249.  
  250. class InboxUiData(FppClass):
  251.     _fields_ = [
  252.         ('FolderListHtml', '_string'),
  253.         ('MessageListHtml', '_string'),
  254.         ('MessageHtml', '_string'),
  255.         ('RedirectUrl', '_string')]
  256.  
  257.  
  258. class HmCandidacyInfo(FppClass):
  259.     _fields_ = [
  260.         ('Status', '_enum'),
  261.         ('Guid', '_string'),
  262.         ('ShowMakeLiveContact', '_enum')]
  263.  
  264.  
  265. class HmAuxData(FppClass):
  266.     QueryArgName = 'Aux'
  267.     _fields_ = [
  268.         ('Value', '_string'),
  269.         ('LiveContactCandidacyInfo', 'HmCandidacyInfo')]
  270.  
  271.  
  272. class MessageRenderingInfo(FppClass):
  273.     _fields_ = [
  274.         ('MessageId', '_string'),
  275.         ('FolderId', '_string'),
  276.         ('OpenMessageBody', '_primitive'),
  277.         ('AllowUnsafeContent', '_primitive'),
  278.         ('OverrideCodepage', '_primitive'),
  279.         ('HmAuxData', 'HmAuxData'),
  280.         ('SortKey', '_enum'),
  281.         ('SortAsc', '_primitive'),
  282.         ('Action', '_enum')]
  283.  
  284.  
  285. class MessageRenderingInfoNew(MessageRenderingInfo):
  286.     _fields_ = [
  287.         ('MessageId', '_string'),
  288.         ('FolderId', '_string'),
  289.         ('OpenMessageBody', '_primitive'),
  290.         ('AllowUnsafeContent', '_primitive'),
  291.         ('OverrideCodepage', '_primitive'),
  292.         ('UnknownArgument', '_primitive'),
  293.         ('HmAuxData', 'HmAuxData'),
  294.         ('SortKey', '_enum'),
  295.         ('SortAsc', '_primitive'),
  296.         ('Action', '_enum'),
  297.         ('UnknownArgument2', '_primitive')]
  298.  
  299.  
  300. class MessageListRenderingInfo(FppClass):
  301.     _fields_ = [
  302.         ('FolderId', '_string'),
  303.         ('PageSize', '_primitive'),
  304.         ('PageDirection', '_enum'),
  305.         ('PageSkip', '_primitive'),
  306.         ('SortKey', '_enum'),
  307.         ('SortAsc', '_primitive'),
  308.         ('AnchorMessageId', '_string'),
  309.         ('AnchorMessageDate', '_string'),
  310.         ('PageNumCurrent', '_primitive'),
  311.         ('PageNumMidStart', '_primitive'),
  312.         ('IsSearchResults', '_primitive'),
  313.         ('SearchKeyword', '_string'),
  314.         ('IsRtl', '_primitive'),
  315.         ('MessageCount', '_primitive')]
  316.  
  317.  
  318. class MessageListRenderingInfoNew(MessageListRenderingInfo):
  319.     _fields_ = [
  320.         ('FolderId', '_string'),
  321.         ('PageDirection', '_enum'),
  322.         ('PageSkip', '_primitive'),
  323.         ('SortKey', '_enum'),
  324.         ('SortAsc', '_primitive'),
  325.         ('AnchorMessageId', '_string'),
  326.         ('AnchorMessageDate', '_string'),
  327.         ('PageNumCurrent', '_primitive'),
  328.         ('PageNumMidStart', '_primitive'),
  329.         ('IsSearchResults', '_primitive'),
  330.         ('SearchKeyword', '_string'),
  331.         ('UnknownArgument1', '_primitive'),
  332.         ('UnknownArgument2', '_primitive'),
  333.         ('UnknownArgument3', '_enum')]
  334.  
  335.  
  336. class HmSimpleMsg(FppClass):
  337.     _fields_ = [
  338.         ('IsBlocking', '_primitive'),
  339.         ('YesCode', '_primitive'),
  340.         ('NoCode', '_primitive'),
  341.         ('Message', '_string')]
  342.  
  343.  
  344. class __2(FppClass):
  345.     _fields_ = [
  346.         ('IsBlocking', '_primitive'),
  347.         ('YesCode', '_primitive'),
  348.         ('NoCode', '_primitive'),
  349.         ('Message', '_string')]
  350.  
  351.  
  352. class __5(FppClass):
  353.     _fields_ = [
  354.         ('ExistingContacts', '_array'),
  355.         ('PotentialContacts', '_array'),
  356.         ('HasExistingContacts', '_primitive'),
  357.         ('HasPotentialContacts', '_primitive')]
  358.  
  359.  
  360. class __0(FppClass):
  361.     _fields_ = [
  362.         ('Url', '_string'),
  363.         ('CommandCode', '_primitive'),
  364.         ('Text', '_string')]
  365.  
  366.  
  367. class __1(FppClass):
  368.     _fields_ = [
  369.         ('MessageType', '_enum'),
  370.         ('InfoCode', '_primitive'),
  371.         ('Message', '_string'),
  372.         ('ExtendedMessage', '_string'),
  373.         ('PSValue', '_string')]
  374.  
  375.  
  376. class __3(FppClass):
  377.     _fields_ = [
  378.         ('FileName', '_string'),
  379.         ('FileId', '_string'),
  380.         ('Success', '_primitive'),
  381.         ('ShowMessage', '_primitive'),
  382.         ('ErrorCode', '_primitive')]
  383.  
  384.  
  385. class ABContact(FppClass):
  386.     _fields_ = [
  387.         ('DisplayName', '_string'),
  388.         ('PreferredEmail', '_string'),
  389.         ('ContactType', '_enum'),
  390.         ('PassportName', '_string'),
  391.         ('Guid', '_string'),
  392.         ('IsMessengerUser', '_primitive'),
  393.         ('IsFavorite', '_primitive'),
  394.         ('Cid', '_string'),
  395.         ('Emails', '_array'),
  396.         ('GleamState', '_enum')]
  397.  
  398.  
  399. class ABDetailedContact(FppClass):
  400.     _fields_ = [
  401.         ('ContactType', '_enum'),
  402.         ('FirstName', '_string'),
  403.         ('LastName', '_string'),
  404.         ('PassportName', '_string'),
  405.         ('NickName', '_string'),
  406.         ('Comment', '_string'),
  407.         ('IsMessengerUser', '_primitive'),
  408.         ('IsSmtpContact', '_primitive'),
  409.         ('IsFavorite', '_primitive'),
  410.         ('Emails', '_array'),
  411.         ('Phones', '_array'),
  412.         ('Locations', '_array'),
  413.         ('WebSites', '_array'),
  414.         ('Dates', '_array'),
  415.         ('Guid', '_string'),
  416.         ('Cid', '_string')]
  417.  
  418.  
  419. class ABGroup(FppClass):
  420.     _fields_ = [
  421.         ('Guid', '_string'),
  422.         ('QuickName', '_string')]
  423.  
  424.  
  425. class ABDetailedGroup(FppClass):
  426.     _fields_ = [
  427.         ('Guid', '_string'),
  428.         ('QuickName', '_string'),
  429.         ('Count', '_primitive')]
  430.  
  431.  
  432. class __4(FppClass):
  433.     _fields_ = [
  434.         ('Groups', '_array'),
  435.         ('Contacts', '_array'),
  436.         ('FileAs', '_enum'),
  437.         ('SelectedGuid', '_string'),
  438.         ('SelectedGroup', 'ABDetailedGroup'),
  439.         ('SelectedContact', 'ABDetailedContact'),
  440.         ('HasSelectedGuid', '_primitive'),
  441.         ('HasSelectedGroup', '_primitive')]
  442.  
  443.  
  444. class ABEmail(FppClass):
  445.     _fields_ = [
  446.         ('Type', '_enum'),
  447.         ('Email', '_string')]
  448.  
  449.  
  450. class ABPhone(FppClass):
  451.     _fields_ = [
  452.         ('Type', '_enum'),
  453.         ('Phone', '_string')]
  454.  
  455.  
  456. class ABLocation(FppClass):
  457.     _fields_ = [
  458.         ('Name', '_string'),
  459.         ('Street', '_string'),
  460.         ('City', '_string'),
  461.         ('State', '_string'),
  462.         ('Country', '_string'),
  463.         ('PostalCode', '_string')]
  464.  
  465.  
  466. class ABDate(FppClass):
  467.     _fields_ = [
  468.         ('Day', '_string'),
  469.         ('Month', '_string')]
  470.  
  471.  
  472. class ABWebSite(FppClass):
  473.     _fields_ = []
  474.  
  475.  
  476. class __6(FppClass):
  477.     _fields_ = [
  478.         ('MailboxSize', '_string'),
  479.         ('MailboxQuota', '_string')]
  480.  
  481.  
  482. class __7(FppClass):
  483.     _fields_ = [
  484.         ('FolderId', '_string'),
  485.         ('Name', '_string'),
  486.         ('Icon', '_string'),
  487.         ('UnreadMessagesCount', '_primitive'),
  488.         ('TotalMessagesCount', '_primitive'),
  489.         ('Size', '_string'),
  490.         ('IsSystem', '_primitive'),
  491.         ('IsHidden', '_primitive'),
  492.         ('FolderType', '_enum'),
  493.         ('SystemFolderType', '_enum')]
  494.  
  495.  
  496. class __8(FppClass):
  497.     _fields_ = [
  498.         ('Name', '_string'),
  499.         ('Address', '_string'),
  500.         ('EncodedName', '_string')]
  501.  
  502.  
  503. class __9(FppClass):
  504.     _fields_ = [
  505.         ('Name', '_string')]
  506.  
  507.  
  508. class __10(FppClass):
  509.     _fields_ = [
  510.         ('SenderIDResult', '_enum'),
  511.         ('SenderEmail', '__8'),
  512.         ('IsKnownSender', '_primitive'),
  513.         ('ListUnsubscribeEmail', '_string'),
  514.         ('IsSenderInContactList', '_primitive')]
  515.  
  516.  
  517. class __12(FppClass):
  518.     _fields_ = [
  519.         ('DidSenderIDPass', '_primitive'),
  520.         ('DidSenderIDFail', '_primitive'),
  521.         ('IsBlockAvailableInBL', '_primitive'),
  522.         ('IsSameDomainInBL', '_primitive'),
  523.         ('IsSafeListDomain', '_primitive'),
  524.         ('IsMailingList', '_primitive'),
  525.         ('IsSenderHeaderPresent', '_primitive'),
  526.         ('IsListUnsubscribePresent', '_primitive'),
  527.         ('IsListUnsubscribeInEmailFormat', '_primitive'),
  528.         ('HasReachedMaxFilterLimit', '_primitive'),
  529.         ('IsNeverAllowOrBlockDomain', '_primitive'),
  530.         ('IsBlockSenderException', '_primitive')]
  531.  
  532.  
  533. class __13(FppClass):
  534.     _fields_ = [
  535.         ('IsFromPRAOnBlockList', '_primitive'),
  536.         ('HasReachedSafeListLimit', '_primitive'),
  537.         ('HasEntriesFromSameDomainInSafeList', '_primitive'),
  538.         ('IsDomainSafe', '_primitive'),
  539.         ('IsSingleToAndNotRecipient', '_primitive'),
  540.         ('HasFilterToJunkToAddress', '_primitive'),
  541.         ('IsRecipientAddressRFCCompliant', '_primitive'),
  542.         ('HasReachedMailingListLimit', '_primitive'),
  543.         ('IsNeverAllowOrBlockDomain', '_primitive'),
  544.         ('IsInContacts', '_primitive')]
  545.  
  546.  
  547. class __14(FppClass):
  548.     _fields_ = [
  549.         ('Action', '_enum'),
  550.         ('Reason', '_string'),
  551.         ('CalendarEventUrl', '_string'),
  552.         ('Subject', '_string'),
  553.         ('To', '_string'),
  554.         ('Where', '_string'),
  555.         ('When', '_string')]
  556.  
  557.  
  558. class __16(FppClass):
  559.     _fields_ = [
  560.         ('Header', '__22'),
  561.         ('Body', '_string'),
  562.         ('Attachments', '_array'),
  563.         ('ToLineString', '_string'),
  564.         ('CCLineString', '_string'),
  565.         ('BccLineString', '_string'),
  566.         ('Rfc822References', '_string'),
  567.         ('Rfc822MessageId', '_string'),
  568.         ('Rfc822InReplyTo', '_string'),
  569.         ('DateSentLocal', '_string'),
  570.         ('DateReceivedLocal', '_string'),
  571.         ('SafetyLevel', '_enum'),
  572.         ('MailSenderInfo', '__10'),
  573.         ('MeetingResponseInfo', '__14'),
  574.         ('MeetingIcalId', '_string'),
  575.         ('ReplyFromAddress', '_string'),
  576.         ('HasPhishingLinks', '_primitive'),
  577.         ('IsVerifiedMail', '_primitive'),
  578.         ('AllowUnsafeContentOverride', '_primitive'),
  579.         ('UnsafeContentFiltered', '_primitive'),
  580.         ('UnsafeImagesFiltered', '_primitive'),
  581.         ('DetectedCodePages', '_array'),
  582.         ('CurrentCodePage', '_primitive'),
  583.         ('DraftId', '_string')]
  584.  
  585.  
  586. class __17(FppClass):
  587.     _fields_ = [
  588.         ('ContentType', '_string'),
  589.         ('Name', '_string'),
  590.         ('Size', '_string'),
  591.         ('BodyIndex', '_primitive'),
  592.         ('AttachmentIndex', '_primitive'),
  593.         ('ForwardId', '_string')]
  594.  
  595.  
  596. class __18(FppClass):
  597.     _fields_ = [
  598.         ('EOF', '_primitive')]
  599.  
  600.  
  601. class __19(FppClass):
  602.     _fields_ = [
  603.         ('Prefix', '_string'),
  604.         ('Text', '_string')]
  605.  
  606.  
  607. class __21(FppClass):
  608.     _fields_ = [
  609.         ('MessageId', '_string'),
  610.         ('IsRead', '_primitive'),
  611.         ('TimeStamp', '_string'),
  612.         ('IsDraft', '_primitive'),
  613.         ('CP', '_primitive'),
  614.         ('AllowUnsafeContent', '_primitive'),
  615.         ('IsVoicemail', '_primitive'),
  616.         ('IsCalllog', '_primitive'),
  617.         ('IsPrivateVoicemail', '_primitive'),
  618.         ('IsMeetingReq', '_primitive')]
  619.  
  620.  
  621. class __22(FppClass):
  622.     _fields_ = [
  623.         ('AuxData', 'HmAuxData'),
  624.         ('MessageId', '_string'),
  625.         ('OriginalMessageId', '_string'),
  626.         ('FolderId', '_string'),
  627.         ('ExtendedType', '_enum'),
  628.         ('TypeData', '_enum'),
  629.         ('IsRead', '_primitive'),
  630.         ('PopSettingIndex', '_primitive'),
  631.         ('OriginalReplyState', '_enum'),
  632.         ('IsInWhiteList', '_primitive'),
  633.         ('SentState', '_enum'),
  634.         ('MessageSize', '_string'),
  635.         ('HasAttachments', '_primitive'),
  636.         ('From', '__8'),
  637.         ('Subject', '__19'),
  638.         ('DateReceivedUTC', '_date'),
  639.         ('DateReceived', '_date'),
  640.         ('Importance', '_enum'),
  641.         ('IsDraft', '_primitive'),
  642.         ('Marker', '__18'),
  643.         ('MessageSizeString', '_string'),
  644.         ('DateReceivedLocal', '_string'),
  645.         ('TimeStamp', '_string')]
  646.  
  647.  
  648. class BootstrapSeed(FppClass):
  649.     _fields_ = [
  650.         ('Mode', '_enum'),
  651.         ('FolderId', '_string'),
  652.         ('messageId', '_string'),
  653.         ('count', '_primitive'),
  654.         ('ascendingOrder', '_primitive'),
  655.         ('pageSize', '_primitive'),
  656.         ('totalMessages', '_primitive'),
  657.         ('renderHtml', '_primitive'),
  658.         ('returnHeaders', '_primitive'),
  659.         ('sortBy', '_enum')]
  660.  
  661.  
  662. class __23(FppClass):
  663.     _fields_ = [
  664.         ('User', '_string'),
  665.         ('UserName', '_string'),
  666.         ('Timestamp', '_string'),
  667.         ('Configuration', '__26'),
  668.         ('Folders', '_array'),
  669.         ('MessageInfo', '__24'),
  670.         ('TodayPage', '_string')]
  671.  
  672.  
  673. class __24(FppClass):
  674.     _fields_ = [
  675.         ('MessageListHtml', '_string'),
  676.         ('Headers', '_array'),
  677.         ('HeaderTags', '_array'),
  678.         ('MessageHtml', '_string'),
  679.         ('SelectedFolderId', '_string'),
  680.         ('SelectedMessageIndex', '_primitive'),
  681.         ('IsPlainText', '_primitive'),
  682.         ('OverrideCodePage', '_primitive'),
  683.         ('AllowUnsafeContent', '_primitive')]
  684.  
  685.  
  686. class __25(FppClass):
  687.     _fields_ = [
  688.         ('Signature', '_string'),
  689.         ('FromAddresses', '_array')]
  690.  
  691.  
  692. class __26(FppClass):
  693.     _fields_ = [
  694.         ('DefaultMsgsInListView', '_primitive'),
  695.         ('KeyboardPressesDelay', '_primitive'),
  696.         ('CachePagesOfMessageHeaders', '_primitive'),
  697.         ('EnableReadingPane', '_primitive'),
  698.         ('HasAcceptedJunkReporting', '_primitive'),
  699.         ('JunkReportingUISeen', '_primitive'),
  700.         ('DefaultContactsInListview', '_primitive'),
  701.         ('SpacesContactBindingEnabled', '_primitive'),
  702.         ('DoSpellCheckAsYouType', '_primitive'),
  703.         ('SpellCheckEnabledInLocale', '_primitive'),
  704.         ('ReadingPaneConfiguration', '_enum'),
  705.         ('AutoSelectMessage', '_primitive'),
  706.         ('MinimumIntervalBetweenSpellChecks', '_primitive'),
  707.         ('UserThemeID', '_primitive'),
  708.         ('SaveSentMessages', '_primitive'),
  709.         ('BalloonTipsEnabled', '_primitive'),
  710.         ('BalloonTipUserPreference', '_primitive'),
  711.         ('IsBigInbox', '_primitive'),
  712.         ('IsAdsDown', '_primitive'),
  713.         ('ForwardingOn', '_primitive')]
  714.  
  715.  
  716. class __27(FppClass):
  717.     _fields_ = [
  718.         ('ErrorCode', '_string'),
  719.         ('Folders', '_array'),
  720.         ('Headers', '_array')]
  721.  
  722.  
  723. class FppProxy(object):
  724.     
  725.     def escape(b):
  726.         if b is None:
  727.             return b
  728.         
  729.         a = ''
  730.         
  731.         def slash_escape(m):
  732.             return '\\' + m.group(0)
  733.  
  734.         if isinstance(b, unicode):
  735.             _b = b
  736.             b = b.encode('utf-8')
  737.         
  738.         a = ''.join([
  739.             '"',
  740.             str(b),
  741.             '"'])
  742.         a = re.sub('([\\{|\\}\\[|\\]\\,\\\\:])', slash_escape, a).encode('url')
  743.         return a
  744.  
  745.     escape = staticmethod(escape)
  746.     
  747.     def objToStringImpl(a):
  748.         t = type(a)
  749.         if t is unicode:
  750.             a = a.encode('utf-8')
  751.             t = str
  752.         
  753.         if a is None:
  754.             return 'null'
  755.         elif t is str:
  756.             return FppProxy.escape(a)
  757.         elif t is list:
  758.             return FppProxy.arrayToString(a)
  759.         elif t is dict and hasattr(a, 'toString') or getattr(a, '_isFppObject', False):
  760.             return a.toString()
  761.         else:
  762.             return FppProxy.objToString(a)
  763.  
  764.     objToStringImpl = staticmethod(objToStringImpl)
  765.     
  766.     def arrayToString(a):
  767.         res = [
  768.             '[']
  769.         for x in a:
  770.             res.append(FppProxy.objToStringImpl(x))
  771.             res.append(',')
  772.         
  773.         if a:
  774.             res.pop()
  775.         
  776.         res.append(']')
  777.         return ''.join(res)
  778.  
  779.     arrayToString = staticmethod(arrayToString)
  780.     
  781.     def objToString(c):
  782.         if c is None:
  783.             return 'null'
  784.         
  785.         a = [
  786.             '{']
  787.         for name, typ in getattr(c, '_fields_'):
  788.             a.append(FppProxy.objToStringImpl(getattr(c, name)))
  789.             a.append(',')
  790.         
  791.         a[-1] = '}'
  792.         return ''.join(a)
  793.  
  794.     objToString = staticmethod(objToString)
  795.     
  796.     def registerFppMethod(self, name, params, mn, tm, g, ns):
  797.         args = [ x.name for x in params ]
  798.         args.extend(('cb', 'ctx', 'cbError'))
  799.         args_str = ', '.join(args)
  800.         dynamic = [
  801.             'def %s(%s):\n' % (name, args_str)]
  802.         
  803.         def fppmethod(*args):
  804.             vals = dict(zip((lambda .0: for p in .0:
  805. p.name)(params), args))
  806.             cb = None
  807.             ctx = None
  808.             cbError = None
  809.             for remaining in args[len(vals):]:
  810.                 if cb is None:
  811.                     cb = remaining
  812.                     continue
  813.                 
  814.                 if ctx is None:
  815.                     ctx = remaining
  816.                     continue
  817.                 
  818.                 if cbError is None:
  819.                     cbError = remaining
  820.                     continue
  821.                     continue
  822.             
  823.             f = self.Network.createFppMethod(ns, mn, cb, cbError)
  824.             for param in params:
  825.                 f.addParameter(param.type, vals[param.name])
  826.             
  827.             f.invoke(ctx)
  828.  
  829.         fppmethod.__name__ == name
  830.         setattr(self, name, fppmethod)
  831.  
  832.  
  833.  
  834. class Network_Type(object):
  835.     configuration = None
  836.     
  837.     def __init__(self, b, opener = None):
  838.         self._isIE = False
  839.         self._isMoz = True
  840.         self._requests = []
  841.         self.configuration = b
  842.         self.opener = opener
  843.  
  844.     
  845.     def set_base_url(self, baseurl):
  846.         self.base_url = baseurl
  847.  
  848.     
  849.     def createFppMethod(self, className, methodName, cb, cbError):
  850.         a = getattr(self, '_fppPrevious', None)
  851.         if a is not None and a._request is not None:
  852.             a._request.abort()
  853.         
  854.         fm = FppMethod(className, methodName, cb, cbError)
  855.         fm.Network = self
  856.         self._fppPrevious = fm
  857.         return fm
  858.  
  859.     
  860.     def createRequest(self, url, callback, verb):
  861.         return HM_Request(url, callback, self, self.opener, verb)
  862.  
  863.     
  864.     def process_response(self, resp, callback):
  865.         data = resp.read()
  866.         log.info('Processing hotmail response: %r', data)
  867.         if resp.code // 100 != 2:
  868.             e = Exception('%r was not successful (code = %r)', resp, resp.code)
  869.             log.info('%r', e)
  870.             return callback.error(e)
  871.         
  872.         match = re.search('new HM\\.FppReturnPackage\\((\\S+?),', data)
  873.         if match is None:
  874.             e = Exception('Response has unknown status code: %r', data)
  875.             log.info('%r', e)
  876.             return callback.error(e)
  877.         
  878.         status = match.group(1)
  879.         log.info('Got status code %r for hotmail request. data was: %r', status, data)
  880.         
  881.         try:
  882.             status = int(status)
  883.         except (ValueError, TypeError):
  884.             e = Exception("Status code could not be int()'d. it was %r (the whole response was %r)", status, data)
  885.             log.info('%r', e)
  886.             return callback.error(e)
  887.  
  888.         if status != 0:
  889.             e = Exception("Got a non-zero status code (%r). Here's the whole response: %r", status, data)
  890.             log.info('%r', e)
  891.             return callback.error(e)
  892.         
  893.         return callback.success(data)
  894.  
  895.     process_response = util.callsback(process_response)
  896.  
  897.  
  898. class HM_Request(object):
  899.     
  900.     def __init__(self, url, cb, network, opener, verb = None):
  901.         self.url = url
  902.         self.callback = cb
  903.         if not verb:
  904.             pass
  905.         self.verb = 'GET'
  906.         self.postString = None
  907.         self.context = None
  908.         self.headers = { }
  909.         self.opener = weakref.ref(opener)
  910.         self.network = network
  911.  
  912.     
  913.     def send(self, context):
  914.         self.context = context
  915.         r = asynchttp.HTTPRequest(self.url, self.postString, self.headers, method = self.verb)
  916.         cbargs = dict(success = self.on_response, error = self.on_error)
  917.         if self.opener is None:
  918.             asynchttp.httpopen(r, **cbargs)
  919.         else:
  920.             opener = self.opener()
  921.             if opener is None:
  922.                 log.info("weakref'd opener is gone, not doing request %r", self.url)
  923.                 return None
  924.             
  925.             (None, util.threaded)((lambda : opener.open(r)))(**cbargs)
  926.  
  927.     
  928.     def on_response(self, resp = None):
  929.         network = getattr(self, 'network', None)
  930.         if network is not None:
  931.             log.info('Got response for %r: %r', self, resp)
  932.             self.network.process_response(resp, callback = self.callback)
  933.             self.abort()
  934.         else:
  935.             log.warning('This request (%r) already got response, so not doing anything with this response: %r', self, resp)
  936.  
  937.     
  938.     def on_error(self, e = None):
  939.         log.error('Error in hotmail request: %r', e)
  940.         self.callback.error(e)
  941.         self.abort()
  942.  
  943.     
  944.     def abort(self):
  945.         self.__dict__.clear()
  946.         self.__getattr__ = Null
  947.  
  948.  
  949.  
  950. class FPPConfig(object):
  951.     RequestHandler = 'mail.fpp'
  952.     FppVersion = '1'
  953.     SessionId = ''
  954.     AuthUser = ''
  955.     CanaryToken = 'mt'
  956.     Version = '1'
  957.     PartnerID = ''
  958.     
  959.     def __init__(self, hotmail):
  960.         self.hotmail = weakref.ref(hotmail)
  961.  
  962.     
  963.     def CanaryValue(self):
  964.         hm = self.hotmail()
  965.         if hm is None:
  966.             return None
  967.         
  968.         return hm.get_cookie(self.CanaryToken, domain = '.mail.live.com')
  969.  
  970.     CanaryValue = property(CanaryValue)
  971.  
  972.  
  973. class PageInfo(object):
  974.     fppCfg = None
  975.     SELF_PATH = '/mail/InboxLight.aspx'
  976.     queryString = {
  977.         'nonce': '2122195423' }
  978.  
  979.  
  980. class FppMethod(object):
  981.     _HTTP_HEADERS = {
  982.         'X-FPP-Command': '0',
  983.         'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }
  984.     
  985.     def __init__(self, className, methodName, cb, cbError):
  986.         self.className = className
  987.         self.methodName = methodName
  988.         self.callback = cb
  989.         self.callbackError = cbError
  990.         self.context = None
  991.         self._request = None
  992.         self._isInvoked = False
  993.         self._params = []
  994.  
  995.     
  996.     def addParameter(self, a, b):
  997.         self._params.append({
  998.             'fppType': a,
  999.             'value': b })
  1000.  
  1001.     
  1002.     def invoke(self, context):
  1003.         self.context = context
  1004.         if not self.Network.configuration:
  1005.             raise Exception('Network is not configured')
  1006.         
  1007.         if self._isInvoked:
  1008.             raise Exception('FppMethod %r already used', self)
  1009.         
  1010.         self._isInvoked = True
  1011.         h = None
  1012.         i = None
  1013.         l = None
  1014.         g = ''
  1015.         a = self.Network.configuration
  1016.         e = self._params
  1017.         f = len(e)
  1018.         if f > 0:
  1019.             d = []
  1020.             j = TypeSystem.escape
  1021.             for c in e:
  1022.                 d.append(j({
  1023.                     'type': c['fppType'],
  1024.                     'value': c['value'] }))
  1025.                 d.append(',')
  1026.             
  1027.             g = ''.join(d[:-1])
  1028.         
  1029.         if not a.PartnerID:
  1030.             pass
  1031.         i = ''.join((util.httpjoin(self.Network.base_url, a.RequestHandler), '?cnmn=', self.className, '.', self.methodName, '&a=', a.SessionId.encode('url'), '&au=', a.AuthUser, '&ptid=', '0'))
  1032.         h = ''.join(map(str, ('cn=', self.className, '&mn=', self.methodName, '&d=', g, '&v=', a.FppVersion, '&', a.CanaryToken, '=', a.CanaryValue)))
  1033.         
  1034.         def clear_request(resp):
  1035.             self._request = None
  1036.             self._isInvoked = False
  1037.  
  1038.         self.callback.error.append(clear_request)
  1039.         self.callback.success.append(clear_request)
  1040.         b.headers = self._HTTP_HEADERS
  1041.         b.postString = h
  1042.         b.send(self)
  1043.         del self.Network
  1044.         del self._params
  1045.  
  1046.  
  1047.  
  1048. class HM_Type(FppProxy):
  1049.     namespace = 'HM'
  1050.     SortBy = FlagsCreate('Sender', 0, 'Subject', 1, 'Size', 2, 'Type', 3, 'Date', 4)
  1051.     FppStatus = FlagsCreate('SUCCESS', 0, 'ERR_HTTP_MISCONFIGURATION', -7, 'ERR_HTTP_PARSE_FAILURE', -6, 'ERR_HTTP_CONNECT_FAILURE', -5, 'ERR_HTTP_TIMEOUT', -4, 'ERR_SERVER_UNCAUGHT', -3, 'ERR_APP_SPECIFIC', -2, 'ERR_FPP_PROTOCOL', -1)
  1052.     ListNavigateDirection = FlagsCreate('FirstPage', 0, 'LastPage', 1, 'NextPage', 2, 'PreviousPage', 3, 'CurrentPage', 4)
  1053.     JmrType = FlagsCreate('Junk', 0, 'NotJunk', 1, 'AV', 2, 'SVMOptInOptOut', 3, 'SVMClassification', 4, 'Phish', 5, 'Unsubscribe', 6, 'Unknown', -1)
  1054.     ReadMessageOperation = FlagsCreate('GetMessage', 0, 'NextMessage', 1, 'PreviousMessage', 2, 'MarkAsNotJunk', 3, 'Unsubscribe', 4, 'AddContact', 5, 'None', 6)
  1055.     __11 = FlagsCreate('Passed', 0, 'Failed', 1, 'Unknown', 2, 'SoftFail', 3)
  1056.     __15 = FlagsCreate('Ok', 0, 'OverQuota', 1, 'DoesntExist', 2, 'Error', 3, 'AccountDoesntExist', 4, 'AccountError', 5)
  1057.     __20 = FlagsCreate('Unknown', 0, 'MakeLiveContact', 1, 'AddLiveContact', 2, 'DontShow', 3)
  1058.     
  1059.     def __init__(self, network):
  1060.         self.Network = network
  1061.         self._init_methods()
  1062.  
  1063.     
  1064.     def set_base_url(self, hostname):
  1065.         self.base_url = 'http://%s/mail/' % hostname
  1066.         self.Network.set_base_url(self.base_url)
  1067.  
  1068.     
  1069.     def _init_methods(self):
  1070.         self.registerFppMethod('GetInboxData', [
  1071.             _primitive('fetchFolderList'),
  1072.             _primitive('fetchMessageList'),
  1073.             _custom('messageListRenderingInfo'),
  1074.             _primitive('fetchMessage'),
  1075.             _custom('messageRenderingInfo')], 'GetInboxData', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1076.         self.registerFppMethod('ClearFolder', [
  1077.             _string('clearFolderId'),
  1078.             _custom('messageListRenderingInfo')], 'ClearFolder', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1079.         self.registerFppMethod('MoveMessagesToFolder', [
  1080.             _string('fromFolderId'),
  1081.             _string('toFolderId'),
  1082.             _array('messageList'),
  1083.             _array('messageAuxData'),
  1084.             _custom('messageListRenderingInfo'),
  1085.             _custom('messageRenderingInfo')], 'MoveMessagesToFolder', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1086.         self.registerFppMethod('MoveMessagesToFolderNew', [
  1087.             _string('fromFolderId'),
  1088.             _string('toFolderId'),
  1089.             _array('messageList'),
  1090.             _array('messageAuxData'),
  1091.             _custom('messageListRenderingInfo')], 'MoveMessagesToFolder', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1092.         self.registerFppMethod('MarkMessagesForJmr', [
  1093.             _string('folderId'),
  1094.             _array('messages'),
  1095.             _array('auxData'),
  1096.             _enum('jmrType'),
  1097.             _primitive('reportToJunk'),
  1098.             _custom('messageListRenderingInfo'),
  1099.             _custom('messageRenderingInfo')], 'MarkMessagesForJmr', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1100.         self.registerFppMethod('ReportError', [
  1101.             _string('message')], 'ReportError', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1102.         self.registerFppMethod('AddContactFromMessage', [
  1103.             _custom('messageRenderingInfo'),
  1104.             _string('contactName'),
  1105.             _string('contactEmail')], 'AddContactFromMessage', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1106.         self.registerFppMethod('SvmFeedback', [
  1107.             _string('svmUrl'),
  1108.             _custom('messageRenderingInfo'),
  1109.             _custom('messageListRenderingInfo')], 'SvmFeedback', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1110.         self.registerFppMethod('MarkMessagesReadState', [
  1111.             _primitive('readState'),
  1112.             _array('messages'),
  1113.             _custom('messageListRenderingInfo')], 'MarkMessagesReadState', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1114.         self.registerFppMethod('SendMessage_ec', [
  1115.             _string('to'),
  1116.             _string('from'),
  1117.             _string('cc'),
  1118.             _string('bcc'),
  1119.             _enum('priority'),
  1120.             _string('subject'),
  1121.             _string('message'),
  1122.             _array('attachments'),
  1123.             _string('draftId'),
  1124.             _string('draftFolderId'),
  1125.             _string('originalMessageId'),
  1126.             _string('rfc822MessageId'),
  1127.             _string('rfc822References'),
  1128.             _string('rfc822InReplyTo'),
  1129.             _enum('sentState'),
  1130.             _primitive('sendByPlainTextFormat'),
  1131.             _array('ignoredWordsFromSpellCheck'),
  1132.             _string('hipAnswer'),
  1133.             _string('hipMode'),
  1134.             _string('meetingIcalId')], 'SendMessage_ec', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox')
  1135.  
  1136.  
  1137.  
  1138. def doAction(actionName, f):
  1139.     a = InboxPage.getSelectedMessageData(true)
  1140.     if actionName == 'MarkAsJunk':
  1141.         MarkAsJunk(a.mids, a.mads, InboxPage.folderList.fid)
  1142.     elif actionName == 'DeleteMessages':
  1143.         Messages_remove(a.mids, a.mads)
  1144.     
  1145.  
  1146.  
  1147. def Messages_remove(messageList, messageAuxData):
  1148.     Messages_move(messageList, messageAuxData, InboxPage.folderList.fid, App.config.sysFldrs.trashFid)
  1149.  
  1150.  
  1151. def Messages_move(messageList, messageAuxData, fromFolderId, toFolderId):
  1152.     messageListRenderingInfo = InboxPage.createMessageListRenderingInfo(true)
  1153.     messageRenderingInfo = None if InboxPage.isReadMessageMode else null
  1154.     HM.MoveMessagesToFolder(fromFolderId, toFolderId, messageList, messageAuxData, messageListRenderingInfo, messageRenderingInfo, InboxServices__endUpdateUi)
  1155.  
  1156.  
  1157. def MarkAsJunk(messageIds, messageAuxData, folderid):
  1158.     messageListRenderingInfo = InboxPage.createMessageListRenderingInfo(true)
  1159.     messageRenderingInfo = None if InboxPage.isReadMessageMode else null
  1160.     HM.MarkMessagesForJmr(messageIds, messageAuxData, folderId, App.config.allowReporting, HM.JmrType.Junk, messageListRenderingInfo, messageRenderingInfo, InboxServices._endSetJunkStatus, {
  1161.         'jmrType': a })
  1162.  
  1163.  
  1164. def InboxPage_getSelectedMessageData(b):
  1165.     if InboxPage.isReadMessageMode:
  1166.         d = [
  1167.             InboxPage.readingPane.mid]
  1168.         e = HM.HmAuxData(Value = a)
  1169.         c = [
  1170.             e]
  1171.         return {
  1172.             'mids': d,
  1173.             'mads': c }
  1174.     
  1175.     a = InboxPage.messageList.getSelectedMessageData()
  1176.     if b and 0 == a.mids.length:
  1177.         alert(compatibleDecode(Res.strings.noMessagesSelected))
  1178.     
  1179.     return a
  1180.  
  1181.  
  1182. def get_classname(js):
  1183.     return re.search('HM\\.registerFppClass\\("(.+?)",', js).group(1)
  1184.  
  1185.  
  1186. def get_fields(js):
  1187.     fields_re = re.compile('Web\\.Network\\.FppProxy\\._(_(?:.+?))\\("(.+?)"\\),')
  1188.     return [ x[::-1] for x in fields_re.findall(js) ]
  1189.  
  1190.  
  1191. def fppclass_to_python(js):
  1192.     pformat = pformat
  1193.     import pprint
  1194.     cname = get_classname(js)
  1195.     fields = get_fields(js)
  1196.     return 'class %s(FppClass):\n    _fields_ = %s\n' % (cname, pformat(fields))
  1197.  
  1198.  
  1199. def main():
  1200.     print str(HmAuxData('10\\|0\\|8CA6DDB632DFE40\\|', null))
  1201.  
  1202.  
  1203. def main2():
  1204.     testapp = testapp
  1205.     import tests.testapp
  1206.     a = testapp()
  1207.     Page = PageInfo()
  1208.     Page.fppCfg = FPPConfig(None)
  1209.     Network = Network_Type(Page.fppCfg)
  1210.     HM = HM_Type(Network)
  1211.     
  1212.     def doit(callback = (None,)):
  1213.         HM.GetInboxData(True, True, None, True, None, Null, None, None)
  1214.  
  1215.     doit = util.callsback(doit)
  1216.     
  1217.     def success(resp):
  1218.         print 'success', resp
  1219.  
  1220.     
  1221.     def error(e):
  1222.         print 'error', e
  1223.  
  1224.     doit(success = success, error = error)
  1225.  
  1226. if __name__ == '__main__':
  1227.     main()
  1228.  
  1229.