|
1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html" |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Manasij Roy, Nalina Hariharan |
|
14 * |
|
15 * Description: |
|
16 * The group class represents an instance of a group as per SN site terminolgy |
|
17 */ |
|
18 |
|
19 #include "smfgroup.h" |
|
20 #include "smfgroup_p.h" |
|
21 |
|
22 /** |
|
23 * Constructor with default argument |
|
24 * @param list The list of members in the group |
|
25 */ |
|
26 SmfGroup::SmfGroup( QList<SmfContact>* list ) |
|
27 { |
|
28 d = new SmfGroupPrivate; |
|
29 if(list) |
|
30 d->m_members = list; |
|
31 } |
|
32 |
|
33 /** |
|
34 * Copy Constructor |
|
35 * @param aOther The reference object |
|
36 */ |
|
37 SmfGroup::SmfGroup( const SmfGroup &aOther ): d(aOther.d) |
|
38 { |
|
39 |
|
40 } |
|
41 |
|
42 /** |
|
43 * Overloaded = operator |
|
44 * @param aOther The reference object |
|
45 * @return The target reference value |
|
46 */ |
|
47 SmfGroup& SmfGroup::operator=( const SmfGroup &aOther ) |
|
48 { |
|
49 d->m_members = aOther.d->m_members; |
|
50 d->m_groupName = aOther.d->m_groupName; |
|
51 d->m_groupId = aOther.d->m_groupId; |
|
52 return *this; |
|
53 } |
|
54 |
|
55 /** |
|
56 * Destructor |
|
57 */ |
|
58 SmfGroup::~SmfGroup( ) |
|
59 { |
|
60 |
|
61 } |
|
62 |
|
63 /** |
|
64 * Method to get the list of members in the group |
|
65 * @return The list of members in the group |
|
66 */ |
|
67 QList<SmfContact> SmfGroup::members( ) const |
|
68 { |
|
69 return *(d->m_members) ; |
|
70 } |
|
71 |
|
72 /** |
|
73 * Method to set members |
|
74 * |
|
75 */ |
|
76 void SmfGroup::setMembers(QList<SmfContact>* mems) |
|
77 { |
|
78 d->m_members = mems; |
|
79 } |
|
80 |
|
81 /** |
|
82 * Method to get the name of the group |
|
83 * @return The name of the group |
|
84 */ |
|
85 QString SmfGroup::name( ) const |
|
86 { |
|
87 return d->m_groupName; |
|
88 } |
|
89 |
|
90 /** |
|
91 * Method to set name |
|
92 */ |
|
93 void SmfGroup::setName(QString& name) |
|
94 { |
|
95 d->m_groupName = name; |
|
96 } |
|
97 |
|
98 /** |
|
99 * Method to get the id of the group |
|
100 * @return The ID value |
|
101 */ |
|
102 QString SmfGroup::id( ) const |
|
103 { |
|
104 return d->m_groupId; |
|
105 } |
|
106 |
|
107 /** |
|
108 * Method to set id |
|
109 */ |
|
110 void SmfGroup::setId(QString& id) |
|
111 { |
|
112 d->m_groupId = id; |
|
113 |
|
114 } |
|
115 /** |
|
116 * Method for Externalization. Writes the SmfGroup object to |
|
117 * the stream and returns a reference to the stream. |
|
118 * @param aDataStream Stream to be written |
|
119 * @param aGroup The SmfGroup object to be externalized |
|
120 * @return reference to the written stream |
|
121 */ |
|
122 QDataStream &operator<<( QDataStream &aDataStream, |
|
123 const SmfGroup &aGroup ) |
|
124 { |
|
125 aDataStream<<aGroup.members(); |
|
126 aDataStream<<aGroup.name(); |
|
127 aDataStream<<aGroup.id(); |
|
128 return aDataStream; |
|
129 } |
|
130 |
|
131 /** |
|
132 * Method for Internalization. Reads a SmfGroup object from |
|
133 * the stream and returns a reference to the stream. |
|
134 * @param aDataStream Stream to be read |
|
135 * @param aGroup The SmfGroup object to be internalized |
|
136 * @return reference to the stream |
|
137 */ |
|
138 QDataStream &operator>>( QDataStream &aDataStream, |
|
139 SmfGroup &aGroup) |
|
140 { |
|
141 QList<SmfContact> list; |
|
142 aDataStream>>list; |
|
143 aGroup.setMembers(&list); |
|
144 |
|
145 QString grpname; |
|
146 aDataStream>>grpname; |
|
147 aGroup.d->m_groupName = grpname; |
|
148 |
|
149 QString grpId; |
|
150 aDataStream>>grpId; |
|
151 aGroup.d->m_groupId = grpId; |
|
152 |
|
153 return aDataStream; |
|
154 } |