Commit 1d4d5a95 authored by smorlat's avatar smorlat

enable sipsetup plugins.



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@279 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 06850348
......@@ -273,6 +273,9 @@ AC_SUBST(LINPHONE_LIBS)
AC_DEFINE_UNQUOTED(LINPHONE_VERSION,"$PACKAGE_VERSION",[Linphone's version number])
AC_DEFINE_UNQUOTED(LINPHONE_PLUGINS_DIR, "${prefix}/lib/liblinphone/plugins" ,[path of liblinphone plugins, not mediastreamer2 plugins])
LINPHONE_PLUGINS_DIR="${prefix}/lib/liblinphone/plugins"
AC_SUBST(LINPHONE_PLUGINS_DIR)
AC_ARG_ENABLE(external-ortp,
[ --enable-external-ortp Use external oRTP library],
......
......@@ -3,7 +3,7 @@ EXTRA_DIST=liblinphone.dev
## Process this file with automake to produce Makefile.in
linphone_includedir=$(includedir)/linphone
linphone_include_HEADERS=linphonecore.h ../config.h lpconfig.h
linphone_include_HEADERS=linphonecore.h ../config.h lpconfig.h sipsetup.h
INCLUDES = \
-I$(top_srcdir)\
......
......@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ortp/payloadtype.h"
#include "mediastreamer2/mscommon.h"
#include "mediastreamer2/msvideo.h"
#include "sipsetup.h"
#define LINPHONE_IPADDR_SIZE 64
#define LINPHONE_HOSTNAME_SIZE 128
......@@ -316,7 +317,8 @@ bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj);
void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg);
LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(struct _LpConfig *config, int index);
void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,LinphoneProxyConfig *obj, int index);
void linphone_proxy_config_set_setup_object(LinphoneProxyConfig *cfg, const char *type);
void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type);
SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg);
typedef struct _LinphoneAuthInfo
......
......@@ -558,12 +558,12 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config
tmp=lp_config_get_string(config,key,"type",NULL);
if (tmp!=NULL && strlen(tmp)>0)
linphone_proxy_config_set_setup_object(cfg,tmp);
linphone_proxy_config_set_sip_setup(cfg,tmp);
return cfg;
}
void linphone_proxy_config_set_setup_object(LinphoneProxyConfig *cfg, const char *type){
void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type){
SipSetup *ss=sip_setup_lookup(type);
SipSetupContext *ssc;
if (!ss) return ;
......@@ -577,4 +577,8 @@ void linphone_proxy_config_set_setup_object(LinphoneProxyConfig *cfg, const char
cfg->ssctx=ssc;
}
SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg){
return cfg->ssctx;
}
......@@ -18,7 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "sipsetup.h"
#include "linphonecore.h"
#include "../config.h"
#ifndef LINPHONE_PLUGINS_DIR
#ifdef WIN32
#define LINPHONE_PLUGINS_DIR "liblinphone\plugins\\"
#else
#define LINPHONE_PLUGINS_DIR "."
#endif
#endif
#ifdef HAVE_FONIS
extern SipSetup fonis_sip_setup;
......@@ -31,21 +40,33 @@ static SipSetup *all_sip_setups[]={
NULL
};
void sip_setup_register_all(void){
static MSList *registered_sip_setups=NULL;
void sip_setup_register(SipSetup *ss){
registered_sip_setups=ms_list_append(registered_sip_setups,ss);
}
SipSetup *sip_setup_lookup(const char *type_name){
void sip_setup_register_all(void){
SipSetup **p=all_sip_setups;
ms_load_plugins(LINPHONE_PLUGINS_DIR);
while(*p!=NULL){
if ( strcmp((*p)->name,type_name)==0){
if (!(*p)->initialized){
(*p)->init();
(*p)->initialized=TRUE;
if ((*p)->capabilities==0){
ms_error("%s SipSetup isn't capable of anything ?");
sip_setup_register(*p);
}
}
SipSetup *sip_setup_lookup(const char *type_name){
MSList *elem;
for(elem=registered_sip_setups;elem!=NULL;elem=elem->next){
SipSetup *ss=(SipSetup*)elem->data;
if ( strcmp(ss->name,type_name)==0){
if (!ss->initialized){
ss->init();
ss->initialized=TRUE;
if (ss->capabilities==0){
ms_error("%s SipSetup isn't capable of anything ?",ss->name);
}
}
return *p;
return ss;
}
}
ms_warning("no %s setup manager declared.",type_name);
......@@ -53,11 +74,12 @@ SipSetup *sip_setup_lookup(const char *type_name){
}
void sip_setup_unregister_all(void){
SipSetup **p=all_sip_setups;
while(*p!=NULL){
if ((*p)->initialized){
(*p)->exit();
(*p)->initialized=FALSE;
MSList *elem;
for(elem=registered_sip_setups;elem!=NULL;elem=elem->next){
SipSetup *ss=(SipSetup*)elem->data;
if (ss->initialized){
ss->exit();
ss->initialized=FALSE;
}
}
}
......@@ -73,6 +95,10 @@ SipSetupContext *sip_setup_context_new(SipSetup *s){
return obj;
}
int sip_setup_context_get_capabilities(SipSetupContext *ctx){
return ctx->funcs->capabilities;
}
int sip_setup_new_account(SipSetup *funcs, const char *uri, const char *passwd){
if (funcs->create_account)
return funcs->create_account(uri, passwd);
......
......@@ -20,7 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef sipsetup_h
#define sipsetup_h
#include "linphonecore.h"
#include "mediastreamer2/mscommon.h"
struct _SipSetup;
......@@ -86,6 +87,7 @@ typedef enum _BuddyLookupStatus{
BuddyLookupFailure
}BuddyLookupStatus;
void sip_setup_register(SipSetup *ss);
void sip_setup_register_all(void);
SipSetup *sip_setup_lookup(const char *type_name);
void sip_setup_unregister_all(void);
......@@ -104,3 +106,4 @@ void sip_setup_context_free_results(MSList *results);
void sip_setup_context_free(SipSetupContext *ctx);
#endif
......@@ -394,6 +394,16 @@ void linphone_gtk_contact_ok(GtkWidget *button){
gtk_widget_destroy(w);
}
SipSetupContext* linphone_gtk_get_default_sip_setup_context(void){
LinphoneCore *lc=linphone_gtk_get_core();
LinphoneProxyConfig *cfg=NULL;
linphone_core_get_default_proxy(lc,&cfg);
if (cfg){
return linphone_proxy_config_get_sip_setup_context(cfg);
}
return NULL;
}
static GtkWidget *linphone_gtk_create_contact_menu(GtkWidget *contact_list){
GtkWidget *menu=gtk_menu_new();
GtkWidget *menu_item;
......@@ -404,6 +414,8 @@ static GtkWidget *linphone_gtk_create_contact_menu(GtkWidget *contact_list){
GtkTreeIter iter;
GtkTreeModel *model;
GtkWidget *image;
SipSetupContext* ssc=linphone_gtk_get_default_sip_setup_context();
g_signal_connect(G_OBJECT(menu), "selection-done", G_CALLBACK (gtk_widget_destroy), NULL);
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(contact_list));
if (gtk_tree_selection_get_selected (select, &model, &iter)){
......@@ -438,6 +450,18 @@ static GtkWidget *linphone_gtk_create_contact_menu(GtkWidget *contact_list){
gtk_widget_show(menu_item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_remove_contact,contact_list);
if (ssc && sip_setup_context_get_capabilities(ssc) & SIP_SETUP_CAP_BUDDY_LOOKUP){
menu_item=gtk_image_menu_item_new_with_label(_("Search contact"));
image=gtk_image_new_from_stock(GTK_STOCK_FIND,GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),image);
gtk_widget_show(image);
gtk_widget_show(menu_item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_show_buddy_lookup_window,ssc);
gtk_widget_show(menu);
}
menu_item=gtk_image_menu_item_new_from_stock(GTK_STOCK_ADD,NULL);
gtk_widget_show(menu_item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
......
......@@ -62,4 +62,5 @@ int linphone_gtk_get_ui_config_int(const char *key, int def);
void linphone_gtk_open_browser(const char *url);
void linphone_gtk_check_for_new_version(void);
const char *linphone_gtk_get_lang(const char *config_file);
SipSetupContext* linphone_gtk_get_default_sip_setup_context(void);
void linphone_gtk_show_buddy_lookup_window(SipSetupContext *ctx);
......@@ -147,6 +147,10 @@ void ms_init(void);
/**
* Load plugins from a specific directory.
* This method basically loads all libraries in the specified directory and attempts to call a C function called
* \<libraryname\>_init. For example if a library 'libdummy.so' or 'libdummy.dll' is found, then the loader tries to locate
* a C function called 'libdummy_init()' and calls it if it exists.
* ms_load_plugins() can be used to load non-mediastreamer2 plugins as it does not expect mediastreamer2 specific entry points.
*
* @param directory A directory where plugins library are available.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment