]> sjero.net Git - linphone/commitdiff
Merge branch 'master' of git.savannah.nongnu.org:/srv/git/linphone
authorJehan Monnier <jehan.monnier@linphone.org>
Fri, 22 Oct 2010 16:29:09 +0000 (18:29 +0200)
committerJehan Monnier <jehan.monnier@linphone.org>
Fri, 22 Oct 2010 16:29:09 +0000 (18:29 +0200)
coreapi/linphonecore_jni.cc
java/common/org/linphone/core/LinphoneAuthInfo.java
java/common/org/linphone/core/LinphoneChatRoom.java [new file with mode: 0644]
java/common/org/linphone/core/LinphoneCore.java
java/common/org/linphone/core/LinphoneCoreFactory.java
java/common/org/linphone/core/LinphoneCoreListener.java
java/common/org/linphone/core/LinphoneFriend.java [new file with mode: 0644]
java/common/org/linphone/core/LinphoneProxyConfig.java
java/common/org/linphone/core/OnlineStatus.java [new file with mode: 0644]
java/common/org/linphone/core/package.html [new file with mode: 0644]

index d1351a362069cc88970546960c519327a1922485..1ba35d6e6c9d7a0120a730510cd389426b158321 100644 (file)
@@ -456,7 +456,34 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_getCurrentCall(JNIEnv*
                                                                                                                                                        ) {
        return (jlong)linphone_core_get_current_call((LinphoneCore*)lc);
 }
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv*  env
+                                                                                                                                                       ,jobject  thiz
+                                                                                                                                                       ,jlong lc
+                                                                                                                                                       ,jlong aFriend
+                                                                                                                                                       ) {
+       linphone_core_add_friend((LinphoneCore*)lc,(LinphoneFriend*)aFriend);
+}
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv*  env
+                                                                                                                                                       ,jobject  thiz
+                                                                                                                                                       ,jlong lc
+                                                                                                                                                       ,jint minute_away
+                                                                                                                                                       ,jstring jalternative_contact
+                                                                                                                                                       ,jint status) {
+       const char* alternative_contact = env->GetStringUTFChars(jalternative_contact, NULL);
+       linphone_core_set_presence_info((LinphoneCore*)lc,minute_away,alternative_contact,status);
+       env->ReleaseStringUTFChars(jalternative_contact, alternative_contact);
+}
 
+extern "C" long Java_org_linphone_core_LinphoneCoreImpl_createChatRoom(JNIEnv*  env
+                                                                                                                                                       ,jobject  thiz
+                                                                                                                                                       ,jlong lc
+                                                                                                                                                       ,jstring jto) {
+
+       const char* to = env->GetStringUTFChars(jto, NULL);
+       LinphoneChatRoom* lResult = linphone_core_create_chat_room((LinphoneCore*)lc,to);
+       env->ReleaseStringUTFChars(jto, to);
+       return (long)lResult;
+}
 
 //ProxyConfig
 
@@ -741,6 +768,82 @@ extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState(  JNIEnv*  env
        return (jint)linphone_call_get_state((LinphoneCall*)ptr);
 }
 
+//LinphoneFriend
+extern "C" long Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jstring jFriendUri) {
+       LinphoneFriend* lResult;
 
+       if (jFriendUri) {
+               const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL);
+               lResult= linphone_friend_new_with_addr(friendUri);
+               env->ReleaseStringUTFChars(jFriendUri, friendUri);
+       } else {
+               lResult = linphone_friend_new();
+       }
+       return (long)lResult;
+}
+extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr
+                                                                                                                                               ,jlong linphoneAddress) {
+       linphone_friend_set_address((LinphoneFriend*)ptr,(LinphoneAddress*)linphoneAddress);
+}
+extern "C" long Java_org_linphone_core_LinphoneFriendImpl_setAddress(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr) {
+       return (long)linphone_friend_get_address((LinphoneFriend*)ptr);
+}
+extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setIncSubscribePolicy(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr
+                                                                                                                                               ,jint policy) {
+       linphone_friend_set_inc_subscribe_policy((LinphoneFriend*)ptr,policy);
+}
+extern "C" jint Java_org_linphone_core_LinphoneFriendImpl_getIncSubscribePolicy(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr) {
+       return linphone_friend_get_inc_subscribe_policy((LinphoneFriend*)ptr);
+}
+extern "C" void Java_org_linphone_core_LinphoneFriendImpl_enableSubscribes(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr
+                                                                                                                                               ,jboolean value) {
+       linphone_friend_enable_subscribes((LinphoneFriend*)ptr,value);
+}
+extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_isSubscribesEnabled(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr) {
+       return linphone_friend_subscribes_enabled((LinphoneFriend*)ptr);
+}
+extern "C" jboolean Java_org_linphone_core_LinphoneFriendImpl_getStatus(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr) {
+       return linphone_friend_get_status((LinphoneFriend*)ptr);
+}
+extern "C" void Java_org_linphone_core_LinphoneFriendImpl_edit(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr) {
+       return linphone_friend_edit((LinphoneFriend*)ptr);
+}
+extern "C" void Java_org_linphone_core_LinphoneFriendImpl_done(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr) {
+        linphone_friend_done((LinphoneFriend*)ptr);
+}
+//LinphoneChatRoom
+extern "C" long Java_org_linphone_core_LinphoneChatRoomImpl_getPeerAddress(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr) {
+       return (long) linphone_chat_room_get_peer_address((LinphoneChatRoom*)ptr);
+}
+extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv*  env
+                                                                                                                                               ,jobject  thiz
+                                                                                                                                               ,jlong ptr
+                                                                                                                                               ,jstring jmessage) {
+       const char* message = env->GetStringUTFChars(jmessage, NULL);
+       linphone_chat_room_send_message((LinphoneChatRoom*)ptr,message);
+       env->ReleaseStringUTFChars(jmessage, message);
 
+}
 
index 8ae3aeea522a518d4453cae632fcc233c2274cd8..f679307c596de2fa53503abb2be044f8eeeebbc0 100644 (file)
@@ -17,13 +17,52 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 package org.linphone.core;
-
+/**
+ * Object holding authentication information.
+ * Note:
+ * The object's fields should not be accessed directly. Prefer using the accessor methods.
+ * In most case, authentication information consists of a username and password. Sometimes, a userid is required by proxy, and realm can be useful to discriminate different SIP domains.
+ *<br>
+ *Once created and filled, a LinphoneAuthInfo must be added to the LinphoneCore in order to become known and used automatically when needed. 
+ *Use {@link LinphoneCore#addAuthInfo(LinphoneAuthInfo)} for that purpose.
+ *<br>
+ *The LinphoneCore object can take the initiative to request authentication information when needed to the application 
+ *through the {@link LinphoneCoreListener#authInfoRequested(LinphoneCore, String, String)} listener.
+ *<br>
+ *The application can respond to this information request later using  {@link LinphoneCore#addAuthInfo(LinphoneAuthInfo)}. 
+ *This will unblock all pending authentication transactions and retry them with authentication headers.
+ *
+ */
 public interface LinphoneAuthInfo {
+       /**
+        * 
+        * @return username
+        */
        String getUsername();
-       String getPassword();
-       String getRealm();
+       /**
+        * Sets the username.
+        * @param username
+        */
        void setUsername(String username);
+       /**
+        * 
+        * @return paasword
+        */
+       String getPassword();
+       /**
+        * sets password
+        * @param password
+        */
        void setPassword(String password);
+       /**
+        * get realm
+        * @return
+        */
+       String getRealm();
+       /**
+        * set realm
+        * @param realm
+        */
        void setRealm(String realm);
 }
 
diff --git a/java/common/org/linphone/core/LinphoneChatRoom.java b/java/common/org/linphone/core/LinphoneChatRoom.java
new file mode 100644 (file)
index 0000000..a8ef5e2
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+LinphoneChatRoom.java
+Copyright (C) 2010  Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+package org.linphone.core;
+/**
+ * 
+ * A chat room is the place where text messages are exchanged. 
+Can be created by linphone_core_create_chat_room().
+ *
+ */
+public interface LinphoneChatRoom {
+       /**
+        * get peer address associated to this LinphoneChatRoom
+        *
+        * @return LinphoneAddress peer address
+        */
+       LinphoneAddress getPeerAddress();
+       /**
+       * send a message to peer member of this chat room.
+       * @param        message to be sent
+       */
+       void sendMessage(String message);
+
+}
index c09ff9814d8dbf1d589220ae97adb6f5cbc47cd3..d74997d52524aeb5c5f7d81194e7039871609beb 100644 (file)
@@ -23,7 +23,7 @@ import java.util.Vector;
 
        
 public interface LinphoneCore {
-       /*
+       /**
         * linphone core states
         */
        static public class     GlobalState {
@@ -255,5 +255,24 @@ public interface LinphoneCore {
        public void enableSpeaker(boolean value);
        
        public boolean isSpeakerEnabled();
+       /**
+        * add a friend to the current buddy list, if subscription attribute is set, a SIP SUBSCRIBE message is sent.
+        * @param lf LinphoenFriend to add
+        * @throws LinphoneCoreException
+        */
+       void addFriend(LinphoneFriend lf) throws LinphoneCoreException;
 
+       /**
+        * Set my presence status
+        * @param minute_away how long in away
+        * @param status sip uri used to redirect call in state LinphoneStatusMoved
+        */
+       void setPresenceInfo(int minute_away,String alternative_contact, OnlineStatus status);
+       /**
+        * Create a new chat room for messaging from a sip uri like sip:joe@sip.linphone.org
+        * @param to    destination address for messages 
+        *
+        * @return {@link LinphoneChatRoom} where messaging can take place.
+        */
+       LinphoneChatRoom createChatRoom(String to);
 }
index b3e2952fb702f9695a6a3e34095e1c6afd323e3f..c0d09b0a67f80f63cfac2e2513c48a6f3cd9e96d 100644 (file)
@@ -62,4 +62,17 @@ abstract public class LinphoneCoreFactory {
        abstract public  void setDebugMode(boolean enable);
        
        abstract public void setLogHandler(LinphoneLogHandler handler);
+       /**
+        * Create a LinphoneFriend, similar to {@link #createLinphoneFriend()} + {@link LinphoneFriend#setAddress(LinphoneAddress)} 
+        * @param friendUri a buddy address, must be a sip uri like sip:joe@sip.linphone.org
+        * @return a new LinphoneFriend with address initialized
+        */
+       abstract LinphoneFriend createLinphoneFriend(String friendUri);
+       /**
+        * Create a new LinphoneFriend
+        * @return
+        */
+       abstract LinphoneFriend createLinphoneFriend();
+       
+       
 }
index c37e5d7c748d014bf3c410a13030b01034e26afe..6cb038cddad76b9d05a3eab4f4383091190279ef 100644 (file)
@@ -55,5 +55,28 @@ public interface LinphoneCoreListener {
                 * Registration state notification
                 * */
                public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String smessage);
+               /**
+                * Reports that a new subscription request has been received and wait for a decision. 
+                *Status on this subscription request is notified by changing policy for this friend
+                *@param lc LinphoneCore        
+                *@param lf LinphoneFriend corresponding to the subscriber
+                *@param url of the subscriber
+                * 
+                */
+               public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url);
+               /**
+                * Report status change for a friend previously added to LinphoneCore.
+                * @param lc LinphoneCore
+                * @param lf updated LinphoneFriend
+                */
+               public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);
+               /**
+                * invoked when a new text message is received
+                * @param lc LinphoneCore
+                * @param  room         LinphoneChatRoom involved in this conversation. Can be be created by the framework in case the from is not present in any chat room.
+                * @param from          LinphoneAddress from
+                * @param message       incoming message
+                */
+               public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message);
 }
 
diff --git a/java/common/org/linphone/core/LinphoneFriend.java b/java/common/org/linphone/core/LinphoneFriend.java
new file mode 100644 (file)
index 0000000..f9ba9b7
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+LinphoneFriend.java
+Copyright (C) 2010  Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+package org.linphone.core;
+
+import java.util.Vector;
+
+
+
+/**
+ * Represents a buddy, all presence actions like subscription and status change notification are performed on this object
+ * 
+ *
+ */
+public interface LinphoneFriend {
+       /**
+        * Enum controlling behavior for incoming subscription request. 
+        *      Use by {@link LinphoneFriend#setIncSubscribePolicy()}
+        *
+        */
+       static class SubscribePolicy {
+               static private Vector values = new Vector();
+               protected final int mValue;
+               private final String mStringValue;
+               /**
+                * Does not automatically accept an incoming subscription request. 
+                * This policy implies that a decision has to be taken for each incoming subscription request notified by {@link LinphoneCoreListener#newSubscriptionRequest(LinphoneCore, LinphoneFriend, String)}
+                */
+               public final static SubscribePolicy SPWait = new SubscribePolicy(0,"SPWait");
+               /**
+                * Rejects incoming subscription request.
+                */
+               public final static SubscribePolicy SPDeny = new SubscribePolicy(1,"SPDeny");
+               /**
+                * Automatically accepts a subscription request.
+                */
+               public final static SubscribePolicy SPAccept = new SubscribePolicy(2,"SPAccept");
+               private SubscribePolicy(int value,String stringValue) {
+                       mValue = value;
+                       values.addElement(this);
+                       mStringValue=stringValue;
+               }
+               public static SubscribePolicy fromInt(int value) {
+
+                       for (int i=0; i<values.size();i++) {
+                               SubscribePolicy policy = (SubscribePolicy) values.elementAt(i);
+                               if (policy.mValue == value) return policy;
+                       }
+                       throw new RuntimeException("Policy not found ["+value+"]");
+               }
+               public String toString() {
+                       return mStringValue;
+               }
+       }
+       /**
+        * Set a {@link LinphoneAddress } for this friend
+        * @param anAddress
+        */
+       void setAddress(LinphoneAddress anAddress);
+       /**
+        * get address of this friend
+        * @return
+        */
+       LinphoneAddress getAddress();
+       /**
+        * Configure incoming subscription policy for this friend.
+        * @param policy to apply
+        */
+       void setIncSubscribePolicy(SubscribePolicy policy);
+       /**
+        * get current subscription policy for this LinphoneFriend
+        * @return
+        */
+       SubscribePolicy getIncSubscribePolicy();
+       /**
+        * Configure LinphoneFriend to subscribe to presence information
+        * @param enable if true this friend will receive subscription message
+        */
+       void enableSubscribes(boolean enable);
+       /**
+        * get subscription flag value
+        * @return true is subscription is activated for this friend.
+        */
+       boolean isSubscribesEnabled();
+       /**
+        * get friend status
+        * @return
+        */
+       OnlineStatus getStatus();
+       /**
+        * Starts editing a friend configuration.
+        *<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). 
+        *Once the modifications are done, then the application must call {@link #done()} to commit the changes.
+        */
+       void edit();
+       /**
+        * Commits modification made to the friend configuration.
+        */
+       void done();
+       /**
+        * Human readable representation of this friend
+        * @return
+        */
+       String toString();
+       
+
+}
index 236bded395da6c3aa18497e38a66a4b02437452f..729fd249d5c389c2740ddc9d0738c8d80b4918c8 100644 (file)
@@ -17,34 +17,62 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 package org.linphone.core;
-
+/**
+ * The LinphoneProxyConfig object represents a proxy configuration to be used by the LinphoneCore object. Its fields must not be used directly in favour of the accessors methods. 
+ * Once created and filled properly the LinphoneProxyConfig can be given to LinphoneCore with {@link LinphoneCore#addProxyConfig(LinphoneProxyConfig)}. This will automatically triggers the registration, if enabled.
+ *<br>The proxy configuration are persistent to restarts because they are saved in the configuration file. As a consequence, after {@link LinphoneCoreFactory#createLinphoneCore(LinphoneCoreListener, String, String, Object)} there might already be a default proxy that can be examined with {@link LinphoneCore#getDefaultProxyConfig()} .
+ *
+ */
 public interface LinphoneProxyConfig {
        
        /**
-        * Unregister proxy config a enable edition 
+        *Starts editing a proxy configuration.
+        *Because proxy configuration must be consistent, applications MUST call {@link #edit()} before doing any attempts to modify proxy configuration (such as identity, proxy address and so on). 
+        *Once the modifications are done, then the application must call {@link #done()} to commit the changes.
         */
        public void edit();
        /**
-        * Validate proxy config changes. Start registration in case
+        * Commits modification made to the proxy configuration.
         */
        public void done();
        /**
-        * sip user made by sip:username@domain
+        * Sets the user identity as a SIP address.
+        * @param identy This identity is normally formed with display name, username and domain, such as: Alice <sip:alice@example.net> The REGISTER messages will have from and to set to this identity.
         */
        public void setIdentity(String identity) throws LinphoneCoreException;
        /**
-        * Set proxy uri, like sip:linphone.org:5060
+        *get  the SIP identity that belongs to this proxy configuration.
+        *
+        * @return The SIP identity is a SIP address (Display Name <sip:username> )
+        */
+       public String getIdentity();
+       /**
+        *Sets the proxy address
+        * Examples of valid sip proxy address are:
+        *<li>IP address: sip:87.98.157.38
+        *<li>IP address with port: sip:87.98.157.38:5062
+        *<li>hostnames : sip:sip.example.net
         * @param proxyUri
         * @throws LinphoneCoreException
         */
        public void setProxy(String proxyUri) throws LinphoneCoreException;
+       /**
+        * get the proxy's SIP address.
+        *  
+        */
+       public String getProxy();
        /**
         * Enable register for this proxy config.
         * Register message is issued after call to {@link #done()}
         * @param value
         * @throws LinphoneCoreException
-        */
+        */     
        public void enableRegister(boolean value) throws LinphoneCoreException;
+       /**
+        * @return true if registration to the proxy is enabled.
+        */
+       public boolean registerEnabled();
+       
        /**
         * normalize a human readable phone number into a basic string. 888-444-222 becomes 888444222
         * @param number
@@ -52,7 +80,7 @@ public interface LinphoneProxyConfig {
         */
        public String normalizePhoneNumber(String number);
        /**
-        * usefull function to automatically add internationnal prefix to e164 phone numbers
+        * Useful function to automatically add international prefix to e164 phone numbers
         * @param prefix
         */
        public void setDialPrefix(String prefix);
@@ -64,15 +92,25 @@ public interface LinphoneProxyConfig {
        public void setDialEscapePlus(boolean value);
        
        /**
-        * rget domain host name or ip
+        * get domain host name or ip
         * @return may be null
         */
        public String getDomain();
-       public String getIdentity();
-       public String getProxy();
-       public boolean registerEnabled();
+       /**
+        * 
+        * @return  a boolean indicating that the user is successfully registered on the proxy.
+        */
        public boolean isRegistered();
+       /**
+        * Sets a SIP route. When a route is set, all outgoing calls will go to the route's destination if this proxy is the default one (see {@link LinphoneCore#getDefaultProxyConfig()} ).
+        * @param routeUri ex sip:git.linphone.org
+        * @throws LinphoneCoreException
+        */
        public void setRoute(String routeUri) throws LinphoneCoreException;
+       /**
+        * 
+        * @return  the route set for this proxy configuration.
+        */
        public String getRoute();
        
 }
diff --git a/java/common/org/linphone/core/OnlineStatus.java b/java/common/org/linphone/core/OnlineStatus.java
new file mode 100644 (file)
index 0000000..36aca19
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+OnlineStatus.java
+Copyright (C) 2010  Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*/
+package org.linphone.core;
+
+import java.util.Vector;
+
+
+/**
+ * Enum describing remote friend status
+ *
+ */
+public class OnlineStatus {
+
+               static private Vector values = new Vector();
+               /**
+                * Offline
+                */
+               static public OnlineStatus Offline = new OnlineStatus(0,"Offline");
+               /**
+                * Online 
+                */
+               static public OnlineStatus Online = new OnlineStatus(1,"Online");
+               /**
+                * Busy
+                */
+               static public OnlineStatus Busy = new OnlineStatus(2,"Busy");
+               /**
+                * Be Right Back
+                */
+               static public OnlineStatus BeRightBack = new OnlineStatus(3,"BeRightBack");
+               /**
+                * Away
+                */
+               static public OnlineStatus Away = new OnlineStatus(4,"Away");
+               /**
+                * On The Phone
+                */
+               static public OnlineStatus OnThePhone = new OnlineStatus(5,"OnThePhone");
+               /**
+                * Out To Lunch 
+                */
+               static public OnlineStatus OutToLunch  = new OnlineStatus(6,"OutToLunch ");             
+               /**
+                * Do Not Disturb
+                */
+               static public OnlineStatus DoNotDisturb = new OnlineStatus(7,"DoNotDisturb");           
+               /**
+                * Moved in this sate, call can be redirected if an alternate contact address has been set using function {@link LinphoneCore#setPresenceInfo(int, String, OnlineStatus)}
+                */
+               static public OnlineStatus StatusMoved = new OnlineStatus(8,"StatusMoved");             
+               /**
+                * Using another messaging service
+                */
+               static public OnlineStatus StatusAltService = new OnlineStatus(9,"StatusAltService");           
+               /**
+                * Pending
+                */
+               static public OnlineStatus Pending = new OnlineStatus(10,"Pending");
+               
+               protected final int mValue;
+               private final String mStringValue;
+
+               private OnlineStatus(int value,String stringValue) {
+                       mValue = value;
+                       values.addElement(this);
+                       mStringValue=stringValue;
+               }
+               public static OnlineStatus fromInt(int value) {
+
+                       for (int i=0; i<values.size();i++) {
+                               OnlineStatus state = (OnlineStatus) values.elementAt(i);
+                               if (state.mValue == value) return state;
+                       }
+                       throw new RuntimeException("state not found ["+value+"]");
+               }
+               public String toString() {
+                       return mStringValue;
+               }
+
+}
diff --git a/java/common/org/linphone/core/package.html b/java/common/org/linphone/core/package.html
new file mode 100644 (file)
index 0000000..65e82dd
--- /dev/null
@@ -0,0 +1,194 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+
+  @(#)package.html     
+
+Copyright (C) 2010  Belledonne Communications, Grenoble, France
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+
+-->
+</head>
+<body bgcolor="white">
+
+Liblinphone is a high level library for bringing SIP video call functionnality into an application. It aims at making easy the integration of the SIP video calls into any applications. All variants of linphone are directly based on it:
+
+       <li>linphone (GUI interface)
+       <li>linphonec (console interface)
+<br> Liblinphone is GPL (see COPYING file). Please understand the licencing details before using it!
+
+<br>For any use of this library beyond the rights granted to you by the GPL license, please contact Belledonne Communications (contact@belledonne-communications.com)
+
+
+
+
+<h2>Package Specification</h2>
+
+LibLinphone package is organized in submodules.
+<ul>
+  <li><a href="#proxy">Managing proxies</a>
+</ul>
+<ul>
+  <li><a href="#buddy">Managing Buddies and buddy list and presence</a>
+</ul>
+<ul>
+  <li><a href="#chat">Chat room and Messaging</a>
+</ul>
+
+<h2>Related Documentation</h2>
+
+For overviews, tutorials, examples, guides, and tool documentation, please see:
+<ul>
+  <li><a href="http://www.linphone.org">linphone web site</a>
+</ul>
+
+<!-- Put @see and @since tags down here. -->
+<h3>
+<a name="proxy">Managing proxies</a>
+</h3>
+User registration is controled by  {@link org.linphone.core.LinphoneProxyConfig } settings.
+<br> Each {@link org.linphone.core.LinphoneProxyConfig } object can be configured with registration informations 
+like {@link org.linphone.core.LinphoneProxyConfig#setProxy proxy address } , {@link org.linphone.core.LinphoneProxyConfig#setIdentity user id}, and so on. 
+<br> A created proxy config using {@link org.linphone.core.LinphoneCoreFactory#createProxyConfig }, once configured, must be added to {@link org.linphone.core.LinphoneCore} using function {@link org.linphone.core.LinphoneCore#addProxyConfig }.
+<br> It is recommended to set a default {@link org.linphone.core.LinphoneProxyConfig proxy config }  using function {@link org.linphone.core.LinphoneCore#setDefaultProxyConfig }. Once done, if {@link org.linphone.core.LinphoneProxyConfig a proxy config } has been configured with attribute {@link org.linphone.core.LinphoneProxyConfig#enableRegister enable register }  , next call to {@link org.linphone.core.LinphoneCore#iterate } triggers a SIP register.  
+<br> Registration status is reported by {@link org.linphone.core.LinphoneCoreListener#registrationState registration listener}.
+<br>
+<br> This pseudo code demonstrates basic registration operations:
+<br> 
+<pre>
+<code>
+       
+       LinphoneProxyConfig proxy_cfg;
+       /*create proxy config*/
+       proxy_cfg = LinphoneCoreFactory.instance().createProxyConfig();
+       /*parse identity*/
+       LinphoneAddress from = LinphoneCoreFactory.instance().createAddress("sip:toto@sip.titi.com");
+       LinphoneAuthInfo info;
+       if (password!=NULL){
+               info=LinphoneCoreFactory.instance().createAuthInfo(from.getUsername(),null,"secret",null,null); /*create authentication structure from identity*/
+               lc.addAuthInfo(info); /*add authentication info to LinphoneCore*/
+       }       
+       // configure proxy entries
+       proxy_cfg.setIdenty(identity); /*set identity with user name and domain*/
+       String server_addr = from.getDomain(); /*extract domain address from identity*/
+       proxy_cfg.setProxy(server_addr); /* we assume domain = proxy server address*/
+       proxy_cfg.enableRegister(true); /*activate registration for this proxy config*/
+       
+       lc.addProxyConfig(proxy_cfg); /*add proxy config to linphone core*/
+       lc.setDefaultProxyconfig(proxy_cfg); /*set to default proxy*/ 
+</code>
+</pre>
+<br>
+  {@link org.linphone.core.LinphoneCoreListener#registrationState Registration state listener} :
+<pre>
+<code>
+ void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState cstate, String message){
+               System.out.println(New registration state ["+cstate+"] for user id ["+cfg.getUserName()+"] at proxy ["+cfg.getProxy()+"]";
+}
+</pre>
+</code>
+
+<br><b>Authentication:</b>
+<br>Most of the time, registration requires {@link org.linphone.core.LinphoneAuthInfo authentication } to succed. {@link org.linphone.core.LinphoneAuthInfo} info must be either added to {@link org.linphone.core.LinphoneCore } using method {@link org.linphone.core.LinphoneCore#addAuthInfo } before {@link org.linphone.core.LinphoneProxyConfig} is added to Linphone core, or on demand from listener {@link org.linphone.core.LinphoneCoreListener#authInfoRequested(LinphoneCore, String, String)}  .    
+<br>
+<br><b>Unregistration:</b>
+<br> Unregistration or any changes to {@link org.linphone.core.LinphoneProxyConfig} must be first started by a call to function {@link org.linphone.core.LinphoneProxyConfig#edit } and validated by  function {@link org.linphone.core.LinphoneProxyConfig#done }
+<br> This pseudo code shows how to unregister a user associated to a{@link org.linphone.core.LinphoneProxyConfig}
+<pre>
+<code>
+       LinphoneProxyConfig proxy_cfg;
+       lc.setDefaultProxyConfig(proxy_cfg); /* get default proxy config*/
+       proxy_cfg.edit(); /*start editing proxy configuration*/
+       proxy_cfg.enableRegister(false); /*de-activate registration for this proxy config*/
+       proxy_cfg.done(); /*initiate REGISTER with expire = 0*/
+</pre>
+</code>
+<br>
+<br>
+<h3>
+<a name="buddy">Managing Buddies and buddy list and presence</a>
+</h3>
+<br>
+<b>Buddies and buddy list</b>
+<br>Each buddy is represented by a {@link org.linphone.core.LinphoneFriend } object created by function {@link org.linphone.core.LinphoneCoreFactory#createLinphoneFriend()}. 
+Buddy configuration parameters like {@link org.linphone.core.LinphoneFriend#setAddress(LinphoneAddress) sip uri} or  {@link org.linphone.core.LinphoneFriend#setIncSubscribePolicy(LinphoneFriend.SubscribePolicy) status publication}  are configurable for each buddy.
+<br>Here under a typical buddy creation:
+<br>
+<pre>
+<code>
+       LinphoneFriend my_friend=LinphoneFactory.instance().createFriend("sip:joe@sip.linphone.org"); /*creates friend object for buddy joe*/
+       my_friend.enableSubscribes(true); /*configure this friend to emit SUBSCRIBE message after being added to LinphoneCore*/
+       my_friend.setIncSubscribePolicy(LinphoneFriend.SubscribePolicy.Accept); /* accept Incoming subscription request for this friend*/
+</code>
+</pre>
+{@link LinphoneFriend  friends } status changes are reported by  {@link org.linphone.core.LinphoneCoreListener#notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf)} .
+<pre>
+<code>
+ void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf){
+       LinphoneAddress friend_address = lf.getAddress();
+       System.out.println("New state ["+lf.getStatus()+"] for user id ["+friend_address+"] ");
+}
+</code>
+</pre>
+
+<br>Once created a buddy can be added to the buddy list using function {@link org.linphone.core.LinphoneCore#addFriend(LinphoneFriend lf) } . Added friends will be notified about {@link org.linphone.core.LinphoneCore#setPresenceInfo(int minute_away,String alternative_contact, OnlineStatus status) local status changes }
+<br>
+Any subsequente modifications to {@link org.linphone.core.LinphoneFriend} must be first started by a call to function  to {@link org.linphone.core.LinphoneFriend#edit()} and validated by  function {@link org.linphone.core.LinphoneFriend#done()}
+<pre>
+<code>
+       my_friend.edit(); /* start editing friend */
+       my_friend.enableSubscribes(true); /*disable subscription for this friend*/
+       my_friend.done(); /*commit changes triggering an UNSUBSCRIBE message*/
+</code>
+</pre>
+
+<b> Publishing presence status </b>
+<br>Local presence status can be changed using function {@link org.linphone.core.LinphoneCore#setPresenceInfo }.New status is propagated to all friends {@link org.linphone.core.LinphoneCore#addFriend(LinphoneFriend lf)  previously added } to LinphoneCore. 
+<br>
+<br>
+<b>Handling incoming subscription request</b>
+<br> New incoming subscription requests are process according to{@link org.linphone.core.LinphoneFriend#setIncSubscribePolicy(LinphoneFriend.SubscribePolicy)  the incoming subscription policy state}  for subscription initiated by {@link org.linphone.core.LinphoneCore#addFriend(LinphoneFriend lf) members of the buddy list. }
+<br> For incoming request coming from an unknown buddy, the call back  {@link org.linphone.core.LinphoneCoreListener#newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)}
+
+<h3>
+<a name="chat">Chat room and Messaging</a>
+</h3>
+<b> Exchanging text messages</b>
+<br> Messages are sent using {@link org.linphone.core.LinphoneChatRoom} object. First step is to create a {@link org.linphone.core.LinphoneCore#createChatRoom chat room }
+from a peer sip uri.
+<pre>
+<code>
+       LinphoneChatRoom chat_room = lc.createChatRoom("sip:joe@sip.linphone.org");
+</pre>
+</code>
+<br>Once created, messages are sent using function {@link org.linphone.core.LinphoneChatRoom#sendMessage }  . 
+<pre>
+<code>
+       chat_room.sendMessage("Hello world"); /*sending message*/
+</pre>
+</code>
+<br>Incoming message are received from {@link org.linphone.core.LinphoneCoreListener#textReceived  a listener }
+<pre>
+<code>
+       void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message) {
+               System.out.println("Message ["+message+"] received from ["+from+"] ");
+       }
+</code>
+<pre>
+</body>
+</html>
\ No newline at end of file