]> sjero.net Git - linphone/blob - java/common/org/linphone/core/LinphoneFriend.java
Few changes in JNI interface for linphone friends + fix issue in linphone_friend_destroy
[linphone] / java / common / org / linphone / core / LinphoneFriend.java
1 /*
2 LinphoneFriend.java
3 Copyright (C) 2010  Belledonne Communications, Grenoble, France
4
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.
9
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.
14
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.
18 */
19 package org.linphone.core;
20
21 import java.util.Vector;
22
23
24
25 /**
26  * Represents a buddy, all presence actions like subscription and status change notification are performed on this object
27  * 
28  *
29  */
30
31 public interface LinphoneFriend {
32         /**
33          * Enum controlling behavior for incoming subscription request. 
34          *      Use by {@link LinphoneFriend#setIncSubscribePolicy()}
35          *
36          */
37         static class SubscribePolicy {
38
39                 
40                 static private Vector values = new Vector();
41                 protected final int mValue;
42                 private final String mStringValue;
43                 /**
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)}
46                  */
47                 public final static SubscribePolicy SPWait = new SubscribePolicy(0,"SPWait");
48                 /**
49                  * Rejects incoming subscription request.
50                  */
51                 public final static SubscribePolicy SPDeny = new SubscribePolicy(1,"SPDeny");
52                 /**
53                  * Automatically accepts a subscription request.
54                  */
55                 public final static SubscribePolicy SPAccept = new SubscribePolicy(2,"SPAccept");
56                 
57                 
58                 private SubscribePolicy(int value,String stringValue) {
59                         mValue = value;
60                         values.addElement(this);
61                         mStringValue=stringValue;
62                 }
63                 public static SubscribePolicy fromInt(int value) {
64
65                         for (int i=0; i<values.size();i++) {
66                                 SubscribePolicy policy = (SubscribePolicy) values.elementAt(i);
67                                 if (policy.mValue == value) return policy;
68                         }
69                         throw new RuntimeException("Policy not found ["+value+"]");
70                 }
71                 public String toString() {
72                         return mStringValue;
73                 }
74         }
75         /**
76          * Set a {@link LinphoneAddress } for this friend
77          * @param anAddress
78          */
79         void setAddress(LinphoneAddress anAddress);
80         /**
81          * get address of this friend
82          * @return
83          */
84         LinphoneAddress getAddress();
85         /**
86          * Configure incoming subscription policy for this friend.
87          * @param policy to apply
88          */
89         void setIncSubscribePolicy(SubscribePolicy policy);
90         /**
91          * get current subscription policy for this LinphoneFriend
92          * @return
93          */
94         SubscribePolicy getIncSubscribePolicy();
95         /**
96          * Configure LinphoneFriend to subscribe to presence information
97          * @param enable if true this friend will receive subscription message
98          */
99         void enableSubscribes(boolean enable);
100         /**
101          * get subscription flag value
102          * @return true is subscription is activated for this friend.
103          */
104         boolean isSubscribesEnabled();
105         /**
106          * get friend status
107          * @return
108          */
109         OnlineStatus getStatus();
110         /**
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.
114          */
115         void edit();
116         /**
117          * Commits modification made to the friend configuration.
118          */
119         void done();
120         /**
121          * Human readable representation of this friend
122          * @return
123          */
124         String toString();
125         
126         /**
127          * Return the native pointer for this object
128          */
129         long getNativePtr();
130 }