Home · All Classes · All Namespaces · Modules · Functions · Files
generic-capability-filter.h
1 
23 #ifndef _TelepathyQt_generic_capability_filter_h_HEADER_GUARD_
24 #define _TelepathyQt_generic_capability_filter_h_HEADER_GUARD_
25 
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
28 #endif
29 
30 #include <TelepathyQt/ConnectionCapabilities>
31 #include <TelepathyQt/Filter>
32 #include <TelepathyQt/Types>
33 
34 namespace Tp
35 {
36 
37 template <class T>
39 {
40 public:
43  {
45  rccSpecs));
46  }
47 
48  inline virtual ~GenericCapabilityFilter() { }
49 
50  inline virtual bool isValid() const { return true; }
51 
52  inline virtual bool matches(const SharedPtr<T> &t) const
53  {
54  bool supportedRcc;
55  RequestableChannelClassSpecList objectRccSpecs = t->capabilities().allClassSpecs();
56  Q_FOREACH (const RequestableChannelClassSpec &filterRccSpec, mFilter) {
57  supportedRcc = false;
58 
59  Q_FOREACH (const RequestableChannelClassSpec &objectRccSpec, objectRccSpecs) {
60  /* check if fixed properties match */
61  if (filterRccSpec.fixedProperties() == objectRccSpec.fixedProperties()) {
62  supportedRcc = true;
63 
64  /* check if all allowed properties in the filter RCC
65  * are in the object RCC allowed properties */
66  Q_FOREACH (const QString &value, filterRccSpec.allowedProperties()) {
67  if (!objectRccSpec.allowsProperty(value)) {
68  /* one of the properties in the filter RCC
69  * allowed properties is not in the object RCC
70  * allowed properties */
71  supportedRcc = false;
72  break;
73  }
74  }
75 
76  /* this RCC is supported, no need to check anymore */
77  if (supportedRcc) {
78  break;
79  }
80  }
81  }
82 
83  /* one of the filter RCC is not supported, this object
84  * won't match filter */
85  if (!supportedRcc) {
86  return false;
87  }
88  }
89 
90  return true;
91  }
92 
93  inline RequestableChannelClassSpecList filter() const { return mFilter; }
94 
96  {
97  mFilter.append(rccSpec.bareClass());
98  }
99 
101  {
102  mFilter = rccSpecs.bareClasses();
103  }
104 
105 private:
107  : Filter<T>(), mFilter(rccSpecs) { }
108 
110 };
111 
112 } // Tp
113 
114 #endif
void addRequestableChannelClassSubset(const RequestableChannelClassSpec &rccSpec)
Definition: generic-capability-filter.h:95
QVariantMap fixedProperties() const
Definition: requestable-channel-class-spec.cpp:559
virtual ~GenericCapabilityFilter()
Definition: generic-capability-filter.h:48
The GenericCapabilityFilter class provides a generic filter object to be used to filter objects by ca...
Definition: generic-capability-filter.h:38
RequestableChannelClass bareClass() const
Definition: requestable-channel-class-spec.cpp:583
bool allowsProperty(const QString &name) const
Definition: requestable-channel-class-spec.cpp:567
QStringList allowedProperties() const
Definition: requestable-channel-class-spec.cpp:575
RequestableChannelClassList bareClasses() const
Definition: requestable-channel-class-spec.h:125
void setRequestableChannelClassesSubset(const RequestableChannelClassSpecList &rccSpecs)
Definition: generic-capability-filter.h:100
Definition: abstract-adaptor.cpp:31
The RequestableChannelClassSpec class represents a Telepathy requestable channel class.
Definition: requestable-channel-class-spec.h:36
The Filter class provides a base class to be used by specialized filters such as GenericCapabilityFil...
Definition: filter.h:37
virtual bool isValid() const
Definition: generic-capability-filter.h:50
virtual bool matches(const SharedPtr< T > &t) const
Definition: generic-capability-filter.h:52
static SharedPtr< GenericCapabilityFilter< T > > create(const RequestableChannelClassSpecList &rccSpecs=RequestableChannelClassSpecList())
Definition: generic-capability-filter.h:41
The SharedPtr class is a pointer to an explicitly shared object.
Definition: shared-ptr.h:39
RequestableChannelClassSpecList filter() const
Definition: generic-capability-filter.h:93
The RequestableChannelClassSpecList class represents a list of RequestableChannelClassSpec.
Definition: requestable-channel-class-spec.h:101


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt 0.9.7