]> sjero.net Git - linphone/blob - java/common/org/linphone/core/LinphoneCoreFactory.java
399b9ec8d8b2321ab28854762d32b04b6c017231
[linphone] / java / common / org / linphone / core / LinphoneCoreFactory.java
1 /*
2 LinphoneCoreFactory.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
22
23
24
25 abstract public class LinphoneCoreFactory {
26         
27         private static String factoryName = "org.linphone.core.LinphoneCoreFactoryImpl";
28         
29         
30         static LinphoneCoreFactory theLinphoneCoreFactory; 
31         /**
32          * Indicate the name of the class used by this factory
33          * @param pathName
34          */
35         public static void setFactoryClassName (String className) {
36                 factoryName = className;
37         }
38         
39         
40         public static final synchronized LinphoneCoreFactory instance() {
41                 try {
42                         if (theLinphoneCoreFactory == null) {
43                                 Class<?> lFactoryClass = Class.forName(factoryName);
44                                 theLinphoneCoreFactory = (LinphoneCoreFactory) lFactoryClass.newInstance();
45                         }
46                 } catch (Exception e) {
47                         System.err.println("Cannot instanciate factory ["+factoryName+"]");
48                 }
49                 return theLinphoneCoreFactory;
50         }
51         abstract public LinphoneAuthInfo createAuthInfo(String username,String password, String realm);
52         
53         abstract public LinphoneCore createLinphoneCore(LinphoneCoreListener listener, String userConfig,String factoryConfig,Object  userdata) throws LinphoneCoreException;
54         abstract public LinphoneCore createLinphoneCore(LinphoneCoreListener listener) throws LinphoneCoreException;
55
56         /**
57          * Constructs a LinphoneAddress object
58          * @param username 
59          * @param domain
60          * @param displayName
61          * @return 
62          */
63         abstract public LinphoneAddress createLinphoneAddress(String username,String domain,String displayName);
64         /**
65          * Constructs a LinphoneAddress object by parsing the user supplied address, given as a string.
66          * @param address should be like sip:joe@sip.linphone.org
67          * @return
68          */
69         abstract public LinphoneAddress createLinphoneAddress(String address);
70         abstract public LpConfig createLpConfig(String file);
71         
72         abstract public  LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException;
73         /**
74          * Enable verbose traces
75          * @param enable 
76          * @param tag
77          */
78         abstract public  void setDebugMode(boolean enable, String tag);
79         
80         abstract public void setLogHandler(LinphoneLogHandler handler);
81         /**
82          * Create a LinphoneFriend, similar to {@link #createLinphoneFriend()} + {@link LinphoneFriend#setAddress(LinphoneAddress)} 
83          * @param friendUri a buddy address, must be a sip uri like sip:joe@sip.linphone.org
84          * @return a new LinphoneFriend with address initialized
85          */
86         abstract public LinphoneFriend createLinphoneFriend(String friendUri);
87         /**
88          * Create a new LinphoneFriend
89          * @return
90          */
91         abstract public LinphoneFriend createLinphoneFriend();
92         
93         
94 }