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