]> sjero.net Git - linphone/blob - java/common/org/linphone/core/LinphoneChatMessage.java
Added JNI getFrom to LinphoneChatMessage
[linphone] / java / common / org / linphone / core / LinphoneChatMessage.java
1 package org.linphone.core;
2
3 import java.util.Vector;
4
5
6 public interface LinphoneChatMessage {
7         interface StateListener{
8                 void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state);
9         }
10         static class State {
11                 @SuppressWarnings("rawtypes")
12                 static private Vector values = new Vector();
13                 private final int mValue;
14                 public final int value() {return mValue;}
15                 
16                 private final String mStringValue;
17                 /**
18                  * Idle
19                  */
20                 public final static State Idle = new State(0,"Idle");
21                 /**
22                  * Incoming call received.
23                  */
24                 public final static State InProgress = new State(1,"InProgress");
25                 /**
26                  * Outgoing call initialiazed.
27                  */
28                 public final static State Delivered = new State(2,"Delivered");
29                 /**
30                  * Outgoing call in progress. 
31                  */
32                 public final static State NotDelivered = new State(3,"NotDelivered");
33                 
34                 @SuppressWarnings("unchecked")
35                 private State(int value,String stringValue) {
36                         mValue = value;
37                         values.addElement(this);
38                         mStringValue=stringValue;
39                 }
40                 
41                 public static State fromInt(int value) {
42
43                         for (int i=0; i<values.size();i++) {
44                                 State state = (State) values.elementAt(i);
45                                 if (state.mValue == value) return state;
46                         }
47                         throw new RuntimeException("state not found ["+value+"]");
48                 }
49                 public String toString() {
50                         return mStringValue;
51                 }
52                 public int toInt() {
53                         return mValue;
54                 }
55         }
56         
57         long getNativePtr();
58         
59         Object getUserData();
60         
61         void setUserData();
62         
63         /**
64          * get text associated to this LinphoneChatMessage
65          * 
66          * @return text sent along with the message
67          */
68         String getMessage();
69         
70         /**
71          * get peer address associated to this LinphoneChatMessage
72          *
73          * @return LinphoneAddress peer address
74          */
75         LinphoneAddress getPeerAddress();
76         
77         /**
78          * get from address associated to this LinphoneChatMessage
79          *
80          * @return LinphoneAddress from address
81          */
82         LinphoneAddress getFrom();
83         
84         /**
85          * Linphone message can carry external body as defined by rfc2017
86          * @param message #LinphoneChatMessage
87          * @return return external body url null if not present.
88          */
89         String getExternalBodyUrl();
90         
91         /**
92          * Linphone message can carry external body as defined by rfc2017
93          * @param  #LinphoneChatMessage  
94          * @param url ex: access-type=URL; URL="http://www.foo.com/file"
95          */
96         void setExternalBodyUrl(String url);
97 }