App Engine Python SDK version 1.8.8
[gae.git] / python / google / appengine / api / mail_service_pb.py
blobf5eb4a05b0708040889795cd0861d75684ee3fb6
1 #!/usr/bin/env python
3 # Copyright 2007 Google Inc.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
20 from google.net.proto import ProtocolBuffer
21 import array
22 import dummy_thread as thread
24 __pychecker__ = """maxreturns=0 maxbranches=0 no-callinit
25 unusednames=printElemNumber,debug_strs no-special"""
27 if hasattr(ProtocolBuffer, 'ExtendableProtocolMessage'):
28 _extension_runtime = True
29 _ExtendableProtocolMessage = ProtocolBuffer.ExtendableProtocolMessage
30 else:
31 _extension_runtime = False
32 _ExtendableProtocolMessage = ProtocolBuffer.ProtocolMessage
34 from google.appengine.api.api_base_pb import *
35 import google.appengine.api.api_base_pb
36 class MailServiceError(ProtocolBuffer.ProtocolMessage):
39 OK = 0
40 INTERNAL_ERROR = 1
41 BAD_REQUEST = 2
42 UNAUTHORIZED_SENDER = 3
43 INVALID_ATTACHMENT_TYPE = 4
44 INVALID_HEADER_NAME = 5
45 INVALID_CONTENT_ID = 6
47 _ErrorCode_NAMES = {
48 0: "OK",
49 1: "INTERNAL_ERROR",
50 2: "BAD_REQUEST",
51 3: "UNAUTHORIZED_SENDER",
52 4: "INVALID_ATTACHMENT_TYPE",
53 5: "INVALID_HEADER_NAME",
54 6: "INVALID_CONTENT_ID",
57 def ErrorCode_Name(cls, x): return cls._ErrorCode_NAMES.get(x, "")
58 ErrorCode_Name = classmethod(ErrorCode_Name)
61 def __init__(self, contents=None):
62 pass
63 if contents is not None: self.MergeFromString(contents)
66 def MergeFrom(self, x):
67 assert x is not self
69 def Equals(self, x):
70 if x is self: return 1
71 return 1
73 def IsInitialized(self, debug_strs=None):
74 initialized = 1
75 return initialized
77 def ByteSize(self):
78 n = 0
79 return n
81 def ByteSizePartial(self):
82 n = 0
83 return n
85 def Clear(self):
86 pass
88 def OutputUnchecked(self, out):
89 pass
91 def OutputPartial(self, out):
92 pass
94 def TryMerge(self, d):
95 while d.avail() > 0:
96 tt = d.getVarInt32()
99 if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
100 d.skipData(tt)
103 def __str__(self, prefix="", printElemNumber=0):
104 res=""
105 return res
108 def _BuildTagLookupTable(sparse, maxtag, default=None):
109 return tuple([sparse.get(i, default) for i in xrange(0, 1+maxtag)])
112 _TEXT = _BuildTagLookupTable({
113 0: "ErrorCode",
114 }, 0)
116 _TYPES = _BuildTagLookupTable({
117 0: ProtocolBuffer.Encoder.NUMERIC,
118 }, 0, ProtocolBuffer.Encoder.MAX_TYPE)
121 _STYLE = """"""
122 _STYLE_CONTENT_TYPE = """"""
123 _PROTO_DESCRIPTOR_NAME = 'apphosting.MailServiceError'
124 class MailAttachment(ProtocolBuffer.ProtocolMessage):
125 has_filename_ = 0
126 filename_ = ""
127 has_data_ = 0
128 data_ = ""
129 has_contentid_ = 0
130 contentid_ = ""
132 def __init__(self, contents=None):
133 if contents is not None: self.MergeFromString(contents)
135 def filename(self): return self.filename_
137 def set_filename(self, x):
138 self.has_filename_ = 1
139 self.filename_ = x
141 def clear_filename(self):
142 if self.has_filename_:
143 self.has_filename_ = 0
144 self.filename_ = ""
146 def has_filename(self): return self.has_filename_
148 def data(self): return self.data_
150 def set_data(self, x):
151 self.has_data_ = 1
152 self.data_ = x
154 def clear_data(self):
155 if self.has_data_:
156 self.has_data_ = 0
157 self.data_ = ""
159 def has_data(self): return self.has_data_
161 def contentid(self): return self.contentid_
163 def set_contentid(self, x):
164 self.has_contentid_ = 1
165 self.contentid_ = x
167 def clear_contentid(self):
168 if self.has_contentid_:
169 self.has_contentid_ = 0
170 self.contentid_ = ""
172 def has_contentid(self): return self.has_contentid_
175 def MergeFrom(self, x):
176 assert x is not self
177 if (x.has_filename()): self.set_filename(x.filename())
178 if (x.has_data()): self.set_data(x.data())
179 if (x.has_contentid()): self.set_contentid(x.contentid())
181 def Equals(self, x):
182 if x is self: return 1
183 if self.has_filename_ != x.has_filename_: return 0
184 if self.has_filename_ and self.filename_ != x.filename_: return 0
185 if self.has_data_ != x.has_data_: return 0
186 if self.has_data_ and self.data_ != x.data_: return 0
187 if self.has_contentid_ != x.has_contentid_: return 0
188 if self.has_contentid_ and self.contentid_ != x.contentid_: return 0
189 return 1
191 def IsInitialized(self, debug_strs=None):
192 initialized = 1
193 if (not self.has_filename_):
194 initialized = 0
195 if debug_strs is not None:
196 debug_strs.append('Required field: filename not set.')
197 if (not self.has_data_):
198 initialized = 0
199 if debug_strs is not None:
200 debug_strs.append('Required field: data not set.')
201 return initialized
203 def ByteSize(self):
204 n = 0
205 n += self.lengthString(len(self.filename_))
206 n += self.lengthString(len(self.data_))
207 if (self.has_contentid_): n += 1 + self.lengthString(len(self.contentid_))
208 return n + 2
210 def ByteSizePartial(self):
211 n = 0
212 if (self.has_filename_):
213 n += 1
214 n += self.lengthString(len(self.filename_))
215 if (self.has_data_):
216 n += 1
217 n += self.lengthString(len(self.data_))
218 if (self.has_contentid_): n += 1 + self.lengthString(len(self.contentid_))
219 return n
221 def Clear(self):
222 self.clear_filename()
223 self.clear_data()
224 self.clear_contentid()
226 def OutputUnchecked(self, out):
227 out.putVarInt32(10)
228 out.putPrefixedString(self.filename_)
229 out.putVarInt32(18)
230 out.putPrefixedString(self.data_)
231 if (self.has_contentid_):
232 out.putVarInt32(26)
233 out.putPrefixedString(self.contentid_)
235 def OutputPartial(self, out):
236 if (self.has_filename_):
237 out.putVarInt32(10)
238 out.putPrefixedString(self.filename_)
239 if (self.has_data_):
240 out.putVarInt32(18)
241 out.putPrefixedString(self.data_)
242 if (self.has_contentid_):
243 out.putVarInt32(26)
244 out.putPrefixedString(self.contentid_)
246 def TryMerge(self, d):
247 while d.avail() > 0:
248 tt = d.getVarInt32()
249 if tt == 10:
250 self.set_filename(d.getPrefixedString())
251 continue
252 if tt == 18:
253 self.set_data(d.getPrefixedString())
254 continue
255 if tt == 26:
256 self.set_contentid(d.getPrefixedString())
257 continue
260 if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
261 d.skipData(tt)
264 def __str__(self, prefix="", printElemNumber=0):
265 res=""
266 if self.has_filename_: res+=prefix+("FileName: %s\n" % self.DebugFormatString(self.filename_))
267 if self.has_data_: res+=prefix+("Data: %s\n" % self.DebugFormatString(self.data_))
268 if self.has_contentid_: res+=prefix+("ContentID: %s\n" % self.DebugFormatString(self.contentid_))
269 return res
272 def _BuildTagLookupTable(sparse, maxtag, default=None):
273 return tuple([sparse.get(i, default) for i in xrange(0, 1+maxtag)])
275 kFileName = 1
276 kData = 2
277 kContentID = 3
279 _TEXT = _BuildTagLookupTable({
280 0: "ErrorCode",
281 1: "FileName",
282 2: "Data",
283 3: "ContentID",
284 }, 3)
286 _TYPES = _BuildTagLookupTable({
287 0: ProtocolBuffer.Encoder.NUMERIC,
288 1: ProtocolBuffer.Encoder.STRING,
289 2: ProtocolBuffer.Encoder.STRING,
290 3: ProtocolBuffer.Encoder.STRING,
291 }, 3, ProtocolBuffer.Encoder.MAX_TYPE)
294 _STYLE = """"""
295 _STYLE_CONTENT_TYPE = """"""
296 _PROTO_DESCRIPTOR_NAME = 'apphosting.MailAttachment'
297 class MailHeader(ProtocolBuffer.ProtocolMessage):
298 has_name_ = 0
299 name_ = ""
300 has_value_ = 0
301 value_ = ""
303 def __init__(self, contents=None):
304 if contents is not None: self.MergeFromString(contents)
306 def name(self): return self.name_
308 def set_name(self, x):
309 self.has_name_ = 1
310 self.name_ = x
312 def clear_name(self):
313 if self.has_name_:
314 self.has_name_ = 0
315 self.name_ = ""
317 def has_name(self): return self.has_name_
319 def value(self): return self.value_
321 def set_value(self, x):
322 self.has_value_ = 1
323 self.value_ = x
325 def clear_value(self):
326 if self.has_value_:
327 self.has_value_ = 0
328 self.value_ = ""
330 def has_value(self): return self.has_value_
333 def MergeFrom(self, x):
334 assert x is not self
335 if (x.has_name()): self.set_name(x.name())
336 if (x.has_value()): self.set_value(x.value())
338 def Equals(self, x):
339 if x is self: return 1
340 if self.has_name_ != x.has_name_: return 0
341 if self.has_name_ and self.name_ != x.name_: return 0
342 if self.has_value_ != x.has_value_: return 0
343 if self.has_value_ and self.value_ != x.value_: return 0
344 return 1
346 def IsInitialized(self, debug_strs=None):
347 initialized = 1
348 if (not self.has_name_):
349 initialized = 0
350 if debug_strs is not None:
351 debug_strs.append('Required field: name not set.')
352 if (not self.has_value_):
353 initialized = 0
354 if debug_strs is not None:
355 debug_strs.append('Required field: value not set.')
356 return initialized
358 def ByteSize(self):
359 n = 0
360 n += self.lengthString(len(self.name_))
361 n += self.lengthString(len(self.value_))
362 return n + 2
364 def ByteSizePartial(self):
365 n = 0
366 if (self.has_name_):
367 n += 1
368 n += self.lengthString(len(self.name_))
369 if (self.has_value_):
370 n += 1
371 n += self.lengthString(len(self.value_))
372 return n
374 def Clear(self):
375 self.clear_name()
376 self.clear_value()
378 def OutputUnchecked(self, out):
379 out.putVarInt32(10)
380 out.putPrefixedString(self.name_)
381 out.putVarInt32(18)
382 out.putPrefixedString(self.value_)
384 def OutputPartial(self, out):
385 if (self.has_name_):
386 out.putVarInt32(10)
387 out.putPrefixedString(self.name_)
388 if (self.has_value_):
389 out.putVarInt32(18)
390 out.putPrefixedString(self.value_)
392 def TryMerge(self, d):
393 while d.avail() > 0:
394 tt = d.getVarInt32()
395 if tt == 10:
396 self.set_name(d.getPrefixedString())
397 continue
398 if tt == 18:
399 self.set_value(d.getPrefixedString())
400 continue
403 if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
404 d.skipData(tt)
407 def __str__(self, prefix="", printElemNumber=0):
408 res=""
409 if self.has_name_: res+=prefix+("name: %s\n" % self.DebugFormatString(self.name_))
410 if self.has_value_: res+=prefix+("value: %s\n" % self.DebugFormatString(self.value_))
411 return res
414 def _BuildTagLookupTable(sparse, maxtag, default=None):
415 return tuple([sparse.get(i, default) for i in xrange(0, 1+maxtag)])
417 kname = 1
418 kvalue = 2
420 _TEXT = _BuildTagLookupTable({
421 0: "ErrorCode",
422 1: "name",
423 2: "value",
424 }, 2)
426 _TYPES = _BuildTagLookupTable({
427 0: ProtocolBuffer.Encoder.NUMERIC,
428 1: ProtocolBuffer.Encoder.STRING,
429 2: ProtocolBuffer.Encoder.STRING,
430 }, 2, ProtocolBuffer.Encoder.MAX_TYPE)
433 _STYLE = """"""
434 _STYLE_CONTENT_TYPE = """"""
435 _PROTO_DESCRIPTOR_NAME = 'apphosting.MailHeader'
436 class MailMessage(ProtocolBuffer.ProtocolMessage):
437 has_sender_ = 0
438 sender_ = ""
439 has_replyto_ = 0
440 replyto_ = ""
441 has_subject_ = 0
442 subject_ = ""
443 has_textbody_ = 0
444 textbody_ = ""
445 has_htmlbody_ = 0
446 htmlbody_ = ""
448 def __init__(self, contents=None):
449 self.to_ = []
450 self.cc_ = []
451 self.bcc_ = []
452 self.attachment_ = []
453 self.header_ = []
454 if contents is not None: self.MergeFromString(contents)
456 def sender(self): return self.sender_
458 def set_sender(self, x):
459 self.has_sender_ = 1
460 self.sender_ = x
462 def clear_sender(self):
463 if self.has_sender_:
464 self.has_sender_ = 0
465 self.sender_ = ""
467 def has_sender(self): return self.has_sender_
469 def replyto(self): return self.replyto_
471 def set_replyto(self, x):
472 self.has_replyto_ = 1
473 self.replyto_ = x
475 def clear_replyto(self):
476 if self.has_replyto_:
477 self.has_replyto_ = 0
478 self.replyto_ = ""
480 def has_replyto(self): return self.has_replyto_
482 def to_size(self): return len(self.to_)
483 def to_list(self): return self.to_
485 def to(self, i):
486 return self.to_[i]
488 def set_to(self, i, x):
489 self.to_[i] = x
491 def add_to(self, x):
492 self.to_.append(x)
494 def clear_to(self):
495 self.to_ = []
497 def cc_size(self): return len(self.cc_)
498 def cc_list(self): return self.cc_
500 def cc(self, i):
501 return self.cc_[i]
503 def set_cc(self, i, x):
504 self.cc_[i] = x
506 def add_cc(self, x):
507 self.cc_.append(x)
509 def clear_cc(self):
510 self.cc_ = []
512 def bcc_size(self): return len(self.bcc_)
513 def bcc_list(self): return self.bcc_
515 def bcc(self, i):
516 return self.bcc_[i]
518 def set_bcc(self, i, x):
519 self.bcc_[i] = x
521 def add_bcc(self, x):
522 self.bcc_.append(x)
524 def clear_bcc(self):
525 self.bcc_ = []
527 def subject(self): return self.subject_
529 def set_subject(self, x):
530 self.has_subject_ = 1
531 self.subject_ = x
533 def clear_subject(self):
534 if self.has_subject_:
535 self.has_subject_ = 0
536 self.subject_ = ""
538 def has_subject(self): return self.has_subject_
540 def textbody(self): return self.textbody_
542 def set_textbody(self, x):
543 self.has_textbody_ = 1
544 self.textbody_ = x
546 def clear_textbody(self):
547 if self.has_textbody_:
548 self.has_textbody_ = 0
549 self.textbody_ = ""
551 def has_textbody(self): return self.has_textbody_
553 def htmlbody(self): return self.htmlbody_
555 def set_htmlbody(self, x):
556 self.has_htmlbody_ = 1
557 self.htmlbody_ = x
559 def clear_htmlbody(self):
560 if self.has_htmlbody_:
561 self.has_htmlbody_ = 0
562 self.htmlbody_ = ""
564 def has_htmlbody(self): return self.has_htmlbody_
566 def attachment_size(self): return len(self.attachment_)
567 def attachment_list(self): return self.attachment_
569 def attachment(self, i):
570 return self.attachment_[i]
572 def mutable_attachment(self, i):
573 return self.attachment_[i]
575 def add_attachment(self):
576 x = MailAttachment()
577 self.attachment_.append(x)
578 return x
580 def clear_attachment(self):
581 self.attachment_ = []
582 def header_size(self): return len(self.header_)
583 def header_list(self): return self.header_
585 def header(self, i):
586 return self.header_[i]
588 def mutable_header(self, i):
589 return self.header_[i]
591 def add_header(self):
592 x = MailHeader()
593 self.header_.append(x)
594 return x
596 def clear_header(self):
597 self.header_ = []
599 def MergeFrom(self, x):
600 assert x is not self
601 if (x.has_sender()): self.set_sender(x.sender())
602 if (x.has_replyto()): self.set_replyto(x.replyto())
603 for i in xrange(x.to_size()): self.add_to(x.to(i))
604 for i in xrange(x.cc_size()): self.add_cc(x.cc(i))
605 for i in xrange(x.bcc_size()): self.add_bcc(x.bcc(i))
606 if (x.has_subject()): self.set_subject(x.subject())
607 if (x.has_textbody()): self.set_textbody(x.textbody())
608 if (x.has_htmlbody()): self.set_htmlbody(x.htmlbody())
609 for i in xrange(x.attachment_size()): self.add_attachment().CopyFrom(x.attachment(i))
610 for i in xrange(x.header_size()): self.add_header().CopyFrom(x.header(i))
612 def Equals(self, x):
613 if x is self: return 1
614 if self.has_sender_ != x.has_sender_: return 0
615 if self.has_sender_ and self.sender_ != x.sender_: return 0
616 if self.has_replyto_ != x.has_replyto_: return 0
617 if self.has_replyto_ and self.replyto_ != x.replyto_: return 0
618 if len(self.to_) != len(x.to_): return 0
619 for e1, e2 in zip(self.to_, x.to_):
620 if e1 != e2: return 0
621 if len(self.cc_) != len(x.cc_): return 0
622 for e1, e2 in zip(self.cc_, x.cc_):
623 if e1 != e2: return 0
624 if len(self.bcc_) != len(x.bcc_): return 0
625 for e1, e2 in zip(self.bcc_, x.bcc_):
626 if e1 != e2: return 0
627 if self.has_subject_ != x.has_subject_: return 0
628 if self.has_subject_ and self.subject_ != x.subject_: return 0
629 if self.has_textbody_ != x.has_textbody_: return 0
630 if self.has_textbody_ and self.textbody_ != x.textbody_: return 0
631 if self.has_htmlbody_ != x.has_htmlbody_: return 0
632 if self.has_htmlbody_ and self.htmlbody_ != x.htmlbody_: return 0
633 if len(self.attachment_) != len(x.attachment_): return 0
634 for e1, e2 in zip(self.attachment_, x.attachment_):
635 if e1 != e2: return 0
636 if len(self.header_) != len(x.header_): return 0
637 for e1, e2 in zip(self.header_, x.header_):
638 if e1 != e2: return 0
639 return 1
641 def IsInitialized(self, debug_strs=None):
642 initialized = 1
643 if (not self.has_sender_):
644 initialized = 0
645 if debug_strs is not None:
646 debug_strs.append('Required field: sender not set.')
647 if (not self.has_subject_):
648 initialized = 0
649 if debug_strs is not None:
650 debug_strs.append('Required field: subject not set.')
651 for p in self.attachment_:
652 if not p.IsInitialized(debug_strs): initialized=0
653 for p in self.header_:
654 if not p.IsInitialized(debug_strs): initialized=0
655 return initialized
657 def ByteSize(self):
658 n = 0
659 n += self.lengthString(len(self.sender_))
660 if (self.has_replyto_): n += 1 + self.lengthString(len(self.replyto_))
661 n += 1 * len(self.to_)
662 for i in xrange(len(self.to_)): n += self.lengthString(len(self.to_[i]))
663 n += 1 * len(self.cc_)
664 for i in xrange(len(self.cc_)): n += self.lengthString(len(self.cc_[i]))
665 n += 1 * len(self.bcc_)
666 for i in xrange(len(self.bcc_)): n += self.lengthString(len(self.bcc_[i]))
667 n += self.lengthString(len(self.subject_))
668 if (self.has_textbody_): n += 1 + self.lengthString(len(self.textbody_))
669 if (self.has_htmlbody_): n += 1 + self.lengthString(len(self.htmlbody_))
670 n += 1 * len(self.attachment_)
671 for i in xrange(len(self.attachment_)): n += self.lengthString(self.attachment_[i].ByteSize())
672 n += 1 * len(self.header_)
673 for i in xrange(len(self.header_)): n += self.lengthString(self.header_[i].ByteSize())
674 return n + 2
676 def ByteSizePartial(self):
677 n = 0
678 if (self.has_sender_):
679 n += 1
680 n += self.lengthString(len(self.sender_))
681 if (self.has_replyto_): n += 1 + self.lengthString(len(self.replyto_))
682 n += 1 * len(self.to_)
683 for i in xrange(len(self.to_)): n += self.lengthString(len(self.to_[i]))
684 n += 1 * len(self.cc_)
685 for i in xrange(len(self.cc_)): n += self.lengthString(len(self.cc_[i]))
686 n += 1 * len(self.bcc_)
687 for i in xrange(len(self.bcc_)): n += self.lengthString(len(self.bcc_[i]))
688 if (self.has_subject_):
689 n += 1
690 n += self.lengthString(len(self.subject_))
691 if (self.has_textbody_): n += 1 + self.lengthString(len(self.textbody_))
692 if (self.has_htmlbody_): n += 1 + self.lengthString(len(self.htmlbody_))
693 n += 1 * len(self.attachment_)
694 for i in xrange(len(self.attachment_)): n += self.lengthString(self.attachment_[i].ByteSizePartial())
695 n += 1 * len(self.header_)
696 for i in xrange(len(self.header_)): n += self.lengthString(self.header_[i].ByteSizePartial())
697 return n
699 def Clear(self):
700 self.clear_sender()
701 self.clear_replyto()
702 self.clear_to()
703 self.clear_cc()
704 self.clear_bcc()
705 self.clear_subject()
706 self.clear_textbody()
707 self.clear_htmlbody()
708 self.clear_attachment()
709 self.clear_header()
711 def OutputUnchecked(self, out):
712 out.putVarInt32(10)
713 out.putPrefixedString(self.sender_)
714 if (self.has_replyto_):
715 out.putVarInt32(18)
716 out.putPrefixedString(self.replyto_)
717 for i in xrange(len(self.to_)):
718 out.putVarInt32(26)
719 out.putPrefixedString(self.to_[i])
720 for i in xrange(len(self.cc_)):
721 out.putVarInt32(34)
722 out.putPrefixedString(self.cc_[i])
723 for i in xrange(len(self.bcc_)):
724 out.putVarInt32(42)
725 out.putPrefixedString(self.bcc_[i])
726 out.putVarInt32(50)
727 out.putPrefixedString(self.subject_)
728 if (self.has_textbody_):
729 out.putVarInt32(58)
730 out.putPrefixedString(self.textbody_)
731 if (self.has_htmlbody_):
732 out.putVarInt32(66)
733 out.putPrefixedString(self.htmlbody_)
734 for i in xrange(len(self.attachment_)):
735 out.putVarInt32(74)
736 out.putVarInt32(self.attachment_[i].ByteSize())
737 self.attachment_[i].OutputUnchecked(out)
738 for i in xrange(len(self.header_)):
739 out.putVarInt32(82)
740 out.putVarInt32(self.header_[i].ByteSize())
741 self.header_[i].OutputUnchecked(out)
743 def OutputPartial(self, out):
744 if (self.has_sender_):
745 out.putVarInt32(10)
746 out.putPrefixedString(self.sender_)
747 if (self.has_replyto_):
748 out.putVarInt32(18)
749 out.putPrefixedString(self.replyto_)
750 for i in xrange(len(self.to_)):
751 out.putVarInt32(26)
752 out.putPrefixedString(self.to_[i])
753 for i in xrange(len(self.cc_)):
754 out.putVarInt32(34)
755 out.putPrefixedString(self.cc_[i])
756 for i in xrange(len(self.bcc_)):
757 out.putVarInt32(42)
758 out.putPrefixedString(self.bcc_[i])
759 if (self.has_subject_):
760 out.putVarInt32(50)
761 out.putPrefixedString(self.subject_)
762 if (self.has_textbody_):
763 out.putVarInt32(58)
764 out.putPrefixedString(self.textbody_)
765 if (self.has_htmlbody_):
766 out.putVarInt32(66)
767 out.putPrefixedString(self.htmlbody_)
768 for i in xrange(len(self.attachment_)):
769 out.putVarInt32(74)
770 out.putVarInt32(self.attachment_[i].ByteSizePartial())
771 self.attachment_[i].OutputPartial(out)
772 for i in xrange(len(self.header_)):
773 out.putVarInt32(82)
774 out.putVarInt32(self.header_[i].ByteSizePartial())
775 self.header_[i].OutputPartial(out)
777 def TryMerge(self, d):
778 while d.avail() > 0:
779 tt = d.getVarInt32()
780 if tt == 10:
781 self.set_sender(d.getPrefixedString())
782 continue
783 if tt == 18:
784 self.set_replyto(d.getPrefixedString())
785 continue
786 if tt == 26:
787 self.add_to(d.getPrefixedString())
788 continue
789 if tt == 34:
790 self.add_cc(d.getPrefixedString())
791 continue
792 if tt == 42:
793 self.add_bcc(d.getPrefixedString())
794 continue
795 if tt == 50:
796 self.set_subject(d.getPrefixedString())
797 continue
798 if tt == 58:
799 self.set_textbody(d.getPrefixedString())
800 continue
801 if tt == 66:
802 self.set_htmlbody(d.getPrefixedString())
803 continue
804 if tt == 74:
805 length = d.getVarInt32()
806 tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
807 d.skip(length)
808 self.add_attachment().TryMerge(tmp)
809 continue
810 if tt == 82:
811 length = d.getVarInt32()
812 tmp = ProtocolBuffer.Decoder(d.buffer(), d.pos(), d.pos() + length)
813 d.skip(length)
814 self.add_header().TryMerge(tmp)
815 continue
818 if (tt == 0): raise ProtocolBuffer.ProtocolBufferDecodeError
819 d.skipData(tt)
822 def __str__(self, prefix="", printElemNumber=0):
823 res=""
824 if self.has_sender_: res+=prefix+("Sender: %s\n" % self.DebugFormatString(self.sender_))
825 if self.has_replyto_: res+=prefix+("ReplyTo: %s\n" % self.DebugFormatString(self.replyto_))
826 cnt=0
827 for e in self.to_:
828 elm=""
829 if printElemNumber: elm="(%d)" % cnt
830 res+=prefix+("To%s: %s\n" % (elm, self.DebugFormatString(e)))
831 cnt+=1
832 cnt=0
833 for e in self.cc_:
834 elm=""
835 if printElemNumber: elm="(%d)" % cnt
836 res+=prefix+("Cc%s: %s\n" % (elm, self.DebugFormatString(e)))
837 cnt+=1
838 cnt=0
839 for e in self.bcc_:
840 elm=""
841 if printElemNumber: elm="(%d)" % cnt
842 res+=prefix+("Bcc%s: %s\n" % (elm, self.DebugFormatString(e)))
843 cnt+=1
844 if self.has_subject_: res+=prefix+("Subject: %s\n" % self.DebugFormatString(self.subject_))
845 if self.has_textbody_: res+=prefix+("TextBody: %s\n" % self.DebugFormatString(self.textbody_))
846 if self.has_htmlbody_: res+=prefix+("HtmlBody: %s\n" % self.DebugFormatString(self.htmlbody_))
847 cnt=0
848 for e in self.attachment_:
849 elm=""
850 if printElemNumber: elm="(%d)" % cnt
851 res+=prefix+("Attachment%s <\n" % elm)
852 res+=e.__str__(prefix + " ", printElemNumber)
853 res+=prefix+">\n"
854 cnt+=1
855 cnt=0
856 for e in self.header_:
857 elm=""
858 if printElemNumber: elm="(%d)" % cnt
859 res+=prefix+("Header%s <\n" % elm)
860 res+=e.__str__(prefix + " ", printElemNumber)
861 res+=prefix+">\n"
862 cnt+=1
863 return res
866 def _BuildTagLookupTable(sparse, maxtag, default=None):
867 return tuple([sparse.get(i, default) for i in xrange(0, 1+maxtag)])
869 kSender = 1
870 kReplyTo = 2
871 kTo = 3
872 kCc = 4
873 kBcc = 5
874 kSubject = 6
875 kTextBody = 7
876 kHtmlBody = 8
877 kAttachment = 9
878 kHeader = 10
880 _TEXT = _BuildTagLookupTable({
881 0: "ErrorCode",
882 1: "Sender",
883 2: "ReplyTo",
884 3: "To",
885 4: "Cc",
886 5: "Bcc",
887 6: "Subject",
888 7: "TextBody",
889 8: "HtmlBody",
890 9: "Attachment",
891 10: "Header",
892 }, 10)
894 _TYPES = _BuildTagLookupTable({
895 0: ProtocolBuffer.Encoder.NUMERIC,
896 1: ProtocolBuffer.Encoder.STRING,
897 2: ProtocolBuffer.Encoder.STRING,
898 3: ProtocolBuffer.Encoder.STRING,
899 4: ProtocolBuffer.Encoder.STRING,
900 5: ProtocolBuffer.Encoder.STRING,
901 6: ProtocolBuffer.Encoder.STRING,
902 7: ProtocolBuffer.Encoder.STRING,
903 8: ProtocolBuffer.Encoder.STRING,
904 9: ProtocolBuffer.Encoder.STRING,
905 10: ProtocolBuffer.Encoder.STRING,
906 }, 10, ProtocolBuffer.Encoder.MAX_TYPE)
909 _STYLE = """"""
910 _STYLE_CONTENT_TYPE = """"""
911 _PROTO_DESCRIPTOR_NAME = 'apphosting.MailMessage'
912 if _extension_runtime:
913 pass
915 __all__ = ['MailServiceError','MailAttachment','MailHeader','MailMessage']