~renatofilho/address-book-service/create-source

« back to all changes in this revision

Viewing changes to lib/dirtycontact-notify.h

  • Committer: Renato Araujo Oliveira Filho
  • Date: 2014-03-18 15:01:59 UTC
  • Revision ID: renato.filho@canonical.com-20140318150159-mj7rwmsargsiv38q
Moved DirtyContactsNotify class to a individual file and make it a QObject.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2014 Canonical Ltd.
 
3
 *
 
4
 * This file is part of contact-service-app.
 
5
 *
 
6
 * contact-service-app is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; version 3.
 
9
 *
 
10
 * contact-service-app 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, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#ifndef __GALERA_DIRTYCONTACT_NOTIFY_H__
 
20
#define __GALERA_DIRTYCONTACT_NOTIFY_H__
 
21
 
 
22
#include <QtCore/QObject>
 
23
#include <QtCore/QTimer>
 
24
#include <QtCore/QSet>
 
25
#include <QtCore/QString>
 
26
#include <QtCore/QStringList>
 
27
 
 
28
namespace galera {
 
29
 
 
30
class AddressBookAdaptor;
 
31
 
 
32
// this is a helper class uses a timer with a small timeout to notify the client about
 
33
// any contact change notification. This class should be used instead of emit the signal directly
 
34
// this will avoid notify about the contact update several times when updating different fields simultaneously
 
35
// With that we can reduce the dbus traffic and skip some client calls to query about the new contact info.
 
36
class DirtyContactsNotify : public QObject
 
37
{
 
38
    Q_OBJECT
 
39
 
 
40
public:
 
41
    DirtyContactsNotify(AddressBookAdaptor *adaptor, QObject *parent=0);
 
42
 
 
43
    void append(QSet<QString> ids);
 
44
 
 
45
private Q_SLOTS:
 
46
    void onTimeout();
 
47
 
 
48
private:
 
49
    AddressBookAdaptor *m_adaptor;
 
50
    QTimer m_timer;
 
51
    QSet<QString> m_ids;
 
52
};
 
53
 
 
54
} //namespace
 
55
 
 
56
#endif