aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java
blob: 59cc17ca106e8d5a5bf7f9df7ab747a5537f3e7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Copyright @ 2015 Atlassian Pty Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.java.sip.communicator.impl.protocol.jabber;

import java.util.*;

import net.java.sip.communicator.impl.protocol.jabber.extensions.caps.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.messagecorrection.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;

import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.util.*;

/**
 * Represents an <tt>OperationSet</tt> to query the <tt>OperationSet</tt>s
 * supported for a specific Jabber <tt>Contact</tt>. The <tt>OperationSet</tt>s
 * reported as supported for a specific Jabber <tt>Contact</tt> are considered
 * by the associated protocol provider to be capabilities possessed by the
 * Jabber <tt>Contact</tt> in question.
 *
 * @author Lyubomir Marinov
 * @author Yana Stamcheva
 */
public class OperationSetContactCapabilitiesJabberImpl
    extends AbstractOperationSetContactCapabilities<ProtocolProviderServiceJabberImpl>
    implements  UserCapsNodeListener,
                ContactPresenceStatusListener
{
    /**
     * The <tt>Logger</tt> used by the
     * <tt>OperationSetContactCapabilitiesJabberImpl</tt> class and its
     * instances for logging output.
     */
    private static final Logger logger
        = Logger.getLogger(OperationSetContactCapabilitiesJabberImpl.class);

    /**
     * The name of the property used to control whether to use
     * all resources to show capabilities
     */
    public static final String PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES =
        "net.java.sip.communicator.XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES";

    /**
     * The default value for the capabilities setting
     */
    public static final boolean USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT =
        true;

    /**
     * The list of <tt>OperationSet</tt> capabilities presumed to be supported
     * by a <tt>Contact</tt> when it is offline.
     */
    private static final Set<Class<? extends OperationSet>>
        OFFLINE_OPERATION_SETS
            = new HashSet<Class<? extends OperationSet>>();

    /**
     * The <tt>Map</tt> which associates specific <tt>OperationSet</tt> classes
     * with the features to be supported by a <tt>Contact</tt> in order to
     * consider the <tt>Contact</tt> to possess the respective
     * <tt>OperationSet</tt> capability.
     */
    private static final Map<Class<? extends OperationSet>, String[]>
        OPERATION_SETS_TO_FEATURES
            = new HashMap<Class<? extends OperationSet>, String[]>();

    static
    {
        OFFLINE_OPERATION_SETS.add(OperationSetBasicInstantMessaging.class);
        OFFLINE_OPERATION_SETS.add(OperationSetMessageCorrection.class);
        OFFLINE_OPERATION_SETS.add(OperationSetServerStoredContactInfo.class);

        OPERATION_SETS_TO_FEATURES.put(
                OperationSetBasicTelephony.class,
                new String[]
                {
                    ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE,
                    ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP,
                    ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP_AUDIO
                });

        OPERATION_SETS_TO_FEATURES.put(
            OperationSetVideoTelephony.class,
            new String[]
            {
                ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE,
                ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP,
                ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP_VIDEO
            });

        OPERATION_SETS_TO_FEATURES.put(
                OperationSetDesktopSharingServer.class,
                new String[]
                {
                    ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE,
                    ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP,
                    ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP_VIDEO
                });

        OPERATION_SETS_TO_FEATURES.put(
                OperationSetMessageCorrection.class,
                new String[]
                {
                    MessageCorrectionExtension.NAMESPACE
                });
    }

    /**
     * The <tt>EntityCapsManager</tt> associated with the
     * <tt>discoveryManager</tt> of {@link #parentProvider}.
     */
    private EntityCapsManager capsManager;

    /**
     * Initializes a new <tt>OperationSetContactCapabilitiesJabberImpl</tt>
     * instance which is to be provided by a specific
     * <tt>ProtocolProviderServiceJabberImpl</tt>.
     *
     * @param parentProvider the <tt>ProtocolProviderServiceJabberImpl</tt>
     * which will provide the new instance
     */
    public OperationSetContactCapabilitiesJabberImpl(
            ProtocolProviderServiceJabberImpl parentProvider)
    {
        super(parentProvider);

        OperationSetPresence presenceOpSet
            = parentProvider.getOperationSet(OperationSetPresence.class);

        if (presenceOpSet != null)
            presenceOpSet.addContactPresenceStatusListener(this);
    }

    /**
     * Gets the <tt>OperationSet</tt> corresponding to the specified
     * <tt>Class</tt> and supported by the specified <tt>Contact</tt>. If the
     * returned value is non-<tt>null</tt>, it indicates that the
     * <tt>Contact</tt> is considered by the associated protocol provider to
     * possess the <tt>opsetClass</tt> capability. Otherwise, the associated
     * protocol provider considers <tt>contact</tt> to not have the
     * <tt>opsetClass</tt> capability.
     *
     * @param <U> the type extending <tt>OperationSet</tt> for which the
     * specified <tt>contact</tt> is to be checked whether it possesses it as a
     * capability
     * @param contact the <tt>Contact</tt> for which the <tt>opsetClass</tt>
     * capability is to be queried
     * @param opsetClass the <tt>OperationSet</tt> <tt>Class</tt> for which the
     * specified <tt>contact</tt> is to be checked whether it possesses it as a
     * capability
     * @param online <tt>true</tt> if <tt>contact</tt> is online; otherwise,
     * <tt>false</tt>
     * @return the <tt>OperationSet</tt> corresponding to the specified
     * <tt>opsetClass</tt> which is considered by the associated protocol
     * provider to be possessed as a capability by the specified
     * <tt>contact</tt>; otherwise, <tt>null</tt>
     * @see AbstractOperationSetContactCapabilities#getOperationSet(Contact,
     * Class)
     */
    @Override
    protected <U extends OperationSet> U getOperationSet(
            Contact contact,
            Class<U> opsetClass,
            boolean online)
    {
        String jid = parentProvider.getFullJid(contact);
        if (jid == null)
            jid = contact.getAddress();

        return getOperationSet(jid, opsetClass, online);
    }

    /**
     * Gets the <tt>OperationSet</tt>s supported by a specific <tt>Contact</tt>.
     * The returned <tt>OperationSet</tt>s are considered by the associated
     * protocol provider to capabilities possessed by the specified
     * <tt>contact</tt>.
     *
     * @param contact the <tt>Contact</tt> for which the supported
     * <tt>OperationSet</tt> capabilities are to be retrieved
     * @param online <tt>true</tt> if <tt>contact</tt> is online; otherwise,
     * <tt>false</tt>
     * @return a <tt>Map</tt> listing the <tt>OperationSet</tt>s considered by
     * the associated protocol provider to be supported by the specified
     * <tt>contact</tt> (i.e. to be possessed as capabilities). Each supported
     * <tt>OperationSet</tt> capability is represented by a <tt>Map.Entry</tt>
     * with key equal to the <tt>OperationSet</tt> class name and value equal to
     * the respective <tt>OperationSet</tt> instance
     * @see AbstractOperationSetContactCapabilities#getSupportedOperationSets(
     * Contact)
     */
    @Override
    protected Map<String, OperationSet> getSupportedOperationSets(
            Contact contact,
            boolean online)
    {
        String jid = parentProvider.getFullJid(contact);
        if (jid == null)
            jid = contact.getAddress();

        return getSupportedOperationSets(jid, online);
    }

    /**
     * Gets the <tt>OperationSet</tt>s supported by a specific <tt>Contact</tt>.
     * The returned <tt>OperationSet</tt>s are considered by the associated
     * protocol provider to capabilities possessed by the specified
     * <tt>contact</tt>.
     *
     * @param jid the <tt>Contact</tt> for which the supported
     * <tt>OperationSet</tt> capabilities are to be retrieved
     * @param online <tt>true</tt> if <tt>contact</tt> is online; otherwise,
     * <tt>false</tt>
     * @return a <tt>Map</tt> listing the <tt>OperationSet</tt>s considered by
     * the associated protocol provider to be supported by the specified
     * <tt>contact</tt> (i.e. to be possessed as capabilities). Each supported
     * <tt>OperationSet</tt> capability is represented by a <tt>Map.Entry</tt>
     * with key equal to the <tt>OperationSet</tt> class name and value equal to
     * the respective <tt>OperationSet</tt> instance
     * @see AbstractOperationSetContactCapabilities#getSupportedOperationSets(
     * Contact)
     */
    @SuppressWarnings("unchecked")
    private Map<String, OperationSet> getSupportedOperationSets(String jid,
                                                                boolean online)
    {
        Map<String, OperationSet> supportedOperationSets
            = parentProvider.getSupportedOperationSets();

        int supportedOperationSetCount = supportedOperationSets.size();
        Map<String, OperationSet> contactSupportedOperationSets
            = new HashMap<String, OperationSet>(supportedOperationSetCount);

        if (supportedOperationSetCount != 0)
        {
            for (Map.Entry<String, OperationSet> supportedOperationSetEntry
                    : supportedOperationSets.entrySet())
            {
                String opsetClassName = supportedOperationSetEntry.getKey();
                Class<? extends OperationSet> opsetClass;

                try
                {
                    opsetClass
                        = (Class<? extends OperationSet>)
                            Class.forName(opsetClassName);
                }
                catch (ClassNotFoundException cnfex)
                {
                    opsetClass = null;
                    logger.error(
                            "Failed to get OperationSet class for name: "
                                + opsetClassName,
                            cnfex);
                }
                if (opsetClass != null)
                {
                    OperationSet opset
                        = getOperationSet(jid, opsetClass, online);

                    if (opset != null)
                    {
                        contactSupportedOperationSets.put(
                                opsetClassName,
                                opset);
                    }
                }
            }
        }
        return contactSupportedOperationSets;
    }

    /**
     * Gets the largest set of <tt>OperationSet</tt>s supported from a
     * list of full JIDs. The returned <tt>OperationSet</tt>s are considered
     * by the associated protocol provider to capabilities possessed by the
     * specified <tt>contact</tt>.
     *
     * @param fullJids a list of full JIDs in which to find the resource with
     * the most capabilities.
     * @return the <tt>Map</tt> listing the most <tt>OperationSet</tt>s
     * considered by the associated protocol provider to be supported by the
     * specified <tt>contact</tt> (i.e. to be possessed as capabilities).
     * Each supported <tt>OperationSet</tt> capability is represented by a
     * <tt>Map.Entry</tt> with key equal to the <tt>OperationSet</tt> class
     * name and value equal to the respective <tt>OperationSet</tt> instance
     */
    protected Map<String, OperationSet> getLargestSupportedOperationSet(
            ArrayList<String> fullJids)
    {
        Map<String, OperationSet> supportedOperationSets =
            new HashMap<String, OperationSet>();
        if (fullJids!=null)
        {
            for (String fullJid : fullJids)
            {
                Map<String, OperationSet> newSupportedOperationSets=
                getSupportedOperationSets(fullJid, true);
                if (newSupportedOperationSets.size()>
                    supportedOperationSets.size())
                {
                    supportedOperationSets = newSupportedOperationSets;
                }
            }
        }
        return supportedOperationSets;
    }

    /**
     * Gets the <tt>OperationSet</tt> corresponding to the specified
     * <tt>Class</tt> and supported by the specified <tt>Contact</tt>. If the
     * returned value is non-<tt>null</tt>, it indicates that the
     * <tt>Contact</tt> is considered by the associated protocol provider to
     * possess the <tt>opsetClass</tt> capability. Otherwise, the associated
     * protocol provider considers <tt>contact</tt> to not have the
     * <tt>opsetClass</tt> capability.
     *
     * @param <U> the type extending <tt>OperationSet</tt> for which the
     * specified <tt>contact</tt> is to be checked whether it possesses it as a
     * capability
     * @param jid the Jabber id for which we're checking supported operation
     * sets
     * @param opsetClass the <tt>OperationSet</tt> <tt>Class</tt> for which the
     * specified <tt>contact</tt> is to be checked whether it possesses it as a
     * capability
     * @param online <tt>true</tt> if <tt>contact</tt> is online; otherwise,
     * <tt>false</tt>
     * @return the <tt>OperationSet</tt> corresponding to the specified
     * <tt>opsetClass</tt> which is considered by the associated protocol
     * provider to be possessed as a capability by the specified
     * <tt>contact</tt>; otherwise, <tt>null</tt>
     * @see AbstractOperationSetContactCapabilities#getOperationSet(Contact,
     * Class)
     */
    private <U extends OperationSet> U getOperationSet(String jid,
                                                       Class<U> opsetClass,
                                                       boolean online)
    {
        U opset = parentProvider.getOperationSet(opsetClass);

        if (opset == null)
            return null;

        /*
         * If the specified contact is offline, don't query its features (they
         * should fail anyway).
         */
        if (!online)
            return OFFLINE_OPERATION_SETS.contains(opsetClass) ? opset : null;

        /*
         * If we know the features required for the support of opsetClass, check
         * whether the contact supports them. Otherwise, presume the contact
         * possesses the opsetClass capability in light of the fact that we miss
         * any knowledge of the opsetClass whatsoever.
         */
        if (OPERATION_SETS_TO_FEATURES.containsKey(opsetClass))
        {
            String[] features = OPERATION_SETS_TO_FEATURES.get(opsetClass);

            /*
             * Either we've completely disabled the opsetClass capability by
             * mapping it to the null list of features or we've mapped it to an
             * actual list of features which are to be checked whether the
             * contact supports them.
             */
            if ((features == null)
                    || ((features.length != 0)
                            && !parentProvider.isFeatureListSupported(
                                    jid,
                                    features)))
            {
                opset = null;
            }
        }

        return opset;
    }

    /**
     * Sets the <tt>EntityCapsManager</tt> which is associated with the
     * <tt>discoveryManager</tt> of {@link #parentProvider}.
     *
     * @param capsManager the <tt>EntityCapsManager</tt> which is associated
     * with the <tt>discoveryManager</tt> of {@link #parentProvider}
     */
    private void setCapsManager(EntityCapsManager capsManager)
    {
        if (this.capsManager != capsManager)
        {
            if (this.capsManager != null)
                this.capsManager.removeUserCapsNodeListener(this);

            this.capsManager = capsManager;

            if (this.capsManager != null)
                this.capsManager.addUserCapsNodeListener(this);
        }
    }

    /**
     * Sets the <tt>ScServiceDiscoveryManager</tt> which is the
     * <tt>discoveryManager</tt> of {@link #parentProvider}.
     *
     * @param discoveryManager the <tt>ScServiceDiscoveryManager</tt> which is
     * the <tt>discoveryManager</tt> of {@link #parentProvider}
     */
    void setDiscoveryManager(ScServiceDiscoveryManager discoveryManager)
    {
        setCapsManager(
            (discoveryManager == null)
                ? null
                : discoveryManager.getCapsManager());
    }

    /**
     * Notifies this listener that an <tt>EntityCapsManager</tt> has added a
     * record for a specific user about the caps node the user has.
     *
     * @param user the user (full JID)
     * @param fullJids a list of all resources of the user (full JIDs)
     * @param node the entity caps node#ver
     * @param online indicates if the user is currently online
     * @see UserCapsNodeListener#userCapsNodeAdded(String, String, boolean)
     */
    public void userCapsNodeAdded(String user, ArrayList<String> fullJids,
        String node, boolean online)
    {
        /*
         * It doesn't matter to us whether a caps node has been added or removed
         * for the specified user because we report all changes.
         */
        userCapsNodeChanged(user, fullJids, node, online);
    }

    /**
     * Notifies this listener that an <tt>EntityCapsManager</tt> has removed a
     * record for a specific user about the caps node the user has.
     *
     * @param user the user (full JID)
     * @param fullJids a list of all resources of the user (full JIDs)
     * @param node the entity caps node#ver
     * @param online indicates if the user is currently online
     * @see UserCapsNodeListener#userCapsNodeAdded(String, String, boolean)
     */
    public void userCapsNodeRemoved(String user, ArrayList<String> fullJids,
        String node, boolean online)
    {
        /*
         * It doesn't matter to us whether a caps node has been added or removed
         * for the specified user because we report all changes.
         */
        userCapsNodeChanged(user, fullJids, node, online);
    }

    /**
     * Notifies this listener that an <tt>EntityCapsManager</tt> has changed a
     * record for a specific user about the caps node the user has.
     *
     * @param user the user (full JID)
     * @param fullJids a list of all resources of the user (full JIDs)
     * @param node the entity caps node#ver
     * @param online indicates if the given user is online
     */
    public void userCapsNodeChanged(String user, ArrayList<String> fullJids,
        String node, boolean online)
    {
        OperationSetPresence opsetPresence
        = parentProvider.getOperationSet(OperationSetPresence.class);
        if (opsetPresence != null) {
            if(JabberActivator.getConfigurationService()
                .getBoolean(
                    PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES,
                    USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT)
                && !fullJids.isEmpty())
            {
                String bareJid = StringUtils.parseBareAddress(user);
                Contact contact = opsetPresence.findContactByID(bareJid);
                if (contact != null)
                {
                    fireContactCapabilitiesEvent(
                        contact,
                        ContactCapabilitiesEvent.
                        SUPPORTED_OPERATION_SETS_CHANGED,
                        getLargestSupportedOperationSet(fullJids));
                }
            }
            else
            {
                String jid = StringUtils.parseBareAddress(user);
                Contact contact = opsetPresence.findContactByID(jid);

                // If the contact isn't null and is online we try to discover
                // the new set of operation sets and to notify interested
                // parties. Otherwise we ignore the event.
                if (contact != null)
                {
                    if(online)
                    {
                        // when going online we have received a presence
                        // and make sure we discover this particular jid
                        // for getSupportedOperationSets
                        fireContactCapabilitiesEvent(
                            contact,
                            ContactCapabilitiesEvent.
                            SUPPORTED_OPERATION_SETS_CHANGED,
                            getSupportedOperationSets(user,
                                online));
                    }
                    else
                    {
                        // when offline, we use the contact, and selecting
                        // the most connected jid
                        // for getSupportedOperationSets
                        fireContactCapabilitiesEvent(
                            contact,
                            ContactCapabilitiesEvent.
                            SUPPORTED_OPERATION_SETS_CHANGED,
                            getSupportedOperationSets(contact));
                    }
                }
            }
        }
    }

    /**
     * Removes the capabilities when the user goes offline.
     *
     * @param evt the <tt>ContactPresenceStatusChangeEvent</tt> that notified
     * us
     */
    public void contactPresenceStatusChanged(
        ContactPresenceStatusChangeEvent evt)
    {
        // If the user goes offline we ensure to remove the caps node.
        if (capsManager != null
            && evt.getNewStatus().getStatus() < PresenceStatus.ONLINE_THRESHOLD
            && !evt.isResourceChanged())
        {
            capsManager.removeContactCapsNode(evt.getSourceContact());
        }
    }

    /**
     * Fires event that contact capabilities has changed.
     * @param user the user to search for its contact.
     * @param fullJids a list of all resources of the user (full JIDs)
     */
    public void fireContactCapabilitiesChanged(String user,
        ArrayList<String> fullJids)
    {
        if(!JabberActivator.getConfigurationService()
            .getBoolean(
                PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES,
                USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT)
            || fullJids.isEmpty())
        {
            OperationSetPresence opsetPresence
            = parentProvider.getOperationSet(OperationSetPresence.class);

            if (opsetPresence != null)
            {
                String userID = StringUtils.parseBareAddress(user);
                Contact contact = opsetPresence.findContactByID(userID);

                // this called by received discovery info for particular jid
                // so we use its online and opsets for this particular jid
                boolean online = false;
                Presence presence = parentProvider.getConnection().getRoster()
                    .getPresence(user);
                if(presence != null)
                    online = presence.isAvailable();

                if(contact != null)
                {
                    fireContactCapabilitiesEvent(
                        contact,
                        ContactCapabilitiesEvent.
                        SUPPORTED_OPERATION_SETS_CHANGED,
                        getSupportedOperationSets(user, online));
                }
            }
        }
        else
        {
            OperationSetPresence opsetPresence
            = parentProvider.getOperationSet(OperationSetPresence.class);
            if (opsetPresence != null)
            {
                String bareJid = StringUtils.parseBareAddress(user);
                Contact contact = opsetPresence.findContactByID(bareJid);
                if(contact != null)
                {
                    fireContactCapabilitiesEvent(
                        contact,
                        ContactCapabilitiesEvent.
                        SUPPORTED_OPERATION_SETS_CHANGED,
                        getLargestSupportedOperationSet(fullJids));
                }
            }
        }
    }
}