22 #include "caclientnotifierproxy.h" |
22 #include "caclientnotifierproxy.h" |
23 |
23 |
24 CaNotifiers::NotifierHash CaNotifiers::mNotifiers; |
24 CaNotifiers::NotifierHash CaNotifiers::mNotifiers; |
25 |
25 |
26 int CaNotifiers::addNotifier(const CaNotifierFilter *notifierFilter, |
26 int CaNotifiers::addNotifier(const CaNotifierFilter *notifierFilter, |
27 CaNotifierPrivate::NotifierType notifierType, |
27 CaNotifierPrivate::NotifierType notifierType, |
28 const CaClientNotifierProxy *notifierProxy) |
28 const CaClientNotifierProxy *notifierProxy) |
29 { |
29 { |
30 NotifierKey key = NotifierKey(notifierFilter, notifierType); |
30 NotifierKey key = NotifierKey(notifierFilter, notifierType); |
31 if (!mNotifiers.contains(key)) { |
31 if (!mNotifiers.contains(key)) { |
32 mNotifiers.insert(key, notifierProxy); |
32 mNotifiers.insert(key, notifierProxy); |
33 } |
33 } |
34 return 0; |
34 return 0; |
35 } |
35 } |
36 |
36 |
37 void CaNotifiers::removeNotifier(const CaNotifierFilter *notifierFilter, |
37 void CaNotifiers::removeNotifier(const CaNotifierFilter *notifierFilter, |
38 CaNotifierPrivate::NotifierType notifierType) |
38 CaNotifierPrivate::NotifierType notifierType) |
39 { |
39 { |
40 mNotifiers.remove(NotifierKey(notifierFilter, notifierType)); |
40 mNotifiers.remove(NotifierKey(notifierFilter, notifierType)); |
41 } |
41 } |
42 |
42 |
43 void CaNotifiers::Notify(int groupId) |
43 void CaNotifiers::Notify(int groupId) |
44 { |
44 { |
45 for (NotifierHash::const_iterator i = mNotifiers.constBegin(); |
45 for (NotifierHash::const_iterator i = mNotifiers.constBegin(); |
46 i != mNotifiers.constEnd(); |
46 i != mNotifiers.constEnd(); |
47 ++i) { |
47 ++i) { |
48 const CaNotifierFilter *filter = i.key().first; |
48 const CaNotifierFilter *filter = i.key().first; |
49 if (filter->getIds().isEmpty() || filter->getIds().contains(groupId)) { |
49 if (filter->getIds().isEmpty() || filter->getIds().contains(groupId)) { |
50 if (i.key().second |
50 if (i.key().second |
51 == CaNotifierPrivate::GroupContentChangedNotifierType) { |
51 == CaNotifierPrivate::GroupContentChangedNotifierType) { |
52 i.value()->groupContentChanged(groupId); |
52 i.value()->groupContentChanged(groupId); |
53 } |
53 } |
54 } |
54 } |
55 } |
55 } |
56 } |
56 } |
57 |
57 |
58 void CaNotifiers::Notify(const CaEntry &targetEntry, |
58 void CaNotifiers::Notify(const CaEntry &targetEntry, |
59 ChangeType changeType, |
59 ChangeType changeType, |
60 QList<int> &parentIds) |
60 QList<int> &parentIds) |
61 { |
61 { |
62 for (NotifierHash::const_iterator i = mNotifiers.constBegin(); |
62 for (NotifierHash::const_iterator i = mNotifiers.constBegin(); |
63 i != mNotifiers.constEnd(); |
63 i != mNotifiers.constEnd(); |
64 ++i) { |
64 ++i) { |
65 if (isRegisterdForNotification( |
65 if (isRegisterdForNotification( |
66 *i.key().first, targetEntry, parentIds)) { |
66 *i.key().first, targetEntry, parentIds)) { |
67 if (i.key().second |
67 if (i.key().second |
68 == CaNotifierPrivate::EntryChangedWithIdNotifierType) { |
68 == CaNotifierPrivate::EntryChangedWithIdNotifierType) { |
69 i.value()->entryChanged(targetEntry.id(), changeType); |
69 i.value()->entryChanged(targetEntry.id(), changeType); |
70 } else if (i.key().second |
70 } else if (i.key().second |
71 == CaNotifierPrivate::EntryChangedWithEntryNotifierType) { |
71 == CaNotifierPrivate::EntryChangedWithEntryNotifierType) { |
72 i.value()->entryChanged(targetEntry, changeType); |
72 i.value()->entryChanged(targetEntry, changeType); |
73 } else if (i.key().second |
73 } else if (i.key().second |
74 == CaNotifierPrivate::EntryTouchedNotifierType) { |
74 == CaNotifierPrivate::EntryTouchedNotifierType) { |
75 i.value()->entryChanged(targetEntry.id(), changeType); |
75 i.value()->entryChanged(targetEntry.id(), changeType); |
76 } |
76 } |
77 } |
77 } |
78 } |
78 } |
79 } |
79 } |