source: qutecom-coip/libs/coipmanager/include/coipmanager/datamanager/ContactManager.h @ 125:d648f4cb122f

Last change on this file since 125:d648f4cb122f was 125:d648f4cb122f, checked in by laurent, 3 years ago

wengo => qutecom

File size: 3.4 KB
Line 
1/*
2 * QuteCom, a voice over Internet phone
3 * Copyright (C) 2010 Mbdsys
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20#ifndef OWCONTACTMANAGER_H
21#define OWCONTACTMANAGER_H
22
23#include <coipmanager_base/EnumUpdateSection.h>
24#include <coipmanager_base/contact/ContactList.h>
25#include <coipmanager_base/imcontact/IMContact.h>
26
27#include <coipmanager/coipmanagerdll.h>
28
29#include <QtCore/QMutex>
30#include <QtCore/QObject>
31
32class Contact;
33
34/**
35 * Contact list manager.
36 *
37 * It accesses an ContactList in a thread-safe manner.
38 *
39 * @ingroup CoIpManager
40 * @author Philippe Bernery
41 */
42class COIPMANAGER_API ContactManager : public QObject {
43        Q_OBJECT
44public:
45
46        ContactManager(ContactList & contactList);
47
48        ~ContactManager();
49
50        /**
51         * Adds an Contact.
52         *
53         * Checks if the contact is not already in the list.
54         *
55         * @return true if actuallt added (the Contact was not present)
56         */
57        bool add(const Contact & contact);
58
59        /**
60         * Removes an Contact.
61         *
62         * @return true if actually removed (the Contact was present)
63         */
64        bool remove(const std::string & contactId);
65
66        /**
67         * Updates an Contact.
68         *
69         * @param section used to specify which part of the Contact has been updated.
70         *        This parameter is used for emitting contactUpdatedEvent and optimize
71         *        some part of the code. It is usually only specified by internal classes of
72         *        CoIpManager
73         * @return true if actually update (the Contact was updated)
74         */
75        bool update(const Contact & contact,
76                EnumUpdateSection::UpdateSection section = EnumUpdateSection::UpdateSectionUnknown);
77
78Q_SIGNALS:
79
80        /**
81         * Emitted when an Contact has been added.
82         */
83        void contactAddedSignal(std::string contactId);
84
85        /**
86         * Emitted when an Contact has been removed.
87         */
88        void contactRemovedSignal(std::string contactId);
89
90        /**
91         * Emitted when an Contact has been updated.
92         *
93         * @param contactId id of the updated Contact
94         * @param section updated section of the Contact
95         */
96        void contactUpdatedSignal(std::string contactId,
97                EnumUpdateSection::UpdateSection section);
98
99        /**
100         * Emitted when an IMContact has been added to a Contact.
101         * Typically useful for internal modules (like synchronizers)
102         *
103         * @param contactId the Contact where the IMContact is from
104         * @param imContact the added IMContact
105         */
106        void imContactAddedSignal(std::string contactId, IMContact imContact);
107
108        /**
109         * Emitted when an IMContact has been removed from a Contact.
110         * Typically useful for internal modules (like synchronizers).
111         *
112         * @param contactId the Contact where the IMContact is from
113         * @param imContact the removed IMContact
114         */
115        void imContactRemovedSignal(std::string contactId, IMContact imContact);
116
117private:
118
119        static ContactList::iterator findContact(ContactList & contactList, const Contact & contact);
120
121        ContactList & _contactList;
122
123        QMutex * _mutex;
124};
125
126#endif  //OWCONTACTMANAGER_H
Note: See TracBrowser for help on using the repository browser.