1 | #ifndef __msn_buddy_h__ |
2 | #define __msn_buddy_h__ |
3 | |
4 | /* |
5 | * buddy.h |
6 | * libmsn |
7 | * |
8 | * Created by Mark Rowe on Mon Apr 19 2004. |
9 | * Refactored by Tiago Salem Herrmann on 08/2007. |
10 | * Copyright (c) 2004 Mark Rowe. All rights reserved. |
11 | * Copyright (c) 2007 Tiago Salem Herrmann. All rights reserved |
12 | * |
13 | * This program is free software; you can redistribute it and/or modify |
14 | * it under the terms of the GNU General Public License as published by |
15 | * the Free Software Foundation; either version 2 of the License, or |
16 | * (at your option) any later version. |
17 | * |
18 | * This program is distributed in the hope that it will be useful, |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | * GNU General Public License for more details. |
22 | * |
23 | * You should have received a copy of the GNU General Public License |
24 | * along with this program; if not, write to the Free Software |
25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
26 | */ |
27 | |
28 | #include <string> |
29 | #include <list> |
30 | #include <vector> |
31 | #include <map> |
32 | #include <msn/passport.h> |
33 | |
34 | #include "libmsn_export.h" |
35 | |
36 | namespace MSN |
37 | { |
38 | /** The online state of a buddy. |
39 | */ |
40 | |
41 | enum BuddyStatus |
42 | { |
43 | STATUS_AVAILABLE, /**< Contact is available */ |
44 | STATUS_BUSY, /**< Contact is busy */ |
45 | STATUS_IDLE, /**< Contact is idle */ |
46 | STATUS_BERIGHTBACK, /**< Contact will be right back */ |
47 | STATUS_AWAY, /**< Contact is away */ |
48 | STATUS_ONTHEPHONE, /**< Contact is on the phone */ |
49 | STATUS_OUTTOLUNCH, /**< Contact is out to lunch */ |
50 | STATUS_INVISIBLE /**< Contact is invisible */ |
51 | }; |
52 | |
53 | std::string LIBMSN_EXPORT buddyStatusToString(BuddyStatus s); |
54 | BuddyStatus LIBMSN_EXPORT buddyStatusFromString(std::string s); |
55 | |
56 | class Group; |
57 | |
58 | /** The Buddy class contains information about a member of a buddy list. |
59 | * |
60 | * Each Buddy is made up of their passport address (@a userName), |
61 | * user-visible display name (@a friendlyName), a list of properties |
62 | * (@a properties) and zero or more @a groups on the buddy list that they belong to. |
63 | * |
64 | */ |
65 | class LIBMSN_EXPORT Buddy |
66 | { |
67 | public: |
68 | /** The PhoneNumbers class contains information about one or more phone numbers |
69 | * that are retrieved during the buddy list synchronisation process. |
70 | */ |
71 | class PhoneNumber |
72 | { |
73 | public: |
74 | /** The name of this phone number. |
75 | * |
76 | * @todo Should this be an enumeration containing the possible |
77 | * types of phone number? |
78 | */ |
79 | std::string title; |
80 | |
81 | std::string number; |
82 | |
83 | bool enabled; |
84 | |
85 | PhoneNumber(std::string title_, std::string number_, bool enabled_=true) |
86 | : title(title_), number(number_), enabled(enabled_) {}; |
87 | |
88 | }; |
89 | |
90 | /** all the properties received at login time */ |
91 | std::map<std::string, std::string> properties; |
92 | |
93 | /** Their passport address */ |
94 | Passport userName; |
95 | |
96 | /** Their friendly name */ |
97 | std::string friendlyName; |
98 | |
99 | /** A list of phone numbers related to this buddy */ |
100 | std::list<Buddy::PhoneNumber> phoneNumbers; |
101 | |
102 | /** A list of Group's that this buddy is a member of */ |
103 | std::list<Group *> groups; |
104 | |
105 | /** Lists which this contact belong. Pending, Forward, Block... **/ |
106 | unsigned int lists; |
107 | |
108 | Buddy(Passport userName_, std::string friendlyName_ = "" ) : |
109 | userName(userName_), friendlyName(friendlyName_), lists(0) {}; |
110 | bool operator==(const Buddy &other) { return userName == other.userName; } |
111 | }; |
112 | |
113 | /** The Group class represents a group of contacts on the buddy list. |
114 | * |
115 | * Each group is represented by a @a groupID, a list of buddies @buddies |
116 | * and has a user-visible @a name. |
117 | */ |
118 | class LIBMSN_EXPORT Group |
119 | { |
120 | public: |
121 | |
122 | /** Id of this group **/ |
123 | std::string groupID; |
124 | |
125 | /** Name of this group **/ |
126 | std::string name; |
127 | |
128 | /** List of contacts in this group **/ |
129 | std::list<Buddy *> buddies; |
130 | |
131 | Group(std::string groupID_, std::string name_) |
132 | : groupID(groupID_), name(name_) {}; |
133 | |
134 | Group() : name("INVALID" ) {}; |
135 | }; |
136 | } |
137 | |
138 | #endif |
139 | |