home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 February / maximum-cd-2011-02.iso / DiscContents / digsby_setup85.exe / lib / mail / hotmail / ajax.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-11-24  |  81.5 KB  |  1,725 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. import random
  5. import logging
  6. import digsbysite
  7. import common.asynchttp as asynchttp
  8. import re
  9. import util
  10. import util.net as net
  11. import util.primitives.funcs as funcs
  12. import util.callbacks as callbacks
  13. import weakref
  14. import uuid
  15.  
  16. def ntok():
  17.     return str(random.randint(0, 2147483647))
  18.  
  19. log = logging.getLogger('hotmail.ajax')
  20.  
  21. def Flags(*args):
  22.     return util.Storage(zip(args[::2], args[1::2]))
  23.  
  24. XMLPost = 0
  25. null = None
  26. import collections
  27. _versioned_classes = collections.defaultdict(dict)
  28.  
  29. def ForBuild(buildnum, clsname = None):
  30.     
  31.     def decorator(cls):
  32.         if not clsname:
  33.             pass
  34.         _versioned_classes[cls.__name__][buildnum] = cls
  35.         return cls
  36.  
  37.     return decorator
  38.  
  39.  
  40. class FppParamType(object):
  41.     String = ('_string',)
  42.     Date = ('_date',)
  43.     Array = ('_array',)
  44.     oArray = ('_oArray',)
  45.     Primitive = ('_primitive',)
  46.     Object = ('_object',)
  47.     Enum = ('_enum',)
  48.     Custom = '_custom'
  49.  
  50.  
  51. class TypeSystem(object):
  52.     _isFppObject = True
  53.     _default = None
  54.     
  55.     def __init__(self, name_or_type, name = None, val = None):
  56.         if name is not None:
  57.             type = name_or_type
  58.             name = name
  59.         else:
  60.             type = FppParamType.Custom
  61.             name = name_or_type
  62.         self.name = name
  63.         self.type = type
  64.         self.value = val
  65.  
  66.     
  67.     def escape(instance):
  68.         f = {
  69.             '_string': FppProxy.escape,
  70.             '_date': (lambda a: a),
  71.             '_array': FppProxy.arrayToString,
  72.             '_oArray': FppProxy.objToStringImpl,
  73.             '_object': FppProxy.objToStringImpl,
  74.             '_primitive': FppProxy.primitiveToString,
  75.             '_enum': (lambda a: str(a)) }.get(funcs.get(instance, 'type', None), FppProxy.objToString)
  76.         escaped_val = f(funcs.get(instance, 'value', None))
  77.         if escaped_val is None:
  78.             return 'null'
  79.         return escaped_val
  80.  
  81.     escape = staticmethod(escape)
  82.     
  83.     def __str__(self):
  84.         return '<TypeSystem %r>' % self.name
  85.  
  86.     
  87.     def toString(self):
  88.         return TypeSystem.escape(self)
  89.  
  90.     
  91.     def default(cls):
  92.         x = cls('')
  93.         if cls._default is None:
  94.             x.value = None
  95.         else:
  96.             x.value = type(cls._default)(cls._default)
  97.         return x
  98.  
  99.     default = classmethod(default)
  100.  
  101.  
  102. class NamedTypeSystem(TypeSystem):
  103.     
  104.     def __init__(self, name, val = None):
  105.         TypeSystem.__init__(self, type(self).__name__, name, val)
  106.  
  107.  
  108.  
  109. class _string(NamedTypeSystem):
  110.     _default = ''
  111.  
  112.  
  113. class _array(NamedTypeSystem):
  114.     _default = []
  115.  
  116.  
  117. class _enum(NamedTypeSystem):
  118.     _default = 0
  119.  
  120.  
  121. class _primitive(NamedTypeSystem):
  122.     _default = False
  123.  
  124.  
  125. class _oArray(NamedTypeSystem):
  126.     _default = { }
  127.  
  128.  
  129. class _object(NamedTypeSystem):
  130.     _default = { }
  131.  
  132. _custom = TypeSystem
  133.  
  134. class FppProperty(object):
  135.     
  136.     def __init__(self, name, typ, default = Sentinel):
  137.         self._name = name
  138.         self._type = typ
  139.         if default is not Sentinel:
  140.             self._default = FppMetaclass._classes[self._type](name)
  141.             self._default.value = default
  142.         
  143.  
  144.     
  145.     def __get__(self, obj, objtype):
  146.         default = getattr(self, '_default', FppMetaclass._classes[self._type].default())
  147.         if obj is None:
  148.             return default
  149.         if not hasattr(obj, '_field_%s' % self._name):
  150.             setattr(obj, '_field_%s' % self._name, default)
  151.         
  152.         val = getattr(obj, '_field_%s' % self._name)
  153.         if getattr(val, 'type', None) != self._type:
  154.             if val is None or val._isFppObject:
  155.                 return val
  156.             raise ValueError('%r has an invalid %r (with type = %r, value = %r)', obj, self._name, val.type, val.value)
  157.         getattr(val, 'type', None) != self._type
  158.         return val
  159.  
  160.     
  161.     def __set__(self, obj, val):
  162.         if (val is not None or getattr(val, 'value', None) is not None) and hasattr(val, 'type'):
  163.             if val.type != self._type:
  164.                 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)
  165.             val.type != self._type
  166.         elif val is None or getattr(val, '_isFppObject', False):
  167.             pass
  168.         else:
  169.             x = FppMetaclass._classes[self._type].default()
  170.             x.value = val
  171.             val = x
  172.         setattr(obj, '_field_%s' % self._name, val)
  173.  
  174.  
  175.  
  176. class FppMetaclass(type):
  177.     _classes = {
  178.         '_enum': _enum,
  179.         '_string': _string,
  180.         '_array': _array,
  181.         '_primitive': _primitive,
  182.         '_object': _object,
  183.         '_oArray': _oArray,
  184.         '_custom': TypeSystem }
  185.     
  186.     def __init__(cls, name, bases, dict):
  187.         for field in cls._fields_:
  188.             setattr(cls, field[0], FppProperty(*field))
  189.         
  190.         
  191.         def default(_cls):
  192.             i = cls()
  193.             for _field in i._fields_:
  194.                 if len(_field) == 2:
  195.                     _default = FppMetaclass._classes[_field[1]].default()
  196.                 elif len(_field) == 3:
  197.                     if _field[2] is None:
  198.                         _default = None
  199.                     else:
  200.                         _default = FppMetaclass._classes[_field[1]](_field[2])
  201.                 
  202.                 setattr(i, _field[0], _default)
  203.             
  204.             return i
  205.  
  206.         default = (classmethod,)(default)
  207.         dict['default'] = default
  208.         FppMetaclass._classes[name] = cls
  209.         cls.default = default
  210.         cls._isFppObject = True
  211.         type.__init__(cls, name, bases, dict)
  212.  
  213.  
  214.  
  215. class FppClass(object):
  216.     _fields_ = []
  217.     __metaclass__ = FppMetaclass
  218.     
  219.     def __init__(self, *args, **kwds):
  220.         fieldnames = []
  221.         for field in self._fields_:
  222.             if len(field) == 3:
  223.                 setattr(self, field[0], field[2])
  224.             else:
  225.                 setattr(self, field[0], FppMetaclass._classes[field[1]].default())
  226.             fieldnames.append(field[0])
  227.         
  228.         for i in range(len(args)):
  229.             setattr(self, self._fields_[i][0], args[i])
  230.         
  231.         for key in kwds:
  232.             setattr(self, key, kwds[key])
  233.         
  234.  
  235.     
  236.     def __str__(self):
  237.         res = [
  238.             '{']
  239.         for field in self._fields_:
  240.             cls = FppMetaclass._classes[field[1]]
  241.             val = getattr(self, field[0])
  242.             if val is None:
  243.                 res.append('null')
  244.             else:
  245.                 res.append(cls.escape(val))
  246.             res.append(',')
  247.         
  248.         if res[-1] == ',':
  249.             res.pop(-1)
  250.         
  251.         res.append('}')
  252.         return ''.join(res)
  253.  
  254.     toString = escape = __str__
  255.     
  256.     def __repr__(self):
  257.         return '<%s %s>' % (type(self).__name__, (' '.join,)((lambda .0: for entry in .0:
  258. '%s=%r' % (entry[0], getattr(self, entry[0], None)))(self._fields_)))
  259.  
  260.  
  261.  
  262. class FppError(FppClass):
  263.     _fields_ = [
  264.         ('ErrorCode', '_string'),
  265.         ('Message', '_string'),
  266.         ('ErrorObj', '_object'),
  267.         ('StackTrace', '_string')]
  268.  
  269.  
  270. class FppReturnPackage(FppClass):
  271.     _fields_ = [
  272.         ('Status', '_enum'),
  273.         ('Value', '_object'),
  274.         ('OutRefParams', '_oArray'),
  275.         ('Error', 'FppError'),
  276.         ('ProfilingInfo', '_object')]
  277.  
  278. InboxUiData = ForBuild('1')(<NODE:12>)
  279. InboxUiData = ForBuild('13.3.3227.0707')(<NODE:12>)
  280. InboxUiData = ForBuild('15.3.2495.0616')(<NODE:12>)
  281.  
  282. class HmCandidacyInfo(FppClass):
  283.     _fields_ = [
  284.         ('Status', '_enum'),
  285.         ('Guid', '_string'),
  286.         ('ShowMakeLiveContact', '_enum')]
  287.  
  288. HmAuxData = ForBuild('1')(<NODE:12>)
  289. HmAuxData = ForBuild('15.1.3020.0910')(<NODE:12>)
  290. MessageRenderingInfo = ForBuild('1')(<NODE:12>)
  291. MessageRenderingInfo = ForBuild('13.3.3227.0707')(<NODE:12>)
  292. MessageRenderingInfo = ForBuild('15.3.2495.0616')(<NODE:12>)
  293. AdvancedSearch = ForBuild('15.3.2495.0616')(<NODE:12>)
  294. MessageListRenderingInfo = ForBuild('1')(<NODE:12>)
  295. MessageListRenderingInfo = ForBuild('13.3.3227.0707')(<NODE:12>)
  296. MessageListRenderingInfo = ForBuild('15.3.2495.0616')(<NODE:12>)
  297. MessageListRenderingInfo = ForBuild('15.4.0317.0921')(<NODE:12>)
  298.  
  299. class HmSimpleMsg(FppClass):
  300.     _fields_ = [
  301.         ('IsBlocking', '_primitive'),
  302.         ('YesCode', '_primitive'),
  303.         ('NoCode', '_primitive'),
  304.         ('Message', '_string')]
  305.  
  306.  
  307. class __2(FppClass):
  308.     _fields_ = [
  309.         ('IsBlocking', '_primitive'),
  310.         ('YesCode', '_primitive'),
  311.         ('NoCode', '_primitive'),
  312.         ('Message', '_string')]
  313.  
  314.  
  315. class __5(FppClass):
  316.     _fields_ = [
  317.         ('ExistingContacts', '_array'),
  318.         ('PotentialContacts', '_array'),
  319.         ('HasExistingContacts', '_primitive'),
  320.         ('HasPotentialContacts', '_primitive')]
  321.  
  322.  
  323. class __0(FppClass):
  324.     _fields_ = [
  325.         ('Url', '_string'),
  326.         ('CommandCode', '_primitive'),
  327.         ('Text', '_string')]
  328.  
  329.  
  330. class __1(FppClass):
  331.     _fields_ = [
  332.         ('MessageType', '_enum'),
  333.         ('InfoCode', '_primitive'),
  334.         ('Message', '_string'),
  335.         ('ExtendedMessage', '_string'),
  336.         ('PSValue', '_string')]
  337.  
  338.  
  339. class __3(FppClass):
  340.     _fields_ = [
  341.         ('FileName', '_string'),
  342.         ('FileId', '_string'),
  343.         ('Success', '_primitive'),
  344.         ('ShowMessage', '_primitive'),
  345.         ('ErrorCode', '_primitive')]
  346.  
  347.  
  348. class ABContact(FppClass):
  349.     _fields_ = [
  350.         ('DisplayName', '_string'),
  351.         ('PreferredEmail', '_string'),
  352.         ('ContactType', '_enum'),
  353.         ('PassportName', '_string'),
  354.         ('Guid', '_string'),
  355.         ('IsMessengerUser', '_primitive'),
  356.         ('IsFavorite', '_primitive'),
  357.         ('Cid', '_string'),
  358.         ('Emails', '_array'),
  359.         ('GleamState', '_enum')]
  360.  
  361.  
  362. class ABDetailedContact(FppClass):
  363.     _fields_ = [
  364.         ('ContactType', '_enum'),
  365.         ('FirstName', '_string'),
  366.         ('LastName', '_string'),
  367.         ('PassportName', '_string'),
  368.         ('NickName', '_string'),
  369.         ('Comment', '_string'),
  370.         ('IsMessengerUser', '_primitive'),
  371.         ('IsSmtpContact', '_primitive'),
  372.         ('IsFavorite', '_primitive'),
  373.         ('Emails', '_array'),
  374.         ('Phones', '_array'),
  375.         ('Locations', '_array'),
  376.         ('WebSites', '_array'),
  377.         ('Dates', '_array'),
  378.         ('Guid', '_string'),
  379.         ('Cid', '_string')]
  380.  
  381.  
  382. class ABGroup(FppClass):
  383.     _fields_ = [
  384.         ('Guid', '_string'),
  385.         ('QuickName', '_string')]
  386.  
  387.  
  388. class ABDetailedGroup(FppClass):
  389.     _fields_ = [
  390.         ('Guid', '_string'),
  391.         ('QuickName', '_string'),
  392.         ('Count', '_primitive')]
  393.  
  394.  
  395. class __4(FppClass):
  396.     _fields_ = [
  397.         ('Groups', '_array'),
  398.         ('Contacts', '_array'),
  399.         ('FileAs', '_enum'),
  400.         ('SelectedGuid', '_string'),
  401.         ('SelectedGroup', 'ABDetailedGroup'),
  402.         ('SelectedContact', 'ABDetailedContact'),
  403.         ('HasSelectedGuid', '_primitive'),
  404.         ('HasSelectedGroup', '_primitive')]
  405.  
  406.  
  407. class ABEmail(FppClass):
  408.     _fields_ = [
  409.         ('Type', '_enum'),
  410.         ('Email', '_string')]
  411.  
  412.  
  413. class ABPhone(FppClass):
  414.     _fields_ = [
  415.         ('Type', '_enum'),
  416.         ('Phone', '_string')]
  417.  
  418.  
  419. class ABLocation(FppClass):
  420.     _fields_ = [
  421.         ('Name', '_string'),
  422.         ('Street', '_string'),
  423.         ('City', '_string'),
  424.         ('State', '_string'),
  425.         ('Country', '_string'),
  426.         ('PostalCode', '_string')]
  427.  
  428.  
  429. class ABDate(FppClass):
  430.     _fields_ = [
  431.         ('Day', '_string'),
  432.         ('Month', '_string')]
  433.  
  434.  
  435. class ABWebSite(FppClass):
  436.     _fields_ = []
  437.  
  438.  
  439. class __6(FppClass):
  440.     _fields_ = [
  441.         ('MailboxSize', '_string'),
  442.         ('MailboxQuota', '_string')]
  443.  
  444.  
  445. class __7(FppClass):
  446.     _fields_ = [
  447.         ('FolderId', '_string'),
  448.         ('Name', '_string'),
  449.         ('Icon', '_string'),
  450.         ('UnreadMessagesCount', '_primitive'),
  451.         ('TotalMessagesCount', '_primitive'),
  452.         ('Size', '_string'),
  453.         ('IsSystem', '_primitive'),
  454.         ('IsHidden', '_primitive'),
  455.         ('FolderType', '_enum'),
  456.         ('SystemFolderType', '_enum')]
  457.  
  458.  
  459. class __8(FppClass):
  460.     _fields_ = [
  461.         ('Name', '_string'),
  462.         ('Address', '_string'),
  463.         ('EncodedName', '_string')]
  464.  
  465.  
  466. class __9(FppClass):
  467.     _fields_ = [
  468.         ('Name', '_string')]
  469.  
  470.  
  471. class __10(FppClass):
  472.     _fields_ = [
  473.         ('SenderIDResult', '_enum'),
  474.         ('SenderEmail', '__8'),
  475.         ('IsKnownSender', '_primitive'),
  476.         ('ListUnsubscribeEmail', '_string'),
  477.         ('IsSenderInContactList', '_primitive')]
  478.  
  479.  
  480. class __12(FppClass):
  481.     _fields_ = [
  482.         ('DidSenderIDPass', '_primitive'),
  483.         ('DidSenderIDFail', '_primitive'),
  484.         ('IsBlockAvailableInBL', '_primitive'),
  485.         ('IsSameDomainInBL', '_primitive'),
  486.         ('IsSafeListDomain', '_primitive'),
  487.         ('IsMailingList', '_primitive'),
  488.         ('IsSenderHeaderPresent', '_primitive'),
  489.         ('IsListUnsubscribePresent', '_primitive'),
  490.         ('IsListUnsubscribeInEmailFormat', '_primitive'),
  491.         ('HasReachedMaxFilterLimit', '_primitive'),
  492.         ('IsNeverAllowOrBlockDomain', '_primitive'),
  493.         ('IsBlockSenderException', '_primitive')]
  494.  
  495.  
  496. class __13(FppClass):
  497.     _fields_ = [
  498.         ('IsFromPRAOnBlockList', '_primitive'),
  499.         ('HasReachedSafeListLimit', '_primitive'),
  500.         ('HasEntriesFromSameDomainInSafeList', '_primitive'),
  501.         ('IsDomainSafe', '_primitive'),
  502.         ('IsSingleToAndNotRecipient', '_primitive'),
  503.         ('HasFilterToJunkToAddress', '_primitive'),
  504.         ('IsRecipientAddressRFCCompliant', '_primitive'),
  505.         ('HasReachedMailingListLimit', '_primitive'),
  506.         ('IsNeverAllowOrBlockDomain', '_primitive'),
  507.         ('IsInContacts', '_primitive')]
  508.  
  509.  
  510. class __14(FppClass):
  511.     _fields_ = [
  512.         ('Action', '_enum'),
  513.         ('Reason', '_string'),
  514.         ('CalendarEventUrl', '_string'),
  515.         ('Subject', '_string'),
  516.         ('To', '_string'),
  517.         ('Where', '_string'),
  518.         ('When', '_string')]
  519.  
  520.  
  521. class __16(FppClass):
  522.     _fields_ = [
  523.         ('Header', '__22'),
  524.         ('Body', '_string'),
  525.         ('Attachments', '_array'),
  526.         ('ToLineString', '_string'),
  527.         ('CCLineString', '_string'),
  528.         ('BccLineString', '_string'),
  529.         ('Rfc822References', '_string'),
  530.         ('Rfc822MessageId', '_string'),
  531.         ('Rfc822InReplyTo', '_string'),
  532.         ('DateSentLocal', '_string'),
  533.         ('DateReceivedLocal', '_string'),
  534.         ('SafetyLevel', '_enum'),
  535.         ('MailSenderInfo', '__10'),
  536.         ('MeetingResponseInfo', '__14'),
  537.         ('MeetingIcalId', '_string'),
  538.         ('ReplyFromAddress', '_string'),
  539.         ('HasPhishingLinks', '_primitive'),
  540.         ('IsVerifiedMail', '_primitive'),
  541.         ('AllowUnsafeContentOverride', '_primitive'),
  542.         ('UnsafeContentFiltered', '_primitive'),
  543.         ('UnsafeImagesFiltered', '_primitive'),
  544.         ('DetectedCodePages', '_array'),
  545.         ('CurrentCodePage', '_primitive'),
  546.         ('DraftId', '_string')]
  547.  
  548.  
  549. class __17(FppClass):
  550.     _fields_ = [
  551.         ('ContentType', '_string'),
  552.         ('Name', '_string'),
  553.         ('Size', '_string'),
  554.         ('BodyIndex', '_primitive'),
  555.         ('AttachmentIndex', '_primitive'),
  556.         ('ForwardId', '_string')]
  557.  
  558.  
  559. class __18(FppClass):
  560.     _fields_ = [
  561.         ('EOF', '_primitive')]
  562.  
  563.  
  564. class __19(FppClass):
  565.     _fields_ = [
  566.         ('Prefix', '_string'),
  567.         ('Text', '_string')]
  568.  
  569.  
  570. class __21(FppClass):
  571.     _fields_ = [
  572.         ('MessageId', '_string'),
  573.         ('IsRead', '_primitive'),
  574.         ('TimeStamp', '_string'),
  575.         ('IsDraft', '_primitive'),
  576.         ('CP', '_primitive'),
  577.         ('AllowUnsafeContent', '_primitive'),
  578.         ('IsVoicemail', '_primitive'),
  579.         ('IsCalllog', '_primitive'),
  580.         ('IsPrivateVoicemail', '_primitive'),
  581.         ('IsMeetingReq', '_primitive')]
  582.  
  583.  
  584. class __22(FppClass):
  585.     _fields_ = [
  586.         ('AuxData', 'HmAuxData'),
  587.         ('MessageId', '_string'),
  588.         ('OriginalMessageId', '_string'),
  589.         ('FolderId', '_string'),
  590.         ('ExtendedType', '_enum'),
  591.         ('TypeData', '_enum'),
  592.         ('IsRead', '_primitive'),
  593.         ('PopSettingIndex', '_primitive'),
  594.         ('OriginalReplyState', '_enum'),
  595.         ('IsInWhiteList', '_primitive'),
  596.         ('SentState', '_enum'),
  597.         ('MessageSize', '_string'),
  598.         ('HasAttachments', '_primitive'),
  599.         ('From', '__8'),
  600.         ('Subject', '__19'),
  601.         ('DateReceivedUTC', '_date'),
  602.         ('DateReceived', '_date'),
  603.         ('Importance', '_enum'),
  604.         ('IsDraft', '_primitive'),
  605.         ('Marker', '__18'),
  606.         ('MessageSizeString', '_string'),
  607.         ('DateReceivedLocal', '_string'),
  608.         ('TimeStamp', '_string')]
  609.  
  610.  
  611. class BootstrapSeed(FppClass):
  612.     _fields_ = [
  613.         ('Mode', '_enum'),
  614.         ('FolderId', '_string'),
  615.         ('messageId', '_string'),
  616.         ('count', '_primitive'),
  617.         ('ascendingOrder', '_primitive'),
  618.         ('pageSize', '_primitive'),
  619.         ('totalMessages', '_primitive'),
  620.         ('renderHtml', '_primitive'),
  621.         ('returnHeaders', '_primitive'),
  622.         ('sortBy', '_enum')]
  623.  
  624.  
  625. class __23(FppClass):
  626.     _fields_ = [
  627.         ('User', '_string'),
  628.         ('UserName', '_string'),
  629.         ('Timestamp', '_string'),
  630.         ('Configuration', '__26'),
  631.         ('Folders', '_array'),
  632.         ('MessageInfo', '__24'),
  633.         ('TodayPage', '_string')]
  634.  
  635.  
  636. class __24(FppClass):
  637.     _fields_ = [
  638.         ('MessageListHtml', '_string'),
  639.         ('Headers', '_array'),
  640.         ('HeaderTags', '_array'),
  641.         ('MessageHtml', '_string'),
  642.         ('SelectedFolderId', '_string'),
  643.         ('SelectedMessageIndex', '_primitive'),
  644.         ('IsPlainText', '_primitive'),
  645.         ('OverrideCodePage', '_primitive'),
  646.         ('AllowUnsafeContent', '_primitive')]
  647.  
  648.  
  649. class __25(FppClass):
  650.     _fields_ = [
  651.         ('Signature', '_string'),
  652.         ('FromAddresses', '_array')]
  653.  
  654.  
  655. class __26(FppClass):
  656.     _fields_ = [
  657.         ('DefaultMsgsInListView', '_primitive'),
  658.         ('KeyboardPressesDelay', '_primitive'),
  659.         ('CachePagesOfMessageHeaders', '_primitive'),
  660.         ('EnableReadingPane', '_primitive'),
  661.         ('HasAcceptedJunkReporting', '_primitive'),
  662.         ('JunkReportingUISeen', '_primitive'),
  663.         ('DefaultContactsInListview', '_primitive'),
  664.         ('SpacesContactBindingEnabled', '_primitive'),
  665.         ('DoSpellCheckAsYouType', '_primitive'),
  666.         ('SpellCheckEnabledInLocale', '_primitive'),
  667.         ('ReadingPaneConfiguration', '_enum'),
  668.         ('AutoSelectMessage', '_primitive'),
  669.         ('MinimumIntervalBetweenSpellChecks', '_primitive'),
  670.         ('UserThemeID', '_primitive'),
  671.         ('SaveSentMessages', '_primitive'),
  672.         ('BalloonTipsEnabled', '_primitive'),
  673.         ('BalloonTipUserPreference', '_primitive'),
  674.         ('IsBigInbox', '_primitive'),
  675.         ('IsAdsDown', '_primitive'),
  676.         ('ForwardingOn', '_primitive')]
  677.  
  678.  
  679. class __27(FppClass):
  680.     _fields_ = [
  681.         ('ErrorCode', '_string'),
  682.         ('Folders', '_array'),
  683.         ('Headers', '_array')]
  684.  
  685. BatchInfo = ForBuild('15.3.2495.0616')(<NODE:12>)
  686. ConversationRenderingInfo = ForBuild('15.3.2495.0616')(<NODE:12>)
  687. MessagePartsUiData = ForBuild('15.3.2495.0616')(<NODE:12>)
  688. HMLiveViewRequestObject = ForBuild('15.3.2495.0616')(<NODE:12>)
  689. HMLiveViewRequestObject = ForBuild('15.4.0317.0921')(<NODE:12>)
  690. HMLiveViewResponseObject = ForBuild('15.3.2495.0616')(<NODE:12>)
  691. SandboxRequest = ForBuild('15.3.2495.0616')(<NODE:12>)
  692. SandboxResponse = ForBuild('15.3.2495.0616')(<NODE:12>)
  693.  
  694. class FppProxy(object):
  695.     
  696.     def escape(b):
  697.         if b is None:
  698.             return b
  699.         a = ''
  700.         
  701.         def slash_escape(m):
  702.             return '\\' + m.group(0)
  703.  
  704.         if isinstance(b, unicode):
  705.             _b = b
  706.             b = b.encode('utf-8')
  707.         
  708.         a = ''.join([
  709.             '"',
  710.             str(b),
  711.             '"'])
  712.         a = re.sub('([\\{|\\}\\[|\\]\\,\\\\:])', slash_escape, a).encode('url')
  713.         return a
  714.  
  715.     escape = staticmethod(escape)
  716.     
  717.     def objToStringImpl(a):
  718.         t = type(a)
  719.         if t is unicode:
  720.             a = a.encode('utf-8')
  721.             t = str
  722.         
  723.         if a is None:
  724.             return 'null'
  725.         if t is str:
  726.             return FppProxy.escape(a)
  727.         if t is list:
  728.             return FppProxy.arrayToString(a)
  729.         if t is dict and hasattr(a, 'toString') or getattr(a, '_isFppObject', False):
  730.             return a.toString()
  731.         return FppProxy.objToString(a)
  732.  
  733.     objToStringImpl = staticmethod(objToStringImpl)
  734.     
  735.     def primitiveToString(a):
  736.         if a in ('', None, null, Null):
  737.             return 'null'
  738.         return str(a).lower()
  739.  
  740.     primitiveToString = staticmethod(primitiveToString)
  741.     
  742.     def arrayToString(a):
  743.         res = [
  744.             '[']
  745.         for x in a:
  746.             res.append(FppProxy.objToStringImpl(x))
  747.             res.append(',')
  748.         
  749.         if a:
  750.             res.pop()
  751.         
  752.         res.append(']')
  753.         return ''.join(res)
  754.  
  755.     arrayToString = staticmethod(arrayToString)
  756.     
  757.     def objToString(c):
  758.         if c is None:
  759.             return 'null'
  760.         a = [
  761.             '{']
  762.         for field in getattr(c, '_fields_'):
  763.             a.append(FppProxy.objToStringImpl(getattr(c, field[0])))
  764.             a.append(',')
  765.         
  766.         a[-1] = '}'
  767.         return ''.join(a)
  768.  
  769.     objToString = staticmethod(objToString)
  770.  
  771.  
  772. class Network_Type(object):
  773.     configuration = None
  774.     
  775.     def __init__(self, b, opener = None, start_config = { }):
  776.         self._isIE = False
  777.         self._isMoz = True
  778.         self._requests = []
  779.         self.configuration = b
  780.         self.opener = opener
  781.         self.configuration.__dict__.update(start_config)
  782.         self.configuration.SessionId = self.configuration.SessionId.decode('url')
  783.         self.HM = None
  784.  
  785.     
  786.     def set_HM(self, hm):
  787.         self.HM = hm
  788.  
  789.     
  790.     def set_base_url(self, baseurl):
  791.         self.base_url = baseurl
  792.  
  793.     
  794.     def createRequest(self, url, callback, verb):
  795.         return HM_Request(url, callback, self, self.opener, verb)
  796.  
  797.     
  798.     def process_response(self, resp, callback):
  799.         data = resp.read()
  800.         log.info('Processing hotmail response: %r', data)
  801.         if resp.code // 100 != 2:
  802.             e = Exception('%r was not successful (code = %r)', resp, resp.code)
  803.             log.info('%r', e)
  804.             return callback.error(e)
  805.         result = None
  806.         
  807.         try:
  808.             data = data.replace('new HM.', ' HM.')
  809.             _data = data
  810.             d = dict(HM = self.HM, true = True, false = False, null = None)
  811.             exec 'result = ' + data in d, d
  812.             result = d['result']
  813.         except Exception:
  814.             resp.code // 100 != 2
  815.             e = resp.code // 100 != 2
  816.             log.info('Could not process javascript response: %r', _data)
  817.             log.info('\terror was: %r', e)
  818.             data = _data
  819.             return self._process_response_re(data, callback)
  820.  
  821.         if result.Status.value == 0:
  822.             return callback.success(result.Value)
  823.         log.error("Got a non-zero status code (%r). Here's the whole response: %r", result.Status.value, _data)
  824.         return callback.error(result.Error)
  825.  
  826.     process_response = util.callsback(process_response)
  827.     
  828.     def _process_response_re(self, data, callback):
  829.         match = re.search('new HM\\.FppReturnPackage\\((\\S+?),', data)
  830.         if match is None:
  831.             e = Exception('Response has unknown status code: %r', data)
  832.             log.info('%r', e)
  833.             return callback.error(e)
  834.         status = match.group(1)
  835.         log.info('Got status code %r for hotmail request. data was: %r', status, data)
  836.         
  837.         try:
  838.             status = int(status)
  839.         except (ValueError, TypeError):
  840.             match is None
  841.             match is None
  842.             e = Exception("Status code could not be int()'d. it was %r (the whole response was %r)", status, data)
  843.             log.info('%r', e)
  844.             return callback.error(e)
  845.  
  846.         if status != 0:
  847.             e = Exception("Got a non-zero status code (%r). Here's the whole response: %r", status, data)
  848.             log.info('%r', e)
  849.             return callback.error(e)
  850.         return callback.success(data)
  851.  
  852.  
  853.  
  854. class HM_Request(object):
  855.     
  856.     def __init__(self, url, cb, network, opener, verb = None):
  857.         self.url = url
  858.         self.callback = cb
  859.         if not verb:
  860.             pass
  861.         self.verb = 'GET'
  862.         self.postString = None
  863.         self.context = None
  864.         self.headers = { }
  865.         self.opener = weakref.ref(opener)
  866.         self.network = network
  867.  
  868.     
  869.     def send(self, context):
  870.         self.context = context
  871.         r = asynchttp.HTTPRequest(self.url, self.postString, self.headers, method = self.verb, adjust_headers = False)
  872.         log.debug('opening request: method=%r url=%r post_data=%r headers=%r', self.verb, self.url, self.postString, self.headers)
  873.         cbargs = dict(success = self.on_response, error = self.on_error)
  874.  
  875.     
  876.     def on_response(self, req_or_resp = None, resp = None):
  877.         network = getattr(self, 'network', None)
  878.         if not resp:
  879.             pass
  880.         resp = req_or_resp
  881.         if network is not None:
  882.             log.info('Got response for %r: %r', self, resp)
  883.             self.network.process_response(resp, callback = self.callback)
  884.             self.abort()
  885.         else:
  886.             log.warning('This request (%r) already got response, so not doing anything with this response: %r', self, resp)
  887.  
  888.     
  889.     def on_error(self, e = None, resp = None):
  890.         log.error('Error in hotmail request: %r', e)
  891.         if not resp:
  892.             pass
  893.         self.callback.error(e)
  894.         self.abort()
  895.  
  896.     
  897.     def abort(self):
  898.         self.__dict__.clear()
  899.         self.__getattr__ = Null
  900.  
  901.     
  902.     def __repr__(self):
  903.         return '<%s %s>' % (type(self).__name__, (' '.join,)((lambda .0: for x in .0:
  904. '%s=%r' % (x, getattr(self, x)))(('verb', 'url', 'postString'))))
  905.  
  906.  
  907.  
  908. class FPPConfig(object):
  909.     RequestHandler = 'mail.fpp'
  910.     FppVersion = '1'
  911.     SessionId = ''
  912.     AuthUser = ''
  913.     CanaryToken = 'mt'
  914.     Version = '1'
  915.     PartnerID = ''
  916.     
  917.     def __init__(self, hotmail):
  918.         self.hotmail = weakref.ref(hotmail)
  919.  
  920.     
  921.     def CanaryValue(self):
  922.         hm = self.hotmail()
  923.         if hm is None:
  924.             return None
  925.         return hm.get_cookie(self.CanaryToken, domain = '.mail.live.com')
  926.  
  927.     CanaryValue = property(CanaryValue)
  928.  
  929.  
  930. class PageInfo(object):
  931.     fppCfg = None
  932.     SELF_PATH = '/mail/InboxLight.aspx'
  933.     queryString = {
  934.         'nonce': '2122195423' }
  935.  
  936.  
  937. def get_build_for(my_build, builds):
  938.     build = None
  939.     for build in reversed(sorted(builds)):
  940.         if my_build >= build:
  941.             return build
  942.     
  943.     return build
  944.  
  945.  
  946. class FppMethod(object):
  947.     
  948.     def __init__(self, impls):
  949.         self.impls = impls
  950.  
  951.     
  952.     def __get__(self, obj, objtype):
  953.         my_build = obj.build
  954.         build = get_build_for(my_build, self.impls.keys())
  955.         details = self.impls.get(build)
  956.         if details is None:
  957.             raise AttributeError('not valid for build %r' % my_build)
  958.         details is None
  959.         return FppMethodImpl(obj, *details)
  960.  
  961.  
  962.  
  963. class FppMethodImpl(object):
  964.     
  965.     def __init__(self, HM, params, method_name, tm, g, namespace):
  966.         self.HM = HM
  967.         self.method_name = self.name = method_name
  968.         new_params = []
  969.         for param in params:
  970.             if isinstance(param, tuple):
  971.                 (name, typ) = param
  972.                 cls = FppMetaclass._classes[typ]
  973.                 if type(cls) is FppMetaclass:
  974.                     new_params.append(_custom(name))
  975.                 else:
  976.                     new_params.append(cls(name))
  977.             type(cls) is FppMetaclass
  978.             new_params.append(param)
  979.         
  980.         self.params = new_params
  981.         self.tm = tm
  982.         self.g = g
  983.         self.namespace = namespace
  984.  
  985.     
  986.     def __call__(self, *args, **kwargs):
  987.         arg_names = [ x.name for x in self.params ]
  988.         arg_names.extend(('cb', 'ctx', 'cbError'))
  989.         vals = dict(zip(arg_names, args))
  990.         vals.update(kwargs)
  991.         cb = None
  992.         ctx = None
  993.         cbError = None
  994.         if 'cbError' in kwargs:
  995.             cbError = kwargs.get('cbError')
  996.         
  997.         if 'ctx' in kwargs:
  998.             ctx = kwargs.get('ctx')
  999.         
  1000.         for remaining in args[len(vals):]:
  1001.             if cb is None:
  1002.                 cb = remaining
  1003.                 continue
  1004.             
  1005.             if ctx is None:
  1006.                 ctx = remaining
  1007.                 continue
  1008.             
  1009.             if cbError is None:
  1010.                 cbError = remaining
  1011.                 continue
  1012.                 continue
  1013.         
  1014.         Network = self.HM.Network
  1015.         prev = getattr(Network, '_fppPrevious', None)
  1016.         if prev is not None and prev._request is not None:
  1017.             prev._request.abort()
  1018.         
  1019.         f = FppMethodInvocation(self.namespace, self.method_name, cb, cbError, self.HM.build)
  1020.         f.Network = self.HM.Network
  1021.         f.Network._fppPrevious = f
  1022.         for param in self.params:
  1023.             if param.name not in vals:
  1024.                 vals[param.name] = FppMetaclass._classes[param.type].default().value
  1025.             
  1026.             f.addParameter(param.type, vals[param.name])
  1027.         
  1028.         f.invoke(ctx)
  1029.  
  1030.  
  1031.  
  1032. class FppMethodInvocation(object):
  1033.     _HTTP_HEADERS = {
  1034.         'X-FPP-Command': '0',
  1035.         'Accept': 'text/html,application/xhtml+xml,application/xml,application/x-javascript',
  1036.         'Accept-Charset': 'utf-8',
  1037.         'Accept-Encoding': 'gzip,identity',
  1038.         'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }
  1039.     
  1040.     def __init__(self, className, methodName, cb, cbError, build):
  1041.         self.className = className
  1042.         self.methodName = methodName
  1043.         self.callback = cb
  1044.         self.callbackError = cbError
  1045.         self.context = None
  1046.         self._request = None
  1047.         self._isInvoked = False
  1048.         self._params = []
  1049.         self.build = build
  1050.  
  1051.     
  1052.     def addParameter(self, a, b):
  1053.         self._params.append({
  1054.             'fppType': a,
  1055.             'value': b })
  1056.  
  1057.     
  1058.     def invoke(self, context):
  1059.         self.context = context
  1060.         if not self.Network.configuration:
  1061.             raise Exception('Network is not configured')
  1062.         self.Network.configuration
  1063.         if self._isInvoked:
  1064.             raise Exception('FppMethod %r already used', self)
  1065.         self._isInvoked
  1066.         self._isInvoked = True
  1067.         argstring = ''
  1068.         netconfig = self.Network.configuration
  1069.         if self._params:
  1070.             param_buffer = []
  1071.             escape = TypeSystem.escape
  1072.             for param in self._params:
  1073.                 escaped = escape({
  1074.                     'type': param['fppType'],
  1075.                     'value': param['value'] })
  1076.                 param_buffer.append(escaped)
  1077.                 param_buffer.append(',')
  1078.             
  1079.             argstring = ''.join(param_buffer[:-1])
  1080.         
  1081.         if not netconfig.PartnerID:
  1082.             pass
  1083.         url = net.UrlQuery(util.httpjoin(self.Network.base_url, netconfig.RequestHandler), cnmn = self.className + '.' + self.methodName, a = netconfig.SessionId, au = netconfig.AuthUser, ptid = '0')
  1084.         post_data = dict(cn = self.className, mn = self.methodName, d = argstring, v = netconfig.FppVersion)
  1085.         hdrs = self._HTTP_HEADERS.copy()
  1086.         if self.build >= '15.3.2506.0629':
  1087.             hdrs[netconfig.CanaryToken] = netconfig.CanaryValue
  1088.         else:
  1089.             post_data[netconfig.CanaryToken] = netconfig.CanaryValue
  1090.         
  1091.         def clear_request(resp):
  1092.             self._request = None
  1093.             self._isInvoked = False
  1094.  
  1095.         if self.callback is not None:
  1096.             self.callback.error.append(clear_request)
  1097.             self.callback.success.append(clear_request)
  1098.         
  1099.         b = self._request = self.Network.createRequest(url, self.callback, 'POST')
  1100.         b.headers = hdrs
  1101.         b.postString = '&'.join((lambda .0: for i in .0:
  1102. '%s=%s' % i)(post_data.items()))
  1103.         b.send(self)
  1104.         del self.Network
  1105.         del self._params
  1106.  
  1107.  
  1108.  
  1109. class HM_Type(FppProxy):
  1110.     namespace = 'HM'
  1111.     SortBy = Flags('Sender', 0, 'Subject', 1, 'Size', 2, 'Type', 3, 'Date', 4)
  1112.     FppStatus = Flags('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)
  1113.     ListNavigateDirection = Flags('FirstPage', 0, 'LastPage', 1, 'NextPage', 2, 'PreviousPage', 3, 'CurrentPage', 4)
  1114.     JmrType = Flags('Junk', 0, 'NotJunk', 1, 'AV', 2, 'SVMOptInOptOut', 3, 'SVMClassification', 4, 'Phish', 5, 'Unsubscribe', 6, 'Unknown', -1)
  1115.     ReadMessageOperation = Flags('GetMessage', 0, 'NextMessage', 1, 'PreviousMessage', 2, 'MarkAsNotJunk', 3, 'Unsubscribe', 4, 'AddContact', 5, 'None', 6)
  1116.     RemoveSenderFromListOption = Flags('None', 0, 'KeepContact', 1, 'RemoveContact', 2, 'KeepSafeSender', 3, 'RemoveSafeSender', 4)
  1117.     ImportanceType = Flags('NORMAL', 0, 'LOW', 1, 'HIGH', 2)
  1118.     MessageSentStateType = Flags('NOACTION', 0, 'REPLIED', 1, 'FORWARDED', 2)
  1119.     NounEnum = Flags('SendersEmailAddress', 97, 'SendersName', 110, 'Subject', 115, 'ToOrCCHeader', 116, 'HasAttachments', 104)
  1120.     MessagePartDataType = Flags('Body', 0, 'ToList', 1, 'Message', 2)
  1121.     HMLiveViewResultCode = Flags('Success', 0, 'Failure', 1)
  1122.     SandboxAuthenticationOption = Flags('None', 0, 'Oauth', 1)
  1123.     ReadingPaneLocation = Flags('None', 0, 'Off', 1, 'Right', 2, 'Bottom', 3)
  1124.     __11 = Flags('Passed', 0, 'Failed', 1, 'Unknown', 2, 'SoftFail', 3)
  1125.     __15 = Flags('Ok', 0, 'OverQuota', 1, 'DoesntExist', 2, 'Error', 3, 'AccountDoesntExist', 4, 'AccountError', 5)
  1126.     __20 = Flags('Unknown', 0, 'MakeLiveContact', 1, 'AddLiveContact', 2, 'DontShow', 3)
  1127.     
  1128.     def FppReturnPackage(self):
  1129.         return self.GetFppTypeConstructor('FppReturnPackage')
  1130.  
  1131.     FppReturnPackage = property(FppReturnPackage)
  1132.     
  1133.     def FppError(self):
  1134.         return self.GetFppTypeConstructor('FppError')
  1135.  
  1136.     FppError = property(FppError)
  1137.     
  1138.     def HmSimpleMsg(self):
  1139.         return self.GetFppTypeConstructor('HmSimpleMsg')
  1140.  
  1141.     HmSimpleMsg = property(HmSimpleMsg)
  1142.     
  1143.     def InboxUiData(self):
  1144.         return self.GetFppTypeConstructor('InboxUiData')
  1145.  
  1146.     InboxUiData = property(InboxUiData)
  1147.     
  1148.     def build(self):
  1149.         return self.app_info.get('BUILD')
  1150.  
  1151.     build = property(build)
  1152.     
  1153.     def GetFppTypeConstructor(self, clsname):
  1154.         if clsname not in _versioned_classes:
  1155.             return globals()[clsname]
  1156.         
  1157.         try:
  1158.             cls_impls = _versioned_classes.get(clsname, None)
  1159.             if not cls_impls:
  1160.                 raise Exception("Class %r not found for build %r. here's known classes: %r", clsname, self.build, _versioned_classes)
  1161.             cls_impls
  1162.             build = get_build_for(self.build, cls_impls.keys())
  1163.             if build is None:
  1164.                 raise Exception("Build %r not found for cls = %r. here's known classes: %r", self.build, clsname, _versioned_classes)
  1165.             build is None
  1166.             cls = cls_impls[build]
  1167.             log.debug('Found class %r for version %r (my version is %r)', clsname, build, self.build)
  1168.             return cls
  1169.         except KeyError:
  1170.             clsname not in _versioned_classes
  1171.             e2 = clsname not in _versioned_classes
  1172.             log.error('Error looking for versioned class %r: %r', clsname, e2)
  1173.             raise e
  1174.         except:
  1175.             clsname not in _versioned_classes
  1176.  
  1177.  
  1178.     
  1179.     def __init__(self, network, base_url, app_info):
  1180.         self.Network = network
  1181.         self.app_info = app_info
  1182.         self.set_base_url(base_url)
  1183.         self.Network.set_HM(self)
  1184.  
  1185.     
  1186.     def set_base_url(self, hostname):
  1187.         self.base_url = 'http://%s/mail/' % hostname
  1188.         self.Network.set_base_url(self.base_url)
  1189.  
  1190.     AddContactFromMessagePart = FppMethod({
  1191.         '15.3.2506.0629': ([
  1192.             ('conversationId', '_string'),
  1193.             ('folderId', '_string'),
  1194.             ('startingMid', '_string'),
  1195.             ('numParts', '_primitive'),
  1196.             ('mpIndexMap', '_object'),
  1197.             ('messageRenderingInfo', 'MessageRenderingInfo'),
  1198.             ('contactName', '_string'),
  1199.             ('contactEmail', '_string'),
  1200.             ('demandLoadContentValues', '_array')], 'AddContactFromMessagePart', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1201.     GetInboxData = FppMethod({
  1202.         '1': ([
  1203.             _primitive('fetchFolderList'),
  1204.             _primitive('fetchMessageList'),
  1205.             _custom('messageListRenderingInfo'),
  1206.             _primitive('fetchMessage'),
  1207.             _custom('messageRenderingInfo')], 'GetInboxData', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox'),
  1208.         '15.1.3020.0910': ([
  1209.             ('fetchFolderList', '_primitive'),
  1210.             ('renderUrlsInFolderList', '_primitive'),
  1211.             ('fetchMessageList', '_primitive'),
  1212.             ('messageListRenderingInfo', '_custom'),
  1213.             ('fetchMessage', '_primitive'),
  1214.             ('messageRenderingInfo', '_custom')], 'GetInboxData', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1215.     ClearFolder = FppMethod({
  1216.         '1': ([
  1217.             _string('clearFolderId'),
  1218.             _custom('messageListRenderingInfo')], 'ClearFolder', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1219.     MoveMessagesToFolder = FppMethod({
  1220.         '1': ([
  1221.             _string('fromFolderId'),
  1222.             _string('toFolderId'),
  1223.             _array('messageList'),
  1224.             _array('messageAuxData'),
  1225.             _custom('messageListRenderingInfo'),
  1226.             _custom('messageRenderingInfo')], 'MoveMessagesToFolder', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox'),
  1227.         '13.3.3227.0707': ([
  1228.             _string('fromFolderId'),
  1229.             _string('toFolderId'),
  1230.             _array('messageList'),
  1231.             _array('messageAuxData'),
  1232.             _custom('messageListRenderingInfo')], 'MoveMessagesToFolder', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox'),
  1233.         '15.3.2495.0616': ([
  1234.             ('fromFolderId', '_string'),
  1235.             ('toFolderId', '_string'),
  1236.             ('messageList', '_array'),
  1237.             ('messageAuxData', '_array'),
  1238.             ('batchInfo', '_custom'),
  1239.             ('messageListRenderingInfo', '_custom'),
  1240.             ('fetchMessageList', '_primitive'),
  1241.             ('refreshFolderAndQuickViewLists', '_primitive'),
  1242.             ('folderNameForRuleSuggestion', '_string'),
  1243.             ('messageRenderingInfo', '_custom'),
  1244.             ('conversationRenderingInfo', '_custom'),
  1245.             ('fetchItem', '_primitive')], 'MoveMessagesToFolder', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox'),
  1246.         '15.4.0317.0921': ([
  1247.             ('fromFolderId', '_string'),
  1248.             ('toFolderId', '_string'),
  1249.             ('messageList', '_array'),
  1250.             ('messageAuxData', '_array'),
  1251.             ('batchInfo', 'BatchInfo'),
  1252.             ('messageListRenderingInfo', 'MessageListRenderingInfo'),
  1253.             ('fetchMessageList', '_primitive'),
  1254.             ('refreshFolderAndQuickViewLists', '_primitive'),
  1255.             ('folderNameForRuleSuggestion', '_string'),
  1256.             ('messageRenderingInfo', 'MessageRenderingInfo'),
  1257.             ('conversationRenderingInfo', 'ConversationRenderingInfo'),
  1258.             ('fetchItem', '_primitive'),
  1259.             ('blockIfDelete', '_primitive')], 'MoveMessagesToFolder', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1260.     ViewAllFromSender = FppMethod({
  1261.         '15.3.2495.0616': ([
  1262.             ('messageListRenderingInfo', 'MessageListRenderingInfo'),
  1263.             ('senderEmail', '_string')], 'ViewAllFromSender', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1264.     MarkMessagesForJmr = FppMethod({
  1265.         '1': ([
  1266.             _string('folderId'),
  1267.             _array('messages'),
  1268.             _array('auxData'),
  1269.             _enum('jmrType'),
  1270.             _primitive('reportToJunk'),
  1271.             _custom('messageListRenderingInfo'),
  1272.             _custom('messageRenderingInfo')], 'MarkMessagesForJmr', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox'),
  1273.         '15.3.2495.0616': ([
  1274.             ('folderId', '_string'),
  1275.             ('messages', '_array'),
  1276.             ('auxData', '_array'),
  1277.             ('BatchInfo', 'BatchInfo'),
  1278.             ('jmrType', '_enum'),
  1279.             ('setReportToJunkOK', '_primitive'),
  1280.             ('messageListRenderingInfo', 'MessageListRenderingInfo'),
  1281.             ('messageRenderingInfo', 'MessageRenderingInfo'),
  1282.             ('refreshFolderAndQuickViewLists', '_primitive'),
  1283.             ('removeFromList', '_enum'),
  1284.             ('suppressListTransition', '_primitive'),
  1285.             ('markSenderAsSafe', '_primitive')], 'MarkMessagesForJmr', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1286.     ReportError = FppMethod({
  1287.         '1': ([
  1288.             _string('message')], 'ReportError', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1289.     AddContactFromMessage = FppMethod({
  1290.         '1': ([
  1291.             _custom('messageRenderingInfo'),
  1292.             _string('contactName'),
  1293.             _string('contactEmail')], 'AddContactFromMessage', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox'),
  1294.         '15.3.2495.0616': ([
  1295.             ('messageRenderingInfo', 'MessageRenderingInfo'),
  1296.             ('messageListRenderingInfo', 'MessageListRenderingInfo'),
  1297.             ('contactName', '_string'),
  1298.             ('contactEmail', '_string'),
  1299.             ('demandLoadContentValues', '_array')], 'AddContactFromMessage', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1300.     SvmFeedback = FppMethod({
  1301.         '1': ([
  1302.             _string('svmUrl'),
  1303.             _custom('messageRenderingInfo'),
  1304.             _custom('messageListRenderingInfo')], 'SvmFeedback', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1305.     MarkMessagesReadState = FppMethod({
  1306.         '1': ([
  1307.             _primitive('readState'),
  1308.             _array('messages'),
  1309.             _custom('messageListRenderingInfo')], 'MarkMessagesReadState', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox'),
  1310.         '15.1.3020.0910': ([
  1311.             _primitive('readState'),
  1312.             _array('messages'),
  1313.             _array('HmAuxData'),
  1314.             _custom('messageListRenderingInfo')], 'MarkMessagesReadState', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox'),
  1315.         '15.3.2495.0616': ([
  1316.             ('readState', '_primitive'),
  1317.             ('messages', '_array'),
  1318.             ('auxData', '_array'),
  1319.             ('batchInfo', '_custom'),
  1320.             ('messageListRenderingInfo', '_custom'),
  1321.             ('refreshFolderAndQuickViewLists', '_primitive')], 'MarkMessagesReadState', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1322.     MarkMessagesFlagState = FppMethod({
  1323.         '15.3.2495.0616': ([
  1324.             ('flagState', '_primitive'),
  1325.             ('messages', '_array'),
  1326.             ('auxData', '_array'),
  1327.             ('batchInfo', 'BatchInfo'),
  1328.             ('messageListRenderingInfo', 'MessageListRenderingInfo'),
  1329.             ('refreshFolderAndQuickViewLists', '_primitive')], 'MarkMessagesFlagState', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1330.     MarkMessagesFlagState = FppMethod({
  1331.         '15.3.2495.0616': ([
  1332.             ('flagState', '_primitive'),
  1333.             ('messages', '_array'),
  1334.             ('auxData', '_array'),
  1335.             ('batchInfo', 'BatchInfo'),
  1336.             ('messageListRenderingInfo', 'MessageListRenderingInfo'),
  1337.             ('refreshFolderAndQuickViewLists', '_primitive')], 'MarkMessagesFlagState', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1338.     SaveVoicemailOnPhone = FppMethod({
  1339.         '15.3.2495.0616': ([
  1340.             ('messageIdList', '_array')], 'SaveVoicemailOnPhone', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1341.     DeleteVoicemailOnPhone = FppMethod({
  1342.         '15.3.2495.0616': ([
  1343.             ('messageIdList', '_array')], 'DeleteVoicemailOnPhone', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1344.     GetConversationInboxData = FppMethod({
  1345.         '15.3.2495.0616': ([
  1346.             ('fetchFolderList', '_primitive'),
  1347.             ('renderUrlsInFolderList', '_primitive'),
  1348.             ('fetchConversationList', '_primitive'),
  1349.             ('conversationListRenderingInfo', 'conversationListRenderingInfo'),
  1350.             ('fetchConversation', '_primitive'),
  1351.             ('conversationRenderingInfo', 'ConversationRenderingInfo')], 'GetConversationInboxData', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1352.     GetSingleMessagePart = FppMethod({
  1353.         '15.3.2495.0616': ([
  1354.             ('conversationId', '_string'),
  1355.             ('folderId', '_string'),
  1356.             ('messageRenderingInfo', 'MessageRenderingInfo'),
  1357.             ('messagePartIndex', '_primitive'),
  1358.             ('showUnsubscribeLink', '_primitive')], 'GetSingleMessagePart', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1359.     GetManyMessageParts = FppMethod({
  1360.         '15.3.2495.0616': ([
  1361.             ('conversationId', '_string'),
  1362.             ('folderId', '_string'),
  1363.             ('startingMessageId', '_string'),
  1364.             ('numParts', '_primitive'),
  1365.             ('messageIdToIndexMap', '_object'),
  1366.             ('showUnsubscribeLink', '_primitive')], 'GetManyMessageParts', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1367.     GetFullMessagePart = FppMethod({
  1368.         '15.3.2495.0616': ([
  1369.             ('messageRenderingInfo', 'MessageRenderingInfo'),
  1370.             ('messagePartIndex', '_primitive'),
  1371.             ('showUnsubscribeLink', '_primitive')], 'GetFullMessagePart', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1372.     MarkMessagePartForJmr = FppMethod({
  1373.         '15.3.2495.0616': ([
  1374.             ('fetchConversation', '_primitive'),
  1375.             ('cid', '_string'),
  1376.             ('fid', '_string'),
  1377.             ('startingMid', '_string'),
  1378.             ('numParts', '_primitive'),
  1379.             ('mpIndexMap', '_object'),
  1380.             ('messageListRenderingInfo', 'MessageListRenderingInfo'),
  1381.             ('mpMids', '_array'),
  1382.             ('mpAuxDatas', '_array'),
  1383.             ('mpFid', '_string'),
  1384.             ('jmrType', '_enum'),
  1385.             ('setReportToJunkOK', '_primitive'),
  1386.             ('removeFromList', '_enum'),
  1387.             ('markSenderAsSafe', '_primitive')], 'MarkMessagePartForJmr', XMLPost, 'abortable', 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1388.     CreateMoveRule = FppMethod({
  1389.         '15.3.2495.0616': ([
  1390.             ('ruleNoun', '_enum'),
  1391.             ('matchingString', '_string'),
  1392.             ('fid', '_string')], 'CreateMoveRule', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1393.     CreateSendersMoveRules = FppMethod({
  1394.         '15.3.2495.0616': ([
  1395.             ('emails', '_array'),
  1396.             ('fid', '_string')], 'CreateSendersMoveRules', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1397.     CreateRecipientMoveRule = FppMethod({
  1398.         '15.4.0317.0921': ([
  1399.             ('recipientEmail', '_string'),
  1400.             ('folderId', '_string'),
  1401.             ('folderName', '_string')], 'CreateRecipientMoveRule', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1402.     BlockSenders = FppMethod({
  1403.         '15.3.2495.0616': ([
  1404.             ('emails', '_array')], 'BlockSenders', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1405.     DemandLoad = FppMethod({
  1406.         '15.3.2495.0616': ([
  1407.             ('demandLoadContentValues', '_array')], 'DemandLoad', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1408.     UndoSenderMoveToBlockList = FppMethod({
  1409.         '15.3.2495.0616': ([
  1410.             ('senderAddress', '_string')], 'UndoSenderMoveToBlockList', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1411.     GetHMLiveViews = FppMethod({
  1412.         '15.3.2495.0616': ([
  1413.             ('requests', '_array')], 'GetHMLiveViews', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1414.     DispatchSandboxRequests = FppMethod({
  1415.         '15.3.2495.0616': ([
  1416.             ('requests', '_array')], 'DispatchSandboxRequests', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1417.     SendMessage_ec = FppMethod({
  1418.         '1': ([
  1419.             _string('to'),
  1420.             _string('from'),
  1421.             _string('cc'),
  1422.             _string('bcc'),
  1423.             _enum('priority'),
  1424.             _string('subject'),
  1425.             _string('message'),
  1426.             _array('attachments'),
  1427.             _string('draftId'),
  1428.             _string('draftFolderId'),
  1429.             _string('originalMessageId'),
  1430.             _string('rfc822MessageId'),
  1431.             _string('rfc822References'),
  1432.             _string('rfc822InReplyTo'),
  1433.             _enum('sentState'),
  1434.             _primitive('sendByPlainTextFormat'),
  1435.             _array('ignoredWordsFromSpellCheck'),
  1436.             _string('hipAnswer'),
  1437.             _string('hipMode'),
  1438.             _string('meetingIcalId')], 'SendMessage_ec', XMLPost, null, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox'),
  1439.         '15.1.3020.0910': None,
  1440.         '15.4.0317.0921': ([
  1441.             ('to', '_string'),
  1442.             ('from', '_string'),
  1443.             ('cc', '_string'),
  1444.             ('bcc', '_string'),
  1445.             ('ImportanceType', '_enum'),
  1446.             ('subject', '_string'),
  1447.             ('message', '_string'),
  1448.             ('messageForPlainTextConversion', '_string'),
  1449.             ('attachments', '_array'),
  1450.             ('draftId', '_string'),
  1451.             ('draftFolderId', '_string'),
  1452.             ('originalMessageId', '_string'),
  1453.             ('rfc822MessageId', '_string'),
  1454.             ('rfc822References', '_string'),
  1455.             ('rfc822InReplyTo', '_string'),
  1456.             ('MessageSentStateType', '_enum'),
  1457.             ('sendByPlainTextFormat', '_primitive'),
  1458.             ('ignoredWordsFromSpellCheck', '_array'),
  1459.             ('hipAnswer', '_string'),
  1460.             ('hipMode', '_string'),
  1461.             ('meetingIcalId', '_string')], 'SendMessage_ec', XMLPost, None, 'Microsoft.Msn.Hotmail.Ui.Fpp.MailBox') })
  1462.  
  1463.  
  1464. class MailFolder(list):
  1465.     
  1466.     def __init__(self, account):
  1467.         list.__init__(self)
  1468.         self.account = account
  1469.         self.cur_page = 0
  1470.         self.more_pages = True
  1471.  
  1472.     
  1473.     def open(self):
  1474.         log.info('you clicked the inbox too soon')
  1475.  
  1476.     
  1477.     def __repr__(self):
  1478.         return '<%s %s>' % (type(self).__name__, list.__repr__(self))
  1479.  
  1480.  
  1481.  
  1482. class LivemaiLFolderBase(MailFolder):
  1483.     domain = 'mail.live.com'
  1484.     PAGECOUNT = 25
  1485.     
  1486.     def __init__(self, account, **k):
  1487.         MailFolder.__init__(self, account)
  1488.         self.count = 0
  1489.         util.autoassign(self, k)
  1490.         if getattr(self, 'link', None) is None:
  1491.             self.link = self.link_from_fid(str(uuid.UUID(int = folderids[self.name])))
  1492.         
  1493.         self.link = self.link + '&InboxSortAscending=False&InboxSortBy=Date'
  1494.  
  1495.     
  1496.     def link_from_fid(self, fid):
  1497.         return util.UrlQuery(util.httpjoin(self.account.base_url, 'InboxLight.aspx'), FolderID = fid)
  1498.  
  1499.     
  1500.     def from_doc(cls, doc, account):
  1501.         li = doc
  1502.         id = uuid.UUID(li.get('id'))
  1503.         
  1504.         try:
  1505.             count = int(li.get('count'))
  1506.         except Exception:
  1507.             _e = None
  1508.  
  1509.         if not doc.base_url:
  1510.             pass
  1511.         link = util.UrlQuery(account.base_url, FolderID = id)
  1512.         caption_span = doc.find('.//span[@class="Caption"]')
  1513.         if caption_span is not None:
  1514.             name = caption_span.text.strip()
  1515.         
  1516.         log.info('Folder %r for %s has %d new messages', name, account.name, count)
  1517.         return cls(account, id = id, name = name, link = link, count = count)
  1518.  
  1519.     from_doc = classmethod(from_doc)
  1520.     
  1521.     def link_for_page(self, pagenum):
  1522.         return util.UrlQuery(self.link, InboxPage = 'Next', Page = pagenum, InboxPageAnchor = getattr(self, 'last_seen_message', ''), NotAutoSelect = '', n = ntok())
  1523.  
  1524.     
  1525.     def open(self, callback = None):
  1526.         return callback.error('deprecated')
  1527.  
  1528.     open = util.callsback(open)
  1529.     
  1530.     def process_one_page(self, doc):
  1531.         max_ = self.count
  1532.         if not self.get_num_pages(doc):
  1533.             pass
  1534.         num_pages = max_ // self.PAGECOUNT + 1
  1535.         self.more_pages = self.cur_page < num_pages
  1536.         log.info('Parsing page %d of %d of folder %s', self.cur_page, num_pages, self.name)
  1537.         last_id_on_page = ''
  1538.         unreadcount = 0
  1539.         all_msgs = doc.findall('.//tr[@id]')
  1540.         for msg in all_msgs:
  1541.             msg = self.account.HM.GetFppTypeConstructor('LivemailMessage').from_doc(msg, self)
  1542.             unread = self.process_message(msg)
  1543.             if unread:
  1544.                 unreadcount += 1
  1545.                 self.append(msg)
  1546.             
  1547.             msgid = msg.id
  1548.             if msgid is not None:
  1549.                 if not msgid:
  1550.                     pass
  1551.                 last_id_on_page = last_id_on_page
  1552.                 continue
  1553.         
  1554.         self.last_seen_message = last_id_on_page
  1555.         return unreadcount
  1556.  
  1557.     
  1558.     def process_message(self, msg):
  1559.         return not (msg.opened)
  1560.  
  1561.     
  1562.     def get_num_pages(self, doc):
  1563.         num_pages = None
  1564.         
  1565.         try:
  1566.             lastpage_li = doc.find('.//*[@pndir="LastPage"]')
  1567.             if lastpage_li is not None:
  1568.                 lastpage_num_str = lastpage_li.get('pncur', None)
  1569.                 
  1570.                 try:
  1571.                     num_pages = int(lastpage_num_str)
  1572.                 except (TypeError, ValueError):
  1573.                     pass
  1574.                 except:
  1575.                     None<EXCEPTION MATCH>(TypeError, ValueError)
  1576.                 
  1577.  
  1578.             None<EXCEPTION MATCH>(TypeError, ValueError)
  1579.         except Exception:
  1580.             traceback.print_exc()
  1581.  
  1582.         return num_pages
  1583.  
  1584.  
  1585. LivemailFolder = ForBuild('1')(<NODE:12>)
  1586. import mail
  1587.  
  1588. class LivemailMessageBase(mail.emailobj.Email):
  1589.     
  1590.     def parsedate(self, datestring):
  1591.         return datestring
  1592.  
  1593.     
  1594.     def from_doc(cls, doc, folder):
  1595.         raise NotImplementedError
  1596.  
  1597.     from_doc = classmethod(from_doc)
  1598.     
  1599.     def __init__(self, folder, **k):
  1600.         self.folder = folder
  1601.         self.account = folder.account
  1602.         util.autoassign(self, k)
  1603.         mail.emailobj.Email.__init__(self, id = self.id, fromname = self.sender, sendtime = self.parsedate(self.date), subject = self.subject, attachments = self.attach)
  1604.         self.set_link()
  1605.         self.opened = False
  1606.  
  1607.     
  1608.     def set_link(self):
  1609.         self.link = util.UrlQuery(util.httpjoin(self.account.base_url, 'InboxLight.aspx'), Aux = self._mad, ReadMessageId = self.id, n = ntok())
  1610.  
  1611.     
  1612.     def mark_as_read(self):
  1613.         self.open()
  1614.  
  1615.     
  1616.     def open(self):
  1617.         log.info('Opening %r for %s', self, self.account.name)
  1618.         if self.opened:
  1619.             return None
  1620.         
  1621.         try:
  1622.             response = self.account.http.open(self.link)
  1623.             response.read()
  1624.             response.close()
  1625.         except Exception:
  1626.             self.opened
  1627.             self.opened
  1628.         except:
  1629.             self.opened
  1630.  
  1631.         self.opened = True
  1632.         log.info('Done opening %r for %s', self, self.account.name)
  1633.         return self.link
  1634.  
  1635.     
  1636.     def delete(self):
  1637.         log.info('Deleting %r', self)
  1638.         self.mark_as_read()
  1639.  
  1640.     
  1641.     def spam(self):
  1642.         log.info('Marking %r as spam', self)
  1643.         self.open()
  1644.  
  1645.     
  1646.     def Messages_remove(self, messageList, messageAuxData, callback = None):
  1647.         self.Messages_move(messageList, messageAuxData, self.folder.id, self.account.trash.id, callback = callback)
  1648.  
  1649.     Messages_remove = callbacks.callsback(Messages_remove)
  1650.     
  1651.     def Messages_move(self, messageList, messageAuxData, fromFolderId, toFolderId, callback = None):
  1652.         messageIds = [
  1653.             str(self.id)]
  1654.         messageListRenderingInfo = self.make_mlri()
  1655.         messageRenderingInfo = None
  1656.         kwargs = dict(fromFolderId = fromFolderId, toFolderId = toFolderId, messageList = messageList, messageAuxData = messageAuxData, messageListRenderingInfo = messageListRenderingInfo, messageRenderingInfo = messageRenderingInfo, callback = callback)
  1657.         self.account.HM.MoveMessagesToFolder(**kwargs)
  1658.  
  1659.     Messages_move = callbacks.callsback(Messages_move)
  1660.     
  1661.     def MarkMessagesReadState(self, callback = None):
  1662.         messageListRenderingInfo = self.make_mlri()
  1663.         mad = self.make_message_aux_data()
  1664.         self.account.HM.MarkMessagesReadState(readState = True, messages = [
  1665.             str(self.id)], HmAuxData = [
  1666.             mad], messageListRenderingInfo = messageListRenderingInfo, callback = callback)
  1667.  
  1668.     MarkMessagesReadState = callbacks.callsback(MarkMessagesReadState)
  1669.     
  1670.     def login_link(self):
  1671.         return '/cgi-bin/getmsg?msg=%s' % str(self.id).upper()
  1672.  
  1673.  
  1674. LivemailMessageOld = ForBuild('1', 'LivemailMessage')(<NODE:12>)
  1675. LivemailMessage = ForBuild('15.3.2495.0616')(<NODE:12>)
  1676. __BuildVersionDummy = ForBuild('15.4.0332.1110')(<NODE:12>)
  1677.  
  1678. def get_classname(js):
  1679.     return re.search('HM\\.registerFppClass\\("(.+?)",', js).group(1)
  1680.  
  1681.  
  1682. def get_fields(js):
  1683.     fields_re = re.compile('Web\\.Network\\.FppProxy\\._(_(?:.+?))\\("(.+?)"\\),')
  1684.     return [ x[::-1] for x in fields_re.findall(js) ]
  1685.  
  1686.  
  1687. def fppclass_to_python(js):
  1688.     pformat = pformat
  1689.     import pprint
  1690.     cname = get_classname(js)
  1691.     fields = get_fields(js)
  1692.     return 'class %s(FppClass):\n    _fields_ = %s\n' % (cname, pformat(fields))
  1693.  
  1694.  
  1695. def main():
  1696.     print str(HmAuxData('10\\|0\\|8CA6DDB632DFE40\\|', null))
  1697.  
  1698.  
  1699. def main2():
  1700.     testapp = testapp
  1701.     import tests.testapp
  1702.     a = testapp()
  1703.     Page = PageInfo()
  1704.     Page.fppCfg = FPPConfig(None)
  1705.     Network = Network_Type(Page.fppCfg)
  1706.     HM = HM_Type(Network)
  1707.     
  1708.     def doit(callback = (None,)):
  1709.         HM.GetInboxData(True, True, None, True, None, Null, None, None)
  1710.  
  1711.     doit = util.callsback(doit)
  1712.     
  1713.     def success(resp):
  1714.         print 'success', resp
  1715.  
  1716.     
  1717.     def error(e):
  1718.         print 'error', e
  1719.  
  1720.     doit(success = success, error = error)
  1721.  
  1722. if __name__ == '__main__':
  1723.     main()
  1724.  
  1725.