3 Copyright (C) 2010 Belledonne Communications, Grenoble, France
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program 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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package org.linphone.core;
21 import java.util.Vector;
26 * Represents a buddy, all presence actions like subscription and status change notification are performed on this object
31 public interface LinphoneFriend {
33 * Enum controlling behavior for incoming subscription request.
34 * Use by {@link LinphoneFriend#setIncSubscribePolicy()}
37 static class SubscribePolicy {
40 static private Vector values = new Vector();
41 protected final int mValue;
42 private final String mStringValue;
44 * Does not automatically accept an incoming subscription request.
45 * This policy implies that a decision has to be taken for each incoming subscription request notified by {@link LinphoneCoreListener#newSubscriptionRequest(LinphoneCore, LinphoneFriend, String)}
47 public final static SubscribePolicy SPWait = new SubscribePolicy(0,"SPWait");
49 * Rejects incoming subscription request.
51 public final static SubscribePolicy SPDeny = new SubscribePolicy(1,"SPDeny");
53 * Automatically accepts a subscription request.
55 public final static SubscribePolicy SPAccept = new SubscribePolicy(2,"SPAccept");
58 private SubscribePolicy(int value,String stringValue) {
60 values.addElement(this);
61 mStringValue=stringValue;
63 public static SubscribePolicy fromInt(int value) {
65 for (int i=0; i<values.size();i++) {
66 SubscribePolicy policy = (SubscribePolicy) values.elementAt(i);
67 if (policy.mValue == value) return policy;
69 throw new RuntimeException("Policy not found ["+value+"]");
71 public String toString() {
76 * Set a {@link LinphoneAddress } for this friend
79 void setAddress(LinphoneAddress anAddress);
81 * get address of this friend
84 LinphoneAddress getAddress();
86 * Configure incoming subscription policy for this friend.
87 * @param policy to apply
89 void setIncSubscribePolicy(SubscribePolicy policy);
91 * get current subscription policy for this LinphoneFriend
94 SubscribePolicy getIncSubscribePolicy();
96 * Configure LinphoneFriend to subscribe to presence information
97 * @param enable if true this friend will receive subscription message
99 void enableSubscribes(boolean enable);
101 * get subscription flag value
102 * @return true is subscription is activated for this friend.
104 boolean isSubscribesEnabled();
109 OnlineStatus getStatus();
111 * Starts editing a friend configuration.
112 *<br> Because friend configuration must be consistent, applications MUST call {@link #edit()} before doing any attempts to modify friend configuration (such as address or subscription policy and so on).
113 *Once the modifications are done, then the application must call {@link #done()} to commit the changes.
117 * Commits modification made to the friend configuration.
121 * Human readable representation of this friend