OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/time.h" |
| 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 14 |
| 15 namespace contacts { |
| 16 |
| 17 // Struct representing a contact, roughly based on the GData Contact kind: |
| 18 // https://developers.google.com/gdata/docs/2.0/elements#gdContactKind |
| 19 // All strings are UTF-8. |
| 20 struct Contact { |
| 21 // Describes an address-like field's type. |
| 22 struct AddressType { |
| 23 enum Relation { |
| 24 RELATION_HOME = 0, |
| 25 RELATION_WORK = 1, |
| 26 RELATION_MOBILE = 2, |
| 27 RELATION_OTHER = 3, |
| 28 }; |
| 29 |
| 30 Relation relation; |
| 31 std::string label; |
| 32 }; |
| 33 |
| 34 struct EmailAddress { |
| 35 std::string address; |
| 36 AddressType type; |
| 37 bool primary; |
| 38 }; |
| 39 |
| 40 struct PhoneNumber { |
| 41 std::string number; |
| 42 AddressType type; |
| 43 bool primary; |
| 44 }; |
| 45 |
| 46 struct PostalAddress { |
| 47 std::string address; |
| 48 AddressType type; |
| 49 bool primary; |
| 50 }; |
| 51 |
| 52 struct InstantMessagingAddress { |
| 53 // Taken from https://developers.google.com/gdata/docs/2.0/elements#gdIm. |
| 54 enum Protocol { |
| 55 PROTOCOL_AIM = 0, |
| 56 PROTOCOL_MSN = 1, |
| 57 PROTOCOL_YAHOO = 2, |
| 58 PROTOCOL_SKYPE = 3, |
| 59 PROTOCOL_QQ = 4, |
| 60 PROTOCOL_GOOGLE_TALK = 5, |
| 61 PROTOCOL_ICQ = 6, |
| 62 PROTOCOL_JABBER = 7, |
| 63 PROTOCOL_OTHER = 8, |
| 64 }; |
| 65 |
| 66 std::string address; |
| 67 Protocol protocol; |
| 68 AddressType type; |
| 69 bool primary; |
| 70 }; |
| 71 |
| 72 Contact(); |
| 73 ~Contact(); |
| 74 |
| 75 int64 serialized_update_time() const { |
| 76 return update_time.ToInternalValue(); |
| 77 } |
| 78 void set_serialized_update_time(int64 serialized) { |
| 79 update_time = base::Time::FromInternalValue(serialized); |
| 80 } |
| 81 |
| 82 // NOTE: Any changes to the below fields must be reflected in |
| 83 // contact_test_lib.cc's CopyContact() function. |
| 84 |
| 85 // Provider-assigned unique identifier. |
| 86 std::string provider_id; |
| 87 |
| 88 // Last time at which this contact was updated. |
| 89 base::Time update_time; |
| 90 |
| 91 // Has the contact been deleted? |
| 92 bool deleted; |
| 93 |
| 94 // Taken from https://developers.google.com/gdata/docs/2.0/elements#gdName. |
| 95 std::string full_name; |
| 96 std::string given_name; |
| 97 std::string additional_name; |
| 98 std::string family_name; |
| 99 std::string name_prefix; |
| 100 std::string name_suffix; |
| 101 |
| 102 SkBitmap photo; |
| 103 |
| 104 std::vector<EmailAddress> email_addresses; |
| 105 std::vector<PhoneNumber> phone_numbers; |
| 106 std::vector<PostalAddress> postal_addresses; |
| 107 std::vector<InstantMessagingAddress> instant_messaging_addresses; |
| 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(Contact); |
| 110 }; |
| 111 |
| 112 typedef std::vector<const Contact*> ContactPointers; |
| 113 |
| 114 } // namespace contacts |
| 115 |
| 116 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_H_ |
OLD | NEW |