thirdparty/google_appengine/google/appengine/api/mail_service_pb.py
changeset 109 620f9b141567
child 149 f2e327a7c5de
equal deleted inserted replaced
108:261778de26ff 109:620f9b141567
       
     1 #!/usr/bin/env python
       
     2 #
       
     3 # Copyright 2007 Google Inc.
       
     4 #
       
     5 # Licensed under the Apache License, Version 2.0 (the "License");
       
     6 # you may not use this file except in compliance with the License.
       
     7 # You may obtain a copy of the License at
       
     8 #
       
     9 #     http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 # Unless required by applicable law or agreed to in writing, software
       
    12 # distributed under the License is distributed on an "AS IS" BASIS,
       
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 # See the License for the specific language governing permissions and
       
    15 # limitations under the License.
       
    16 #
       
    17 
       
    18 from google.net.proto import ProtocolBuffer
       
    19 import array
       
    20 import dummy_thread as thread
       
    21 
       
    22 __pychecker__ = """maxreturns=0 maxbranches=0 no-callinit
       
    23                    unusednames=printElemNumber,debug_strs no-special"""
       
    24 
       
    25 from google.appengine.api.api_base_pb import VoidProto
       
    26 class MailServiceError(ProtocolBuffer.ProtocolMessage):
       
    27 
       
    28   OK           =    0
       
    29   INTERNAL_ERROR =    1
       
    30   BAD_REQUEST  =    2
       
    31   UNAUTHORIZED_SENDER =    3
       
    32   INVALID_ATTACHMENT_TYPE =    4
       
    33 
       
    34   _ErrorCode_NAMES = {
       
    35     0: "OK",
       
    36     1: "INTERNAL_ERROR",
       
    37     2: "BAD_REQUEST",
       
    38     3: "UNAUTHORIZED_SENDER",
       
    39     4: "INVALID_ATTACHMENT_TYPE",
       
    40   }
       
    41 
       
    42   def ErrorCode_Name(cls, x): return cls._ErrorCode_NAMES.get(x, "")
       
    43   ErrorCode_Name = classmethod(ErrorCode_Name)
       
    44 
       
    45   def __init__(self, contents=None):
       
    46     pass
       
    47     if contents is not None: self.MergeFromString(contents)
       
    48 
       
    49 
       
    50   def MergeFrom(self, x):
       
    51     assert x is not self
       
    52 
       
    53   def Equals(self, x):
       
    54     if x is self: return 1
       
    55     return 1
       
    56 
       
    57   def __eq__(self, other):
       
    58     return (other is not None) and (other.__class__ == self.__class__) and self.Equals(other)
       
    59 
       
    60   def __ne__(self, other):
       
    61     return not (self == other)
       
    62 
       
    63   def IsInitialized(self, debug_strs=None):
       
    64     initialized = 1
       
    65     return initialized
       
    66 
       
    67   def ByteSize(self):
       
    68     n = 0
       
    69     return n + 0
       
    70 
       
    71   def Clear(self):
       
    72     pass
       
    73 
       
    74   def OutputUnchecked(self, out):
       
    75     pass
       
    76 
       
    77   def TryMerge(self, d):
       
    78     while d.avail() > 0:
       
    79       tt = d.getVarInt32()
       
    80       if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
       
    81       d.skipData(tt)
       
    82 
       
    83 
       
    84   def __str__(self, prefix="", printElemNumber=0):
       
    85     res=""
       
    86     return res
       
    87 
       
    88 
       
    89   _TEXT = (
       
    90    "ErrorCode",
       
    91   )
       
    92 
       
    93   _TYPES = (
       
    94    ProtocolBuffer.Encoder.NUMERIC,
       
    95   )
       
    96 
       
    97   _STYLE = """"""
       
    98   _STYLE_CONTENT_TYPE = """"""
       
    99 class MailAttachment(ProtocolBuffer.ProtocolMessage):
       
   100   def __init__(self, contents=None):
       
   101     self.filename_ = ""
       
   102     self.data_ = ""
       
   103     self.has_filename_ = 0
       
   104     self.has_data_ = 0
       
   105     if contents is not None: self.MergeFromString(contents)
       
   106 
       
   107   def filename(self): return self.filename_
       
   108 
       
   109   def set_filename(self, x):
       
   110     self.has_filename_ = 1
       
   111     self.filename_ = x
       
   112 
       
   113   def clear_filename(self):
       
   114     self.has_filename_ = 0
       
   115     self.filename_ = ""
       
   116 
       
   117   def has_filename(self): return self.has_filename_
       
   118 
       
   119   def data(self): return self.data_
       
   120 
       
   121   def set_data(self, x):
       
   122     self.has_data_ = 1
       
   123     self.data_ = x
       
   124 
       
   125   def clear_data(self):
       
   126     self.has_data_ = 0
       
   127     self.data_ = ""
       
   128 
       
   129   def has_data(self): return self.has_data_
       
   130 
       
   131 
       
   132   def MergeFrom(self, x):
       
   133     assert x is not self
       
   134     if (x.has_filename()): self.set_filename(x.filename())
       
   135     if (x.has_data()): self.set_data(x.data())
       
   136 
       
   137   def Equals(self, x):
       
   138     if x is self: return 1
       
   139     if self.has_filename_ != x.has_filename_: return 0
       
   140     if self.has_filename_ and self.filename_ != x.filename_: return 0
       
   141     if self.has_data_ != x.has_data_: return 0
       
   142     if self.has_data_ and self.data_ != x.data_: return 0
       
   143     return 1
       
   144 
       
   145   def __eq__(self, other):
       
   146     return (other is not None) and (other.__class__ == self.__class__) and self.Equals(other)
       
   147 
       
   148   def __ne__(self, other):
       
   149     return not (self == other)
       
   150 
       
   151   def IsInitialized(self, debug_strs=None):
       
   152     initialized = 1
       
   153     if (not self.has_filename_):
       
   154       initialized = 0
       
   155       if debug_strs is not None:
       
   156         debug_strs.append('Required field: filename not set.')
       
   157     if (not self.has_data_):
       
   158       initialized = 0
       
   159       if debug_strs is not None:
       
   160         debug_strs.append('Required field: data not set.')
       
   161     return initialized
       
   162 
       
   163   def ByteSize(self):
       
   164     n = 0
       
   165     n += self.lengthString(len(self.filename_))
       
   166     n += self.lengthString(len(self.data_))
       
   167     return n + 2
       
   168 
       
   169   def Clear(self):
       
   170     self.clear_filename()
       
   171     self.clear_data()
       
   172 
       
   173   def OutputUnchecked(self, out):
       
   174     out.putVarInt32(10)
       
   175     out.putPrefixedString(self.filename_)
       
   176     out.putVarInt32(18)
       
   177     out.putPrefixedString(self.data_)
       
   178 
       
   179   def TryMerge(self, d):
       
   180     while d.avail() > 0:
       
   181       tt = d.getVarInt32()
       
   182       if tt == 10:
       
   183         self.set_filename(d.getPrefixedString())
       
   184         continue
       
   185       if tt == 18:
       
   186         self.set_data(d.getPrefixedString())
       
   187         continue
       
   188       if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
       
   189       d.skipData(tt)
       
   190 
       
   191 
       
   192   def __str__(self, prefix="", printElemNumber=0):
       
   193     res=""
       
   194     if self.has_filename_: res+=prefix+("FileName: %s\n" % self.DebugFormatString(self.filename_))
       
   195     if self.has_data_: res+=prefix+("Data: %s\n" % self.DebugFormatString(self.data_))
       
   196     return res
       
   197 
       
   198   kFileName = 1
       
   199   kData = 2
       
   200 
       
   201   _TEXT = (
       
   202    "ErrorCode",
       
   203    "FileName",
       
   204    "Data",
       
   205   )
       
   206 
       
   207   _TYPES = (
       
   208    ProtocolBuffer.Encoder.NUMERIC,
       
   209    ProtocolBuffer.Encoder.STRING,
       
   210 
       
   211    ProtocolBuffer.Encoder.STRING,
       
   212 
       
   213   )
       
   214 
       
   215   _STYLE = """"""
       
   216   _STYLE_CONTENT_TYPE = """"""
       
   217 class MailMessage(ProtocolBuffer.ProtocolMessage):
       
   218   def __init__(self, contents=None):
       
   219     self.sender_ = ""
       
   220     self.replyto_ = ""
       
   221     self.to_ = []
       
   222     self.cc_ = []
       
   223     self.bcc_ = []
       
   224     self.subject_ = ""
       
   225     self.textbody_ = ""
       
   226     self.htmlbody_ = ""
       
   227     self.attachment_ = []
       
   228     self.has_sender_ = 0
       
   229     self.has_replyto_ = 0
       
   230     self.has_subject_ = 0
       
   231     self.has_textbody_ = 0
       
   232     self.has_htmlbody_ = 0
       
   233     if contents is not None: self.MergeFromString(contents)
       
   234 
       
   235   def sender(self): return self.sender_
       
   236 
       
   237   def set_sender(self, x):
       
   238     self.has_sender_ = 1
       
   239     self.sender_ = x
       
   240 
       
   241   def clear_sender(self):
       
   242     self.has_sender_ = 0
       
   243     self.sender_ = ""
       
   244 
       
   245   def has_sender(self): return self.has_sender_
       
   246 
       
   247   def replyto(self): return self.replyto_
       
   248 
       
   249   def set_replyto(self, x):
       
   250     self.has_replyto_ = 1
       
   251     self.replyto_ = x
       
   252 
       
   253   def clear_replyto(self):
       
   254     self.has_replyto_ = 0
       
   255     self.replyto_ = ""
       
   256 
       
   257   def has_replyto(self): return self.has_replyto_
       
   258 
       
   259   def to_size(self): return len(self.to_)
       
   260   def to_list(self): return self.to_
       
   261 
       
   262   def to(self, i):
       
   263     return self.to_[i]
       
   264 
       
   265   def set_to(self, i, x):
       
   266     self.to_[i] = x
       
   267 
       
   268   def add_to(self, x):
       
   269     self.to_.append(x)
       
   270 
       
   271   def clear_to(self):
       
   272     self.to_ = []
       
   273 
       
   274   def cc_size(self): return len(self.cc_)
       
   275   def cc_list(self): return self.cc_
       
   276 
       
   277   def cc(self, i):
       
   278     return self.cc_[i]
       
   279 
       
   280   def set_cc(self, i, x):
       
   281     self.cc_[i] = x
       
   282 
       
   283   def add_cc(self, x):
       
   284     self.cc_.append(x)
       
   285 
       
   286   def clear_cc(self):
       
   287     self.cc_ = []
       
   288 
       
   289   def bcc_size(self): return len(self.bcc_)
       
   290   def bcc_list(self): return self.bcc_
       
   291 
       
   292   def bcc(self, i):
       
   293     return self.bcc_[i]
       
   294 
       
   295   def set_bcc(self, i, x):
       
   296     self.bcc_[i] = x
       
   297 
       
   298   def add_bcc(self, x):
       
   299     self.bcc_.append(x)
       
   300 
       
   301   def clear_bcc(self):
       
   302     self.bcc_ = []
       
   303 
       
   304   def subject(self): return self.subject_
       
   305 
       
   306   def set_subject(self, x):
       
   307     self.has_subject_ = 1
       
   308     self.subject_ = x
       
   309 
       
   310   def clear_subject(self):
       
   311     self.has_subject_ = 0
       
   312     self.subject_ = ""
       
   313 
       
   314   def has_subject(self): return self.has_subject_
       
   315 
       
   316   def textbody(self): return self.textbody_
       
   317 
       
   318   def set_textbody(self, x):
       
   319     self.has_textbody_ = 1
       
   320     self.textbody_ = x
       
   321 
       
   322   def clear_textbody(self):
       
   323     self.has_textbody_ = 0
       
   324     self.textbody_ = ""
       
   325 
       
   326   def has_textbody(self): return self.has_textbody_
       
   327 
       
   328   def htmlbody(self): return self.htmlbody_
       
   329 
       
   330   def set_htmlbody(self, x):
       
   331     self.has_htmlbody_ = 1
       
   332     self.htmlbody_ = x
       
   333 
       
   334   def clear_htmlbody(self):
       
   335     self.has_htmlbody_ = 0
       
   336     self.htmlbody_ = ""
       
   337 
       
   338   def has_htmlbody(self): return self.has_htmlbody_
       
   339 
       
   340   def attachment_size(self): return len(self.attachment_)
       
   341   def attachment_list(self): return self.attachment_
       
   342 
       
   343   def attachment(self, i):
       
   344     return self.attachment_[i]
       
   345 
       
   346   def mutable_attachment(self, i):
       
   347     return self.attachment_[i]
       
   348 
       
   349   def add_attachment(self):
       
   350     x = MailAttachment()
       
   351     self.attachment_.append(x)
       
   352     return x
       
   353 
       
   354   def clear_attachment(self):
       
   355     self.attachment_ = []
       
   356 
       
   357   def MergeFrom(self, x):
       
   358     assert x is not self
       
   359     if (x.has_sender()): self.set_sender(x.sender())
       
   360     if (x.has_replyto()): self.set_replyto(x.replyto())
       
   361     for i in xrange(x.to_size()): self.add_to(x.to(i))
       
   362     for i in xrange(x.cc_size()): self.add_cc(x.cc(i))
       
   363     for i in xrange(x.bcc_size()): self.add_bcc(x.bcc(i))
       
   364     if (x.has_subject()): self.set_subject(x.subject())
       
   365     if (x.has_textbody()): self.set_textbody(x.textbody())
       
   366     if (x.has_htmlbody()): self.set_htmlbody(x.htmlbody())
       
   367     for i in xrange(x.attachment_size()): self.add_attachment().CopyFrom(x.attachment(i))
       
   368 
       
   369   def Equals(self, x):
       
   370     if x is self: return 1
       
   371     if self.has_sender_ != x.has_sender_: return 0
       
   372     if self.has_sender_ and self.sender_ != x.sender_: return 0
       
   373     if self.has_replyto_ != x.has_replyto_: return 0
       
   374     if self.has_replyto_ and self.replyto_ != x.replyto_: return 0
       
   375     if len(self.to_) != len(x.to_): return 0
       
   376     for e1, e2 in zip(self.to_, x.to_):
       
   377       if e1 != e2: return 0
       
   378     if len(self.cc_) != len(x.cc_): return 0
       
   379     for e1, e2 in zip(self.cc_, x.cc_):
       
   380       if e1 != e2: return 0
       
   381     if len(self.bcc_) != len(x.bcc_): return 0
       
   382     for e1, e2 in zip(self.bcc_, x.bcc_):
       
   383       if e1 != e2: return 0
       
   384     if self.has_subject_ != x.has_subject_: return 0
       
   385     if self.has_subject_ and self.subject_ != x.subject_: return 0
       
   386     if self.has_textbody_ != x.has_textbody_: return 0
       
   387     if self.has_textbody_ and self.textbody_ != x.textbody_: return 0
       
   388     if self.has_htmlbody_ != x.has_htmlbody_: return 0
       
   389     if self.has_htmlbody_ and self.htmlbody_ != x.htmlbody_: return 0
       
   390     if len(self.attachment_) != len(x.attachment_): return 0
       
   391     for e1, e2 in zip(self.attachment_, x.attachment_):
       
   392       if e1 != e2: return 0
       
   393     return 1
       
   394 
       
   395   def __eq__(self, other):
       
   396     return (other is not None) and (other.__class__ == self.__class__) and self.Equals(other)
       
   397 
       
   398   def __ne__(self, other):
       
   399     return not (self == other)
       
   400 
       
   401   def IsInitialized(self, debug_strs=None):
       
   402     initialized = 1
       
   403     if (not self.has_sender_):
       
   404       initialized = 0
       
   405       if debug_strs is not None:
       
   406         debug_strs.append('Required field: sender not set.')
       
   407     if (not self.has_subject_):
       
   408       initialized = 0
       
   409       if debug_strs is not None:
       
   410         debug_strs.append('Required field: subject not set.')
       
   411     for i in xrange(len(self.attachment_)):
       
   412       if (not self.attachment_[i].IsInitialized(debug_strs)): initialized=0
       
   413     return initialized
       
   414 
       
   415   def ByteSize(self):
       
   416     n = 0
       
   417     n += self.lengthString(len(self.sender_))
       
   418     if (self.has_replyto_): n += 1 + self.lengthString(len(self.replyto_))
       
   419     n += 1 * len(self.to_)
       
   420     for i in xrange(len(self.to_)): n += self.lengthString(len(self.to_[i]))
       
   421     n += 1 * len(self.cc_)
       
   422     for i in xrange(len(self.cc_)): n += self.lengthString(len(self.cc_[i]))
       
   423     n += 1 * len(self.bcc_)
       
   424     for i in xrange(len(self.bcc_)): n += self.lengthString(len(self.bcc_[i]))
       
   425     n += self.lengthString(len(self.subject_))
       
   426     if (self.has_textbody_): n += 1 + self.lengthString(len(self.textbody_))
       
   427     if (self.has_htmlbody_): n += 1 + self.lengthString(len(self.htmlbody_))
       
   428     n += 1 * len(self.attachment_)
       
   429     for i in xrange(len(self.attachment_)): n += self.lengthString(self.attachment_[i].ByteSize())
       
   430     return n + 2
       
   431 
       
   432   def Clear(self):
       
   433     self.clear_sender()
       
   434     self.clear_replyto()
       
   435     self.clear_to()
       
   436     self.clear_cc()
       
   437     self.clear_bcc()
       
   438     self.clear_subject()
       
   439     self.clear_textbody()
       
   440     self.clear_htmlbody()
       
   441     self.clear_attachment()
       
   442 
       
   443   def OutputUnchecked(self, out):
       
   444     out.putVarInt32(10)
       
   445     out.putPrefixedString(self.sender_)
       
   446     if (self.has_replyto_):
       
   447       out.putVarInt32(18)
       
   448       out.putPrefixedString(self.replyto_)
       
   449     for i in xrange(len(self.to_)):
       
   450       out.putVarInt32(26)
       
   451       out.putPrefixedString(self.to_[i])
       
   452     for i in xrange(len(self.cc_)):
       
   453       out.putVarInt32(34)
       
   454       out.putPrefixedString(self.cc_[i])
       
   455     for i in xrange(len(self.bcc_)):
       
   456       out.putVarInt32(42)
       
   457       out.putPrefixedString(self.bcc_[i])
       
   458     out.putVarInt32(50)
       
   459     out.putPrefixedString(self.subject_)
       
   460     if (self.has_textbody_):
       
   461       out.putVarInt32(58)
       
   462       out.putPrefixedString(self.textbody_)
       
   463     if (self.has_htmlbody_):
       
   464       out.putVarInt32(66)
       
   465       out.putPrefixedString(self.htmlbody_)
       
   466     for i in xrange(len(self.attachment_)):
       
   467       out.putVarInt32(74)
       
   468       out.putVarInt32(self.attachment_[i].ByteSize())
       
   469       self.attachment_[i].OutputUnchecked(out)
       
   470 
       
   471   def TryMerge(self, d):
       
   472     while d.avail() > 0:
       
   473       tt = d.getVarInt32()
       
   474       if tt == 10:
       
   475         self.set_sender(d.getPrefixedString())
       
   476         continue
       
   477       if tt == 18:
       
   478         self.set_replyto(d.getPrefixedString())
       
   479         continue
       
   480       if tt == 26:
       
   481         self.add_to(d.getPrefixedString())
       
   482         continue
       
   483       if tt == 34:
       
   484         self.add_cc(d.getPrefixedString())
       
   485         continue
       
   486       if tt == 42:
       
   487         self.add_bcc(d.getPrefixedString())
       
   488         continue
       
   489       if tt == 50:
       
   490         self.set_subject(d.getPrefixedString())
       
   491         continue
       
   492       if tt == 58:
       
   493         self.set_textbody(d.getPrefixedString())
       
   494         continue
       
   495       if tt == 66:
       
   496         self.set_htmlbody(d.getPrefixedString())
       
   497         continue
       
   498       if tt == 74:
       
   499         length = d.getVarInt32()
       
   500         tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
       
   501         d.skip(length)
       
   502         self.add_attachment().TryMerge(tmp)
       
   503         continue
       
   504       if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
       
   505       d.skipData(tt)
       
   506 
       
   507 
       
   508   def __str__(self, prefix="", printElemNumber=0):
       
   509     res=""
       
   510     if self.has_sender_: res+=prefix+("Sender: %s\n" % self.DebugFormatString(self.sender_))
       
   511     if self.has_replyto_: res+=prefix+("ReplyTo: %s\n" % self.DebugFormatString(self.replyto_))
       
   512     cnt=0
       
   513     for e in self.to_:
       
   514       elm=""
       
   515       if printElemNumber: elm="(%d)" % cnt
       
   516       res+=prefix+("To%s: %s\n" % (elm, self.DebugFormatString(e)))
       
   517       cnt+=1
       
   518     cnt=0
       
   519     for e in self.cc_:
       
   520       elm=""
       
   521       if printElemNumber: elm="(%d)" % cnt
       
   522       res+=prefix+("Cc%s: %s\n" % (elm, self.DebugFormatString(e)))
       
   523       cnt+=1
       
   524     cnt=0
       
   525     for e in self.bcc_:
       
   526       elm=""
       
   527       if printElemNumber: elm="(%d)" % cnt
       
   528       res+=prefix+("Bcc%s: %s\n" % (elm, self.DebugFormatString(e)))
       
   529       cnt+=1
       
   530     if self.has_subject_: res+=prefix+("Subject: %s\n" % self.DebugFormatString(self.subject_))
       
   531     if self.has_textbody_: res+=prefix+("TextBody: %s\n" % self.DebugFormatString(self.textbody_))
       
   532     if self.has_htmlbody_: res+=prefix+("HtmlBody: %s\n" % self.DebugFormatString(self.htmlbody_))
       
   533     cnt=0
       
   534     for e in self.attachment_:
       
   535       elm=""
       
   536       if printElemNumber: elm="(%d)" % cnt
       
   537       res+=prefix+("Attachment%s <\n" % elm)
       
   538       res+=e.__str__(prefix + "  ", printElemNumber)
       
   539       res+=prefix+">\n"
       
   540       cnt+=1
       
   541     return res
       
   542 
       
   543   kSender = 1
       
   544   kReplyTo = 2
       
   545   kTo = 3
       
   546   kCc = 4
       
   547   kBcc = 5
       
   548   kSubject = 6
       
   549   kTextBody = 7
       
   550   kHtmlBody = 8
       
   551   kAttachment = 9
       
   552 
       
   553   _TEXT = (
       
   554    "ErrorCode",
       
   555    "Sender",
       
   556    "ReplyTo",
       
   557    "To",
       
   558    "Cc",
       
   559    "Bcc",
       
   560    "Subject",
       
   561    "TextBody",
       
   562    "HtmlBody",
       
   563    "Attachment",
       
   564   )
       
   565 
       
   566   _TYPES = (
       
   567    ProtocolBuffer.Encoder.NUMERIC,
       
   568    ProtocolBuffer.Encoder.STRING,
       
   569 
       
   570    ProtocolBuffer.Encoder.STRING,
       
   571 
       
   572    ProtocolBuffer.Encoder.STRING,
       
   573 
       
   574    ProtocolBuffer.Encoder.STRING,
       
   575 
       
   576    ProtocolBuffer.Encoder.STRING,
       
   577 
       
   578    ProtocolBuffer.Encoder.STRING,
       
   579 
       
   580    ProtocolBuffer.Encoder.STRING,
       
   581 
       
   582    ProtocolBuffer.Encoder.STRING,
       
   583 
       
   584    ProtocolBuffer.Encoder.STRING,
       
   585 
       
   586   )
       
   587 
       
   588   _STYLE = """"""
       
   589   _STYLE_CONTENT_TYPE = """"""
       
   590 
       
   591 __all__ = ['MailServiceError','MailAttachment','MailMessage']