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 * Interface spefication for managing associations between various social contacts |
|
17 */ |
|
18 #ifndef SMFRELATIONMGR_H |
|
19 #define SMFRELATIONMGR_H |
|
20 |
|
21 #include "smfprovider.h" |
|
22 #include "smfcontact.h" |
|
23 #include "smfglobal.h" |
|
24 |
|
25 /** implementaion constants */ |
|
26 const int maxSmfRelationIdSize = 500; |
|
27 const int maxSmfRelationItemSize = 1000; |
|
28 const int maxRelationItems = 1000; |
|
29 |
|
30 |
|
31 /** forward*/ |
|
32 class SmfRelationMgrPrivate; |
|
33 |
|
34 /** |
|
35 * persistent Id of a relation. |
|
36 */ |
|
37 typedef QString SmfRelationId; |
|
38 |
|
39 /** |
|
40 * One record of a contact in a relation. Index specifies their position in the relationship. |
|
41 */ |
|
42 class SMFCLIENT_EXPORT SmfRelationItem : public SmfContact |
|
43 { |
|
44 public: |
|
45 SmfRelationItem(SmfProvider* provider=0); |
|
46 public: |
|
47 SmfProvider getProvider() const; |
|
48 void setProvider(SmfProvider& provider); |
|
49 SmfContact getContact() const; |
|
50 void setContact(SmfContact& contact); |
|
51 quint32 getIndex() const; |
|
52 void setIndex(quint32 index); |
|
53 private: |
|
54 SmfProvider m_provider; |
|
55 SmfContact m_contact; |
|
56 quint32 m_index; |
|
57 }; |
|
58 SMFCLIENT_EXPORT QDataStream &operator<<( QDataStream &aDataStream, |
|
59 const SmfRelationItem &aRelnItem ); |
|
60 |
|
61 SMFCLIENT_EXPORT QDataStream &operator>>( QDataStream &aDataStream, |
|
62 SmfRelationItem &aRelnItem); |
|
63 /** |
|
64 * All remote profiles (e.g. facebook, twitter, flicker) for a particular |
|
65 * person (or entity) constitutes a relation. Relation Manager stores |
|
66 * these relations in persistent memory. |
|
67 * |
|
68 * Relations and Items can be visualized in rows and columns. |
|
69 * Each row is identified by a RelationId. |
|
70 * Each column is identified by index of that Item in the relation |
|
71 * Each Items holds necessary information for SmfProvider and SmfContact. |
|
72 * In the diagram below C1, C2... could be local or remote contacts, which means |
|
73 * that C1, C2 .. could be contacts from device-resident phonebook. For example, for contact C1, |
|
74 * items at index 1,2,3.. in this relationship denotes C1's id in Facebook, Twitter, flickr,... . |
|
75 * |
|
76 * Relation Item Relation Item Relation Item Relation Item Relation Item |
|
77 * Index1 index2 index3 index4 index5 |
|
78 * _______________________________________________________________________ |
|
79 * | | | | | | |
|
80 * RelationId 1 | C1 | Remote | Remote | Remote | Remote | |
|
81 * | | Contact | Contact | Contact | Contact | |
|
82 * ------------------------------------------------------------------------------------------------------------------ |
|
83 * | | | | | | |
|
84 * RelationId 2 | C2 | Remote | Remote | | | |
|
85 * | | Contact | Contact | | | |
|
86 * ----------------------------------------------------------------------------------------------------------------- |
|
87 * | | | | | | |
|
88 * RelationId 3 | C3 | Remote | | | | |
|
89 * | | Contact | | | | |
|
90 * ----------------------------------------------------------------------------------------------------------------- |
|
91 * | | | | | | |
|
92 * RelationId 4 | C4 | Remote | Remote | | | |
|
93 * | | Contact | Contact | | | |
|
94 * ----------------------------------------------------------------------------------------------------------------- |
|
95 * | | | | | | |
|
96 * RelationId 5 | C5 | Remote | | | | |
|
97 * | | Contact | | | | |
|
98 * ----------------------------------------------------------------------------------------------------------------- |
|
99 * |
|
100 * Items can be added (associated) to a given relation. So this is one-to-many |
|
101 * relationship. Typically no items be present in more than one relation. |
|
102 * |
|
103 * All functions are synchronous at this moment. |
|
104 */ |
|
105 class SMFCLIENT_EXPORT SmfRelationMgr : public QObject |
|
106 { |
|
107 Q_OBJECT |
|
108 public: |
|
109 SmfRelationMgr(QObject* parent = 0); |
|
110 ~SmfRelationMgr(); |
|
111 |
|
112 public slots: |
|
113 |
|
114 /** create a new relation. The contact provided is the first contact in this |
|
115 * relation. |
|
116 * Please note that contact should have valid Guid @ref QtMobility::QContactGuid |
|
117 * (used by Smf to store the unique id of user from facebook, etc.) and valid Url |
|
118 * @ref QtMobility::QContactUrl |
|
119 * |
|
120 * If the contact is already stored with ContactManager (e.g. contact exists in phonebook), |
|
121 * then it would have QtMobility::QContactId properly filled with managerUri and localId. |
|
122 * These two field would also be stored in SmfRelationMgr (for easily identifying the SmfContacts). |
|
123 * |
|
124 * After successful creation, a relationId would be returned. More and more SmfContacts can |
|
125 * be added to this relation using this RelationId |
|
126 */ |
|
127 SmfRelationId create(SmfProvider *provider=NULL, SmfContact *contact=NULL); |
|
128 |
|
129 /** assign contact to a relation */ |
|
130 SmfError associate( const SmfRelationId& relation, |
|
131 const SmfContact* contact, |
|
132 SmfProvider* provider); |
|
133 |
|
134 /** remove contact from a relation */ |
|
135 SmfError remove(SmfRelationId& relation, |
|
136 const SmfContact* conact); |
|
137 |
|
138 /** returns first relation item in the relation when exists, NULL otherwise */ |
|
139 SmfRelationItem searchById(const SmfRelationId& relation); |
|
140 |
|
141 /** returns relation Id for a given contacts if exists, NULL otherwise */ |
|
142 SmfRelationId searchByContact( SmfContact contact); |
|
143 |
|
144 /** returns number of contacts in a relation*/ |
|
145 uint count(SmfRelationId relation); |
|
146 |
|
147 /** contacts and their provider */ |
|
148 SmfRelationItem get(SmfRelationId& relation, quint32 index); |
|
149 |
|
150 /** list of contacts and their provider */ |
|
151 QList<SmfRelationItem> getAll(SmfRelationId& relation); |
|
152 |
|
153 /** list of all relations */ |
|
154 QList<SmfRelationId> getAllRelations(); |
|
155 |
|
156 /** delete a particular relation*/ |
|
157 SmfError Delete(SmfRelationId& relation); |
|
158 |
|
159 private: |
|
160 //private impl wrapper |
|
161 SmfRelationMgrPrivate* m_private; |
|
162 }; |
|
163 |
|
164 #endif // SMFRELATIONMGR_H |
|