aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/service/protocol/ContactResource.java
blob: 3a766b6e4df86cab9a7938defc32aa0f5c488749 (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
/*
 * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.service.protocol;

/**
 * The <tt>ContactResource</tt> class represents a resource, from which a
 * <tt>Contact</tt> is connected.
 *
 * @author Yana Stamcheva
 */
public class ContactResource
{
    /**
     * A static instance of this class representing the base resource. If this
     * base resource is passed as a parameter for any operation (send message,
     * call) the operation should explicitly use the base contact address. This
     * is meant to force a call or a message sending to all the resources for
     * the corresponding contact.
     */
    public static ContactResource BASE_RESOURCE = new ContactResource();

    /**
     * The contact, to which this resource belongs.
     */
    private Contact contact;

    /**
     * The name of this contact resource.
     */
    private String resourceName;

    /**
     * The presence status of this contact resource.
     */
    protected PresenceStatus presenceStatus;

    /**
     * The priority of this contact source.
     */
    protected int priority;

    /**
     * Whether this contact resource is a mobile one.
     */
    protected boolean mobile = false;

    /**
     * Creates an empty instance of <tt>ContactResource</tt> representing the
     * base resource.
     */
    public ContactResource() {}

    /**
     * Creates a <tt>ContactResource</tt> by specifying the
     * <tt>resourceName</tt>, the <tt>presenceStatus</tt> and the
     * <tt>priority</tt>.
     *
     * @param contact the parent <tt>Contact</tt> this resource is about
     * @param resourceName the name of this resource
     * @param presenceStatus the presence status of this resource
     * @param priority the priority of this resource
     */
    public ContactResource( Contact contact,
                            String resourceName,
                            PresenceStatus presenceStatus,
                            int priority,
                            boolean mobile)
    {
        this.contact = contact;
        this.resourceName = resourceName;
        this.presenceStatus = presenceStatus;
        this.priority = priority;
        this.mobile = mobile;
    }

    /**
     * Returns the <tt>Contact</tt>, this resources belongs to.
     *
     * @return the <tt>Contact</tt>, this resources belongs to
     */
    public Contact getContact()
    {
        return contact;
    }

    /**
     * Returns the name of this resource.
     *
     * @return the name of this resource
     */
    public String getResourceName()
    {
        return resourceName;
    }

    /**
     * Returns the presence status of this resource.
     *
     * @return the presence status of this resource
     */
    public PresenceStatus getPresenceStatus()
    {
        return presenceStatus;
    }

    /**
     * Returns the priority of the resources.
     *
     * @return the priority of this resource
     */
    public int getPriority()
    {
        return priority;
    }

    /**
     * Whether contact is mobile one. Logged in only from mobile device.
     * @return whether contact is mobile one.
     */
    public boolean isMobile()
    {
        return mobile;
    }
}